From 7dbb9214d2590745958475cf33f399954a5564f4 Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 18 Oct 2018 16:57:09 +0200 Subject: [PATCH 001/172] Added .gitignore --- .gitignore | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..06d578749 --- /dev/null +++ b/.gitignore @@ -0,0 +1,45 @@ +# Logs +logs +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules +jspm_packages + +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history + +# mac files +.DS_Store + +# vim swap files +*.swp + +package-lock.json From e1b80882af37d24fd9eac125d3dc7ae28aa2d931 Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 18 Oct 2018 17:27:31 +0200 Subject: [PATCH 002/172] Initial prototype --- index.js | 79 +++++++++++++++ lib/Connection.js | 83 ++++++++++++++++ lib/ConnectionPool.js | 223 ++++++++++++++++++++++++++++++++++++++++++ lib/Selectors.js | 23 +++++ lib/Serializer.js | 28 ++++++ lib/Transport.js | 126 ++++++++++++++++++++++++ lib/errors.js | 76 ++++++++++++++ lib/symbols.js | 15 +++ 8 files changed, 653 insertions(+) create mode 100644 index.js create mode 100644 lib/Connection.js create mode 100644 lib/ConnectionPool.js create mode 100644 lib/Selectors.js create mode 100644 lib/Serializer.js create mode 100644 lib/Transport.js create mode 100644 lib/errors.js create mode 100644 lib/symbols.js diff --git a/index.js b/index.js new file mode 100644 index 000000000..5691a6638 --- /dev/null +++ b/index.js @@ -0,0 +1,79 @@ +'use strict' + +const Transport = require('./lib/Transport') +const Connection = require('./lib/Connection') +const ConnectionPool = require('./lib/ConnectionPool') +const Serializer = require('./lib/Serializer') +const selectors = require('./lib/Selectors') +const symbols = require('./lib/symbols') +const { BadConfigurationError } = require('./lib/errors') + +// const buildApi = require('../monorepo/packages/es-api-6') + +const { + kTransport, + kConnectionPool, + kSerializer, + kSelector +} = symbols + +class Client { + constructor (opts = {}) { + if (!opts.host) { + throw new BadConfigurationError('Missing host option') + } + + // if (opts.log) { + // this.on('response', console.log) + // this.on('error', console.log) + // } + + const Selector = selectors.RoundRobinSelector + const options = Object.assign({}, { + Connection, + ConnectionPool, + Transport, + Serializer, + Selector, + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }, opts) + + this[kSelector] = new options.Selector() + this[kSerializer] = new options.Serializer() + this[kConnectionPool] = new options.ConnectionPool({ + selector: this[kSelector] + }) + this[kTransport] = new options.Transport({ + connectionPool: this[kConnectionPool], + serializer: this[kSerializer], + maxRetries: options.maxRetries, + requestTimeout: options.requestTimeout, + sniffInterval: options.sniffInterval, + sniffOnStart: options.sniffOnStart + }) + + this.request = this[kTransport].request.bind(this[kTransport]) + + // const apis = buildApi({ + // makeRequest: this[kTransport].request.bind(this[kTransport]) + // }) + + // Object.keys(apis).forEach(api => { + // this[api] = apis[api] + // }) + + this[kConnectionPool].addConnection(options.host) + } +} + +module.exports = { + Client, + Transport, + ConnectionPool, + Serializer, + selectors, + symbols +} diff --git a/lib/Connection.js b/lib/Connection.js new file mode 100644 index 000000000..8e9d74386 --- /dev/null +++ b/lib/Connection.js @@ -0,0 +1,83 @@ +'use strict' + +const assert = require('assert') +const debug = require('debug')('elasticsearch') +const { resolve } = require('url') +const makeRequest = require('simple-get') + +class Connection { + constructor (opts = {}) { + assert(opts.url, 'Missing url') + + this.url = opts.url + this.id = opts.id || opts.url + this.deadCount = 0 + this.resurrectTimeout = 0 + + this._status = opts.status || Connection.statuses.ALIVE + this.roles = opts.roles || defaultRoles + } + + request (params, callback) { + params.url = resolve(this.url, params.path) + debug('Starting a new request', params) + return makeRequest(params, callback) + } + + close () { + debug('Closing connection') + } + + setRole (role, enabled) { + assert( + ~validRoles.indexOf(role), + `Unsupported role: '${role}'` + ) + assert( + typeof enabled === 'boolean', + 'enabled should be a boolean' + ) + this.roles[role] = enabled + return this + } + + get status () { + return this._status + } + + set status (status) { + assert( + ~validStatuses.indexOf(status), + `Unsupported status: '${status}'` + ) + this._status = status + } +} + +Connection.statuses = { + ALIVE: 'alive', + DEAD: 'dead' +} + +Connection.roles = { + MASTER: 'master', + DATA: 'data', + INGEST: 'ingest', + COORDINATING: 'coordinating', + MACHINE_LEARNING: 'machine_learning' +} + +const defaultRoles = { + [Connection.roles.MASTER]: true, + [Connection.roles.DATA]: true, + [Connection.roles.INGEST]: true, + [Connection.roles.COORDINATING]: true, + [Connection.roles.MACHINE_LEARNING]: true +} + +const validStatuses = Object.keys(Connection.statuses) + .map(k => Connection.statuses[k]) +const validRoles = Object.keys(Connection.roles) + .map(k => Connection.roles[k]) + +module.exports = Connection diff --git a/lib/ConnectionPool.js b/lib/ConnectionPool.js new file mode 100644 index 000000000..a1a1c3637 --- /dev/null +++ b/lib/ConnectionPool.js @@ -0,0 +1,223 @@ +'use strict' + +const debug = require('debug')('elasticsearch') +const Connection = require('./Connection') + +class ConnectionPool { + constructor (opts = {}) { + this.connections = new Map() + this.alive = [] + this.dead = [] + this.selector = opts.selector + // the resurrect timeout is 60s + // we multiply it by 2 because the resurrect formula is + // `Math.pow(resurrectTimeout * 2, deadCount -1)` + // and we don't need to multiply by 2 + // the resurrectTimeout every time + this.resurrectTimeout = 1000 * 60 * 2 + // number of consecutive failures after which + // the timeout doesn't increase + this.resurrectTimeoutCutoff = 5 + } + + /** + * Marks a connection as 'alive'. + * If needed moves the connection from the dead list + * to the alive list and then resets the `deadCount`. + * + * @param {object} connection + */ + markAlive (connection) { + const { id } = connection + debug(`Marking as 'alive' connection '${id}'`) + if (this.alive.indexOf(id) === -1) { + this.alive.push(id) + const index = this.dead.indexOf(id) + if (index > -1) this.dead.splice(index, 1) + } + connection.status = Connection.statuses.ALIVE + connection.deadCount = 0 + connection.resurrectTimeout = 0 + this.connections.set(id, connection) + } + + /** + * Marks a connection as 'dead'. + * If needed moves the connection from the alive list + * to the dead list and then increments the `deadCount`. + * + * @param {object} connection + */ + markDead (connection) { + const { id } = connection + debug(`Marking as 'dead' connection '${id}'`) + if (this.dead.indexOf(id) === -1) { + this.dead.push(id) + const index = this.alive.indexOf(id) + if (index > -1) this.alive.splice(index, 1) + } + connection.status = Connection.statuses.DEAD + connection.deadCount++ + // resurrectTimeout formula: + // `Math.pow(resurrectTimeout * 2, deadCount -1)` + // we don't need to multiply the resurrectTimeout by 2 + // every time, it is cached during the initialization + connection.resurrectTimeout = Date.now() + Math.pow( + this.resurrectTimeout, + Math.min( + connection.deadCount - 1, + this.resurrectTimeoutCutoff + ) + ) + this.connections.set(id, connection) + + // sort the dead list in ascending order + // based on the resurrectTimeout + this.dead.sort((a, b) => { + const conn1 = this.connections.get(a) + const conn2 = this.connections.get(b) + return conn1.resurrectTimeout - conn2.resurrectTimeout + }) + } + + /** + * Tries to resurrect a connection if the `resurrectTimeout` + * has been reached, if so, it moves the connection to the + * alive list without resetting the `deadCount` or the `resurrectTimeout` + * + * @param {number} epoch + * @returns {object} connection + */ + resurrect (now = Date.now()) { + if (this.dead.length === 0) return + + // the dead list is sorted in ascending order based on the timeout + // so the first element will always be the one with the smalles timeout + const connection = this.connections.get(this.dead[0]) + if (now < connection.resurrectTimeout) { + debug('Nothing to resurrect') + return + } + + const { id } = connection + debug(`Trying resurrect connection '${id}'`) + this.alive.push(id) + this.dead.splice(this.dead.indexOf(id), 1) + + connection.status = Connection.statuses.ALIVE + this.connections.set(id, connection) + return connection + } + + /** + * Returns an alive connection if present, + * otherwise returns null. + * It uses the selector to choose which + * connection return. + * + * @returns {object|null} connection + */ + getConnection () { + if (this.alive.length === 0) { + return null + } + + const id = this.selector.select(this.alive) + return this.connections.get(id) + } + + /** + * Adds a new connection to the pool. + * + * @param {object|string} host + * @returns {ConnectionPool} + */ + addConnection (host) { + if (Array.isArray(host)) { + host.forEach(h => this.addConnection(h)) + return + } + + if (typeof host === 'string') { + host = this.urlToHost(host) + } + const connection = new Connection(host) + debug('Adding a new connection', connection) + this.connections.set(connection.id, connection) + this.alive.push(connection.id) + return this + } + + /** + * Removes a new connection to the pool. + * + * @param {object} connection + * @returns {ConnectionPool} + */ + removeConnection (connection) { + debug('Removing connection', connection) + const { id } = connection + this.connections.delete(id) + var index = this.dead.indexOf(id) + if (index > -1) this.dead.splice(index, 1) + index = this.alive.indexOf(id) + if (index > -1) this.alive.splice(index, 1) + return this + } + + /** + * Empties the connection pool. + * + * @returns {ConnectionPool} + */ + empty () { + debug('Emptying the connection pool') + this.connections.forEach(connection => { + connection.close() + }) + this.connections = new Map() + this.alive = [] + this.dead = [] + return this + } + + /** + * Transforms the nodes objects to a host object. + * + * @param {object} nodes + * @returns {array} hosts + */ + nodesToHost (nodes) { + const ids = Object.keys(nodes) + const hosts = [] + + for (var i = 0, len = ids.length; i < len; i++) { + const node = nodes[ids[i]] + hosts.push({ + url: node.http.publish_address, + id: ids[i], + roles: node.roles.reduce((acc, role) => { + acc[role] = true + return acc + }, {}) + }) + } + + return hosts + } + + /** + * Transforms an url string to a host object + * + * @param {string} url + * @returns {object} host + */ + urlToHost (url) { + return { + id: url, + url + } + } +} + +module.exports = ConnectionPool diff --git a/lib/Selectors.js b/lib/Selectors.js new file mode 100644 index 000000000..3da41a6de --- /dev/null +++ b/lib/Selectors.js @@ -0,0 +1,23 @@ +'use strict' + +class RoundRobinSelector { + constructor () { + this.current = -1 + } + + select (connections) { + if (++this.current >= connections.length) { + this.current = 0 + } + return connections[this.current] + } +} + +class RandomSelector { + select (connections) { + const index = Math.floor(Math.random() * connections.length) + return connections[index] + } +} + +module.exports = { RoundRobinSelector, RandomSelector } diff --git a/lib/Serializer.js b/lib/Serializer.js new file mode 100644 index 000000000..ea37ed513 --- /dev/null +++ b/lib/Serializer.js @@ -0,0 +1,28 @@ +'use strict' + +const debug = require('debug')('elasticsearch') +const { SerializationError, DeserializationError } = require('./errors') + +class Serializer { + serialize (object) { + debug('Serializing', object) + try { + var json = JSON.stringify(object) + } catch (err) { + throw new SerializationError(err.message) + } + return json + } + + deserialize (json) { + debug('Deserializing', json) + try { + var object = JSON.parse(json) + } catch (err) { + throw new DeserializationError(err.message) + } + return object + } +} + +module.exports = Serializer diff --git a/lib/Transport.js b/lib/Transport.js new file mode 100644 index 000000000..eb8531c3f --- /dev/null +++ b/lib/Transport.js @@ -0,0 +1,126 @@ +'use strict' + +const debug = require('debug')('elasticsearch') +const once = require('once') +const { + ConnectionError, + TimeoutError, + NoLivingConnectionsError, + ResponseError +} = require('./errors') + +const noop = () => {} +const kRemainingAttempts = Symbol('elasticsearch-remaining-attempts') + +class Transport { + constructor (opts = {}) { + this.connectionPool = opts.connectionPool + this.serializer = opts.serializer + this.maxRetries = opts.maxRetries + this.requestTimeout = opts.requestTimeout + this.sniffInterval = opts.sniffInterval + + this._sniffEnabled = typeof this.sniffInterval === 'number' + this._nextSniff = this._sniffEnabled ? (Date.now() + this.sniffInterval) : 0 + this._isSniffing = false + + if (opts.sniffOnStart === true) { + this.sniff() + } + } + + request (params, callback) { + callback = once(callback) + const attempts = params[kRemainingAttempts] || params.maxRetries || this.maxRetries + const connection = this.getConnection() + if (connection === null) { + return callback(new NoLivingConnectionsError('There are not living connections')) + } + + if (params.body !== null) { + try { + params.body = this.serializer.serialize(params.body) + } catch (err) { + return callback(err) + } + params.headers = params.headers || {} + params.headers['Content-Type'] = 'application/json' + params.headers['Content-Length'] = '' + Buffer.byteLength(params.body) + } + + const request = connection.request(params, (err, response) => { + if (err != null) { + this.connectionPool.markDead(connection) + if (attempts > 0) { + debug(`Retrying request, there are still ${attempts} attempts`, params) + params[kRemainingAttempts] = attempts - 1 + return this.request(params, callback) + } + + if (err.message === 'Request timed out') { + return callback(new TimeoutError(err.message)) + } else { + return callback(new ConnectionError(err.message)) + } + } + + var json = '' + response.setEncoding('utf8') + response.on('data', chunk => { json += chunk }) + response.on('error', err => callback(err)) + response.on('end', () => { + this.connectionPool.markAlive(connection) + try { + var payload = this.serializer.deserialize(json) + } catch (err) { + return callback(err) + } + const { statusCode } = response + if (statusCode >= 400) { + callback(new ResponseError(payload)) + } else { + callback(null, payload) + } + }) + }) + + return function requestAborter () { + request.abort() + debug('Request aborted', params) + } + } + + getConnection () { + const now = Date.now() + if (this._sniffEnabled === true && now > this._nextSniff) { + this.sniff(now) + } + this.connectionPool.resurrect(now) + return this.connectionPool.getConnection() + } + + sniff (now = Date.now(), callback = noop) { + if (this._isSniffing === true) return + debug('Started sniffing request') + this.request({ + method: 'GET', + path: '_nodes/_all/http' + }, (err, body) => { + if (this._sniffEnabled === true) { + this._nextSniff = now + this.sniffInterval + } + if (err) { + debug('Siffing errored', err) + return callback(err) + } + debug('Siffing ended successfully', body) + const hosts = this.connectionPool.nodesToHost(body.nodes) + this.connectionPool + .empty() + .addConnection(hosts) + callback() + }) + } +} + +module.exports = Transport diff --git a/lib/errors.js b/lib/errors.js new file mode 100644 index 000000000..38c82eb67 --- /dev/null +++ b/lib/errors.js @@ -0,0 +1,76 @@ +'use strict' + +class BadConfigurationError extends Error { + constructor (message) { + super() + Error.captureStackTrace(this, BadConfigurationError) + this.name = 'BadConfigurationError' + this.message = message || 'Bad Configuration Error' + } +} + +class TimeoutError extends Error { + constructor (message) { + super() + Error.captureStackTrace(this, TimeoutError) + this.name = 'TimeoutError' + this.message = message || 'Timeout Error' + } +} + +class ConnectionError extends Error { + constructor (message) { + super() + Error.captureStackTrace(this, ConnectionError) + this.name = 'ConnectionError' + this.message = message || 'Connection Error' + } +} + +class NoLivingConnectionsError extends Error { + constructor (message) { + super() + Error.captureStackTrace(this, NoLivingConnectionsError) + this.name = 'NoLivingConnectionsError' + this.message = message || 'No Living Connections Error' + } +} + +class SerializationError extends Error { + constructor (message) { + super() + Error.captureStackTrace(this, SerializationError) + this.name = 'SerializationError' + this.message = message || 'Serialization Error' + } +} + +class DeserializationError extends Error { + constructor (message) { + super() + Error.captureStackTrace(this, DeserializationError) + this.name = 'DeserializationError' + this.message = message || 'Deserialization Error' + } +} + +class ResponseError extends Error { + constructor (err) { + super() + Error.captureStackTrace(this, ResponseError) + this.name = 'ResponseError' + this.message = (err && err.error && err.error.type) || 'Response Error' + this.response = err + this.statusCode = err && err.status + } +} + +module.exports = { + BadConfigurationError, + TimeoutError, + ConnectionError, + NoLivingConnectionsError, + SerializationError, + DeserializationError, + ResponseError +} diff --git a/lib/symbols.js b/lib/symbols.js new file mode 100644 index 000000000..313b6d4ce --- /dev/null +++ b/lib/symbols.js @@ -0,0 +1,15 @@ +'use strict' + +const kTransport = Symbol('elasticsearch-transport') +const kConnection = Symbol('elasticsearch-connection') +const kConnectionPool = Symbol('elasticsearch-connection-pool') +const kSerializer = Symbol('elasticsearch-serializer') +const kSelector = Symbol('elasticsearch-selector') + +module.exports = { + kTransport, + kConnection, + kConnectionPool, + kSerializer, + kSelector +} From 76fadd146670e6382865af9298fbb87c6bf5bc4d Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 18 Oct 2018 17:27:38 +0200 Subject: [PATCH 003/172] Added package.json --- package.json | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 package.json diff --git a/package.json b/package.json new file mode 100644 index 000000000..1bce1c6ae --- /dev/null +++ b/package.json @@ -0,0 +1,60 @@ +{ + "name": "@elastic/elasticsearch", + "description": "The official Elasticsearch client for Node.js", + "main": "index.js", + "homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html", + "version": "0.1.0", + "keywords": [ + "elasticsearch", + "elastic", + "kibana", + "mapping", + "REST", + "search" + ], + "scripts": { + "test": "npm run test:unit && npm run test:integration", + "test:unit": "tap test/unit/*.test.js -J -T --harmony", + "test:integration": "tap test/integration/index.js -T --harmony", + "lint": "standard", + "lint:fix": "standard --fix", + "elasticsearch": "docker run --rm -e \"node.attr.testattr=test\" -e \"path.repo=/tmp\" -e \"repositories.url.allowed_urls=http://snapshot.*\" -p 9200:9200 docker.elastic.co/elasticsearch/elasticsearch:6.4.0" + }, + "author": { + "name": "Tomas Della Vedova", + "company": "Elastic BV" + }, + "original-author": { + "name": "Spencer Alger", + "company": "Elasticsearch BV" + }, + "devDependencies": { + "js-yaml": "^3.12.0", + "minimist": "^1.2.0", + "ora": "^3.0.0", + "readable-stream": "^3.0.1", + "semver": "^5.5.1", + "simple-git": "^1.96.0", + "sinon": "^6.1.5", + "standard": "^12.0.0", + "string-to-stream": "^1.1.1", + "tap": "^12.0.1", + "workq": "^2.1.0" + }, + "dependencies": { + "debug": "^4.1.0", + "once": "^1.4.0", + "simple-get": "^3.0.3" + }, + "license": "Apache-2.0", + "repository": { + "type": "git", + "url": "https://github.com/elastic/elasticsearch-js.git" + }, + "bugs": { + "url": "https://github.com/elastic/elasticsearch-js/issues" + }, + "engines": { + "node": ">=6" + } +} From d0ac6b1f52eab2070b72522182965dc03982e1e4 Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 18 Oct 2018 17:49:13 +0200 Subject: [PATCH 004/172] Added LICENSE --- LICENSE | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. From 68cca6069bdd1c2566f82d58b21a2133cdfb9759 Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 19 Oct 2018 15:04:07 +0200 Subject: [PATCH 005/172] WIP: initial prototype - Added keep-alive Agent - Added support for HTTPS - Added log events --- index.js | 31 +++++++++++++++++++++++-------- lib/Connection.js | 28 ++++++++++++++++++++++------ lib/ConnectionPool.js | 27 ++++++++++++++++++--------- lib/Transport.js | 17 +++++++++++------ 4 files changed, 74 insertions(+), 29 deletions(-) diff --git a/index.js b/index.js index 5691a6638..f71ecbf6a 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ 'use strict' +const { EventEmitter } = require('events') const Transport = require('./lib/Transport') const Connection = require('./lib/Connection') const ConnectionPool = require('./lib/ConnectionPool') @@ -17,16 +18,24 @@ const { kSelector } = symbols -class Client { +class Client extends EventEmitter { constructor (opts = {}) { + super() if (!opts.host) { throw new BadConfigurationError('Missing host option') } - // if (opts.log) { - // this.on('response', console.log) - // this.on('error', console.log) - // } + if (opts.log === true) { + this.on('request', console.log) + this.on('response', console.log) + this.on('error', console.log) + } + + // The logging is exposed via events, which the user can + // listen to and log the message its preferred way + // we add a fake listener to the error event to avoid + // the "unhandled error event" error. + this.on('error', () => {}) const Selector = selectors.RoundRobinSelector const options = Object.assign({}, { @@ -38,15 +47,22 @@ class Client { maxRetries: 3, requestTimeout: 30000, sniffInterval: false, - sniffOnStart: false + sniffOnStart: false, + ssl: null }, opts) this[kSelector] = new options.Selector() this[kSerializer] = new options.Serializer() this[kConnectionPool] = new options.ConnectionPool({ - selector: this[kSelector] + selector: this[kSelector], + ssl: options.ssl }) + + // Add the connections before initialize the Transport + this[kConnectionPool].addConnection(options.host) + this[kTransport] = new options.Transport({ + emit: this.emit.bind(this), connectionPool: this[kConnectionPool], serializer: this[kSerializer], maxRetries: options.maxRetries, @@ -65,7 +81,6 @@ class Client { // this[api] = apis[api] // }) - this[kConnectionPool].addConnection(options.host) } } diff --git a/lib/Connection.js b/lib/Connection.js index 8e9d74386..a08765d8a 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -1,31 +1,47 @@ 'use strict' const assert = require('assert') -const debug = require('debug')('elasticsearch') +const { Agent: HttpAgent } = require('http') +const { Agent: HttpsAgent } = require('https') const { resolve } = require('url') +const debug = require('debug')('elasticsearch') const makeRequest = require('simple-get') class Connection { constructor (opts = {}) { - assert(opts.url, 'Missing url') + assert(opts.host, 'Missing host data') - this.url = opts.url - this.id = opts.id || opts.url + this.host = opts.host + this.ssl = opts.host.ssl || opts.ssl || null + this.id = opts.id || opts.host.href this.deadCount = 0 this.resurrectTimeout = 0 this._status = opts.status || Connection.statuses.ALIVE this.roles = opts.roles || defaultRoles + + const agentOptions = Object.assign({}, { + keepAlive: true, + keepAliveMsecs: 1000, + maxSockets: Infinity, + maxFreeSockets: 256, + timeout: 60000 + }, opts.host.agent || opts.agent) + this._agent = this.host.protocol === 'http:' + ? new HttpAgent(agentOptions) + : new HttpsAgent(Object.assign({}, agentOptions, this.ssl)) } request (params, callback) { - params.url = resolve(this.url, params.path) + params.url = resolve(this.host.href, params.path) + params.agent = this._agent debug('Starting a new request', params) return makeRequest(params, callback) } close () { - debug('Closing connection') + debug('Closing connection', this.id) + this._agent.destroy() } setRole (role, enabled) { diff --git a/lib/ConnectionPool.js b/lib/ConnectionPool.js index a1a1c3637..7e16b5269 100644 --- a/lib/ConnectionPool.js +++ b/lib/ConnectionPool.js @@ -1,5 +1,6 @@ 'use strict' +const { URL } = require('url') const debug = require('debug')('elasticsearch') const Connection = require('./Connection') @@ -9,6 +10,7 @@ class ConnectionPool { this.alive = [] this.dead = [] this.selector = opts.selector + this.sll = opts.sll // the resurrect timeout is 60s // we multiply it by 2 because the resurrect formula is // `Math.pow(resurrectTimeout * 2, deadCount -1)` @@ -132,16 +134,17 @@ class ConnectionPool { * @param {object|string} host * @returns {ConnectionPool} */ - addConnection (host) { - if (Array.isArray(host)) { - host.forEach(h => this.addConnection(h)) + addConnection (opts) { + if (Array.isArray(opts)) { + opts.forEach(o => this.addConnection(o)) return } - if (typeof host === 'string') { - host = this.urlToHost(host) + if (typeof opts === 'string') { + opts = this.urlToHost(opts) } - const connection = new Connection(host) + Object.assign(opts, this.ssl) + const connection = new Connection(opts) debug('Adding a new connection', connection) this.connections.set(connection.id, connection) this.alive.push(connection.id) @@ -156,6 +159,7 @@ class ConnectionPool { */ removeConnection (connection) { debug('Removing connection', connection) + connection.close() const { id } = connection this.connections.delete(id) var index = this.dead.indexOf(id) @@ -193,8 +197,14 @@ class ConnectionPool { for (var i = 0, len = ids.length; i < len; i++) { const node = nodes[ids[i]] + // If there is no protocol in + // the `publish_address` new URL wil throw + var address = node.http.publish_address + address = address.slice(0, 4) === 'http' + ? address + : 'http://' + address hosts.push({ - url: node.http.publish_address, + host: new URL(address), id: ids[i], roles: node.roles.reduce((acc, role) => { acc[role] = true @@ -214,8 +224,7 @@ class ConnectionPool { */ urlToHost (url) { return { - id: url, - url + host: new URL(url) } } } diff --git a/lib/Transport.js b/lib/Transport.js index eb8531c3f..3c962f2df 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -14,6 +14,7 @@ const kRemainingAttempts = Symbol('elasticsearch-remaining-attempts') class Transport { constructor (opts = {}) { + this.emit = opts.emit this.connectionPool = opts.connectionPool this.serializer = opts.serializer this.maxRetries = opts.maxRetries @@ -37,7 +38,7 @@ class Transport { return callback(new NoLivingConnectionsError('There are not living connections')) } - if (params.body !== null) { + if (params.body != null) { try { params.body = this.serializer.serialize(params.body) } catch (err) { @@ -48,6 +49,7 @@ class Transport { params.headers['Content-Length'] = '' + Buffer.byteLength(params.body) } + this.emit('request', params) const request = connection.request(params, (err, response) => { if (err != null) { this.connectionPool.markDead(connection) @@ -57,11 +59,12 @@ class Transport { return this.request(params, callback) } - if (err.message === 'Request timed out') { - return callback(new TimeoutError(err.message)) - } else { - return callback(new ConnectionError(err.message)) - } + const error = err.message === 'Request timed out' + ? new TimeoutError(err.message) + : ConnectionError(err.message) + + this.emit('error', error, params) + return callback(error) } var json = '' @@ -73,9 +76,11 @@ class Transport { try { var payload = this.serializer.deserialize(json) } catch (err) { + this.emit('error', err) return callback(err) } const { statusCode } = response + this.emit('response', params, { statusCode, payload }) if (statusCode >= 400) { callback(new ResponseError(payload)) } else { From cef4e2dfc13dd65f28b6f79a0a3dee5b3dba0565 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 22 Oct 2018 16:50:17 +0200 Subject: [PATCH 006/172] WIP: initial prototype - Added support for request timeout - Improved deserializer - Fixed minor bugs - Fixed typos --- index.js | 6 ++++-- lib/Connection.js | 3 +-- lib/ConnectionPool.js | 12 +++++++++--- lib/Transport.js | 28 ++++++++++++++++++---------- 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/index.js b/index.js index f71ecbf6a..8454bce5d 100644 --- a/index.js +++ b/index.js @@ -48,14 +48,16 @@ class Client extends EventEmitter { requestTimeout: 30000, sniffInterval: false, sniffOnStart: false, - ssl: null + ssl: null, + agent: null }, opts) this[kSelector] = new options.Selector() this[kSerializer] = new options.Serializer() this[kConnectionPool] = new options.ConnectionPool({ selector: this[kSelector], - ssl: options.ssl + ssl: options.ssl, + agent: null }) // Add the connections before initialize the Transport diff --git a/lib/Connection.js b/lib/Connection.js index a08765d8a..99d9f7be9 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -24,8 +24,7 @@ class Connection { keepAlive: true, keepAliveMsecs: 1000, maxSockets: Infinity, - maxFreeSockets: 256, - timeout: 60000 + maxFreeSockets: 256 }, opts.host.agent || opts.agent) this._agent = this.host.protocol === 'http:' ? new HttpAgent(agentOptions) diff --git a/lib/ConnectionPool.js b/lib/ConnectionPool.js index 7e16b5269..e6fbd446b 100644 --- a/lib/ConnectionPool.js +++ b/lib/ConnectionPool.js @@ -10,7 +10,8 @@ class ConnectionPool { this.alive = [] this.dead = [] this.selector = opts.selector - this.sll = opts.sll + this._ssl = opts.ssl + this._agent = opts.agent // the resurrect timeout is 60s // we multiply it by 2 because the resurrect formula is // `Math.pow(resurrectTimeout * 2, deadCount -1)` @@ -143,12 +144,17 @@ class ConnectionPool { if (typeof opts === 'string') { opts = this.urlToHost(opts) } - Object.assign(opts, this.ssl) + if (opts.ssl == null) opts.ssl = this._ssl + if (opts.agent == null) opts.agent = this._agent + const connection = new Connection(opts) debug('Adding a new connection', connection) + if (this.connections.has(connection.id)) { + throw new Error(`Connection with id '${connection.id} is already present`) + } this.connections.set(connection.id, connection) this.alive.push(connection.id) - return this + return connection } /** diff --git a/lib/Transport.js b/lib/Transport.js index 3c962f2df..6f30dc7c0 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -49,6 +49,7 @@ class Transport { params.headers['Content-Length'] = '' + Buffer.byteLength(params.body) } + params.timeout = params.timeout || this.requestTimeout this.emit('request', params) const request = connection.request(params, (err, response) => { if (err != null) { @@ -61,7 +62,7 @@ class Transport { const error = err.message === 'Request timed out' ? new TimeoutError(err.message) - : ConnectionError(err.message) + : new ConnectionError(err.message) this.emit('error', error, params) return callback(error) @@ -70,14 +71,19 @@ class Transport { var json = '' response.setEncoding('utf8') response.on('data', chunk => { json += chunk }) - response.on('error', err => callback(err)) + response.on('error', err => callback(new ConnectionError(err.message))) response.on('end', () => { this.connectionPool.markAlive(connection) - try { - var payload = this.serializer.deserialize(json) - } catch (err) { - this.emit('error', err) - return callback(err) + const contentType = response.headers['content-type'] + if (contentType != null && contentType.indexOf('application/json') > -1) { + try { + var payload = this.serializer.deserialize(json) + } catch (err) { + this.emit('error', err) + return callback(err) + } + } else { + payload = json } const { statusCode } = response this.emit('response', params, { statusCode, payload }) @@ -89,9 +95,11 @@ class Transport { }) }) - return function requestAborter () { - request.abort() - debug('Request aborted', params) + return { + abort: () => { + request.abort() + debug('Request aborted', params) + } } } From b6b04f99d8f669b5b371dab858856682073a390d Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 22 Oct 2018 16:52:00 +0200 Subject: [PATCH 007/172] WIP: Added some basic unit tests - Added unit test - Added test fixtures - Added test utils --- test/fixtures/https.cert | 19 ++ test/fixtures/https.key | 27 ++ test/unit/connection-pool.test.js | 137 +++++++++ test/unit/connection.test.js | 194 ++++++++++++ test/unit/selectors.test.js | 24 ++ test/unit/serializer.test.js | 39 +++ test/unit/transport.test.js | 471 ++++++++++++++++++++++++++++++ test/utils/buildServer.js | 34 +++ test/utils/index.js | 7 + 9 files changed, 952 insertions(+) create mode 100644 test/fixtures/https.cert create mode 100644 test/fixtures/https.key create mode 100644 test/unit/connection-pool.test.js create mode 100644 test/unit/connection.test.js create mode 100644 test/unit/selectors.test.js create mode 100644 test/unit/serializer.test.js create mode 100644 test/unit/transport.test.js create mode 100644 test/utils/buildServer.js create mode 100644 test/utils/index.js diff --git a/test/fixtures/https.cert b/test/fixtures/https.cert new file mode 100644 index 000000000..d859cfa9f --- /dev/null +++ b/test/fixtures/https.cert @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDBzCCAe+gAwIBAgIJALbQMeb7k/WqMA0GCSqGSIb3DQEBBQUAMBoxGDAWBgNV +BAMMD3d3dy5mYXN0aWZ5Lm9yZzAeFw0xNzAyMDcyMDE5NDJaFw0yNzAyMDUyMDE5 +NDJaMBoxGDAWBgNVBAMMD3d3dy5mYXN0aWZ5Lm9yZzCCASIwDQYJKoZIhvcNAQEB +BQADggEPADCCAQoCggEBAKtfXzDMmU+n3A7oVVOiqp6Z5cgu1t+qgj7TadwXONvO +RZvuOcE8BZpM9tQEDE5XEIdcszDx0tWKHHSobgZAxDaEuK1PMhh/RTNvw1KzYJFm +2G38mqgm11JUni87xmIFqpgJfeCApHnWUv+3/npuQniOoVSL13jdXEifeFM8onQn +R73TVDyvMOjljTulMo0n9V8pYhVSzPnm2uxTu03p5+HosQE2bU0QKj7k8/8dwRVX +EqnTtbLoW+Wf7V2W3cr/UnfPH8JSaBWTqct0pgXqYIqOSTiWQkO7pE69mGPHrRlm +7+whp4WRriTacB3Ul+Cbx28wHU+D83ver4A8LKGVDSECAwEAAaNQME4wHQYDVR0O +BBYEFHVzTr/tNziIUrR75UHXXA84yqmgMB8GA1UdIwQYMBaAFHVzTr/tNziIUrR7 +5UHXXA84yqmgMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAKVSdGeF +vYcZOi0TG2WX7O3tSmu4G4nGxTldFiEVF89G0AU+HhNy9iwKXQLjDB7zMe/ZKbtJ +cQgc6s8eZWxBk/OoPD1WNFGstx2EO2kRkSUBKhwnOct7CIS5X+NPXyHx2Yi03JHX +unMA4WaHyo0dK4vAuali4OYdQqajNwL74avkRIxXFnZQeHzaq6tc6gX+ryB4dDSr +tYn46Lo14D5jH6PtZ8DlGK+jIzM4IE7TEp2iv0CgaTU4ryt/SHPnLxfwZUpl7gSO +EqkMAy3TlRMpv0oXM2Vh/CsyJzq2P/nY/O3bolsashSPWo9WsQTH4giYVA51ZVDK +lGksQD+oWpfa3X0= +-----END CERTIFICATE----- diff --git a/test/fixtures/https.key b/test/fixtures/https.key new file mode 100644 index 000000000..e3778a191 --- /dev/null +++ b/test/fixtures/https.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpQIBAAKCAQEAq19fMMyZT6fcDuhVU6KqnpnlyC7W36qCPtNp3Bc4285Fm+45 +wTwFmkz21AQMTlcQh1yzMPHS1YocdKhuBkDENoS4rU8yGH9FM2/DUrNgkWbYbfya +qCbXUlSeLzvGYgWqmAl94ICkedZS/7f+em5CeI6hVIvXeN1cSJ94UzyidCdHvdNU +PK8w6OWNO6UyjSf1XyliFVLM+eba7FO7Tenn4eixATZtTRAqPuTz/x3BFVcSqdO1 +suhb5Z/tXZbdyv9Sd88fwlJoFZOpy3SmBepgio5JOJZCQ7ukTr2YY8etGWbv7CGn +hZGuJNpwHdSX4JvHbzAdT4Pze96vgDwsoZUNIQIDAQABAoIBAG278ys/R8he1yVg +lgqo9ZH7P8zwWTz9ZMsv+vAomor9SUtwvuDCO2AzejYGpY6gZ4AV1tQ3dOaxukjk +9Rbh8AJs+AhZ1t0i2b/3B95z6BkS/vFmt+2GeYhJkMT0BLMNp9AU+9p+5VLy71C5 +k6T3525k/l8x8HZ/YDFMk/LQt8GhvM6A3J3BNElKraiDVO6ZIWgQQ5wiefJkApo1 +BsptHNTx83FbnkEbAahmOR8PfKcRdKY/mZDM2WrlfoU2uwVzPV0/KdYucpsfg2et +jb5bdJzcvZDuDF4GsPi1asCSC1c403R0XGuPFW9TiBuOPxbfhYK2o60yTggX6H2X +39WBc/ECgYEA3KNGgXEWzDSLpGciUisP+MzulOdQPawBTUHNykpQklEppnZbNWCX +07dv6uasnp0pFHG4WlhZJ4+IQBpZH6xAVy9y68PvN7IDYdgMiEiYPSyqQu0rvJGa +2ZR79SHDokZ8K5oofocC839RzleNRqWqxIwhHt29sxVs73kvml6OQm0CgYEAxtbA +zbQwf6DXtFwutSgfOLgdXQK72beBdyeTcpUGbkonl5xHSbtz0CFmRpKiPnXfgg4W +GXlTrqlYF/o048B7dU9+jCKY5DXx1Yzg/EFisEIClad3WXMhNOz1vBYVH6xU3Zq1 +YuYr5dcqiCWDv89e6Y6WJOhwIDZi6RqikD2EJQUCgYEAnWSAJFCnIa8OOo4z5oe/ +kg2m2GQWUphEKXeatQbEaUwquQvPTsmEJUzDMr+xPkkAiAwDpbdGijkSyh/Bmh2H +nGpFwbf5CzMaxI6ZihK3P1SAdNO5koAQBcytjJW0eCtt4rDK2E+5pDgcBGVia5Y8 +to78BYfLDlhnaIF7mtR/CRUCgYEAvGCuzvOcUv4F/eirk5NMaQb9QqYZZD2XWVTU +O2T2b7yvX9J+M1t1cESESe4X6cbwlp1T0JSCdGIZhLXWL8Om80/52zfX07VLxP6w +FCy6G7SeEDxVNRh+6E5qzOO65YP17vDoUacxBZJgyBWKiUkkaW9dzd+sgsgj0yYZ +xz+QlyUCgYEAxdNWQnz0pR5Rt2dbIedPs7wmiZ7eAe0VjCdhMa52IyJpejdeB6Bn +Es+3lkHr0Xzty8XlQZcpbswhM8UZRgPVoBvvwQdQbv5yV+LdUu69pLM7InsdZy8u +opPY/+q9lRdJt4Pbep3pOWYeLP7k5l4vei2vOEMHRjHnoqM5etSb6RU= +-----END RSA PRIVATE KEY----- diff --git a/test/unit/connection-pool.test.js b/test/unit/connection-pool.test.js new file mode 100644 index 000000000..3f4738ce4 --- /dev/null +++ b/test/unit/connection-pool.test.js @@ -0,0 +1,137 @@ +'use strict' + +const { test } = require('tap') +const { URL } = require('url') +const ConnectionPool = require('../../lib/ConnectionPool') +const Connection = require('../../lib/Connection') +const { RoundRobinSelector } = require('../../lib/Selectors') + +test('API', t => { + t.test('addConnection', t => { + const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) + const href = 'http://localhost:9200/' + pool.addConnection(href) + t.ok(pool.connections.get(href) instanceof Connection) + t.deepEqual(pool.alive, [href]) + t.deepEqual(pool.dead, []) + t.end() + }) + + t.test('markDead', t => { + const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) + const href = 'http://localhost:9200/' + var connection = pool.addConnection(href) + pool.markDead(connection) + connection = pool.connections.get(href) + t.strictEqual(connection.deadCount, 1) + t.true(connection.resurrectTimeout > 0) + t.deepEqual(pool.alive, []) + t.deepEqual(pool.dead, [href]) + t.end() + }) + + t.test('markAlive', t => { + const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) + const href = 'http://localhost:9200/' + var connection = pool.addConnection(href) + pool.markDead(connection) + pool.markAlive(connection) + connection = pool.connections.get(href) + t.strictEqual(connection.deadCount, 0) + t.strictEqual(connection.resurrectTimeout, 0) + t.deepEqual(pool.alive, [href]) + t.deepEqual(pool.dead, []) + t.end() + }) + + t.test('resurrect', t => { + const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) + const href = 'http://localhost:9200/' + var connection = pool.addConnection(href) + pool.markDead(connection) + connection = pool.resurrect(Date.now() + 1000 * 60 * 3) + t.strictEqual(connection.deadCount, 1) + t.true(connection.resurrectTimeout > 0) + t.deepEqual(pool.alive, [href]) + t.deepEqual(pool.dead, []) + t.end() + }) + + t.test('getConnection', t => { + const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) + const href = 'http://localhost:9200/' + pool.addConnection(href) + t.ok(pool.getConnection() instanceof Connection) + t.end() + }) + + t.test('removeConnection', t => { + const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) + const href = 'http://localhost:9200/' + var connection = pool.addConnection(href) + t.ok(pool.getConnection() instanceof Connection) + pool.removeConnection(connection) + t.strictEqual(pool.getConnection(), null) + t.end() + }) + + t.test('empty', t => { + const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) + pool.addConnection('http://localhost:9200/') + pool.addConnection('http://localhost:9201/') + pool.empty() + t.strictEqual(pool.connections.size, 0) + t.deepEqual(pool.alive, []) + t.deepEqual(pool.dead, []) + t.end() + }) + + t.test('urlToHost', t => { + const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) + const url = 'http://localhost:9200' + t.deepEqual( + pool.urlToHost(url), + { host: new URL(url) } + ) + t.end() + }) + + t.test('nodesToHost', t => { + const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) + const nodes = { + a1: { + http: { + publish_address: '127.0.0.1:9200' + }, + roles: ['master', 'data', 'ingest'] + }, + a2: { + http: { + publish_address: '127.0.0.1:9202' + }, + roles: ['master', 'data', 'ingest'] + } + } + + t.deepEqual(pool.nodesToHost(nodes), [{ + host: new URL('http://127.0.0.1:9200'), + id: 'a1', + roles: { + master: true, + data: true, + ingest: true + } + }, { + host: new URL('http://127.0.0.1:9201'), + id: 'a2', + roles: { + master: true, + data: true, + ingest: true + } + }]) + t.end() + }) + + t.end() +}) diff --git a/test/unit/connection.test.js b/test/unit/connection.test.js new file mode 100644 index 000000000..8ec4eba15 --- /dev/null +++ b/test/unit/connection.test.js @@ -0,0 +1,194 @@ +'use strict' + +const { test } = require('tap') +const { buildServer } = require('../utils') +const Connection = require('../../lib/Connection') + +test('Basic (http)', t => { + t.plan(4) + + function handler (req, res) { + t.match(req.headers, { + 'x-custom-test': 'true', + connection: 'keep-alive' + }) + res.end('ok') + } + + buildServer(handler, ({ port }, server) => { + const connection = new Connection({ + host: { + href: `http://localhost:${port}`, + protocol: 'http:' + } + }) + connection.request({ + path: '/hello', + method: 'GET', + headers: { + 'X-Custom-Test': true + } + }, (err, res) => { + t.error(err) + + t.match(res.headers, { + connection: 'keep-alive' + }) + + var payload = '' + res.setEncoding('utf8') + res.on('data', chunk => { payload += chunk }) + res.on('error', err => t.fail(err)) + res.on('end', () => { + t.strictEqual(payload, 'ok') + }) + }) + }) +}) + +test('Basic (https)', t => { + t.plan(4) + + function handler (req, res) { + t.match(req.headers, { + 'x-custom-test': 'true', + connection: 'keep-alive' + }) + res.end('ok') + } + + buildServer(handler, { secure: true }, ({ port }, server) => { + const connection = new Connection({ + host: { + href: `https://localhost:${port}`, + protocol: 'https:' + } + }) + connection.request({ + path: '/hello', + method: 'GET', + headers: { + 'X-Custom-Test': true + } + }, (err, res) => { + t.error(err) + + t.match(res.headers, { + connection: 'keep-alive' + }) + + var payload = '' + res.setEncoding('utf8') + res.on('data', chunk => { payload += chunk }) + res.on('error', err => t.fail(err)) + res.on('end', () => { + t.strictEqual(payload, 'ok') + }) + }) + }) +}) + +test('Basic (https with ssl agent)', t => { + t.plan(4) + + function handler (req, res) { + t.match(req.headers, { + 'x-custom-test': 'true', + connection: 'keep-alive' + }) + res.end('ok') + } + + buildServer(handler, { secure: true }, ({ port, key, cert }, server) => { + const connection = new Connection({ + host: { + href: `https://localhost:${port}`, + protocol: 'https:' + }, + ssl: { key, cert } + }) + connection.request({ + path: '/hello', + method: 'GET', + headers: { + 'X-Custom-Test': true + } + }, (err, res) => { + t.error(err) + + t.match(res.headers, { + connection: 'keep-alive' + }) + + var payload = '' + res.setEncoding('utf8') + res.on('data', chunk => { payload += chunk }) + res.on('error', err => t.fail(err)) + res.on('end', () => { + t.strictEqual(payload, 'ok') + }) + }) + }) +}) + +test('Disable keep alive', t => { + t.plan(3) + + function handler (req, res) { + t.match(req.headers, { + 'x-custom-test': 'true', + connection: 'close' + }) + res.end('ok') + } + + buildServer(handler, ({ port }, server) => { + const connection = new Connection({ + host: { + href: `http://localhost:${port}`, + protocol: 'http:' + }, + agent: { keepAlive: false } + }) + connection.request({ + path: '/hello', + method: 'GET', + headers: { + 'X-Custom-Test': true + } + }, (err, res) => { + t.error(err) + + t.match(res.headers, { + connection: 'close' + }) + }) + }) +}) + +test('Timeout support', t => { + t.plan(1) + + function handler (req, res) { + setTimeout( + () => res.end('ok'), + 1000 + ) + } + + buildServer(handler, ({ port }, server) => { + const connection = new Connection({ + host: { + href: `http://localhost:${port}`, + protocol: 'http:' + } + }) + connection.request({ + path: '/hello', + method: 'GET', + timeout: 500 + }, (err, res) => { + t.ok(err.message, 'Request timed out') + }) + }) +}) diff --git a/test/unit/selectors.test.js b/test/unit/selectors.test.js new file mode 100644 index 000000000..2f1f18502 --- /dev/null +++ b/test/unit/selectors.test.js @@ -0,0 +1,24 @@ +'use strict' + +const { test } = require('tap') +const { RoundRobinSelector, RandomSelector } = require('../../lib/Selectors') + +test('RoundRobinSelector', t => { + const s = new RoundRobinSelector() + const arr = [0, 1, 2, 3, 4, 5] + + t.plan(arr.length + 1) + for (var i = 0; i <= arr.length; i++) { + t.strictEqual( + s.select(arr), + i === arr.length ? arr[0] : arr[i] + ) + } +}) + +test('RandomSelector', t => { + t.plan(1) + const s = new RandomSelector() + const arr = [0, 1, 2, 3, 4, 5] + t.type(s.select(arr), 'number') +}) diff --git a/test/unit/serializer.test.js b/test/unit/serializer.test.js new file mode 100644 index 000000000..2dbcad272 --- /dev/null +++ b/test/unit/serializer.test.js @@ -0,0 +1,39 @@ +'use strict' + +const { test } = require('tap') +const Serializer = require('../../lib/Serializer') +const { SerializationError, DeserializationError } = require('../../lib/errors') + +test('Basic', t => { + t.plan(2) + const s = new Serializer() + const obj = { hello: 'world' } + const json = JSON.stringify(obj) + t.strictEqual(s.serialize(obj), json) + t.deepEqual(s.deserialize(json), obj) +}) + +test('SerializationError', t => { + t.plan(1) + const s = new Serializer() + const obj = { hello: 'world' } + obj.o = obj + try { + s.serialize(obj) + t.fail('Should fail') + } catch (err) { + t.ok(err instanceof SerializationError) + } +}) + +test('DeserializationError', t => { + t.plan(1) + const s = new Serializer() + const json = '{"hello' + try { + s.deserialize(json) + t.fail('Should fail') + } catch (err) { + t.ok(err instanceof DeserializationError) + } +}) diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js new file mode 100644 index 000000000..ae54af6dc --- /dev/null +++ b/test/unit/transport.test.js @@ -0,0 +1,471 @@ +'use strict' + +const { test } = require('tap') +const { URL } = require('url') +const { buildServer } = require('../utils') +const { + NoLivingConnectionsError, + SerializationError, + DeserializationError, + TimeoutError, + ResponseError +} = require('../../lib/errors') + +const ConnectionPool = require('../../lib/ConnectionPool') +const Serializer = require('../../lib/Serializer') +const Transport = require('../../lib/Transport') +const { RoundRobinSelector } = require('../../lib/Selectors') + +test('Basic', t => { + t.plan(2) + function handler (req, res) { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, body) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + }) + }) +}) + +test('Send POST', t => { + t.plan(4) + function handler (req, res) { + t.match(req.headers, { + 'content-type': 'application/json', + 'content-length': '17' + }) + var json = '' + req.setEncoding('utf8') + req.on('data', chunk => { json += chunk }) + req.on('error', err => t.fail(err)) + req.on('end', () => { + t.deepEqual(JSON.parse(json), { hello: 'world' }) + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + }) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'POST', + path: '/hello', + body: { hello: 'world' } + }, (err, body) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + }) + }) +}) + +test('NoLivingConnectionsError', t => { + t.plan(1) + const pool = new ConnectionPool({ + selector: new RoundRobinSelector() + }) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, body) => { + t.ok(err instanceof NoLivingConnectionsError) + }) +}) + +test('SerializationError', t => { + t.plan(1) + const pool = new ConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection('http://localhost:9200') + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + const body = { hello: 'world' } + body.o = body + transport.request({ + method: 'POST', + path: '/hello', + body + }, (err, body) => { + t.ok(err instanceof SerializationError) + }) +}) + +test('DeserializationError', t => { + t.plan(1) + function handler (req, res) { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end('{"hello)') + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, body) => { + t.ok(err instanceof DeserializationError) + }) + }) +}) + +test('TimeoutError (should call markDead on the failing connection)', t => { + t.plan(2) + + class CustomConnectionPool extends ConnectionPool { + markDead (connection) { + t.strictEqual(connection.id, 'node1') + super.markDead(connection) + } + } + + function handler (req, res) { + setTimeout(() => { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + }, 1000) + } + + buildServer(handler, ({ port }, server) => { + const pool = new CustomConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection({ + host: new URL(`http://localhost:${port}`), + id: 'node1' + }) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 0, + requestTimeout: 500, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, body) => { + t.ok(err instanceof TimeoutError) + }) + }) +}) + +test('Retry mechanism', t => { + t.plan(2) + + var count = 0 + function handler (req, res) { + res.setHeader('Content-Type', 'application/json;utf=8') + if (count++ === 1) { + res.end(JSON.stringify({ hello: 'world' })) + } else { + setTimeout(() => { + res.end(JSON.stringify({ hello: 'world' })) + }, 1000) + } + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection([{ + host: new URL(`http://localhost:${port}`), + id: 'node1' + }, { + host: new URL(`http://localhost:${port}`), + id: 'node2' + }]) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 1, + requestTimeout: 500, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, body) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + }) + }) +}) + +test('Should call markAlive with a successful response', t => { + t.plan(3) + + class CustomConnectionPool extends ConnectionPool { + markAlive (connection) { + t.strictEqual(connection.id, 'node1') + super.markAlive(connection) + } + } + + function handler (req, res) { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const pool = new CustomConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection({ + host: new URL(`http://localhost:${port}`), + id: 'node1' + }) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, body) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + }) + }) +}) + +test('Should call resurrect on every request', t => { + t.plan(3) + + class CustomConnectionPool extends ConnectionPool { + resurrect (now) { + t.type(now, 'number') + } + } + + function handler (req, res) { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const pool = new CustomConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection({ + host: new URL(`http://localhost:${port}`), + id: 'node1' + }) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, body) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + }) + }) +}) + +test('Should return a request aborter utility', t => { + t.plan(1) + + function handler (req, res) { + setTimeout(() => { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + }, 1000) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection({ + host: new URL(`http://localhost:${port}`), + id: 'node1' + }) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + const request = transport.request({ + method: 'GET', + path: '/hello' + }, (_err, body) => { + t.fail('Should not be called') + }) + + request.abort() + t.pass('ok') + }) +}) + +test('ResponseError', t => { + t.plan(3) + + function handler (req, res) { + res.statusCode = 500 + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ status: 500 })) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, body) => { + t.ok(err instanceof ResponseError) + t.deepEqual(err.response, { status: 500 }) + t.strictEqual(err.statusCode, 500) + }) + }) +}) + +test('Override requestTimeout', t => { + t.plan(2) + function handler (req, res) { + setTimeout(() => { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + }, 1000) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 500, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello', + timeout: 2000 + }, (err, body) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + }) + }) +}) diff --git a/test/utils/buildServer.js b/test/utils/buildServer.js new file mode 100644 index 000000000..af038743e --- /dev/null +++ b/test/utils/buildServer.js @@ -0,0 +1,34 @@ +'use strict' + +// allow self signed certificates for testing purposes +process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0 + +const { readFileSync } = require('fs') +const { join } = require('path') +const https = require('https') +const http = require('http') + +const secureOpts = { + key: readFileSync(join(__dirname, '..', 'fixtures', 'https.key'), 'utf8'), + cert: readFileSync(join(__dirname, '..', 'fixtures', 'https.cert'), 'utf8') +} + +function buildServer (handler, opts, cb) { + if (cb == null) { + cb = opts + opts = {} + } + + const server = opts.secure + ? https.createServer(secureOpts) + : http.createServer() + + server.on('request', handler) + server.listen(0, () => { + server.unref() + const port = server.address().port + cb(Object.assign({}, secureOpts, { port }), server) + }) +} + +module.exports = buildServer diff --git a/test/utils/index.js b/test/utils/index.js new file mode 100644 index 000000000..af44045c1 --- /dev/null +++ b/test/utils/index.js @@ -0,0 +1,7 @@ +'use strict' + +const buildServer = require('./buildServer') + +module.exports = { + buildServer +} From 3c8aaaecd118e162721582425e50504930e1f16d Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 24 Oct 2018 15:47:53 +0200 Subject: [PATCH 008/172] WIP: initial prototype - Added more sniffing options - Added support for different resurrection strategies - Fixed url resolving --- index.js | 10 ++++++- lib/Connection.js | 14 ++++++++- lib/ConnectionPool.js | 67 ++++++++++++++++++++++++++++++++++--------- lib/Transport.js | 29 +++++++++++++------ 4 files changed, 96 insertions(+), 24 deletions(-) diff --git a/index.js b/index.js index 8454bce5d..0d62f44ad 100644 --- a/index.js +++ b/index.js @@ -46,8 +46,12 @@ class Client extends EventEmitter { Selector, maxRetries: 3, requestTimeout: 30000, + pingTimeout: 3000, sniffInterval: false, sniffOnStart: false, + sniffEndpoint: '_nodes/_all/http', + sniffOnConnectionFault: false, + resurrectStrategy: 'ping', ssl: null, agent: null }, opts) @@ -55,6 +59,8 @@ class Client extends EventEmitter { this[kSelector] = new options.Selector() this[kSerializer] = new options.Serializer() this[kConnectionPool] = new options.ConnectionPool({ + pingTimeout: opts.pingTimeout, + resurrectStrategy: opts.resurrectStrategy, selector: this[kSelector], ssl: options.ssl, agent: null @@ -70,7 +76,9 @@ class Client extends EventEmitter { maxRetries: options.maxRetries, requestTimeout: options.requestTimeout, sniffInterval: options.sniffInterval, - sniffOnStart: options.sniffOnStart + sniffOnStart: options.sniffOnStart, + sniffOnConnectionFault: options.sniffOnConnectionFault, + sniffEndpoint: options.sniffEndpoint }) this.request = this[kTransport].request.bind(this[kTransport]) diff --git a/lib/Connection.js b/lib/Connection.js index 99d9f7be9..af470eb8c 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -3,7 +3,6 @@ const assert = require('assert') const { Agent: HttpAgent } = require('http') const { Agent: HttpsAgent } = require('https') -const { resolve } = require('url') const debug = require('debug')('elasticsearch') const makeRequest = require('simple-get') @@ -95,4 +94,17 @@ const validStatuses = Object.keys(Connection.statuses) const validRoles = Object.keys(Connection.roles) .map(k => Connection.roles[k]) +function resolve (host, path) { + const hostEndWithSlash = host[host.length - 1] === '/' + const pathStartsWithSlash = path[0] === '/' + + if (hostEndWithSlash === true && pathStartsWithSlash === true) { + return host + path.slice(1) + } else if (hostEndWithSlash !== pathStartsWithSlash) { + return host + path + } else { + return host + '/' + path + } +} + module.exports = Connection diff --git a/lib/ConnectionPool.js b/lib/ConnectionPool.js index e6fbd446b..37bed21e0 100644 --- a/lib/ConnectionPool.js +++ b/lib/ConnectionPool.js @@ -1,8 +1,10 @@ 'use strict' +const assert = require('assert') const { URL } = require('url') const debug = require('debug')('elasticsearch') const Connection = require('./Connection') +const noop = () => {} class ConnectionPool { constructor (opts = {}) { @@ -21,6 +23,14 @@ class ConnectionPool { // number of consecutive failures after which // the timeout doesn't increase this.resurrectTimeoutCutoff = 5 + this.pingTimeout = opts.pingTimeout + + const resurrectStrategy = opts.resurrectStrategy || 'ping' + this.resurrectStrategy = ConnectionPool.resurrectStrategies[resurrectStrategy] + assert( + this.resurrectStrategy != null, + `Invalid resurrection strategy: '${resurrectStrategy}'` + ) } /** @@ -84,18 +94,20 @@ class ConnectionPool { } /** - * Tries to resurrect a connection if the `resurrectTimeout` - * has been reached, if so, it moves the connection to the - * alive list without resetting the `deadCount` or the `resurrectTimeout` + * If enabled, tries to resurrect a connection with the given + * resurrect strategy ('ping', 'optimistic', 'none'). * * @param {number} epoch - * @returns {object} connection + * @param {function} callback (isAlive, connection) */ - resurrect (now = Date.now()) { - if (this.dead.length === 0) return + resurrect (now = Date.now(), callback = noop) { + if (this.resurrectStrategy === 0 || this.dead.length === 0) { + callback(null, null) + return + } // the dead list is sorted in ascending order based on the timeout - // so the first element will always be the one with the smalles timeout + // so the first element will always be the one with the smaller timeout const connection = this.connections.get(this.dead[0]) if (now < connection.resurrectTimeout) { debug('Nothing to resurrect') @@ -103,13 +115,34 @@ class ConnectionPool { } const { id } = connection - debug(`Trying resurrect connection '${id}'`) - this.alive.push(id) - this.dead.splice(this.dead.indexOf(id), 1) - connection.status = Connection.statuses.ALIVE - this.connections.set(id, connection) - return connection + // ping strategy + if (this.resurrectStrategy === 1) { + connection.request({ + method: 'HEAD', + path: '/', + timeout: this.pingTimeout + }, (err, res) => { + var isAlive = true + if (err != null) { + debug(`Resurrect: connection '${id}' is still dead`) + this.markDead(connection) + isAlive = false + } else { + debug(`Resurrect: connection '${id}' is now alive`) + this.markAlive(connection) + } + callback(isAlive, connection) + }) + // optimistic strategy + } else { + debug(`Resurrect: optimistic resurrection for connection '${id}'`) + this.alive.push(id) + this.dead.splice(this.dead.indexOf(id), 1) + connection.status = Connection.statuses.ALIVE + this.connections.set(id, connection) + callback(null, connection) + } } /** @@ -150,7 +183,7 @@ class ConnectionPool { const connection = new Connection(opts) debug('Adding a new connection', connection) if (this.connections.has(connection.id)) { - throw new Error(`Connection with id '${connection.id} is already present`) + throw new Error(`Connection with id '${connection.id}' is already present`) } this.connections.set(connection.id, connection) this.alive.push(connection.id) @@ -235,4 +268,10 @@ class ConnectionPool { } } +ConnectionPool.resurrectStrategies = { + none: 0, + ping: 1, + optimistic: 2 +} + module.exports = ConnectionPool diff --git a/lib/Transport.js b/lib/Transport.js index 6f30dc7c0..eaa9a1ca2 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -20,6 +20,8 @@ class Transport { this.maxRetries = opts.maxRetries this.requestTimeout = opts.requestTimeout this.sniffInterval = opts.sniffInterval + this.sniffOnConnectionFault = opts.sniffOnConnectionFault + this.sniffEndpoint = opts.sniffEndpoint this._sniffEnabled = typeof this.sniffInterval === 'number' this._nextSniff = this._sniffEnabled ? (Date.now() + this.sniffInterval) : 0 @@ -54,6 +56,10 @@ class Transport { const request = connection.request(params, (err, response) => { if (err != null) { this.connectionPool.markDead(connection) + if (this.sniffOnConnectionFault === true) { + this.sniff() + } + if (attempts > 0) { debug(`Retrying request, there are still ${attempts} attempts`, params) params[kRemainingAttempts] = attempts - 1 @@ -73,6 +79,7 @@ class Transport { response.on('data', chunk => { json += chunk }) response.on('error', err => callback(new ConnectionError(err.message))) response.on('end', () => { + debug('JSON response', params, json) this.connectionPool.markAlive(connection) const contentType = response.headers['content-type'] if (contentType != null && contentType.indexOf('application/json') > -1) { @@ -106,32 +113,38 @@ class Transport { getConnection () { const now = Date.now() if (this._sniffEnabled === true && now > this._nextSniff) { - this.sniff(now) + this.sniff() } this.connectionPool.resurrect(now) return this.connectionPool.getConnection() } - sniff (now = Date.now(), callback = noop) { + sniff (callback = noop) { if (this._isSniffing === true) return + this._isSniffing = true debug('Started sniffing request') + this.request({ method: 'GET', - path: '_nodes/_all/http' + path: this.sniffEndpoint }, (err, body) => { + this._isSniffing = false if (this._sniffEnabled === true) { - this._nextSniff = now + this.sniffInterval + this._nextSniff = Date.now() + this.sniffInterval } - if (err) { - debug('Siffing errored', err) + + if (err != null) { + debug('Sniffing errored', err) return callback(err) } - debug('Siffing ended successfully', body) + + debug('Sniffing ended successfully', body) const hosts = this.connectionPool.nodesToHost(body.nodes) this.connectionPool .empty() .addConnection(hosts) - callback() + + callback(null, hosts) }) } } From aca2712161eede1f6c8f579a29aa1301cc002002 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 24 Oct 2018 15:51:54 +0200 Subject: [PATCH 009/172] Updated test --- test/unit/connection-pool.test.js | 129 +++++++++++++- test/unit/transport.test.js | 278 +++++++++++++++++++++++++++++- 2 files changed, 397 insertions(+), 10 deletions(-) diff --git a/test/unit/connection-pool.test.js b/test/unit/connection-pool.test.js index 3f4738ce4..7bc435f48 100644 --- a/test/unit/connection-pool.test.js +++ b/test/unit/connection-pool.test.js @@ -5,6 +5,7 @@ const { URL } = require('url') const ConnectionPool = require('../../lib/ConnectionPool') const Connection = require('../../lib/Connection') const { RoundRobinSelector } = require('../../lib/Selectors') +const { buildServer } = require('../utils') test('API', t => { t.test('addConnection', t => { @@ -17,6 +18,19 @@ test('API', t => { t.end() }) + t.test('addConnection should throw with two connections with the same id', t => { + const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) + const href = 'http://localhost:9200/' + pool.addConnection(href) + try { + pool.addConnection(href) + t.fail('Should throw') + } catch (err) { + t.is(err.message, `Connection with id '${href}' is already present`) + } + t.end() + }) + t.test('markDead', t => { const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) const href = 'http://localhost:9200/' @@ -30,6 +44,20 @@ test('API', t => { t.end() }) + t.test('markDead should sort the dead queue by deadTimeout', t => { + const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) + const href1 = 'http://localhost:9200/1' + const href2 = 'http://localhost:9200/2' + const conn1 = pool.addConnection(href1) + const conn2 = pool.addConnection(href2) + pool.markDead(conn2) + setTimeout(() => { + pool.markDead(conn1) + t.deepEqual(pool.dead, [href2, href1]) + t.end() + }, 10) + }) + t.test('markAlive', t => { const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) const href = 'http://localhost:9200/' @@ -45,15 +73,98 @@ test('API', t => { }) t.test('resurrect', t => { - const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) - const href = 'http://localhost:9200/' - var connection = pool.addConnection(href) - pool.markDead(connection) - connection = pool.resurrect(Date.now() + 1000 * 60 * 3) - t.strictEqual(connection.deadCount, 1) - t.true(connection.resurrectTimeout > 0) - t.deepEqual(pool.alive, [href]) - t.deepEqual(pool.dead, []) + t.test('ping strategy', t => { + t.test('alive', t => { + function handler (req, res) { + res.end() + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector(), + resurrectStrategy: 'ping', + pingTimeout: 3000 + }) + const href = `http://localhost:${port}/` + var connection = pool.addConnection(href) + pool.markDead(connection) + pool.resurrect(Date.now() + 1000 * 60 * 3, (isAlive, connection) => { + t.true(isAlive) + connection = pool.connections.get(connection.id) + t.strictEqual(connection.deadCount, 0) + t.strictEqual(connection.resurrectTimeout, 0) + t.deepEqual(pool.alive, [href]) + t.deepEqual(pool.dead, []) + t.end() + }) + }) + }) + + t.test('dead', t => { + buildServer(() => {}, ({ port }, server) => { + server.close() + const pool = new ConnectionPool({ + selector: new RoundRobinSelector(), + resurrectStrategy: 'ping', + pingTimeout: 3000 + }) + const href = `http://localhost:${port}/` + var connection = pool.addConnection(href) + pool.markDead(connection) + pool.resurrect(Date.now() + 1000 * 60 * 3, (isAlive, connection) => { + t.false(isAlive) + connection = pool.connections.get(connection.id) + t.strictEqual(connection.deadCount, 2) + t.true(connection.resurrectTimeout > 0) + t.deepEqual(pool.alive, []) + t.deepEqual(pool.dead, [href]) + t.end() + }) + }) + }) + + t.end() + }) + + t.test('optimistic strategy', t => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector(), + resurrectStrategy: 'optimistic' + }) + const href = 'http://localhost:9200/' + var connection = pool.addConnection(href) + pool.markDead(connection) + pool.resurrect(Date.now() + 1000 * 60 * 3, (isAlive, connection) => { + t.ok(isAlive === null) + connection = pool.connections.get(connection.id) + t.strictEqual(connection.deadCount, 1) + t.true(connection.resurrectTimeout > 0) + t.deepEqual(pool.alive, [href]) + t.deepEqual(pool.dead, []) + t.end() + }) + }) + + t.test('none strategy', t => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector(), + resurrectStrategy: 'none' + }) + const href = 'http://localhost:9200/' + var connection = pool.addConnection(href) + pool.markDead(connection) + pool.resurrect(Date.now() + 1000 * 60 * 3, (isAlive, connection) => { + t.ok(isAlive === null) + t.ok(connection === null) + connection = pool.connections.get(href) + t.strictEqual(connection.deadCount, 1) + t.true(connection.resurrectTimeout > 0) + t.deepEqual(pool.alive, []) + t.deepEqual(pool.dead, [href]) + t.end() + }) + }) + t.end() }) diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index ae54af6dc..b1de25b44 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -8,7 +8,8 @@ const { SerializationError, DeserializationError, TimeoutError, - ResponseError + ResponseError, + ConnectionError } = require('../../lib/errors') const ConnectionPool = require('../../lib/ConnectionPool') @@ -94,6 +95,39 @@ test('Send POST', t => { }) }) +test('Not JSON payload from server', t => { + t.plan(2) + function handler (req, res) { + res.setHeader('Content-Type', 'text/plain') + res.end('hello!') + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, body) => { + t.error(err) + t.strictEqual(body, 'hello!') + }) + }) +}) + test('NoLivingConnectionsError', t => { t.plan(1) const pool = new ConnectionPool({ @@ -223,6 +257,45 @@ test('TimeoutError (should call markDead on the failing connection)', t => { }) }) +test('ConnectionError (should call markDead on the failing connection)', t => { + t.plan(2) + + class CustomConnectionPool extends ConnectionPool { + markDead (connection) { + t.strictEqual(connection.id, 'node1') + super.markDead(connection) + } + } + + buildServer(() => {}, ({ port }, server) => { + server.close() + const pool = new CustomConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection({ + host: new URL(`http://localhost:${port}`), + id: 'node1' + }) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 0, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, body) => { + t.ok(err instanceof ConnectionError) + }) + }) +}) + test('Retry mechanism', t => { t.plan(2) @@ -469,3 +542,206 @@ test('Override requestTimeout', t => { }) }) }) + +test('sniff', t => { + t.test('sniffOnStart', t => { + t.plan(4) + + class CustomConnectionPool extends ConnectionPool { + empty () { + t.ok('called') + return this + } + + addConnection (hosts) { + // the first `addConnection` call should work + if (typeof hosts === 'string') { + return super.addConnection(hosts) + } + t.true(Array.isArray(hosts)) + } + + nodesToHost (nodes) { + t.ok('called') + return [] + } + } + + function handler (req, res) { + t.strictEqual(req.url, '/sniff') + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const pool = new CustomConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection(`http://localhost:${port}`) + + // eslint-disable-next-line + new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: true, + sniffEndpoint: '/sniff' + }) + }) + }) + + t.test('sniffOnConnectionFault', t => { + t.plan(4) + + class CustomConnectionPool extends ConnectionPool { + empty () { + t.ok('called') + return this + } + + addConnection (hosts) { + // the first `addConnection` call should work + if (typeof hosts === 'string') { + return super.addConnection(hosts) + } + + t.true(Array.isArray(hosts)) + } + + nodesToHost (nodes) { + t.ok('called') + return [] + } + } + + function handler (req, res) { + if (req.url === '/other/sniff') { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } else { + setTimeout(() => res.end(), 1000) + } + } + + buildServer(handler, ({ port }, server) => { + const pool = new CustomConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection(`http://localhost:${port}`) + pool.addConnection(`http://localhost:${port}/other`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 0, + requestTimeout: 500, + sniffInterval: false, + sniffOnConnectionFault: true, + sniffEndpoint: '/sniff' + }) + + transport.request({ + method: 'GET', + path: '/' + }, (err, body) => { + t.ok(err instanceof TimeoutError) + }) + }) + }) + + t.test('sniffInterval', t => { + t.plan(9) + + class CustomConnectionPool extends ConnectionPool { + empty () { + return this + } + + addConnection (hosts) { + // the first `addConnection` call should work + if (typeof hosts === 'string') { + return super.addConnection(hosts) + } + } + + nodesToHost (nodes) { + return [] + } + } + + function handler (req, res) { + // this should be called 6 times + t.ok('called') + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const pool = new CustomConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 3000, + sniffInterval: 1, + sniffEndpoint: '/sniff' + }) + + const params = { method: 'GET', path: '/' } + setTimeout(() => { + transport.request(params, t.error) + }, 100) + + setTimeout(() => { + transport.request(params, t.error) + }, 200) + + setTimeout(() => { + transport.request(params, t.error) + }, 300) + }) + }) + + t.test('errored', t => { + t.plan(1) + + class CustomConnectionPool extends ConnectionPool { + nodesToHost () { + t.fail('This should not be called') + } + } + + buildServer(() => {}, ({ port }, server) => { + server.close() + const pool = new CustomConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 0, + requestTimeout: 30000, + sniffInterval: false, + sniffEndpoint: '/sniff' + }) + + transport.sniff((err, hosts) => { + t.ok(err instanceof ConnectionError) + }) + }) + }) + + t.end() +}) From 145e2ab5e54db0244726c08dae5458f1515a600e Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 25 Oct 2018 17:07:01 +0200 Subject: [PATCH 010/172] Updated .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 06d578749..143024273 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,6 @@ jspm_packages *.swp package-lock.json + +# elasticsearch repo or binary files +elasticsearch* From 8ce9f970f054d3d21fc9d523a91265d01ee9f53d Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 25 Oct 2018 17:10:00 +0200 Subject: [PATCH 011/172] WIP: initial prototype - Added randomizeHost option - Added ignore status code option - Updated error classes - Added ndjson support - Retry on 502/3/4 --- index.js | 2 ++ lib/ConnectionPool.js | 13 ++++++++++++- lib/Serializer.js | 12 ++++++++++++ lib/Transport.js | 42 ++++++++++++++++++++++++++++++++++-------- lib/errors.js | 15 +++++++++------ 5 files changed, 69 insertions(+), 15 deletions(-) diff --git a/index.js b/index.js index 0d62f44ad..02dc24202 100644 --- a/index.js +++ b/index.js @@ -52,6 +52,7 @@ class Client extends EventEmitter { sniffEndpoint: '_nodes/_all/http', sniffOnConnectionFault: false, resurrectStrategy: 'ping', + randomizeHost: true, ssl: null, agent: null }, opts) @@ -61,6 +62,7 @@ class Client extends EventEmitter { this[kConnectionPool] = new options.ConnectionPool({ pingTimeout: opts.pingTimeout, resurrectStrategy: opts.resurrectStrategy, + randomizeHost: opts.randomizeHost, selector: this[kSelector], ssl: options.ssl, agent: null diff --git a/lib/ConnectionPool.js b/lib/ConnectionPool.js index 37bed21e0..8f52a1a77 100644 --- a/lib/ConnectionPool.js +++ b/lib/ConnectionPool.js @@ -24,6 +24,7 @@ class ConnectionPool { // the timeout doesn't increase this.resurrectTimeoutCutoff = 5 this.pingTimeout = opts.pingTimeout + this.randomizeHost = opts.randomizeHost const resurrectStrategy = opts.resurrectStrategy || 'ping' this.resurrectStrategy = ConnectionPool.resurrectStrategies[resurrectStrategy] @@ -141,7 +142,8 @@ class ConnectionPool { this.dead.splice(this.dead.indexOf(id), 1) connection.status = Connection.statuses.ALIVE this.connections.set(id, connection) - callback(null, connection) + // eslint-disable-next-line standard/no-callback-literal + callback(true, connection) } } @@ -187,6 +189,9 @@ class ConnectionPool { } this.connections.set(connection.id, connection) this.alive.push(connection.id) + if (this.randomizeHost === true) { + this.alive = shuffleArray(this.alive) + } return connection } @@ -274,4 +279,10 @@ ConnectionPool.resurrectStrategies = { optimistic: 2 } +// https://gist.github.com/guilhermepontes/17ae0cc71fa2b13ea8c20c94c5c35dc4 +const shuffleArray = arr => arr + .map(a => [Math.random(), a]) + .sort((a, b) => a[0] - b[0]) + .map(a => a[1]) + module.exports = ConnectionPool diff --git a/lib/Serializer.js b/lib/Serializer.js index ea37ed513..52125ea29 100644 --- a/lib/Serializer.js +++ b/lib/Serializer.js @@ -23,6 +23,18 @@ class Serializer { } return object } + + ndserialize (array) { + debug('ndserialize', array) + if (Array.isArray(array) === false) { + throw new SerializationError('The argument provided is not an array') + } + var ndjson = '' + for (var i = 0, len = array.length; i < len; i++) { + ndjson += this.serialize(array[i]) + '\n' + } + return ndjson + } } module.exports = Serializer diff --git a/lib/Transport.js b/lib/Transport.js index eaa9a1ca2..6885d143c 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -40,6 +40,7 @@ class Transport { return callback(new NoLivingConnectionsError('There are not living connections')) } + // handle json body if (params.body != null) { try { params.body = this.serializer.serialize(params.body) @@ -49,6 +50,16 @@ class Transport { params.headers = params.headers || {} params.headers['Content-Type'] = 'application/json' params.headers['Content-Length'] = '' + Buffer.byteLength(params.body) + // handle ndjson body + } else if (params.bulkBody != null) { + try { + params.body = this.serializer.ndserialize(params.bulkBody) + } catch (err) { + return callback(err) + } + params.headers = params.headers || {} + params.headers['Content-Type'] = 'application/x-ndjson' + params.headers['Content-Length'] = '' + Buffer.byteLength(params.body) } params.timeout = params.timeout || this.requestTimeout @@ -67,8 +78,8 @@ class Transport { } const error = err.message === 'Request timed out' - ? new TimeoutError(err.message) - : new ConnectionError(err.message) + ? new TimeoutError(err.message, params) + : new ConnectionError(err.message, params) this.emit('error', error, params) return callback(error) @@ -77,10 +88,10 @@ class Transport { var json = '' response.setEncoding('utf8') response.on('data', chunk => { json += chunk }) - response.on('error', err => callback(new ConnectionError(err.message))) + response.on('error', err => callback(new ConnectionError(err.message, params))) response.on('end', () => { debug('JSON response', params, json) - this.connectionPool.markAlive(connection) + const contentType = response.headers['content-type'] if (contentType != null && contentType.indexOf('application/json') > -1) { try { @@ -92,10 +103,25 @@ class Transport { } else { payload = json } - const { statusCode } = response - this.emit('response', params, { statusCode, payload }) - if (statusCode >= 400) { - callback(new ResponseError(payload)) + + const { statusCode, headers } = response + const ignoreStatusCode = Array.isArray(params.ignore) && params.ignore.indexOf(statusCode) > -1 + + if (ignoreStatusCode === false && + (statusCode === 502 || statusCode === 503 || statusCode === 504)) { + this.connectionPool.markDead(connection) + if (attempts > 0) { + debug(`Retrying request, there are still ${attempts} attempts`, params) + params[kRemainingAttempts] = attempts - 1 + return this.request(params, callback) + } + } else { + this.connectionPool.markAlive(connection) + } + + this.emit('response', params, { statusCode, payload, headers }) + if (ignoreStatusCode === false && statusCode >= 400) { + callback(new ResponseError(payload, statusCode, headers)) } else { callback(null, payload) } diff --git a/lib/errors.js b/lib/errors.js index 38c82eb67..364808168 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -10,20 +10,22 @@ class BadConfigurationError extends Error { } class TimeoutError extends Error { - constructor (message) { + constructor (message, request) { super() Error.captureStackTrace(this, TimeoutError) this.name = 'TimeoutError' this.message = message || 'Timeout Error' + this.request = request } } class ConnectionError extends Error { - constructor (message) { + constructor (message, request) { super() Error.captureStackTrace(this, ConnectionError) this.name = 'ConnectionError' this.message = message || 'Connection Error' + this.request = request } } @@ -55,13 +57,14 @@ class DeserializationError extends Error { } class ResponseError extends Error { - constructor (err) { + constructor (payload, statusCode, headers) { super() Error.captureStackTrace(this, ResponseError) this.name = 'ResponseError' - this.message = (err && err.error && err.error.type) || 'Response Error' - this.response = err - this.statusCode = err && err.status + this.message = (payload && payload.error && payload.error.type) || 'Response Error' + this.response = payload + this.statusCode = (payload && payload.status) || statusCode + this.headers = headers } } From 8429ad28d97fa3577a1fd077c3fdf045ae03ebe1 Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 25 Oct 2018 17:12:30 +0200 Subject: [PATCH 012/172] Updated test --- test/unit/serializer.test.js | 27 +++++ test/unit/transport.test.js | 214 +++++++++++++++++++++++++++++++++++ 2 files changed, 241 insertions(+) diff --git a/test/unit/serializer.test.js b/test/unit/serializer.test.js index 2dbcad272..5f44820e2 100644 --- a/test/unit/serializer.test.js +++ b/test/unit/serializer.test.js @@ -13,6 +13,22 @@ test('Basic', t => { t.deepEqual(s.deserialize(json), obj) }) +test('ndserialize', t => { + t.plan(1) + const s = new Serializer() + const obj = [ + { hello: 'world' }, + { winter: 'is coming' }, + { you_know: 'for search' } + ] + t.strictEqual( + s.ndserialize(obj), + JSON.stringify(obj[0]) + '\n' + + JSON.stringify(obj[1]) + '\n' + + JSON.stringify(obj[2]) + '\n' + ) +}) + test('SerializationError', t => { t.plan(1) const s = new Serializer() @@ -26,6 +42,17 @@ test('SerializationError', t => { } }) +test('SerializationError ndserialize', t => { + t.plan(1) + const s = new Serializer() + try { + s.ndserialize({ hello: 'world' }) + t.fail('Should fail') + } catch (err) { + t.ok(err instanceof SerializationError) + } +}) + test('DeserializationError', t => { t.plan(1) const s = new Serializer() diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index b1de25b44..245a1f2f3 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -95,6 +95,63 @@ test('Send POST', t => { }) }) +test('Send POST (ndjson)', t => { + t.plan(4) + + const bulkBody = [ + { hello: 'world' }, + { winter: 'is coming' }, + { you_know: 'for search' } + ] + + function handler (req, res) { + t.match(req.headers, { + 'content-type': 'application/x-ndjson', + 'content-length': '67' + }) + var json = '' + req.setEncoding('utf8') + req.on('data', chunk => { json += chunk }) + req.on('error', err => t.fail(err)) + req.on('end', () => { + t.strictEqual( + json, + JSON.stringify(bulkBody[0]) + '\n' + + JSON.stringify(bulkBody[1]) + '\n' + + JSON.stringify(bulkBody[2]) + '\n' + ) + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + }) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'POST', + path: '/hello', + bulkBody + }, (err, body) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + }) + }) +}) + test('Not JSON payload from server', t => { t.plan(2) function handler (req, res) { @@ -745,3 +802,160 @@ test('sniff', t => { t.end() }) + +test(`Should mark as dead connections where the statusCode is 502/3/4 + and return a ResponseError if there are no more attempts`, t => { + ;[502, 503, 504].forEach(runTest) + + function runTest (statusCode) { + t.test(statusCode, t => { + t.plan(3) + function handler (req, res) { + res.statusCode = statusCode + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + class CustomConnectionPool extends ConnectionPool { + markDead (connection) { + t.ok('called') + super.markDead(connection) + } + } + + buildServer(handler, ({ port }, server) => { + const pool = new CustomConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 0, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, body) => { + t.ok(err instanceof ResponseError) + t.match(err, { + response: { hello: 'world' }, + headers: { 'content-type': 'application/json;utf=8' }, + statusCode: statusCode + }) + }) + }) + }) + } + + t.end() +}) + +test('Should retry the request if the statusCode is 502/3/4', t => { + ;[502, 503, 504].forEach(runTest) + + function runTest (statusCode) { + t.test(statusCode, t => { + t.plan(3) + + var first = true + function handler (req, res) { + if (first) { + first = false + res.statusCode = statusCode + } + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + class CustomConnectionPool extends ConnectionPool { + markDead (connection) { + t.ok('called') + } + } + + buildServer(handler, ({ port }, server) => { + const pool = new CustomConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 1, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, body) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + }) + }) + }) + } + + t.end() +}) + +test('Ignore status code', t => { + t.plan(4) + function handler (req, res) { + res.statusCode = 404 + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello', + ignore: [404] + }, (err, body) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, body) => { + t.ok(err instanceof ResponseError) + }) + + transport.request({ + method: 'GET', + path: '/hello', + ignore: [403, 405] + }, (err, body) => { + t.ok(err instanceof ResponseError) + }) + }) +}) From 51e6c76511b0b76dc2de6851f8baefd067d383e0 Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 26 Oct 2018 19:04:45 +0200 Subject: [PATCH 013/172] WIP: initial prototype - Added querystring support - Added support for already serialized bodies --- lib/Connection.js | 3 +++ lib/Serializer.js | 14 ++++++++++++++ lib/Transport.js | 25 +++++++++++++++++-------- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/lib/Connection.js b/lib/Connection.js index af470eb8c..a51c51aa9 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -32,6 +32,9 @@ class Connection { request (params, callback) { params.url = resolve(this.host.href, params.path) + if (params.querystring != null && params.querystring.length > 0) { + params.url += '?' + params.querystring + } params.agent = this._agent debug('Starting a new request', params) return makeRequest(params, callback) diff --git a/lib/Serializer.js b/lib/Serializer.js index 52125ea29..97516a2c0 100644 --- a/lib/Serializer.js +++ b/lib/Serializer.js @@ -1,5 +1,6 @@ 'use strict' +const { stringify } = require('querystring') const debug = require('debug')('elasticsearch') const { SerializationError, DeserializationError } = require('./errors') @@ -35,6 +36,19 @@ class Serializer { } return ndjson } + + qserialize (object) { + debug('qserialize', object) + // arrays should be serialized as comma separated list + const keys = Object.keys(object) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (Array.isArray(object[key]) === true) { + object[key] = object[key].join(',') + } + } + return stringify(object) + } } module.exports = Serializer diff --git a/lib/Transport.js b/lib/Transport.js index 6885d143c..420e65767 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -42,28 +42,37 @@ class Transport { // handle json body if (params.body != null) { - try { - params.body = this.serializer.serialize(params.body) - } catch (err) { - return callback(err) + if (typeof params.body !== 'string') { + try { + params.body = this.serializer.serialize(params.body) + } catch (err) { + return callback(err) + } } params.headers = params.headers || {} params.headers['Content-Type'] = 'application/json' params.headers['Content-Length'] = '' + Buffer.byteLength(params.body) // handle ndjson body } else if (params.bulkBody != null) { - try { - params.body = this.serializer.ndserialize(params.bulkBody) - } catch (err) { - return callback(err) + if (typeof params.bulkBody !== 'string') { + try { + params.body = this.serializer.ndserialize(params.bulkBody) + } catch (err) { + return callback(err) + } + } else { + params.body = params.bulkBody } params.headers = params.headers || {} params.headers['Content-Type'] = 'application/x-ndjson' params.headers['Content-Length'] = '' + Buffer.byteLength(params.body) } + // serializes the querystring + params.querystring = this.serializer.qserialize(params.querystring) params.timeout = params.timeout || this.requestTimeout this.emit('request', params) + const request = connection.request(params, (err, response) => { if (err != null) { this.connectionPool.markDead(connection) From 961b8224efdeab0033e85337c5f81ee5470d0b09 Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 26 Oct 2018 19:06:04 +0200 Subject: [PATCH 014/172] Updated test --- test/unit/connection-pool.test.js | 2 +- test/unit/connection.test.js | 54 +++++++++++++++++++++++++++++++ test/unit/serializer.test.js | 29 +++++++++++++++++ test/unit/transport.test.js | 45 ++++++++++++++++++++++++-- 4 files changed, 127 insertions(+), 3 deletions(-) diff --git a/test/unit/connection-pool.test.js b/test/unit/connection-pool.test.js index 7bc435f48..9bd300edf 100644 --- a/test/unit/connection-pool.test.js +++ b/test/unit/connection-pool.test.js @@ -135,7 +135,7 @@ test('API', t => { var connection = pool.addConnection(href) pool.markDead(connection) pool.resurrect(Date.now() + 1000 * 60 * 3, (isAlive, connection) => { - t.ok(isAlive === null) + t.true(isAlive) connection = pool.connections.get(connection.id) t.strictEqual(connection.deadCount, 1) t.true(connection.resurrectTimeout > 0) diff --git a/test/unit/connection.test.js b/test/unit/connection.test.js index 8ec4eba15..f08a1b2fe 100644 --- a/test/unit/connection.test.js +++ b/test/unit/connection.test.js @@ -192,3 +192,57 @@ test('Timeout support', t => { }) }) }) + +test('querystring', t => { + t.test('Should concatenate the querystring', t => { + t.plan(2) + + function handler (req, res) { + t.strictEqual(req.url, '/hello?hello=world&you_know=for%20search') + res.end('ok') + } + + buildServer(handler, ({ port }, server) => { + const connection = new Connection({ + host: { + href: `http://localhost:${port}`, + protocol: 'http:' + } + }) + connection.request({ + path: '/hello', + method: 'GET', + querystring: 'hello=world&you_know=for%20search' + }, (err, res) => { + t.error(err) + }) + }) + }) + + t.test('If the querystring is null should not do anything', t => { + t.plan(2) + + function handler (req, res) { + t.strictEqual(req.url, '/hello') + res.end('ok') + } + + buildServer(handler, ({ port }, server) => { + const connection = new Connection({ + host: { + href: `http://localhost:${port}`, + protocol: 'http:' + } + }) + connection.request({ + path: '/hello', + method: 'GET', + querystring: null + }, (err, res) => { + t.error(err) + }) + }) + }) + + t.end() +}) diff --git a/test/unit/serializer.test.js b/test/unit/serializer.test.js index 5f44820e2..3c587be8a 100644 --- a/test/unit/serializer.test.js +++ b/test/unit/serializer.test.js @@ -1,6 +1,7 @@ 'use strict' const { test } = require('tap') +const { stringify } = require('querystring') const Serializer = require('../../lib/Serializer') const { SerializationError, DeserializationError } = require('../../lib/errors') @@ -29,6 +30,34 @@ test('ndserialize', t => { ) }) +test('qserialize', t => { + t.plan(1) + const s = new Serializer() + const obj = { + hello: 'world', + you_know: 'for search' + } + + t.strictEqual( + s.qserialize(obj), + stringify(obj) + ) +}) + +test('qserialize (array)', t => { + t.plan(1) + const s = new Serializer() + const obj = { + hello: 'world', + arr: ['foo', 'bar'] + } + + t.strictEqual( + s.qserialize(obj), + 'hello=world&arr=foo%2Cbar' + ) +}) + test('SerializationError', t => { t.plan(1) const s = new Serializer() diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index 245a1f2f3..34adc8a8a 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -359,13 +359,14 @@ test('Retry mechanism', t => { var count = 0 function handler (req, res) { res.setHeader('Content-Type', 'application/json;utf=8') - if (count++ === 1) { + if (count > 0) { res.end(JSON.stringify({ hello: 'world' })) } else { setTimeout(() => { res.end(JSON.stringify({ hello: 'world' })) }, 1000) } + count++ } buildServer(handler, ({ port }, server) => { @@ -378,6 +379,9 @@ test('Retry mechanism', t => { }, { host: new URL(`http://localhost:${port}`), id: 'node2' + }, { + host: new URL(`http://localhost:${port}`), + id: 'node3' }]) const transport = new Transport({ @@ -385,7 +389,7 @@ test('Retry mechanism', t => { connectionPool: pool, serializer: new Serializer(), maxRetries: 1, - requestTimeout: 500, + requestTimeout: 250, sniffInterval: false, sniffOnStart: false }) @@ -959,3 +963,40 @@ test('Ignore status code', t => { }) }) }) + +test('Should serialize the querystring', t => { + t.plan(2) + + function handler (req, res) { + t.strictEqual(req.url, '/hello?hello=world&you_know=for%20search') + res.end('ok') + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello', + querystring: { + hello: 'world', + you_know: 'for search' + } + }, (err, body) => { + t.error(err) + }) + }) +}) From c9635c4a71ebe79ac9bba2b00d8066d6dc3d4166 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 30 Oct 2018 16:32:10 +0100 Subject: [PATCH 015/172] WIP: initial prototype - Added support for different format of requestTimemout - Changed api method result - Now we are always returning the result in case of error - Improved body deserialization - Added cast to boolen for HEAD requests - Added support for already serialized strings in the ndserializer - Fixed qserializer in case of null object - Updated Errors --- index.js | 4 ++-- lib/Serializer.js | 7 +++++- lib/Transport.js | 61 ++++++++++++++++++++++++++++++----------------- lib/errors.js | 30 ++++++++++++----------- package.json | 1 + 5 files changed, 64 insertions(+), 39 deletions(-) diff --git a/index.js b/index.js index 02dc24202..25cf37cff 100644 --- a/index.js +++ b/index.js @@ -7,7 +7,7 @@ const ConnectionPool = require('./lib/ConnectionPool') const Serializer = require('./lib/Serializer') const selectors = require('./lib/Selectors') const symbols = require('./lib/symbols') -const { BadConfigurationError } = require('./lib/errors') +const { ConfigurationError } = require('./lib/errors') // const buildApi = require('../monorepo/packages/es-api-6') @@ -22,7 +22,7 @@ class Client extends EventEmitter { constructor (opts = {}) { super() if (!opts.host) { - throw new BadConfigurationError('Missing host option') + throw new ConfigurationError('Missing host option') } if (opts.log === true) { diff --git a/lib/Serializer.js b/lib/Serializer.js index 97516a2c0..de3e70721 100644 --- a/lib/Serializer.js +++ b/lib/Serializer.js @@ -32,13 +32,18 @@ class Serializer { } var ndjson = '' for (var i = 0, len = array.length; i < len; i++) { - ndjson += this.serialize(array[i]) + '\n' + if (typeof array[i] === 'string') { + ndjson += array[i] + '\n' + } else { + ndjson += this.serialize(array[i]) + '\n' + } } return ndjson } qserialize (object) { debug('qserialize', object) + if (object == null) return '' // arrays should be serialized as comma separated list const keys = Object.keys(object) for (var i = 0, len = keys.length; i < len; i++) { diff --git a/lib/Transport.js b/lib/Transport.js index 420e65767..58e697008 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -2,6 +2,7 @@ const debug = require('debug')('elasticsearch') const once = require('once') +const ms = require('ms') const { ConnectionError, TimeoutError, @@ -18,7 +19,7 @@ class Transport { this.connectionPool = opts.connectionPool this.serializer = opts.serializer this.maxRetries = opts.maxRetries - this.requestTimeout = opts.requestTimeout + this.requestTimeout = toMs(opts.requestTimeout) this.sniffInterval = opts.sniffInterval this.sniffOnConnectionFault = opts.sniffOnConnectionFault this.sniffEndpoint = opts.sniffEndpoint @@ -34,10 +35,11 @@ class Transport { request (params, callback) { callback = once(callback) + const result = { body: null, statusCode: null, headers: null } const attempts = params[kRemainingAttempts] || params.maxRetries || this.maxRetries const connection = this.getConnection() if (connection === null) { - return callback(new NoLivingConnectionsError('There are not living connections')) + return callback(new NoLivingConnectionsError('There are not living connections'), result) } // handle json body @@ -46,7 +48,7 @@ class Transport { try { params.body = this.serializer.serialize(params.body) } catch (err) { - return callback(err) + return callback(err, result) } } params.headers = params.headers || {} @@ -58,7 +60,7 @@ class Transport { try { params.body = this.serializer.ndserialize(params.bulkBody) } catch (err) { - return callback(err) + return callback(err, result) } } else { params.body = params.bulkBody @@ -70,7 +72,9 @@ class Transport { // serializes the querystring params.querystring = this.serializer.qserialize(params.querystring) - params.timeout = params.timeout || this.requestTimeout + // handles request timeout + params.timeout = toMs(params.requestTimeout || this.requestTimeout) + this.emit('request', params) const request = connection.request(params, (err, response) => { @@ -91,30 +95,33 @@ class Transport { : new ConnectionError(err.message, params) this.emit('error', error, params) - return callback(error) + return callback(error, result) } - var json = '' - response.setEncoding('utf8') - response.on('data', chunk => { json += chunk }) - response.on('error', err => callback(new ConnectionError(err.message, params))) - response.on('end', () => { - debug('JSON response', params, json) + const { statusCode, headers } = response + result.statusCode = statusCode + result.headers = headers - const contentType = response.headers['content-type'] - if (contentType != null && contentType.indexOf('application/json') > -1) { + var payload = '' + response.setEncoding('utf8') + response.on('data', chunk => { payload += chunk }) + response.on('error', err => callback(new ConnectionError(err.message, params), result)) + response.on('end', () => { + const isHead = params.method === 'HEAD' + const shouldDeserialize = headers['content-type'] != null && isHead === false && payload !== '' + if (shouldDeserialize === true && headers['content-type'].indexOf('application/json') > -1) { try { - var payload = this.serializer.deserialize(json) + result.body = this.serializer.deserialize(payload) } catch (err) { this.emit('error', err) - return callback(err) + return callback(err, result) } } else { - payload = json + result.body = isHead === true ? true : payload } - const { statusCode, headers } = response - const ignoreStatusCode = Array.isArray(params.ignore) && params.ignore.indexOf(statusCode) > -1 + const ignoreStatusCode = (Array.isArray(params.ignore) && params.ignore.indexOf(statusCode) > -1) || + (isHead === true && statusCode === 404) if (ignoreStatusCode === false && (statusCode === 502 || statusCode === 503 || statusCode === 504)) { @@ -128,11 +135,14 @@ class Transport { this.connectionPool.markAlive(connection) } - this.emit('response', params, { statusCode, payload, headers }) + this.emit('response', params, result) if (ignoreStatusCode === false && statusCode >= 400) { - callback(new ResponseError(payload, statusCode, headers)) + callback(new ResponseError(result), result) } else { - callback(null, payload) + if (isHead === true && statusCode === 404) { + result.body = false + } + callback(null, result) } }) }) @@ -184,4 +194,11 @@ class Transport { } } +function toMs (time) { + if (typeof time === 'string') { + return ms(time) + } + return time +} + module.exports = Transport diff --git a/lib/errors.js b/lib/errors.js index 364808168..91a8b0038 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -1,14 +1,5 @@ 'use strict' -class BadConfigurationError extends Error { - constructor (message) { - super() - Error.captureStackTrace(this, BadConfigurationError) - this.name = 'BadConfigurationError' - this.message = message || 'Bad Configuration Error' - } -} - class TimeoutError extends Error { constructor (message, request) { super() @@ -56,24 +47,35 @@ class DeserializationError extends Error { } } +class ConfigurationError extends Error { + constructor (message) { + super() + Error.captureStackTrace(this, ConfigurationError) + this.name = 'ConfigurationError' + this.message = message || 'Configuration Error' + } +} + class ResponseError extends Error { - constructor (payload, statusCode, headers) { + constructor ({ body, statusCode, headers }) { super() Error.captureStackTrace(this, ResponseError) this.name = 'ResponseError' - this.message = (payload && payload.error && payload.error.type) || 'Response Error' - this.response = payload - this.statusCode = (payload && payload.status) || statusCode + this.message = (body && body.error && body.error.type) || 'Response Error' + this.body = body + this.statusCode = body && typeof body.status === 'number' + ? body.status + : statusCode this.headers = headers } } module.exports = { - BadConfigurationError, TimeoutError, ConnectionError, NoLivingConnectionsError, SerializationError, DeserializationError, + ConfigurationError, ResponseError } diff --git a/package.json b/package.json index 1bce1c6ae..a99fcf5d3 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ }, "dependencies": { "debug": "^4.1.0", + "ms": "^2.1.1", "once": "^1.4.0", "simple-get": "^3.0.3" }, From 21a5c29aa859eca2842b66af49b200f39df36fbe Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 30 Oct 2018 16:36:03 +0100 Subject: [PATCH 016/172] Updated test --- test/unit/serializer.test.js | 16 ++ test/unit/transport.test.js | 330 ++++++++++++++++++++++++++++++++--- 2 files changed, 322 insertions(+), 24 deletions(-) diff --git a/test/unit/serializer.test.js b/test/unit/serializer.test.js index 3c587be8a..cfbfb47da 100644 --- a/test/unit/serializer.test.js +++ b/test/unit/serializer.test.js @@ -30,6 +30,22 @@ test('ndserialize', t => { ) }) +test('ndserialize (strings)', t => { + t.plan(1) + const s = new Serializer() + const obj = [ + JSON.stringify({ hello: 'world' }), + JSON.stringify({ winter: 'is coming' }), + JSON.stringify({ you_know: 'for search' }) + ] + t.strictEqual( + s.ndserialize(obj), + obj[0] + '\n' + + obj[1] + '\n' + + obj[2] + '\n' + ) +}) + test('qserialize', t => { t.plan(1) const s = new Serializer() diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index 34adc8a8a..3acc9e8ba 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -43,7 +43,7 @@ test('Basic', t => { transport.request({ method: 'GET', path: '/hello' - }, (err, body) => { + }, (err, { body }) => { t.error(err) t.deepEqual(body, { hello: 'world' }) }) @@ -88,7 +88,7 @@ test('Send POST', t => { method: 'POST', path: '/hello', body: { hello: 'world' } - }, (err, body) => { + }, (err, { body }) => { t.error(err) t.deepEqual(body, { hello: 'world' }) }) @@ -145,7 +145,7 @@ test('Send POST (ndjson)', t => { method: 'POST', path: '/hello', bulkBody - }, (err, body) => { + }, (err, { body }) => { t.error(err) t.deepEqual(body, { hello: 'world' }) }) @@ -178,7 +178,7 @@ test('Not JSON payload from server', t => { transport.request({ method: 'GET', path: '/hello' - }, (err, body) => { + }, (err, { body }) => { t.error(err) t.strictEqual(body, 'hello!') }) @@ -204,7 +204,7 @@ test('NoLivingConnectionsError', t => { transport.request({ method: 'GET', path: '/hello' - }, (err, body) => { + }, (err, { body }) => { t.ok(err instanceof NoLivingConnectionsError) }) }) @@ -232,7 +232,7 @@ test('SerializationError', t => { method: 'POST', path: '/hello', body - }, (err, body) => { + }, (err, { body }) => { t.ok(err instanceof SerializationError) }) }) @@ -263,7 +263,7 @@ test('DeserializationError', t => { transport.request({ method: 'GET', path: '/hello' - }, (err, body) => { + }, (err, { body }) => { t.ok(err instanceof DeserializationError) }) }) @@ -308,7 +308,7 @@ test('TimeoutError (should call markDead on the failing connection)', t => { transport.request({ method: 'GET', path: '/hello' - }, (err, body) => { + }, (err, { body }) => { t.ok(err instanceof TimeoutError) }) }) @@ -347,7 +347,7 @@ test('ConnectionError (should call markDead on the failing connection)', t => { transport.request({ method: 'GET', path: '/hello' - }, (err, body) => { + }, (err, { body }) => { t.ok(err instanceof ConnectionError) }) }) @@ -397,7 +397,7 @@ test('Retry mechanism', t => { transport.request({ method: 'GET', path: '/hello' - }, (err, body) => { + }, (err, { body }) => { t.error(err) t.deepEqual(body, { hello: 'world' }) }) @@ -441,7 +441,7 @@ test('Should call markAlive with a successful response', t => { transport.request({ method: 'GET', path: '/hello' - }, (err, body) => { + }, (err, { body }) => { t.error(err) t.deepEqual(body, { hello: 'world' }) }) @@ -484,7 +484,7 @@ test('Should call resurrect on every request', t => { transport.request({ method: 'GET', path: '/hello' - }, (err, body) => { + }, (err, { body }) => { t.error(err) t.deepEqual(body, { hello: 'world' }) }) @@ -560,9 +560,9 @@ test('ResponseError', t => { transport.request({ method: 'GET', path: '/hello' - }, (err, body) => { + }, (err, { body }) => { t.ok(err instanceof ResponseError) - t.deepEqual(err.response, { status: 500 }) + t.deepEqual(err.body, { status: 500 }) t.strictEqual(err.statusCode, 500) }) }) @@ -596,8 +596,8 @@ test('Override requestTimeout', t => { transport.request({ method: 'GET', path: '/hello', - timeout: 2000 - }, (err, body) => { + requestTimeout: 2000 + }, (err, { body }) => { t.error(err) t.deepEqual(body, { hello: 'world' }) }) @@ -708,7 +708,7 @@ test('sniff', t => { transport.request({ method: 'GET', path: '/' - }, (err, body) => { + }, (err, { body }) => { t.ok(err instanceof TimeoutError) }) }) @@ -846,10 +846,10 @@ test(`Should mark as dead connections where the statusCode is 502/3/4 transport.request({ method: 'GET', path: '/hello' - }, (err, body) => { + }, (err, { body }) => { t.ok(err instanceof ResponseError) t.match(err, { - response: { hello: 'world' }, + body: { hello: 'world' }, headers: { 'content-type': 'application/json;utf=8' }, statusCode: statusCode }) @@ -903,7 +903,7 @@ test('Should retry the request if the statusCode is 502/3/4', t => { transport.request({ method: 'GET', path: '/hello' - }, (err, body) => { + }, (err, { body }) => { t.error(err) t.deepEqual(body, { hello: 'world' }) }) @@ -942,7 +942,7 @@ test('Ignore status code', t => { method: 'GET', path: '/hello', ignore: [404] - }, (err, body) => { + }, (err, { body }) => { t.error(err) t.deepEqual(body, { hello: 'world' }) }) @@ -950,7 +950,7 @@ test('Ignore status code', t => { transport.request({ method: 'GET', path: '/hello' - }, (err, body) => { + }, (err, { body }) => { t.ok(err instanceof ResponseError) }) @@ -958,7 +958,7 @@ test('Ignore status code', t => { method: 'GET', path: '/hello', ignore: [403, 405] - }, (err, body) => { + }, (err, { body }) => { t.ok(err instanceof ResponseError) }) }) @@ -995,8 +995,290 @@ test('Should serialize the querystring', t => { hello: 'world', you_know: 'for search' } - }, (err, body) => { + }, (err, { body }) => { t.error(err) }) }) }) + +test('timeout option', t => { + function handler (req, res) { + setTimeout(() => { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + }, 1000) + } + + t.test('as number', t => { + t.test('global', t => { + t.plan(1) + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection({ + host: new URL(`http://localhost:${port}`), + id: 'node1' + }) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 0, + requestTimeout: 500, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, { body }) => { + t.ok(err instanceof TimeoutError) + }) + }) + }) + + t.test('custom', t => { + t.plan(1) + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection({ + host: new URL(`http://localhost:${port}`), + id: 'node1' + }) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 0, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello', + requestTimeout: 500 + }, (err, { body }) => { + t.ok(err instanceof TimeoutError) + }) + }) + }) + + t.end() + }) + + t.test('as string', t => { + t.test('global', t => { + t.plan(1) + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection({ + host: new URL(`http://localhost:${port}`), + id: 'node1' + }) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 0, + requestTimeout: '0.5s', + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, { body }) => { + t.ok(err instanceof TimeoutError) + }) + }) + }) + + t.test('custom', t => { + t.plan(1) + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection({ + host: new URL(`http://localhost:${port}`), + id: 'node1' + }) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 0, + requestTimeout: '30s', + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello', + requestTimeout: '0.5s' + }, (err, { body }) => { + t.ok(err instanceof TimeoutError) + }) + }) + }) + + t.end() + }) + + t.end() +}) + +test('Should cast to boolean HEAD request', t => { + t.test('2xx response', t => { + t.plan(2) + function handler (req, res) { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end('') + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'HEAD', + path: '/hello' + }, (err, { body }) => { + t.error(err) + t.strictEqual(body, true) + }) + }) + }) + + t.test('404 response', t => { + t.plan(2) + function handler (req, res) { + res.statusCode = 404 + res.setHeader('Content-Type', 'application/json;utf=8') + res.end('') + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'HEAD', + path: '/hello' + }, (err, { body }) => { + t.error(err) + t.strictEqual(body, false) + }) + }) + }) + + t.test('4xx response', t => { + t.plan(1) + function handler (req, res) { + res.statusCode = 400 + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'HEAD', + path: '/hello' + }, (err, { body }) => { + t.ok(err instanceof ResponseError) + }) + }) + }) + + t.test('5xx response', t => { + t.plan(1) + function handler (req, res) { + res.statusCode = 500 + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ + selector: new RoundRobinSelector() + }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'HEAD', + path: '/hello' + }, (err, { body }) => { + t.ok(err instanceof ResponseError) + }) + }) + }) + + t.end() +}) From ad9b68aea6cc4d3e43980c2c526b4fa74e1e2677 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 30 Oct 2018 17:25:23 +0100 Subject: [PATCH 017/172] Added API generation scripts --- package.json | 7 +- scripts/run.js | 72 ++++++ scripts/utils/clone-es.js | 110 +++++++++ scripts/utils/genMain.js | 106 +++++++++ scripts/utils/generate.js | 466 ++++++++++++++++++++++++++++++++++++++ scripts/utils/index.js | 7 + 6 files changed, 766 insertions(+), 2 deletions(-) create mode 100644 scripts/run.js create mode 100644 scripts/utils/clone-es.js create mode 100644 scripts/utils/genMain.js create mode 100644 scripts/utils/generate.js create mode 100644 scripts/utils/index.js diff --git a/package.json b/package.json index a99fcf5d3..ab933f5db 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "test:integration": "tap test/integration/index.js -T --harmony", "lint": "standard", "lint:fix": "standard --fix", + "generate": "node scripts/run.js", "elasticsearch": "docker run --rm -e \"node.attr.testattr=test\" -e \"path.repo=/tmp\" -e \"repositories.url.allowed_urls=http://snapshot.*\" -p 9200:9200 docker.elastic.co/elasticsearch/elasticsearch:6.4.0" }, "author": { @@ -29,12 +30,14 @@ "company": "Elasticsearch BV" }, "devDependencies": { + "dedent": "^0.7.0", "js-yaml": "^3.12.0", "minimist": "^1.2.0", "ora": "^3.0.0", "readable-stream": "^3.0.1", - "semver": "^5.5.1", - "simple-git": "^1.96.0", + "rimraf": "^2.6.2", + "semver": "^5.6.0", + "simple-git": "^1.105.0", "sinon": "^6.1.5", "standard": "^12.0.0", "string-to-stream": "^1.1.1", diff --git a/scripts/run.js b/scripts/run.js new file mode 100644 index 000000000..73af7f447 --- /dev/null +++ b/scripts/run.js @@ -0,0 +1,72 @@ +'use strict' + +const { join } = require('path') +const { readdirSync, writeFileSync } = require('fs') +const minimist = require('minimist') +const semver = require('semver') +const ora = require('ora') +const rimraf = require('rimraf') +const standard = require('standard') +const { generate, cloneAndCheckout, genFactory } = require('./utils') + +start(minimist(process.argv.slice(2), { + string: ['tag'] +})) + +function start (opts) { + const log = ora('Loading Elasticsearch Repository').start() + if (semver.valid(opts.tag) === null) { + log.fail(`Missing or invalid tag: ${opts.tag}`) + return + } + const packageFolder = join(__dirname, '..', 'api') + const apiOutputFolder = join(packageFolder, 'api') + const mainOutputFile = join(packageFolder, 'index.js') + + log.text = 'Cleaning API folder...' + rimraf.sync(join(apiOutputFolder, '*.js')) + + cloneAndCheckout({ log, tag: opts.tag }, (err, apiFolder) => { + if (err) { + log.fail(err.message) + return + } + const files = readdirSync(apiFolder) + files.forEach(generateApiFile(apiFolder, log)) + writeFileSync( + mainOutputFile, + genFactory(apiOutputFolder), + { encoding: 'utf8' } + ) + lintFiles(log) + }) + + function generateApiFile (apiFolder, log) { + var common = null + try { + common = require(join(apiFolder, '_common.json')) + } catch (e) {} + + return function _generateApiFile (file) { + if (file === '_common.json') return + log.text = `Processing ${file}` + + const spec = require(join(apiFolder, file)) + const code = generate(spec, common) + const filePath = join(apiOutputFolder, `${file.slice(0, file.lastIndexOf('.'))}.js`) + + writeFileSync(filePath, code, { encoding: 'utf8' }) + } + } + + function lintFiles (log) { + log.text = 'Linting...' + const files = [join(packageFolder, '*.js'), join(apiOutputFolder, '*.js')] + standard.lintFiles(files, { fix: true }, err => { + if (err) { + return log.fail(err.message) + } + log.succeed('Done!') + }) + } +} diff --git a/scripts/utils/clone-es.js b/scripts/utils/clone-es.js new file mode 100644 index 000000000..02452cda3 --- /dev/null +++ b/scripts/utils/clone-es.js @@ -0,0 +1,110 @@ +'use strict' + +const { accessSync, mkdirSync } = require('fs') +const { join } = require('path') +const Git = require('simple-git') + +const esRepo = 'https://github.com/elastic/elasticsearch.git' +const esFolder = join(__dirname, '..', '..', 'elasticsearch') +const apiFolder = join(esFolder, 'rest-api-spec', 'src', 'main', 'resources', 'rest-api-spec', 'api') + +function cloneAndCheckout (opts, callback) { + const { log, tag } = opts + withTag(tag, callback) + + /** + * Sets the elasticsearch repository to the given tag. + * If the repository is not present in `esFolder` it will + * clone the repository and the checkout the tag. + * If the repository is already present but it cannot checkout to + * the given tag, it will perform a pull and then try again. + * @param {string} tag + * @param {function} callback + */ + function withTag (tag, callback) { + var fresh = false + var retry = 0 + + if (!pathExist(esFolder)) { + if (!createFolder(esFolder)) { + log.fail('Failed folder creation') + return + } + fresh = true + } + + const git = Git(esFolder) + + if (fresh) { + clone(checkout) + } else { + checkout() + } + + function checkout () { + log.text = `Checking out tag '${tag}'` + git.checkout(tag, err => { + if (err) { + if (retry++ > 0) { + callback(new Error(`Cannot checkout tag '${tag}'`)) + return + } + return pull(checkout) + } + callback(null, apiFolder) + }) + } + + function pull (cb) { + log.text = 'Pulling elasticsearch repository...' + git.pull(err => { + if (err) { + callback(err) + return + } + cb() + }) + } + + function clone (cb) { + log.text = 'Cloning elasticsearch repository...' + git.clone(esRepo, esFolder, err => { + if (err) { + callback(err) + return + } + cb() + }) + } + } + + /** + * Checks if the given path exists + * @param {string} path + * @returns {boolean} true if exists, false if not + */ + function pathExist (path) { + try { + accessSync(path) + return true + } catch (err) { + return false + } + } + + /** + * Creates the given folder + * @param {string} name + * @returns {boolean} true on success, false on failure + */ + function createFolder (name) { + try { + mkdirSync(name) + return true + } catch (err) { + return false + } + } +} + +module.exports = cloneAndCheckout diff --git a/scripts/utils/genMain.js b/scripts/utils/genMain.js new file mode 100644 index 000000000..324bd0ad7 --- /dev/null +++ b/scripts/utils/genMain.js @@ -0,0 +1,106 @@ +'use strict' + +const { readdirSync } = require('fs') +const dedent = require('dedent') + +function genFactory (folder) { + const apiToCamel = {} + // get all the API files + const apis = readdirSync(folder) + .map(file => { + const chunks = file.split('.') + // if the api has not a namespace + if (chunks.length === 2) { + return { name: chunks[0], group: null, file } + } else { + const [group, name] = chunks + return { name, group, file } + } + }) + .reduce((acc, obj) => { + const { group, name, file } = obj + // create a namespace if present + if (group) { + acc[group] = acc[group] || {} + acc[group][name] = `require('./api/${file}')(opts)` + } else { + acc[name] = `require('./api/${file}')(opts)` + } + // save the snake_cased APIs for later use + if (isSnakeCased(name)) { + apiToCamel[group || '__root'] = apiToCamel[group || '__root'] || [] + apiToCamel[group || '__root'].push(name) + } + return acc + }, {}) + + // serialize the API object + const apisStr = JSON.stringify(apis, null, 2) + // split & join to fix the indentation + .split('\n') + .join('\n ') + // remove useless quotes + .replace(/"/g, '') + + const fn = dedent` + 'use strict' + + const assert = require('assert') + + function ESAPI (opts) { + assert(opts.makeRequest, 'Missing makeRequest function') + assert(opts.ConfigurationError, 'Missing ConfigurationError class') + + const apis = ${apisStr} + + ${generateDefinedProperties(apiToCamel).join('\n\n ')} + + return apis + } + + module.exports = ESAPI + ` + + // new line at the end of file + return fn + '\n' +} + +// generates an array of Object.defineProperties +// to allow the use of camelCase APIs +// instead of snake_cased +function generateDefinedProperties (apiToCamel) { + const arr = [] + for (const api in apiToCamel) { + const obj = api === '__root' + ? 'apis' + : `apis.${api}` + const code = ` + Object.defineProperties(${obj}, { + ${apiToCamel[api].map(createGetter).join(',\n ')} + }) + `.trim() + arr.push(code) + } + + return arr + + function createGetter (api) { + return ` + ${camelify(api)}: { + get: function () { return this.${api} }, + enumerable: true + } + `.trim() + } +} + +// from snake_case to camelCase +function camelify (str) { + return str.replace(/_([a-z])/g, k => k[1].toUpperCase()) +} + +function isSnakeCased (str) { + return !!~str.indexOf('_') +} + +module.exports = genFactory diff --git a/scripts/utils/generate.js b/scripts/utils/generate.js new file mode 100644 index 000000000..aa5c012d6 --- /dev/null +++ b/scripts/utils/generate.js @@ -0,0 +1,466 @@ +'use strict' + +const dedent = require('dedent') +const allowedMethods = { + noBody: ['GET', 'HEAD', 'DELETE'], + body: ['POST', 'PUT', 'DELETE'] +} + +// list of apis that does not need any kind of validation +// because of how the url is built +const noPathValidation = [ + 'indices.get_alias', + 'indices.exists_alias', + 'indices.get_field_mapping', + 'indices.get_mapping', + 'indices.get_settings', + 'indices.put_mapping', + 'indices.stats', + 'nodes.info', + 'nodes.stats', + 'nodes.usage', + 'tasks.cancel' +] + +// apis that uses bulkBody property +const ndjsonApi = [ + 'bulk', + 'msearch', + 'msearch_template' +] + +function generate (spec, common) { + const api = Object.keys(spec)[0] + const name = api + .replace(/\.([a-z])/g, k => k[1].toUpperCase()) + .replace(/_([a-z])/g, k => k[1].toUpperCase()) + + const methods = spec[api].methods + const { path, paths, parts, params } = spec[api].url + const acceptedQuerystring = [] + const required = [] + + for (const key in parts) { + if (parts[key].required) { + required.push(key) + } + } + + for (const key in params) { + if (params[key].required) { + required.push(key) + } + acceptedQuerystring.push(key) + } + + for (const key in spec[api]) { + const k = spec[api][key] + if (k && k.required) { + required.push(key) + } + } + if (common && common.params) { + for (const key in common.params) { + acceptedQuerystring.push(key) + } + } + + const code = ` + function ${safeWords(name)} (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ${safeWords(name)}(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + ${genRequiredChecks()} + + ${genUrlValidation(paths, api)} + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + ${genAcceptedQuerystring()} + ] + const acceptedQuerystringCamelCased = [ + ${genAcceptedQuerystringCamelCased()} + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + ${generatePickMethod(methods)} + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(\`Headers should be an object, instead got: \${typeof params.headers}\`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ${getUrlParts()} + const request = { + method, + ${buildPath(api)} + querystring, + ${genBody(api, methods, spec[api].body)} + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } + `.trim() // always call trim to avoid newlines + + const fn = dedent` + 'use strict' + + function build${name[0].toUpperCase() + name.slice(1)} (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + ${generateDocumentation(spec[api], api)} + return ${code} + } + + module.exports = build${name[0].toUpperCase() + name.slice(1)} +` + + // new line at the end of file + return fn + '\n' + + function genRequiredChecks (param) { + const code = required + .map(_genRequiredCheck) + .concat(_noBody()) + .filter(Boolean) + + if (code.length) { + code.unshift('// check required parameters') + } + + return code.join('\n ') + + function _genRequiredCheck (param) { + var camelCased = param[0] === '_' + ? '_' + param.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase()) + : param.replace(/_([a-z])/g, k => k[1].toUpperCase()) + + if (param === camelCased) { + const check = ` + if (params['${param}'] == null) { + return callback( + new ConfigurationError('Missing required parameter: ${param}'), + { body: null, headers: null, statusCode: null } + ) + } + ` + return check.trim() + } else { + const check = ` + if (params['${param}'] == null && params['${camelCased}'] == null) { + return callback( + new ConfigurationError('Missing required parameter: ${param} or ${camelCased}'), + { body: null, headers: null, statusCode: null } + ) + } + ` + return check.trim() + } + } + + function _noBody () { + const check = ` + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + ` + return spec[api].body === null ? check.trim() : '' + } + } + + function genAcceptedQuerystring () { + return acceptedQuerystring + .map(q => `'${q}'`) + .join(',\n ') + } + + function genAcceptedQuerystringCamelCased () { + return acceptedQuerystring + .map(q => { + // if the key starts with `_` we should not camelify the first occurence + // eg: _source_include => _sourceInclude + return q[0] === '_' + ? '_' + q.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase()) + : q.replace(/_([a-z])/g, k => k[1].toUpperCase()) + }) + .map(q => `'${q}'`) + .join(',\n ') + } + + function buildPath () { + // if the default path is static, we should add a dynamic check + // to figure out which path to use, see cluster.stats + // otherwise we can skip that check + const p1 = paths + .reduce((a, b) => a.split('/').length > b.split('/').length ? a : b) + .split('/') + .filter(chunk => !chunk.startsWith('{')) + .join('/') + + const p2 = path + .split('/') + .filter(chunk => !chunk.startsWith('{')) + .join('/') + + if (p1 === p2 || !needsPathValidation(api)) { + return `path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),`.trim() + } + + const dynamicParts = checkDynamicParts() + if (dynamicParts.length) { + return ` + path: ${dynamicParts} + ? '/' + parts.filter(Boolean).join('/') + : '${path}', + `.trim() + } else { + return `path: '/' + parts.filter(Boolean).join('/'),`.trim() + } + } + + function checkDynamicParts () { + const chunks = paths + .reduce((a, b) => a.split('/').length > b.split('/').length ? a : b) + .split('/') + .filter(Boolean) + + var str = '' + chunks.forEach((chunk, index) => { + if (chunk.startsWith('{') && chunk.endsWith('}')) { + chunk = chunk.slice(1, -1) + // url parts can be declared in camelCase fashion + var camelCased = chunk[0] === '_' + ? '_' + chunk.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase()) + : chunk.replace(/_([a-z])/g, k => k[1].toUpperCase()) + + if (chunk === camelCased) { + str += `params['${chunk}'] != null && ` + } else { + str += `(params['${chunk}'] || params['${camelCased}']) != null && ` + } + } + }) + + // removes last ' && ' + return str.slice(0, -4) + } + + function getUrlParts () { + const chunks = paths + .reduce((a, b) => a.split('/').length > b.split('/').length ? a : b) + .split('/') + .filter(Boolean) + var str = '[' + chunks.forEach((chunk, index) => { + if (chunk.startsWith('{') && chunk.endsWith('}')) { + chunk = chunk.slice(1, -1) + // url parts can be declared in camelCase fashion + var camelCased = chunk[0] === '_' + ? '_' + chunk.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase()) + : chunk.replace(/_([a-z])/g, k => k[1].toUpperCase()) + + if (chunk === camelCased) { + str += `params['${chunk}']` + } else { + str += `params['${chunk}'] || params['${camelCased}']` + } + } else { + str += `'${chunk}'` + } + if (index !== chunks.length - 1) { + str += ', ' + } + }) + str += ']' + return str + } +} + +function safeWords (str) { + if (str === 'delete') { + return '_delete' + } + return str +} + +function generatePickMethod (methods) { + if (methods.length === 1) { + return `method = '${methods[0]}'` + } + const bodyMethod = getBodyMethod(methods) + const noBodyMethod = getNoBodyMethod(methods) + if (bodyMethod && noBodyMethod) { + return `method = params.body == null ? '${noBodyMethod}' : '${bodyMethod}'` + } else if (bodyMethod) { + return ` + method = '${bodyMethod}' + `.trim() + } else { + return ` + method = '${noBodyMethod}' + `.trim() + } +} + +function genBody (api, methods, body) { + const bodyMethod = getBodyMethod(methods) + if (ndjsonApi.indexOf(api) > -1) { + return 'bulkBody: params.body,' + } + if (body === null && bodyMethod) { + return `body: '',` + } else if (bodyMethod) { + return `body: params.body || '',` + } else { + return 'body: null,' + } +} + +function getBodyMethod (methods) { + const m = methods.filter(m => ~allowedMethods.body.indexOf(m)) + if (m.length) return m[0] + return null +} + +function getNoBodyMethod (methods) { + const m = methods.filter(m => ~allowedMethods.noBody.indexOf(m)) + if (m.length) return m[0] + return null +} + +function genUrlValidation (paths, api) { + // this api does not need url validation + if (!needsPathValidation(api)) return '' + // gets only the dynamic components of the url in an array + // then we reverse it. A parameters always require what is + // at its right in the array. + const chunks = paths + .reduce((a, b) => a.split('/').length > b.split('/').length ? a : b) + .split('/') + .filter(s => s.startsWith('{')) + .map(s => s.slice(1, -1)) + .reverse() + + var code = '' + + const len = chunks.length + chunks.forEach((chunk, index) => { + if (index === len - 1) return + var params = [] + var camelCased = chunk[0] === '_' + ? '_' + chunk.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase()) + : chunk.replace(/_([a-z])/g, k => k[1].toUpperCase()) + + if (chunk === camelCased) { + code += `${index ? '} else ' : ''}if (params['${chunk}'] != null && (` + } else { + code += `${index ? '} else ' : ''}if ((params['${chunk}'] != null || params['${camelCased}'] != null) && (` + } + for (var i = index + 1; i < len; i++) { + params.push(chunks[i]) + // url parts can be declared in camelCase fashion + camelCased = chunks[i][0] === '_' + ? '_' + chunks[i].slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase()) + : chunks[i].replace(/_([a-z])/g, k => k[1].toUpperCase()) + + if (chunks[i] === camelCased) { + code += `params['${chunks[i]}'] == null${i === len - 1 ? '' : ' || '}` + } else { + code += `(params['${chunks[i]}'] == null || params['${camelCased}')${i === len - 1 ? '' : ' || '}` + } + } + code += `)) { + return callback( + new ConfigurationError('Missing required parameter of the url: ${params.join(', ')}'), + { body: null, headers: null, statusCode: null } + )` + }) + + if (chunks.length > 1) { + code += '\n}' + } + + if (code.length) { + code = '// check required url components\n' + code + } + + return code.trim() +} + +function generateDocumentation (api, op) { + const { parts = {}, params = {} } = api.url + const { body } = api + + // we use `replace(/\u00A0/g, ' ')` to remove no breaking spaces + // because some parts of the description fields are using it + + var doc = '/**\n' + doc += ` * Perform a [${op}](${api.documentation}) request\n *\n` + Object.keys(parts).forEach(part => { + const obj = parts[part] + doc += ` * @param {${obj.type}} ${part} - ${obj.description.replace(/\u00A0/g, ' ')}\n` + }) + + Object.keys(params).forEach(param => { + const obj = params[param] + doc += ` * @param {${obj.type}} ${param} - ${obj.description.replace(/\u00A0/g, ' ')}\n` + }) + + if (body) { + doc += ` * @param {${body.type || 'object'}} body - ${body.description.replace(/\u00A0/g, ' ')}\n` + } + + doc += ' */' + + return doc +} + +function needsPathValidation (api) { + return noPathValidation.indexOf(api) === -1 +} + +module.exports = generate diff --git a/scripts/utils/index.js b/scripts/utils/index.js new file mode 100644 index 000000000..8f781cef7 --- /dev/null +++ b/scripts/utils/index.js @@ -0,0 +1,7 @@ +'use strict' + +const generate = require('./generate') +const cloneAndCheckout = require('./clone-es') +const genFactory = require('./genMain') + +module.exports = { generate, cloneAndCheckout, genFactory } From 55c507c423bddb1d570a7901ad14635c6ff8b64c Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 30 Oct 2018 17:26:22 +0100 Subject: [PATCH 018/172] API generation --- api/api/bulk.js | 140 ++++++++++ api/api/cat.aliases.js | 121 ++++++++ api/api/cat.allocation.js | 124 +++++++++ api/api/cat.count.js | 121 ++++++++ api/api/cat.fielddata.js | 127 +++++++++ api/api/cat.health.js | 123 +++++++++ api/api/cat.help.js | 105 +++++++ api/api/cat.indices.js | 130 +++++++++ api/api/cat.master.js | 120 ++++++++ api/api/cat.nodeattrs.js | 120 ++++++++ api/api/cat.nodes.js | 123 +++++++++ api/api/cat.pending_tasks.js | 120 ++++++++ api/api/cat.plugins.js | 120 ++++++++ api/api/cat.recovery.js | 121 ++++++++ api/api/cat.repositories.js | 120 ++++++++ api/api/cat.segments.js | 118 ++++++++ api/api/cat.shards.js | 124 +++++++++ api/api/cat.snapshots.js | 121 ++++++++ api/api/cat.tasks.js | 126 +++++++++ api/api/cat.templates.js | 121 ++++++++ api/api/cat.thread_pool.js | 124 +++++++++ api/api/clear_scroll.js | 93 +++++++ api/api/cluster.allocation_explain.js | 98 +++++++ api/api/cluster.get_settings.js | 111 ++++++++ api/api/cluster.health.js | 130 +++++++++ api/api/cluster.pending_tasks.js | 105 +++++++ api/api/cluster.put_settings.js | 109 ++++++++ api/api/cluster.remote_info.js | 99 +++++++ api/api/cluster.reroute.js | 110 ++++++++ api/api/cluster.state.js | 127 +++++++++ api/api/cluster.stats.js | 108 ++++++++ api/api/count.js | 141 ++++++++++ api/api/create.js | 158 +++++++++++ api/api/delete.js | 154 +++++++++++ api/api/delete_by_query.js | 212 ++++++++++++++ api/api/delete_script.js | 112 ++++++++ api/api/exists.js | 166 +++++++++++ api/api/exists_source.js | 163 +++++++++++ api/api/explain.js | 167 ++++++++++++ api/api/field_caps.js | 105 +++++++ api/api/get.js | 166 +++++++++++ api/api/get_script.js | 109 ++++++++ api/api/get_source.js | 163 +++++++++++ api/api/index.js | 155 +++++++++++ api/api/indices.analyze.js | 96 +++++++ api/api/indices.clear_cache.js | 130 +++++++++ api/api/indices.close.js | 121 ++++++++ api/api/indices.create.js | 113 ++++++++ api/api/indices.delete.js | 121 ++++++++ api/api/indices.delete_alias.js | 129 +++++++++ api/api/indices.delete_template.js | 112 ++++++++ api/api/indices.exists.js | 124 +++++++++ api/api/indices.exists_alias.js | 119 ++++++++ api/api/indices.exists_template.js | 115 ++++++++ api/api/indices.exists_type.js | 133 +++++++++ api/api/indices.flush.js | 115 ++++++++ api/api/indices.flush_synced.js | 109 ++++++++ api/api/indices.forcemerge.js | 118 ++++++++ api/api/indices.get.js | 127 +++++++++ api/api/indices.get_alias.js | 113 ++++++++ api/api/indices.get_field_mapping.js | 123 +++++++++ api/api/indices.get_mapping.js | 116 ++++++++ api/api/indices.get_settings.js | 122 +++++++++ api/api/indices.get_template.js | 109 ++++++++ api/api/indices.get_upgrade.js | 109 ++++++++ api/api/indices.open.js | 124 +++++++++ api/api/indices.put_alias.js | 124 +++++++++ api/api/indices.put_mapping.js | 126 +++++++++ api/api/indices.put_settings.js | 122 +++++++++ api/api/indices.put_template.js | 122 +++++++++ api/api/indices.recovery.js | 106 +++++++ api/api/indices.refresh.js | 109 ++++++++ api/api/indices.rollover.js | 122 +++++++++ api/api/indices.segments.js | 112 ++++++++ api/api/indices.shard_stores.js | 112 ++++++++ api/api/indices.shrink.js | 128 +++++++++ api/api/indices.split.js | 128 +++++++++ api/api/indices.stats.js | 122 +++++++++ api/api/indices.update_aliases.js | 106 +++++++ api/api/indices.upgrade.js | 115 ++++++++ api/api/indices.validate_query.js | 138 ++++++++++ api/api/info.js | 99 +++++++ api/api/ingest.delete_pipeline.js | 112 ++++++++ api/api/ingest.get_pipeline.js | 103 +++++++ api/api/ingest.processor_grok.js | 99 +++++++ api/api/ingest.put_pipeline.js | 113 ++++++++ api/api/ingest.simulate.js | 104 +++++++ api/api/mget.js | 134 +++++++++ api/api/msearch.js | 122 +++++++++ api/api/msearch_template.js | 119 ++++++++ api/api/mtermvectors.js | 141 ++++++++++ api/api/nodes.hot_threads.js | 120 ++++++++ api/api/nodes.info.js | 107 ++++++++ api/api/nodes.stats.js | 126 +++++++++ api/api/nodes.usage.js | 104 +++++++ api/api/ping.js | 99 +++++++ api/api/put_script.js | 125 +++++++++ api/api/rank_eval.js | 110 ++++++++ api/api/reindex.js | 118 ++++++++ api/api/reindex_rethrottle.js | 117 ++++++++ api/api/render_search_template.js | 93 +++++++ api/api/scripts_painless_execute.js | 92 +++++++ api/api/scroll.js | 99 +++++++ api/api/search.js | 216 +++++++++++++++ api/api/search_shards.js | 118 ++++++++ api/api/search_template.js | 140 ++++++++++ api/api/snapshot.create.js | 122 +++++++++ api/api/snapshot.create_repository.js | 116 ++++++++ api/api/snapshot.delete.js | 124 +++++++++ api/api/snapshot.delete_repository.js | 112 ++++++++ api/api/snapshot.get.js | 130 +++++++++ api/api/snapshot.get_repository.js | 106 +++++++ api/api/snapshot.restore.js | 122 +++++++++ api/api/snapshot.status.js | 115 ++++++++ api/api/snapshot.verify_repository.js | 112 ++++++++ api/api/tasks.cancel.js | 109 ++++++++ api/api/tasks.get.js | 112 ++++++++ api/api/tasks.list.js | 120 ++++++++ api/api/termvectors.js | 158 +++++++++++ api/api/update.js | 173 ++++++++++++ api/api/update_by_query.js | 212 ++++++++++++++ api/index.js | 379 ++++++++++++++++++++++++++ index.js | 16 +- 123 files changed, 15280 insertions(+), 8 deletions(-) create mode 100644 api/api/bulk.js create mode 100644 api/api/cat.aliases.js create mode 100644 api/api/cat.allocation.js create mode 100644 api/api/cat.count.js create mode 100644 api/api/cat.fielddata.js create mode 100644 api/api/cat.health.js create mode 100644 api/api/cat.help.js create mode 100644 api/api/cat.indices.js create mode 100644 api/api/cat.master.js create mode 100644 api/api/cat.nodeattrs.js create mode 100644 api/api/cat.nodes.js create mode 100644 api/api/cat.pending_tasks.js create mode 100644 api/api/cat.plugins.js create mode 100644 api/api/cat.recovery.js create mode 100644 api/api/cat.repositories.js create mode 100644 api/api/cat.segments.js create mode 100644 api/api/cat.shards.js create mode 100644 api/api/cat.snapshots.js create mode 100644 api/api/cat.tasks.js create mode 100644 api/api/cat.templates.js create mode 100644 api/api/cat.thread_pool.js create mode 100644 api/api/clear_scroll.js create mode 100644 api/api/cluster.allocation_explain.js create mode 100644 api/api/cluster.get_settings.js create mode 100644 api/api/cluster.health.js create mode 100644 api/api/cluster.pending_tasks.js create mode 100644 api/api/cluster.put_settings.js create mode 100644 api/api/cluster.remote_info.js create mode 100644 api/api/cluster.reroute.js create mode 100644 api/api/cluster.state.js create mode 100644 api/api/cluster.stats.js create mode 100644 api/api/count.js create mode 100644 api/api/create.js create mode 100644 api/api/delete.js create mode 100644 api/api/delete_by_query.js create mode 100644 api/api/delete_script.js create mode 100644 api/api/exists.js create mode 100644 api/api/exists_source.js create mode 100644 api/api/explain.js create mode 100644 api/api/field_caps.js create mode 100644 api/api/get.js create mode 100644 api/api/get_script.js create mode 100644 api/api/get_source.js create mode 100644 api/api/index.js create mode 100644 api/api/indices.analyze.js create mode 100644 api/api/indices.clear_cache.js create mode 100644 api/api/indices.close.js create mode 100644 api/api/indices.create.js create mode 100644 api/api/indices.delete.js create mode 100644 api/api/indices.delete_alias.js create mode 100644 api/api/indices.delete_template.js create mode 100644 api/api/indices.exists.js create mode 100644 api/api/indices.exists_alias.js create mode 100644 api/api/indices.exists_template.js create mode 100644 api/api/indices.exists_type.js create mode 100644 api/api/indices.flush.js create mode 100644 api/api/indices.flush_synced.js create mode 100644 api/api/indices.forcemerge.js create mode 100644 api/api/indices.get.js create mode 100644 api/api/indices.get_alias.js create mode 100644 api/api/indices.get_field_mapping.js create mode 100644 api/api/indices.get_mapping.js create mode 100644 api/api/indices.get_settings.js create mode 100644 api/api/indices.get_template.js create mode 100644 api/api/indices.get_upgrade.js create mode 100644 api/api/indices.open.js create mode 100644 api/api/indices.put_alias.js create mode 100644 api/api/indices.put_mapping.js create mode 100644 api/api/indices.put_settings.js create mode 100644 api/api/indices.put_template.js create mode 100644 api/api/indices.recovery.js create mode 100644 api/api/indices.refresh.js create mode 100644 api/api/indices.rollover.js create mode 100644 api/api/indices.segments.js create mode 100644 api/api/indices.shard_stores.js create mode 100644 api/api/indices.shrink.js create mode 100644 api/api/indices.split.js create mode 100644 api/api/indices.stats.js create mode 100644 api/api/indices.update_aliases.js create mode 100644 api/api/indices.upgrade.js create mode 100644 api/api/indices.validate_query.js create mode 100644 api/api/info.js create mode 100644 api/api/ingest.delete_pipeline.js create mode 100644 api/api/ingest.get_pipeline.js create mode 100644 api/api/ingest.processor_grok.js create mode 100644 api/api/ingest.put_pipeline.js create mode 100644 api/api/ingest.simulate.js create mode 100644 api/api/mget.js create mode 100644 api/api/msearch.js create mode 100644 api/api/msearch_template.js create mode 100644 api/api/mtermvectors.js create mode 100644 api/api/nodes.hot_threads.js create mode 100644 api/api/nodes.info.js create mode 100644 api/api/nodes.stats.js create mode 100644 api/api/nodes.usage.js create mode 100644 api/api/ping.js create mode 100644 api/api/put_script.js create mode 100644 api/api/rank_eval.js create mode 100644 api/api/reindex.js create mode 100644 api/api/reindex_rethrottle.js create mode 100644 api/api/render_search_template.js create mode 100644 api/api/scripts_painless_execute.js create mode 100644 api/api/scroll.js create mode 100644 api/api/search.js create mode 100644 api/api/search_shards.js create mode 100644 api/api/search_template.js create mode 100644 api/api/snapshot.create.js create mode 100644 api/api/snapshot.create_repository.js create mode 100644 api/api/snapshot.delete.js create mode 100644 api/api/snapshot.delete_repository.js create mode 100644 api/api/snapshot.get.js create mode 100644 api/api/snapshot.get_repository.js create mode 100644 api/api/snapshot.restore.js create mode 100644 api/api/snapshot.status.js create mode 100644 api/api/snapshot.verify_repository.js create mode 100644 api/api/tasks.cancel.js create mode 100644 api/api/tasks.get.js create mode 100644 api/api/tasks.list.js create mode 100644 api/api/termvectors.js create mode 100644 api/api/update.js create mode 100644 api/api/update_by_query.js create mode 100644 api/index.js diff --git a/api/api/bulk.js b/api/api/bulk.js new file mode 100644 index 000000000..bba62c2bd --- /dev/null +++ b/api/api/bulk.js @@ -0,0 +1,140 @@ +'use strict' + +function buildBulk (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [bulk](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html) request + * + * @param {string} index - Default index for items which don't provide one + * @param {string} type - Default document type for items which don't provide one + * @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {enum} refresh - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + * @param {string} routing - Specific routing value + * @param {time} timeout - Explicit operation timeout + * @param {string} type - Default document type for items which don't provide one + * @param {list} fields - Default comma-separated list of fields to return in the response for updates, can be overridden on each sub-request + * @param {list} _source - True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request + * @param {list} _source_exclude - Default list of fields to exclude from the returned _source field, can be overridden on each sub-request + * @param {list} _source_include - Default list of fields to extract and return from the _source field, can be overridden on each sub-request + * @param {string} pipeline - The pipeline id to preprocess incoming documents with + * @param {object} body - The operation definition and data (action-data pairs), separated by newlines + */ + return function bulk (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + bulk(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'wait_for_active_shards', + 'refresh', + 'routing', + 'timeout', + 'type', + 'fields', + '_source', + '_source_exclude', + '_source_include', + 'pipeline', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'waitForActiveShards', + 'refresh', + 'routing', + 'timeout', + 'type', + 'fields', + '_source', + '_sourceExclude', + '_sourceInclude', + 'pipeline', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], '_bulk'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + bulkBody: params.body, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildBulk diff --git a/api/api/cat.aliases.js b/api/api/cat.aliases.js new file mode 100644 index 000000000..24e48fa8c --- /dev/null +++ b/api/api/cat.aliases.js @@ -0,0 +1,121 @@ +'use strict' + +function buildCatAliases (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cat.aliases](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-alias.html) request + * + * @param {list} name - A comma-separated list of alias names to return + * @param {string} format - a short version of the Accept header, e.g. json, yaml + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {list} h - Comma-separated list of column names to display + * @param {boolean} help - Return help information + * @param {list} s - Comma-separated list of column names or column aliases to sort by + * @param {boolean} v - Verbose mode. Display column headers + */ + return function catAliases (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catAliases(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'format', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'format', + 'local', + 'masterTimeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cat', 'aliases', params['name']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCatAliases diff --git a/api/api/cat.allocation.js b/api/api/cat.allocation.js new file mode 100644 index 000000000..1abd0c58b --- /dev/null +++ b/api/api/cat.allocation.js @@ -0,0 +1,124 @@ +'use strict' + +function buildCatAllocation (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cat.allocation](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-allocation.html) request + * + * @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information + * @param {string} format - a short version of the Accept header, e.g. json, yaml + * @param {enum} bytes - The unit in which to display byte values + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {list} h - Comma-separated list of column names to display + * @param {boolean} help - Return help information + * @param {list} s - Comma-separated list of column names or column aliases to sort by + * @param {boolean} v - Verbose mode. Display column headers + */ + return function catAllocation (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catAllocation(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'format', + 'bytes', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'format', + 'bytes', + 'local', + 'masterTimeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cat', 'allocation', params['node_id'] || params['nodeId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCatAllocation diff --git a/api/api/cat.count.js b/api/api/cat.count.js new file mode 100644 index 000000000..87136212c --- /dev/null +++ b/api/api/cat.count.js @@ -0,0 +1,121 @@ +'use strict' + +function buildCatCount (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cat.count](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-count.html) request + * + * @param {list} index - A comma-separated list of index names to limit the returned information + * @param {string} format - a short version of the Accept header, e.g. json, yaml + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {list} h - Comma-separated list of column names to display + * @param {boolean} help - Return help information + * @param {list} s - Comma-separated list of column names or column aliases to sort by + * @param {boolean} v - Verbose mode. Display column headers + */ + return function catCount (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catCount(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'format', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'format', + 'local', + 'masterTimeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cat', 'count', params['index']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCatCount diff --git a/api/api/cat.fielddata.js b/api/api/cat.fielddata.js new file mode 100644 index 000000000..3c1476ba2 --- /dev/null +++ b/api/api/cat.fielddata.js @@ -0,0 +1,127 @@ +'use strict' + +function buildCatFielddata (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cat.fielddata](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-fielddata.html) request + * + * @param {list} fields - A comma-separated list of fields to return the fielddata size + * @param {string} format - a short version of the Accept header, e.g. json, yaml + * @param {enum} bytes - The unit in which to display byte values + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {list} h - Comma-separated list of column names to display + * @param {boolean} help - Return help information + * @param {list} s - Comma-separated list of column names or column aliases to sort by + * @param {boolean} v - Verbose mode. Display column headers + * @param {list} fields - A comma-separated list of fields to return in the output + */ + return function catFielddata (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catFielddata(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'format', + 'bytes', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'fields', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'format', + 'bytes', + 'local', + 'masterTimeout', + 'h', + 'help', + 's', + 'v', + 'fields', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cat', 'fielddata', params['fields']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCatFielddata diff --git a/api/api/cat.health.js b/api/api/cat.health.js new file mode 100644 index 000000000..738895a6a --- /dev/null +++ b/api/api/cat.health.js @@ -0,0 +1,123 @@ +'use strict' + +function buildCatHealth (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cat.health](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-health.html) request + * + * @param {string} format - a short version of the Accept header, e.g. json, yaml + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {list} h - Comma-separated list of column names to display + * @param {boolean} help - Return help information + * @param {list} s - Comma-separated list of column names or column aliases to sort by + * @param {boolean} ts - Set to false to disable timestamping + * @param {boolean} v - Verbose mode. Display column headers + */ + return function catHealth (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catHealth(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'format', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'ts', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'format', + 'local', + 'masterTimeout', + 'h', + 'help', + 's', + 'ts', + 'v', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cat', 'health'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCatHealth diff --git a/api/api/cat.help.js b/api/api/cat.help.js new file mode 100644 index 000000000..3c25f7b00 --- /dev/null +++ b/api/api/cat.help.js @@ -0,0 +1,105 @@ +'use strict' + +function buildCatHelp (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cat.help](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat.html) request + * + * @param {boolean} help - Return help information + * @param {list} s - Comma-separated list of column names or column aliases to sort by + */ + return function catHelp (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catHelp(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'help', + 's', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'help', + 's', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cat'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCatHelp diff --git a/api/api/cat.indices.js b/api/api/cat.indices.js new file mode 100644 index 000000000..0d3bcfea0 --- /dev/null +++ b/api/api/cat.indices.js @@ -0,0 +1,130 @@ +'use strict' + +function buildCatIndices (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cat.indices](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-indices.html) request + * + * @param {list} index - A comma-separated list of index names to limit the returned information + * @param {string} format - a short version of the Accept header, e.g. json, yaml + * @param {enum} bytes - The unit in which to display byte values + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {list} h - Comma-separated list of column names to display + * @param {enum} health - A health status ("green", "yellow", or "red" to filter only indices matching the specified health status + * @param {boolean} help - Return help information + * @param {boolean} pri - Set to true to return stats only for primary shards + * @param {list} s - Comma-separated list of column names or column aliases to sort by + * @param {boolean} v - Verbose mode. Display column headers + */ + return function catIndices (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catIndices(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'format', + 'bytes', + 'local', + 'master_timeout', + 'h', + 'health', + 'help', + 'pri', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'format', + 'bytes', + 'local', + 'masterTimeout', + 'h', + 'health', + 'help', + 'pri', + 's', + 'v', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cat', 'indices', params['index']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCatIndices diff --git a/api/api/cat.master.js b/api/api/cat.master.js new file mode 100644 index 000000000..184bd06ca --- /dev/null +++ b/api/api/cat.master.js @@ -0,0 +1,120 @@ +'use strict' + +function buildCatMaster (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cat.master](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-master.html) request + * + * @param {string} format - a short version of the Accept header, e.g. json, yaml + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {list} h - Comma-separated list of column names to display + * @param {boolean} help - Return help information + * @param {list} s - Comma-separated list of column names or column aliases to sort by + * @param {boolean} v - Verbose mode. Display column headers + */ + return function catMaster (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catMaster(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'format', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'format', + 'local', + 'masterTimeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cat', 'master'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCatMaster diff --git a/api/api/cat.nodeattrs.js b/api/api/cat.nodeattrs.js new file mode 100644 index 000000000..bca45c397 --- /dev/null +++ b/api/api/cat.nodeattrs.js @@ -0,0 +1,120 @@ +'use strict' + +function buildCatNodeattrs (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cat.nodeattrs](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodeattrs.html) request + * + * @param {string} format - a short version of the Accept header, e.g. json, yaml + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {list} h - Comma-separated list of column names to display + * @param {boolean} help - Return help information + * @param {list} s - Comma-separated list of column names or column aliases to sort by + * @param {boolean} v - Verbose mode. Display column headers + */ + return function catNodeattrs (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catNodeattrs(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'format', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'format', + 'local', + 'masterTimeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cat', 'nodeattrs'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCatNodeattrs diff --git a/api/api/cat.nodes.js b/api/api/cat.nodes.js new file mode 100644 index 000000000..4a45dd5f5 --- /dev/null +++ b/api/api/cat.nodes.js @@ -0,0 +1,123 @@ +'use strict' + +function buildCatNodes (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cat.nodes](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodes.html) request + * + * @param {string} format - a short version of the Accept header, e.g. json, yaml + * @param {boolean} full_id - Return the full node ID instead of the shortened version (default: false) + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {list} h - Comma-separated list of column names to display + * @param {boolean} help - Return help information + * @param {list} s - Comma-separated list of column names or column aliases to sort by + * @param {boolean} v - Verbose mode. Display column headers + */ + return function catNodes (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catNodes(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'format', + 'full_id', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'format', + 'fullId', + 'local', + 'masterTimeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cat', 'nodes'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCatNodes diff --git a/api/api/cat.pending_tasks.js b/api/api/cat.pending_tasks.js new file mode 100644 index 000000000..8b9caa342 --- /dev/null +++ b/api/api/cat.pending_tasks.js @@ -0,0 +1,120 @@ +'use strict' + +function buildCatPendingTasks (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cat.pending_tasks](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-pending-tasks.html) request + * + * @param {string} format - a short version of the Accept header, e.g. json, yaml + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {list} h - Comma-separated list of column names to display + * @param {boolean} help - Return help information + * @param {list} s - Comma-separated list of column names or column aliases to sort by + * @param {boolean} v - Verbose mode. Display column headers + */ + return function catPendingTasks (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catPendingTasks(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'format', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'format', + 'local', + 'masterTimeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cat', 'pending_tasks'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCatPendingTasks diff --git a/api/api/cat.plugins.js b/api/api/cat.plugins.js new file mode 100644 index 000000000..2b9d3a336 --- /dev/null +++ b/api/api/cat.plugins.js @@ -0,0 +1,120 @@ +'use strict' + +function buildCatPlugins (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cat.plugins](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-plugins.html) request + * + * @param {string} format - a short version of the Accept header, e.g. json, yaml + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {list} h - Comma-separated list of column names to display + * @param {boolean} help - Return help information + * @param {list} s - Comma-separated list of column names or column aliases to sort by + * @param {boolean} v - Verbose mode. Display column headers + */ + return function catPlugins (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catPlugins(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'format', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'format', + 'local', + 'masterTimeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cat', 'plugins'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCatPlugins diff --git a/api/api/cat.recovery.js b/api/api/cat.recovery.js new file mode 100644 index 000000000..11850a0d5 --- /dev/null +++ b/api/api/cat.recovery.js @@ -0,0 +1,121 @@ +'use strict' + +function buildCatRecovery (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cat.recovery](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-recovery.html) request + * + * @param {list} index - A comma-separated list of index names to limit the returned information + * @param {string} format - a short version of the Accept header, e.g. json, yaml + * @param {enum} bytes - The unit in which to display byte values + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {list} h - Comma-separated list of column names to display + * @param {boolean} help - Return help information + * @param {list} s - Comma-separated list of column names or column aliases to sort by + * @param {boolean} v - Verbose mode. Display column headers + */ + return function catRecovery (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catRecovery(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'format', + 'bytes', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'format', + 'bytes', + 'masterTimeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cat', 'recovery', params['index']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCatRecovery diff --git a/api/api/cat.repositories.js b/api/api/cat.repositories.js new file mode 100644 index 000000000..a736f6380 --- /dev/null +++ b/api/api/cat.repositories.js @@ -0,0 +1,120 @@ +'use strict' + +function buildCatRepositories (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cat.repositories](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-repositories.html) request + * + * @param {string} format - a short version of the Accept header, e.g. json, yaml + * @param {boolean} local - Return local information, do not retrieve the state from master node + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {list} h - Comma-separated list of column names to display + * @param {boolean} help - Return help information + * @param {list} s - Comma-separated list of column names or column aliases to sort by + * @param {boolean} v - Verbose mode. Display column headers + */ + return function catRepositories (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catRepositories(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'format', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'format', + 'local', + 'masterTimeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cat', 'repositories'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCatRepositories diff --git a/api/api/cat.segments.js b/api/api/cat.segments.js new file mode 100644 index 000000000..b7e6eecbb --- /dev/null +++ b/api/api/cat.segments.js @@ -0,0 +1,118 @@ +'use strict' + +function buildCatSegments (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cat.segments](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-segments.html) request + * + * @param {list} index - A comma-separated list of index names to limit the returned information + * @param {string} format - a short version of the Accept header, e.g. json, yaml + * @param {enum} bytes - The unit in which to display byte values + * @param {list} h - Comma-separated list of column names to display + * @param {boolean} help - Return help information + * @param {list} s - Comma-separated list of column names or column aliases to sort by + * @param {boolean} v - Verbose mode. Display column headers + */ + return function catSegments (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catSegments(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'format', + 'bytes', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'format', + 'bytes', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cat', 'segments', params['index']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCatSegments diff --git a/api/api/cat.shards.js b/api/api/cat.shards.js new file mode 100644 index 000000000..3313d3d50 --- /dev/null +++ b/api/api/cat.shards.js @@ -0,0 +1,124 @@ +'use strict' + +function buildCatShards (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cat.shards](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-shards.html) request + * + * @param {list} index - A comma-separated list of index names to limit the returned information + * @param {string} format - a short version of the Accept header, e.g. json, yaml + * @param {enum} bytes - The unit in which to display byte values + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {list} h - Comma-separated list of column names to display + * @param {boolean} help - Return help information + * @param {list} s - Comma-separated list of column names or column aliases to sort by + * @param {boolean} v - Verbose mode. Display column headers + */ + return function catShards (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catShards(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'format', + 'bytes', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'format', + 'bytes', + 'local', + 'masterTimeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cat', 'shards', params['index']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCatShards diff --git a/api/api/cat.snapshots.js b/api/api/cat.snapshots.js new file mode 100644 index 000000000..455a0488e --- /dev/null +++ b/api/api/cat.snapshots.js @@ -0,0 +1,121 @@ +'use strict' + +function buildCatSnapshots (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cat.snapshots](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-snapshots.html) request + * + * @param {list} repository - Name of repository from which to fetch the snapshot information + * @param {string} format - a short version of the Accept header, e.g. json, yaml + * @param {boolean} ignore_unavailable - Set to true to ignore unavailable snapshots + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {list} h - Comma-separated list of column names to display + * @param {boolean} help - Return help information + * @param {list} s - Comma-separated list of column names or column aliases to sort by + * @param {boolean} v - Verbose mode. Display column headers + */ + return function catSnapshots (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catSnapshots(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'format', + 'ignore_unavailable', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'format', + 'ignoreUnavailable', + 'masterTimeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cat', 'snapshots', params['repository']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCatSnapshots diff --git a/api/api/cat.tasks.js b/api/api/cat.tasks.js new file mode 100644 index 000000000..bed6b98b8 --- /dev/null +++ b/api/api/cat.tasks.js @@ -0,0 +1,126 @@ +'use strict' + +function buildCatTasks (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cat.tasks](http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html) request + * + * @param {string} format - a short version of the Accept header, e.g. json, yaml + * @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * @param {list} actions - A comma-separated list of actions that should be returned. Leave empty to return all. + * @param {boolean} detailed - Return detailed task information (default: false) + * @param {number} parent_task - Return tasks with specified parent task id. Set to -1 to return all. + * @param {list} h - Comma-separated list of column names to display + * @param {boolean} help - Return help information + * @param {list} s - Comma-separated list of column names or column aliases to sort by + * @param {boolean} v - Verbose mode. Display column headers + */ + return function catTasks (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catTasks(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'format', + 'node_id', + 'actions', + 'detailed', + 'parent_task', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'format', + 'nodeId', + 'actions', + 'detailed', + 'parentTask', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cat', 'tasks'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCatTasks diff --git a/api/api/cat.templates.js b/api/api/cat.templates.js new file mode 100644 index 000000000..c49f9901e --- /dev/null +++ b/api/api/cat.templates.js @@ -0,0 +1,121 @@ +'use strict' + +function buildCatTemplates (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cat.templates](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-templates.html) request + * + * @param {string} name - A pattern that returned template names must match + * @param {string} format - a short version of the Accept header, e.g. json, yaml + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {list} h - Comma-separated list of column names to display + * @param {boolean} help - Return help information + * @param {list} s - Comma-separated list of column names or column aliases to sort by + * @param {boolean} v - Verbose mode. Display column headers + */ + return function catTemplates (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catTemplates(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'format', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'format', + 'local', + 'masterTimeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cat', 'templates', params['name']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCatTemplates diff --git a/api/api/cat.thread_pool.js b/api/api/cat.thread_pool.js new file mode 100644 index 000000000..a37473d5d --- /dev/null +++ b/api/api/cat.thread_pool.js @@ -0,0 +1,124 @@ +'use strict' + +function buildCatThreadPool (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cat.thread_pool](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-thread-pool.html) request + * + * @param {list} thread_pool_patterns - A comma-separated list of regular-expressions to filter the thread pools in the output + * @param {string} format - a short version of the Accept header, e.g. json, yaml + * @param {enum} size - The multiplier in which to display values + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {list} h - Comma-separated list of column names to display + * @param {boolean} help - Return help information + * @param {list} s - Comma-separated list of column names or column aliases to sort by + * @param {boolean} v - Verbose mode. Display column headers + */ + return function catThreadPool (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catThreadPool(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'format', + 'size', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'format', + 'size', + 'local', + 'masterTimeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cat', 'thread_pool', params['thread_pool_patterns'] || params['threadPoolPatterns']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCatThreadPool diff --git a/api/api/clear_scroll.js b/api/api/clear_scroll.js new file mode 100644 index 000000000..51668e8da --- /dev/null +++ b/api/api/clear_scroll.js @@ -0,0 +1,93 @@ +'use strict' + +function buildClearScroll (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [clear_scroll](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-scroll.html) request + * + * @param {list} scroll_id - A comma-separated list of scroll IDs to clear + * @param {object} body - A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter + */ + return function clearScroll (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + clearScroll(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_search', 'scroll', params['scroll_id'] || params['scrollId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildClearScroll diff --git a/api/api/cluster.allocation_explain.js b/api/api/cluster.allocation_explain.js new file mode 100644 index 000000000..2a2e9a541 --- /dev/null +++ b/api/api/cluster.allocation_explain.js @@ -0,0 +1,98 @@ +'use strict' + +function buildClusterAllocationExplain (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cluster.allocation_explain](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-allocation-explain.html) request + * + * @param {boolean} include_yes_decisions - Return 'YES' decisions in explanation (default: false) + * @param {boolean} include_disk_info - Return information about disk usage and shard sizes (default: false) + * @param {object} body - The index, shard, and primary flag to explain. Empty means 'explain the first unassigned shard' + */ + return function clusterAllocationExplain (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + clusterAllocationExplain(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'include_yes_decisions', + 'include_disk_info', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'includeYesDecisions', + 'includeDiskInfo', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cluster', 'allocation', 'explain'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildClusterAllocationExplain diff --git a/api/api/cluster.get_settings.js b/api/api/cluster.get_settings.js new file mode 100644 index 000000000..b99e539c9 --- /dev/null +++ b/api/api/cluster.get_settings.js @@ -0,0 +1,111 @@ +'use strict' + +function buildClusterGetSettings (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cluster.get_settings](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html) request + * + * @param {boolean} flat_settings - Return settings in flat format (default: false) + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {time} timeout - Explicit operation timeout + * @param {boolean} include_defaults - Whether to return all default clusters setting. + */ + return function clusterGetSettings (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + clusterGetSettings(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'flat_settings', + 'master_timeout', + 'timeout', + 'include_defaults', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'flatSettings', + 'masterTimeout', + 'timeout', + 'includeDefaults', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cluster', 'settings'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildClusterGetSettings diff --git a/api/api/cluster.health.js b/api/api/cluster.health.js new file mode 100644 index 000000000..a318a1a53 --- /dev/null +++ b/api/api/cluster.health.js @@ -0,0 +1,130 @@ +'use strict' + +function buildClusterHealth (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cluster.health](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-health.html) request + * + * @param {list} index - Limit the information returned to a specific index + * @param {enum} level - Specify the level of detail for returned information + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {time} timeout - Explicit operation timeout + * @param {string} wait_for_active_shards - Wait until the specified number of shards is active + * @param {string} wait_for_nodes - Wait until the specified number of nodes is available + * @param {enum} wait_for_events - Wait until all currently queued events with the given priority are processed + * @param {boolean} wait_for_no_relocating_shards - Whether to wait until there are no relocating shards in the cluster + * @param {boolean} wait_for_no_initializing_shards - Whether to wait until there are no initializing shards in the cluster + * @param {enum} wait_for_status - Wait until cluster is in a specific state + */ + return function clusterHealth (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + clusterHealth(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'level', + 'local', + 'master_timeout', + 'timeout', + 'wait_for_active_shards', + 'wait_for_nodes', + 'wait_for_events', + 'wait_for_no_relocating_shards', + 'wait_for_no_initializing_shards', + 'wait_for_status', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'level', + 'local', + 'masterTimeout', + 'timeout', + 'waitForActiveShards', + 'waitForNodes', + 'waitForEvents', + 'waitForNoRelocatingShards', + 'waitForNoInitializingShards', + 'waitForStatus', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cluster', 'health', params['index']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildClusterHealth diff --git a/api/api/cluster.pending_tasks.js b/api/api/cluster.pending_tasks.js new file mode 100644 index 000000000..e9ff7e10f --- /dev/null +++ b/api/api/cluster.pending_tasks.js @@ -0,0 +1,105 @@ +'use strict' + +function buildClusterPendingTasks (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cluster.pending_tasks](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-pending.html) request + * + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + * @param {time} master_timeout - Specify timeout for connection to master + */ + return function clusterPendingTasks (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + clusterPendingTasks(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'local', + 'master_timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'local', + 'masterTimeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cluster', 'pending_tasks'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildClusterPendingTasks diff --git a/api/api/cluster.put_settings.js b/api/api/cluster.put_settings.js new file mode 100644 index 000000000..d161d20d1 --- /dev/null +++ b/api/api/cluster.put_settings.js @@ -0,0 +1,109 @@ +'use strict' + +function buildClusterPutSettings (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cluster.put_settings](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html) request + * + * @param {boolean} flat_settings - Return settings in flat format (default: false) + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {time} timeout - Explicit operation timeout + * @param {object} body - The settings to be updated. Can be either `transient` or `persistent` (survives cluster restart). + */ + return function clusterPutSettings (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + clusterPutSettings(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'flat_settings', + 'master_timeout', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'flatSettings', + 'masterTimeout', + 'timeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cluster', 'settings'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildClusterPutSettings diff --git a/api/api/cluster.remote_info.js b/api/api/cluster.remote_info.js new file mode 100644 index 000000000..6626f0530 --- /dev/null +++ b/api/api/cluster.remote_info.js @@ -0,0 +1,99 @@ +'use strict' + +function buildClusterRemoteInfo (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cluster.remote_info](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-remote-info.html) request + * + */ + return function clusterRemoteInfo (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + clusterRemoteInfo(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_remote', 'info'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildClusterRemoteInfo diff --git a/api/api/cluster.reroute.js b/api/api/cluster.reroute.js new file mode 100644 index 000000000..04e7d39a9 --- /dev/null +++ b/api/api/cluster.reroute.js @@ -0,0 +1,110 @@ +'use strict' + +function buildClusterReroute (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cluster.reroute](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-reroute.html) request + * + * @param {boolean} dry_run - Simulate the operation only and return the resulting state + * @param {boolean} explain - Return an explanation of why the commands can or cannot be executed + * @param {boolean} retry_failed - Retries allocation of shards that are blocked due to too many subsequent allocation failures + * @param {list} metric - Limit the information returned to the specified metrics. Defaults to all but metadata + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {time} timeout - Explicit operation timeout + * @param {object} body - The definition of `commands` to perform (`move`, `cancel`, `allocate`) + */ + return function clusterReroute (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + clusterReroute(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'dry_run', + 'explain', + 'retry_failed', + 'metric', + 'master_timeout', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'dryRun', + 'explain', + 'retryFailed', + 'metric', + 'masterTimeout', + 'timeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cluster', 'reroute'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildClusterReroute diff --git a/api/api/cluster.state.js b/api/api/cluster.state.js new file mode 100644 index 000000000..1a47ce670 --- /dev/null +++ b/api/api/cluster.state.js @@ -0,0 +1,127 @@ +'use strict' + +function buildClusterState (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cluster.state](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-state.html) request + * + * @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @param {list} metric - Limit the information returned to the specified metrics + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + * @param {time} master_timeout - Specify timeout for connection to master + * @param {boolean} flat_settings - Return settings in flat format (default: false) + * @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. + */ + return function clusterState (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + clusterState(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['index'] != null && (params['metric'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: metric'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'local', + 'master_timeout', + 'flat_settings', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'local', + 'masterTimeout', + 'flatSettings', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cluster', 'state', params['metric'], params['index']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildClusterState diff --git a/api/api/cluster.stats.js b/api/api/cluster.stats.js new file mode 100644 index 000000000..efc361d97 --- /dev/null +++ b/api/api/cluster.stats.js @@ -0,0 +1,108 @@ +'use strict' + +function buildClusterStats (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [cluster.stats](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-stats.html) request + * + * @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * @param {boolean} flat_settings - Return settings in flat format (default: false) + * @param {time} timeout - Explicit operation timeout + */ + return function clusterStats (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + clusterStats(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'flat_settings', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'flatSettings', + 'timeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cluster', 'stats', 'nodes', params['node_id'] || params['nodeId']] + const request = { + method, + path: (params['node_id'] || params['nodeId']) != null + ? '/' + parts.filter(Boolean).join('/') + : '/_cluster/stats', + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildClusterStats diff --git a/api/api/count.js b/api/api/count.js new file mode 100644 index 000000000..d955bdd0b --- /dev/null +++ b/api/api/count.js @@ -0,0 +1,141 @@ +'use strict' + +function buildCount (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [count](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-count.html) request + * + * @param {list} index - A comma-separated list of indices to restrict the results + * @param {list} type - A comma-separated list of types to restrict the results + * @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 {number} min_score - Include only documents with a specific `_score` value in the result + * @param {string} preference - Specify the node or shard the operation should be performed on (default: random) + * @param {list} routing - A comma-separated list of specific routing values + * @param {string} q - Query in the Lucene query string syntax + * @param {string} analyzer - The analyzer to use for the query string + * @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) + * @param {enum} default_operator - The default operator for query string query (AND or OR) + * @param {string} df - The field to use as default where no field prefix is given in the query string + * @param {boolean} lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * @param {number} terminate_after - The maximum count for each shard, upon reaching which the query execution will terminate early + * @param {object} body - A query to restrict the results specified with the Query DSL (optional) + */ + return function count (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + count(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'min_score', + 'preference', + 'routing', + 'q', + 'analyzer', + 'analyze_wildcard', + 'default_operator', + 'df', + 'lenient', + 'terminate_after', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'minScore', + 'preference', + 'routing', + 'q', + 'analyzer', + 'analyzeWildcard', + 'defaultOperator', + 'df', + 'lenient', + 'terminateAfter', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], '_count'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCount diff --git a/api/api/create.js b/api/api/create.js new file mode 100644 index 000000000..034243834 --- /dev/null +++ b/api/api/create.js @@ -0,0 +1,158 @@ +'use strict' + +function buildCreate (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [create](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html) request + * + * @param {string} id - Document ID + * @param {string} index - The name of the index + * @param {string} type - The type of the document + * @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {string} parent - ID of the parent document + * @param {enum} refresh - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + * @param {string} routing - Specific routing value + * @param {time} timeout - Explicit operation timeout + * @param {number} version - Explicit version number for concurrency control + * @param {enum} version_type - Specific version type + * @param {string} pipeline - The pipeline id to preprocess incoming documents with + * @param {object} body - The document + */ + return function create (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + create(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['id'] == null) { + return callback( + new ConfigurationError('Missing required parameter: id'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['type'] == null) { + return callback( + new ConfigurationError('Missing required parameter: type'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['id'] != null && (params['type'] == null || params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: type, index'), + { body: null, headers: null, statusCode: null } + ) + } else if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'wait_for_active_shards', + 'parent', + 'refresh', + 'routing', + 'timeout', + 'version', + 'version_type', + 'pipeline', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'waitForActiveShards', + 'parent', + 'refresh', + 'routing', + 'timeout', + 'version', + 'versionType', + 'pipeline', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], params['id'], '_create'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCreate diff --git a/api/api/delete.js b/api/api/delete.js new file mode 100644 index 000000000..884a213f6 --- /dev/null +++ b/api/api/delete.js @@ -0,0 +1,154 @@ +'use strict' + +function buildDelete (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [delete](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete.html) request + * + * @param {string} id - The document ID + * @param {string} index - The name of the index + * @param {string} type - The type of the document + * @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {string} parent - ID of parent document + * @param {enum} refresh - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + * @param {string} routing - Specific routing value + * @param {time} timeout - Explicit operation timeout + * @param {number} version - Explicit version number for concurrency control + * @param {enum} version_type - Specific version type + */ + return function _delete (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + _delete(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['id'] == null) { + return callback( + new ConfigurationError('Missing required parameter: id'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['type'] == null) { + return callback( + new ConfigurationError('Missing required parameter: type'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['id'] != null && (params['type'] == null || params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: type, index'), + { body: null, headers: null, statusCode: null } + ) + } else if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'wait_for_active_shards', + 'parent', + 'refresh', + 'routing', + 'timeout', + 'version', + 'version_type', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'waitForActiveShards', + 'parent', + 'refresh', + 'routing', + 'timeout', + 'version', + 'versionType', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], params['id']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildDelete diff --git a/api/api/delete_by_query.js b/api/api/delete_by_query.js new file mode 100644 index 000000000..65796dcfe --- /dev/null +++ b/api/api/delete_by_query.js @@ -0,0 +1,212 @@ +'use strict' + +function buildDeleteByQuery (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [delete_by_query](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html) request + * + * @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types + * @param {string} analyzer - The analyzer to use for the query string + * @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) + * @param {enum} default_operator - The default operator for query string query (AND or OR) + * @param {string} df - The field to use as default where no field prefix is given in the query string + * @param {number} from - Starting offset (default: 0) + * @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} conflicts - What to do when the delete by query hits version conflicts? + * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {boolean} lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * @param {string} preference - Specify the node or shard the operation should be performed on (default: random) + * @param {string} q - Query in the Lucene query string syntax + * @param {list} routing - A comma-separated list of specific routing values + * @param {time} scroll - Specify how long a consistent view of the index should be maintained for scrolled search + * @param {enum} search_type - Search operation type + * @param {time} search_timeout - Explicit timeout for each search request. Defaults to no timeout. + * @param {number} size - Number of hits to return (default: 10) + * @param {list} sort - A comma-separated list of : pairs + * @param {list} _source - True or false to return the _source field or not, or a list of fields to return + * @param {list} _source_exclude - A list of fields to exclude from the returned _source field + * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {number} terminate_after - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + * @param {list} stats - Specific 'tag' of the request for logging and statistical purposes + * @param {boolean} version - Specify whether to return document version as part of a hit + * @param {boolean} request_cache - Specify if request cache should be used for this request or not, defaults to index level setting + * @param {boolean} refresh - Should the effected indexes be refreshed? + * @param {time} timeout - Time each individual bulk request should wait for shards that are unavailable. + * @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {number} scroll_size - Size on the scroll request powering the delete by query + * @param {boolean} wait_for_completion - Should the request should block until the delete by query is complete. + * @param {number} requests_per_second - The throttle for this request in sub-requests per second. -1 means no throttle. + * @param {number} slices - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. + * @param {object} body - The search definition using the Query DSL + */ + return function deleteByQuery (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + deleteByQuery(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'analyzer', + 'analyze_wildcard', + 'default_operator', + 'df', + 'from', + 'ignore_unavailable', + 'allow_no_indices', + 'conflicts', + 'expand_wildcards', + 'lenient', + 'preference', + 'q', + 'routing', + 'scroll', + 'search_type', + 'search_timeout', + 'size', + 'sort', + '_source', + '_source_exclude', + '_source_include', + 'terminate_after', + 'stats', + 'version', + 'request_cache', + 'refresh', + 'timeout', + 'wait_for_active_shards', + 'scroll_size', + 'wait_for_completion', + 'requests_per_second', + 'slices', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'analyzer', + 'analyzeWildcard', + 'defaultOperator', + 'df', + 'from', + 'ignoreUnavailable', + 'allowNoIndices', + 'conflicts', + 'expandWildcards', + 'lenient', + 'preference', + 'q', + 'routing', + 'scroll', + 'searchType', + 'searchTimeout', + 'size', + 'sort', + '_source', + '_sourceExclude', + '_sourceInclude', + 'terminateAfter', + 'stats', + 'version', + 'requestCache', + 'refresh', + 'timeout', + 'waitForActiveShards', + 'scrollSize', + 'waitForCompletion', + 'requestsPerSecond', + 'slices', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], '_delete_by_query'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildDeleteByQuery diff --git a/api/api/delete_script.js b/api/api/delete_script.js new file mode 100644 index 000000000..f1945790c --- /dev/null +++ b/api/api/delete_script.js @@ -0,0 +1,112 @@ +'use strict' + +function buildDeleteScript (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [delete_script](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html) request + * + * @param {string} id - Script ID + * @param {time} timeout - Explicit operation timeout + * @param {time} master_timeout - Specify timeout for connection to master + */ + return function deleteScript (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + deleteScript(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['id'] == null) { + return callback( + new ConfigurationError('Missing required parameter: id'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'timeout', + 'masterTimeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_scripts', params['id']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildDeleteScript diff --git a/api/api/exists.js b/api/api/exists.js new file mode 100644 index 000000000..f2e229dc2 --- /dev/null +++ b/api/api/exists.js @@ -0,0 +1,166 @@ +'use strict' + +function buildExists (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [exists](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request + * + * @param {string} id - The document ID + * @param {string} index - The name of the index + * @param {string} type - The type of the document (use `_all` to fetch the first document matching the ID across all types) + * @param {list} stored_fields - A comma-separated list of stored fields to return in the response + * @param {string} parent - The ID of the parent document + * @param {string} preference - Specify the node or shard the operation should be performed on (default: random) + * @param {boolean} realtime - Specify whether to perform the operation in realtime or search mode + * @param {boolean} refresh - Refresh the shard containing the document before performing the operation + * @param {string} routing - Specific routing value + * @param {list} _source - True or false to return the _source field or not, or a list of fields to return + * @param {list} _source_exclude - A list of fields to exclude from the returned _source field + * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {number} version - Explicit version number for concurrency control + * @param {enum} version_type - Specific version type + */ + return function exists (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + exists(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['id'] == null) { + return callback( + new ConfigurationError('Missing required parameter: id'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['type'] == null) { + return callback( + new ConfigurationError('Missing required parameter: type'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['id'] != null && (params['type'] == null || params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: type, index'), + { body: null, headers: null, statusCode: null } + ) + } else if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'stored_fields', + 'parent', + 'preference', + 'realtime', + 'refresh', + 'routing', + '_source', + '_source_exclude', + '_source_include', + 'version', + 'version_type', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'storedFields', + 'parent', + 'preference', + 'realtime', + 'refresh', + 'routing', + '_source', + '_sourceExclude', + '_sourceInclude', + 'version', + 'versionType', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'HEAD' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], params['id']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildExists diff --git a/api/api/exists_source.js b/api/api/exists_source.js new file mode 100644 index 000000000..1d17db7be --- /dev/null +++ b/api/api/exists_source.js @@ -0,0 +1,163 @@ +'use strict' + +function buildExistsSource (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [exists_source](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request + * + * @param {string} id - The document ID + * @param {string} index - The name of the index + * @param {string} type - The type of the document; use `_all` to fetch the first document matching the ID across all types + * @param {string} parent - The ID of the parent document + * @param {string} preference - Specify the node or shard the operation should be performed on (default: random) + * @param {boolean} realtime - Specify whether to perform the operation in realtime or search mode + * @param {boolean} refresh - Refresh the shard containing the document before performing the operation + * @param {string} routing - Specific routing value + * @param {list} _source - True or false to return the _source field or not, or a list of fields to return + * @param {list} _source_exclude - A list of fields to exclude from the returned _source field + * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {number} version - Explicit version number for concurrency control + * @param {enum} version_type - Specific version type + */ + return function existsSource (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + existsSource(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['id'] == null) { + return callback( + new ConfigurationError('Missing required parameter: id'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['type'] == null) { + return callback( + new ConfigurationError('Missing required parameter: type'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['id'] != null && (params['type'] == null || params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: type, index'), + { body: null, headers: null, statusCode: null } + ) + } else if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'parent', + 'preference', + 'realtime', + 'refresh', + 'routing', + '_source', + '_source_exclude', + '_source_include', + 'version', + 'version_type', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'parent', + 'preference', + 'realtime', + 'refresh', + 'routing', + '_source', + '_sourceExclude', + '_sourceInclude', + 'version', + 'versionType', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'HEAD' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], params['id'], '_source'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildExistsSource diff --git a/api/api/explain.js b/api/api/explain.js new file mode 100644 index 000000000..1f342b291 --- /dev/null +++ b/api/api/explain.js @@ -0,0 +1,167 @@ +'use strict' + +function buildExplain (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [explain](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-explain.html) request + * + * @param {string} id - The document ID + * @param {string} index - The name of the index + * @param {string} type - The type of the document + * @param {boolean} analyze_wildcard - Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false) + * @param {string} analyzer - The analyzer for the query string query + * @param {enum} default_operator - The default operator for query string query (AND or OR) + * @param {string} df - The default field for query string query (default: _all) + * @param {list} stored_fields - A comma-separated list of stored fields to return in the response + * @param {boolean} lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * @param {string} parent - The ID of the parent document + * @param {string} preference - Specify the node or shard the operation should be performed on (default: random) + * @param {string} q - Query in the Lucene query string syntax + * @param {string} routing - Specific routing value + * @param {list} _source - True or false to return the _source field or not, or a list of fields to return + * @param {list} _source_exclude - A list of fields to exclude from the returned _source field + * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {object} body - The query definition using the Query DSL + */ + return function explain (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + explain(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['id'] == null) { + return callback( + new ConfigurationError('Missing required parameter: id'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['type'] == null) { + return callback( + new ConfigurationError('Missing required parameter: type'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['id'] != null && (params['type'] == null || params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: type, index'), + { body: null, headers: null, statusCode: null } + ) + } else if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'analyze_wildcard', + 'analyzer', + 'default_operator', + 'df', + 'stored_fields', + 'lenient', + 'parent', + 'preference', + 'q', + 'routing', + '_source', + '_source_exclude', + '_source_include', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'analyzeWildcard', + 'analyzer', + 'defaultOperator', + 'df', + 'storedFields', + 'lenient', + 'parent', + 'preference', + 'q', + 'routing', + '_source', + '_sourceExclude', + '_sourceInclude', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], params['id'], '_explain'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildExplain diff --git a/api/api/field_caps.js b/api/api/field_caps.js new file mode 100644 index 000000000..d415fb509 --- /dev/null +++ b/api/api/field_caps.js @@ -0,0 +1,105 @@ +'use strict' + +function buildFieldCaps (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [field_caps](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html) request + * + * @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @param {list} fields - A comma-separated list of field names + * @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 {object} body - Field json objects containing an array of field names + */ + return function fieldCaps (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + fieldCaps(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'fields', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'fields', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_field_caps'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildFieldCaps diff --git a/api/api/get.js b/api/api/get.js new file mode 100644 index 000000000..d234e65df --- /dev/null +++ b/api/api/get.js @@ -0,0 +1,166 @@ +'use strict' + +function buildGet (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [get](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request + * + * @param {string} id - The document ID + * @param {string} index - The name of the index + * @param {string} type - The type of the document (use `_all` to fetch the first document matching the ID across all types) + * @param {list} stored_fields - A comma-separated list of stored fields to return in the response + * @param {string} parent - The ID of the parent document + * @param {string} preference - Specify the node or shard the operation should be performed on (default: random) + * @param {boolean} realtime - Specify whether to perform the operation in realtime or search mode + * @param {boolean} refresh - Refresh the shard containing the document before performing the operation + * @param {string} routing - Specific routing value + * @param {list} _source - True or false to return the _source field or not, or a list of fields to return + * @param {list} _source_exclude - A list of fields to exclude from the returned _source field + * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {number} version - Explicit version number for concurrency control + * @param {enum} version_type - Specific version type + */ + return function get (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + get(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['id'] == null) { + return callback( + new ConfigurationError('Missing required parameter: id'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['type'] == null) { + return callback( + new ConfigurationError('Missing required parameter: type'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['id'] != null && (params['type'] == null || params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: type, index'), + { body: null, headers: null, statusCode: null } + ) + } else if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'stored_fields', + 'parent', + 'preference', + 'realtime', + 'refresh', + 'routing', + '_source', + '_source_exclude', + '_source_include', + 'version', + 'version_type', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'storedFields', + 'parent', + 'preference', + 'realtime', + 'refresh', + 'routing', + '_source', + '_sourceExclude', + '_sourceInclude', + 'version', + 'versionType', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], params['id']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildGet diff --git a/api/api/get_script.js b/api/api/get_script.js new file mode 100644 index 000000000..bebd680bc --- /dev/null +++ b/api/api/get_script.js @@ -0,0 +1,109 @@ +'use strict' + +function buildGetScript (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [get_script](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html) request + * + * @param {string} id - Script ID + * @param {time} master_timeout - Specify timeout for connection to master + */ + return function getScript (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + getScript(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['id'] == null) { + return callback( + new ConfigurationError('Missing required parameter: id'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'master_timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'masterTimeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_scripts', params['id']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildGetScript diff --git a/api/api/get_source.js b/api/api/get_source.js new file mode 100644 index 000000000..6a4fc5d55 --- /dev/null +++ b/api/api/get_source.js @@ -0,0 +1,163 @@ +'use strict' + +function buildGetSource (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [get_source](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request + * + * @param {string} id - The document ID + * @param {string} index - The name of the index + * @param {string} type - The type of the document; use `_all` to fetch the first document matching the ID across all types + * @param {string} parent - The ID of the parent document + * @param {string} preference - Specify the node or shard the operation should be performed on (default: random) + * @param {boolean} realtime - Specify whether to perform the operation in realtime or search mode + * @param {boolean} refresh - Refresh the shard containing the document before performing the operation + * @param {string} routing - Specific routing value + * @param {list} _source - True or false to return the _source field or not, or a list of fields to return + * @param {list} _source_exclude - A list of fields to exclude from the returned _source field + * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {number} version - Explicit version number for concurrency control + * @param {enum} version_type - Specific version type + */ + return function getSource (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + getSource(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['id'] == null) { + return callback( + new ConfigurationError('Missing required parameter: id'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['type'] == null) { + return callback( + new ConfigurationError('Missing required parameter: type'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['id'] != null && (params['type'] == null || params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: type, index'), + { body: null, headers: null, statusCode: null } + ) + } else if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'parent', + 'preference', + 'realtime', + 'refresh', + 'routing', + '_source', + '_source_exclude', + '_source_include', + 'version', + 'version_type', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'parent', + 'preference', + 'realtime', + 'refresh', + 'routing', + '_source', + '_sourceExclude', + '_sourceInclude', + 'version', + 'versionType', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], params['id'], '_source'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildGetSource diff --git a/api/api/index.js b/api/api/index.js new file mode 100644 index 000000000..f9a4835f8 --- /dev/null +++ b/api/api/index.js @@ -0,0 +1,155 @@ +'use strict' + +function buildIndex (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [index](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html) request + * + * @param {string} id - Document ID + * @param {string} index - The name of the index + * @param {string} type - The type of the document + * @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {enum} op_type - Explicit operation type + * @param {string} parent - ID of the parent document + * @param {enum} refresh - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + * @param {string} routing - Specific routing value + * @param {time} timeout - Explicit operation timeout + * @param {number} version - Explicit version number for concurrency control + * @param {enum} version_type - Specific version type + * @param {string} pipeline - The pipeline id to preprocess incoming documents with + * @param {object} body - The document + */ + return function index (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + index(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['type'] == null) { + return callback( + new ConfigurationError('Missing required parameter: type'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['id'] != null && (params['type'] == null || params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: type, index'), + { body: null, headers: null, statusCode: null } + ) + } else if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'wait_for_active_shards', + 'op_type', + 'parent', + 'refresh', + 'routing', + 'timeout', + 'version', + 'version_type', + 'pipeline', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'waitForActiveShards', + 'opType', + 'parent', + 'refresh', + 'routing', + 'timeout', + 'version', + 'versionType', + 'pipeline', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], params['id']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndex diff --git a/api/api/indices.analyze.js b/api/api/indices.analyze.js new file mode 100644 index 000000000..d8068bbfa --- /dev/null +++ b/api/api/indices.analyze.js @@ -0,0 +1,96 @@ +'use strict' + +function buildIndicesAnalyze (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.analyze](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-analyze.html) request + * + * @param {string} index - The name of the index to scope the operation + * @param {string} index - The name of the index to scope the operation + * @param {object} body - Define analyzer/tokenizer parameters and the text on which the analysis should be performed + */ + return function indicesAnalyze (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesAnalyze(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'index', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'index', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_analyze'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesAnalyze diff --git a/api/api/indices.clear_cache.js b/api/api/indices.clear_cache.js new file mode 100644 index 000000000..cc38b7ecd --- /dev/null +++ b/api/api/indices.clear_cache.js @@ -0,0 +1,130 @@ +'use strict' + +function buildIndicesClearCache (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.clear_cache](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clearcache.html) request + * + * @param {list} index - A comma-separated list of index name to limit the operation + * @param {boolean} field_data - Clear field data. This is deprecated. Prefer `fielddata`. + * @param {boolean} fielddata - Clear field data + * @param {list} fields - A comma-separated list of fields to clear when using the `fielddata` parameter (default: all) + * @param {boolean} query - Clear query caches + * @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 {list} index - A comma-separated list of index name to limit the operation + * @param {boolean} request_cache - Clear request cache + * @param {boolean} request - Clear request cache + */ + return function indicesClearCache (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesClearCache(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'field_data', + 'fielddata', + 'fields', + 'query', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'index', + 'request_cache', + 'request', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'fieldData', + 'fielddata', + 'fields', + 'query', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'index', + 'requestCache', + 'request', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_cache', 'clear'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesClearCache diff --git a/api/api/indices.close.js b/api/api/indices.close.js new file mode 100644 index 000000000..a33e70dec --- /dev/null +++ b/api/api/indices.close.js @@ -0,0 +1,121 @@ +'use strict' + +function buildIndicesClose (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.close](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html) request + * + * @param {list} index - A comma separated list of indices to close + * @param {time} timeout - Explicit operation timeout + * @param {time} master_timeout - Specify timeout for connection to master + * @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. + */ + return function indicesClose (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesClose(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'timeout', + 'masterTimeout', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_close'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesClose diff --git a/api/api/indices.create.js b/api/api/indices.create.js new file mode 100644 index 000000000..c6868d0ea --- /dev/null +++ b/api/api/indices.create.js @@ -0,0 +1,113 @@ +'use strict' + +function buildIndicesCreate (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.create](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-index.html) request + * + * @param {string} index - The name of the index + * @param {string} wait_for_active_shards - Set the number of active shards to wait for before the operation returns. + * @param {time} timeout - Explicit operation timeout + * @param {time} master_timeout - Specify timeout for connection to master + * @param {boolean} update_all_types - Whether to update the mapping for all fields with the same name across all types or not + * @param {object} body - The configuration for the index (`settings` and `mappings`) + */ + return function indicesCreate (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesCreate(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'wait_for_active_shards', + 'timeout', + 'master_timeout', + 'update_all_types', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'waitForActiveShards', + 'timeout', + 'masterTimeout', + 'updateAllTypes', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesCreate diff --git a/api/api/indices.delete.js b/api/api/indices.delete.js new file mode 100644 index 000000000..ffa02d65d --- /dev/null +++ b/api/api/indices.delete.js @@ -0,0 +1,121 @@ +'use strict' + +function buildIndicesDelete (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.delete](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-index.html) request + * + * @param {list} index - A comma-separated list of indices to delete; use `_all` or `*` string to delete all indices + * @param {time} timeout - Explicit operation timeout + * @param {time} master_timeout - Specify timeout for connection to master + * @param {boolean} ignore_unavailable - Ignore unavailable indexes (default: false) + * @param {boolean} allow_no_indices - Ignore if a wildcard expression resolves to no concrete indices (default: false) + * @param {enum} expand_wildcards - Whether wildcard expressions should get expanded to open or closed indices (default: open) + */ + return function indicesDelete (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesDelete(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'timeout', + 'masterTimeout', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesDelete diff --git a/api/api/indices.delete_alias.js b/api/api/indices.delete_alias.js new file mode 100644 index 000000000..7da283f68 --- /dev/null +++ b/api/api/indices.delete_alias.js @@ -0,0 +1,129 @@ +'use strict' + +function buildIndicesDeleteAlias (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.delete_alias](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html) request + * + * @param {list} index - A comma-separated list of index names (supports wildcards); use `_all` for all indices + * @param {list} name - A comma-separated list of aliases to delete (supports wildcards); use `_all` to delete all aliases for the specified indices. + * @param {time} timeout - Explicit timestamp for the document + * @param {time} master_timeout - Specify timeout for connection to master + */ + return function indicesDeleteAlias (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesDeleteAlias(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['name'] == null) { + return callback( + new ConfigurationError('Missing required parameter: name'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['name'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'timeout', + 'masterTimeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_aliases', params['name']] + const request = { + method, + path: params['index'] != null && params['name'] != null + ? '/' + parts.filter(Boolean).join('/') + : '/{index}/_alias/{name}', + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesDeleteAlias diff --git a/api/api/indices.delete_template.js b/api/api/indices.delete_template.js new file mode 100644 index 000000000..3259a896f --- /dev/null +++ b/api/api/indices.delete_template.js @@ -0,0 +1,112 @@ +'use strict' + +function buildIndicesDeleteTemplate (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.delete_template](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html) request + * + * @param {string} name - The name of the template + * @param {time} timeout - Explicit operation timeout + * @param {time} master_timeout - Specify timeout for connection to master + */ + return function indicesDeleteTemplate (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesDeleteTemplate(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['name'] == null) { + return callback( + new ConfigurationError('Missing required parameter: name'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'timeout', + 'masterTimeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_template', params['name']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesDeleteTemplate diff --git a/api/api/indices.exists.js b/api/api/indices.exists.js new file mode 100644 index 000000000..436c1656e --- /dev/null +++ b/api/api/indices.exists.js @@ -0,0 +1,124 @@ +'use strict' + +function buildIndicesExists (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.exists](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-exists.html) request + * + * @param {list} index - A comma-separated list of index names + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + * @param {boolean} ignore_unavailable - Ignore unavailable indexes (default: false) + * @param {boolean} allow_no_indices - Ignore if a wildcard expression resolves to no concrete indices (default: false) + * @param {enum} expand_wildcards - Whether wildcard expressions should get expanded to open or closed indices (default: open) + * @param {boolean} flat_settings - Return settings in flat format (default: false) + * @param {boolean} include_defaults - Whether to return all default setting for each of the indices. + */ + return function indicesExists (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesExists(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'local', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'flat_settings', + 'include_defaults', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'local', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'flatSettings', + 'includeDefaults', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'HEAD' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesExists diff --git a/api/api/indices.exists_alias.js b/api/api/indices.exists_alias.js new file mode 100644 index 000000000..a076c8fcb --- /dev/null +++ b/api/api/indices.exists_alias.js @@ -0,0 +1,119 @@ +'use strict' + +function buildIndicesExistsAlias (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.exists_alias](http://www.elastic.co/guide/en/elasticsearch/reference/master/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) + */ + return function indicesExistsAlias (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesExistsAlias(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['name'] == null) { + return callback( + new ConfigurationError('Missing required parameter: name'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'local', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'local', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'HEAD' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_alias', params['name']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesExistsAlias diff --git a/api/api/indices.exists_template.js b/api/api/indices.exists_template.js new file mode 100644 index 000000000..b2c459c43 --- /dev/null +++ b/api/api/indices.exists_template.js @@ -0,0 +1,115 @@ +'use strict' + +function buildIndicesExistsTemplate (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.exists_template](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html) request + * + * @param {list} name - The comma separated names of the index templates + * @param {boolean} flat_settings - Return settings in flat format (default: false) + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + */ + return function indicesExistsTemplate (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesExistsTemplate(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['name'] == null) { + return callback( + new ConfigurationError('Missing required parameter: name'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'flat_settings', + 'master_timeout', + 'local', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'flatSettings', + 'masterTimeout', + 'local', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'HEAD' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_template', params['name']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesExistsTemplate diff --git a/api/api/indices.exists_type.js b/api/api/indices.exists_type.js new file mode 100644 index 000000000..7e104eefb --- /dev/null +++ b/api/api/indices.exists_type.js @@ -0,0 +1,133 @@ +'use strict' + +function buildIndicesExistsType (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.exists_type](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-types-exists.html) request + * + * @param {list} index - A comma-separated list of index names; use `_all` to check the types across all indices + * @param {list} type - A comma-separated list of document types to check + * @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) + */ + return function indicesExistsType (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesExistsType(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['type'] == null) { + return callback( + new ConfigurationError('Missing required parameter: type'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'local', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'local', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'HEAD' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_mapping', params['type']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesExistsType diff --git a/api/api/indices.flush.js b/api/api/indices.flush.js new file mode 100644 index 000000000..54834a222 --- /dev/null +++ b/api/api/indices.flush.js @@ -0,0 +1,115 @@ +'use strict' + +function buildIndicesFlush (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.flush](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-flush.html) request + * + * @param {list} index - A comma-separated list of index names; use `_all` or empty string for all indices + * @param {boolean} force - Whether a flush should be forced even if it is not necessarily needed ie. if no changes will be committed to the index. This is useful if transaction log IDs should be incremented even if no uncommitted changes are present. (This setting can be considered as internal) + * @param {boolean} wait_if_ongoing - If set to true the flush operation will block until the flush can be executed if another flush operation is already executing. The default is true. If set to false the flush will be skipped iff if another flush operation is already running. + * @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. + */ + return function indicesFlush (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesFlush(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'force', + 'wait_if_ongoing', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'force', + 'waitIfOngoing', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_flush'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesFlush diff --git a/api/api/indices.flush_synced.js b/api/api/indices.flush_synced.js new file mode 100644 index 000000000..1c76858f7 --- /dev/null +++ b/api/api/indices.flush_synced.js @@ -0,0 +1,109 @@ +'use strict' + +function buildIndicesFlushSynced (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.flush_synced](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-synced-flush.html) request + * + * @param {list} index - A comma-separated list of index names; use `_all` or empty string for all indices + * @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. + */ + return function indicesFlushSynced (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesFlushSynced(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_flush', 'synced'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesFlushSynced diff --git a/api/api/indices.forcemerge.js b/api/api/indices.forcemerge.js new file mode 100644 index 000000000..5cf5a3e06 --- /dev/null +++ b/api/api/indices.forcemerge.js @@ -0,0 +1,118 @@ +'use strict' + +function buildIndicesForcemerge (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.forcemerge](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-forcemerge.html) request + * + * @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @param {boolean} flush - Specify whether the index should be flushed after performing the operation (default: true) + * @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 {number} max_num_segments - The number of segments the index should be merged into (default: dynamic) + * @param {boolean} only_expunge_deletes - Specify whether the operation should only expunge deleted documents + */ + return function indicesForcemerge (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesForcemerge(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'flush', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'max_num_segments', + 'only_expunge_deletes', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'flush', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'maxNumSegments', + 'onlyExpungeDeletes', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_forcemerge'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesForcemerge diff --git a/api/api/indices.get.js b/api/api/indices.get.js new file mode 100644 index 000000000..d6bcafa73 --- /dev/null +++ b/api/api/indices.get.js @@ -0,0 +1,127 @@ +'use strict' + +function buildIndicesGet (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.get](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-index.html) request + * + * @param {list} index - A comma-separated list of index names + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + * @param {boolean} ignore_unavailable - Ignore unavailable indexes (default: false) + * @param {boolean} allow_no_indices - Ignore if a wildcard expression resolves to no concrete indices (default: false) + * @param {enum} expand_wildcards - Whether wildcard expressions should get expanded to open or closed indices (default: open) + * @param {boolean} flat_settings - Return settings in flat format (default: false) + * @param {boolean} include_defaults - Whether to return all default setting for each of the indices. + * @param {time} master_timeout - Specify timeout for connection to master + */ + return function indicesGet (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesGet(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'local', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'flat_settings', + 'include_defaults', + 'master_timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'local', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'flatSettings', + 'includeDefaults', + 'masterTimeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesGet diff --git a/api/api/indices.get_alias.js b/api/api/indices.get_alias.js new file mode 100644 index 000000000..7925d5238 --- /dev/null +++ b/api/api/indices.get_alias.js @@ -0,0 +1,113 @@ +'use strict' + +function buildIndicesGetAlias (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.get_alias](http://www.elastic.co/guide/en/elasticsearch/reference/master/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) + */ + return function indicesGetAlias (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesGetAlias(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'local', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'local', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_alias', params['name']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesGetAlias diff --git a/api/api/indices.get_field_mapping.js b/api/api/indices.get_field_mapping.js new file mode 100644 index 000000000..3af4964ab --- /dev/null +++ b/api/api/indices.get_field_mapping.js @@ -0,0 +1,123 @@ +'use strict' + +function buildIndicesGetFieldMapping (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.get_field_mapping](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-field-mapping.html) request + * + * @param {list} index - A comma-separated list of index names + * @param {list} type - A comma-separated list of document types + * @param {list} fields - A comma-separated list of fields + * @param {boolean} include_defaults - Whether the default mapping values should be returned as well + * @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) + */ + return function indicesGetFieldMapping (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesGetFieldMapping(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['fields'] == null) { + return callback( + new ConfigurationError('Missing required parameter: fields'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'include_defaults', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'local', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'includeDefaults', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'local', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_mapping', params['type'], 'field', params['fields']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesGetFieldMapping diff --git a/api/api/indices.get_mapping.js b/api/api/indices.get_mapping.js new file mode 100644 index 000000000..de130c8ab --- /dev/null +++ b/api/api/indices.get_mapping.js @@ -0,0 +1,116 @@ +'use strict' + +function buildIndicesGetMapping (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.get_mapping](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-mapping.html) request + * + * @param {list} index - A comma-separated list of index names + * @param {list} type - A comma-separated list of document types + * @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 {time} master_timeout - Specify timeout for connection to master + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + */ + return function indicesGetMapping (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesGetMapping(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'master_timeout', + 'local', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'masterTimeout', + 'local', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_mapping', params['type']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesGetMapping diff --git a/api/api/indices.get_settings.js b/api/api/indices.get_settings.js new file mode 100644 index 000000000..c53e859fd --- /dev/null +++ b/api/api/indices.get_settings.js @@ -0,0 +1,122 @@ +'use strict' + +function buildIndicesGetSettings (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.get_settings](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-settings.html) request + * + * @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @param {list} name - The name of the settings that should be included + * @param {time} master_timeout - Specify timeout for connection to master + * @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} flat_settings - Return settings in flat format (default: false) + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + * @param {boolean} include_defaults - Whether to return all default setting for each of the indices. + */ + return function indicesGetSettings (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesGetSettings(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'master_timeout', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'flat_settings', + 'local', + 'include_defaults', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'masterTimeout', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'flatSettings', + 'local', + 'includeDefaults', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_settings', params['name']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesGetSettings diff --git a/api/api/indices.get_template.js b/api/api/indices.get_template.js new file mode 100644 index 000000000..55beaa599 --- /dev/null +++ b/api/api/indices.get_template.js @@ -0,0 +1,109 @@ +'use strict' + +function buildIndicesGetTemplate (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.get_template](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html) request + * + * @param {list} name - The comma separated names of the index templates + * @param {boolean} flat_settings - Return settings in flat format (default: false) + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + */ + return function indicesGetTemplate (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesGetTemplate(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'flat_settings', + 'master_timeout', + 'local', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'flatSettings', + 'masterTimeout', + 'local', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_template', params['name']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesGetTemplate diff --git a/api/api/indices.get_upgrade.js b/api/api/indices.get_upgrade.js new file mode 100644 index 000000000..8bffcf0e5 --- /dev/null +++ b/api/api/indices.get_upgrade.js @@ -0,0 +1,109 @@ +'use strict' + +function buildIndicesGetUpgrade (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.get_upgrade](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-upgrade.html) request + * + * @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @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. + */ + return function indicesGetUpgrade (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesGetUpgrade(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_upgrade'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesGetUpgrade diff --git a/api/api/indices.open.js b/api/api/indices.open.js new file mode 100644 index 000000000..2cb459eee --- /dev/null +++ b/api/api/indices.open.js @@ -0,0 +1,124 @@ +'use strict' + +function buildIndicesOpen (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.open](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html) request + * + * @param {list} index - A comma separated list of indices to open + * @param {time} timeout - Explicit operation timeout + * @param {time} master_timeout - Specify timeout for connection to master + * @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 {string} wait_for_active_shards - Sets the number of active shards to wait for before the operation returns. + */ + return function indicesOpen (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesOpen(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'wait_for_active_shards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'timeout', + 'masterTimeout', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'waitForActiveShards', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_open'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesOpen diff --git a/api/api/indices.put_alias.js b/api/api/indices.put_alias.js new file mode 100644 index 000000000..fce99f4cb --- /dev/null +++ b/api/api/indices.put_alias.js @@ -0,0 +1,124 @@ +'use strict' + +function buildIndicesPutAlias (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.put_alias](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html) request + * + * @param {list} 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} name - The name of the alias to be created or updated + * @param {time} timeout - Explicit timestamp for the document + * @param {time} master_timeout - Specify timeout for connection to master + * @param {object} body - The settings for the alias, such as `routing` or `filter` + */ + return function indicesPutAlias (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesPutAlias(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['name'] == null) { + return callback( + new ConfigurationError('Missing required parameter: name'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['name'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'timeout', + 'masterTimeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_aliases', params['name']] + const request = { + method, + path: params['index'] != null && params['name'] != null + ? '/' + parts.filter(Boolean).join('/') + : '/{index}/_alias/{name}', + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesPutAlias diff --git a/api/api/indices.put_mapping.js b/api/api/indices.put_mapping.js new file mode 100644 index 000000000..bf403dc7a --- /dev/null +++ b/api/api/indices.put_mapping.js @@ -0,0 +1,126 @@ +'use strict' + +function buildIndicesPutMapping (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.put_mapping](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-put-mapping.html) request + * + * @param {list} index - A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. + * @param {string} type - The name of the document type + * @param {time} timeout - Explicit operation timeout + * @param {time} master_timeout - Specify timeout for connection to master + * @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} update_all_types - Whether to update the mapping for all fields with the same name across all types or not + * @param {object} body - The mapping definition + */ + return function indicesPutMapping (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesPutMapping(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['type'] == null) { + return callback( + new ConfigurationError('Missing required parameter: type'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'update_all_types', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'timeout', + 'masterTimeout', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'updateAllTypes', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_mappings', params['type']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesPutMapping diff --git a/api/api/indices.put_settings.js b/api/api/indices.put_settings.js new file mode 100644 index 000000000..c9eb3b0e4 --- /dev/null +++ b/api/api/indices.put_settings.js @@ -0,0 +1,122 @@ +'use strict' + +function buildIndicesPutSettings (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.put_settings](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-update-settings.html) request + * + * @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @param {time} master_timeout - Specify timeout for connection to master + * @param {time} timeout - Explicit operation timeout + * @param {boolean} preserve_existing - Whether to update existing settings. If set to `true` existing settings on an index remain unchanged, the default is `false` + * @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} flat_settings - Return settings in flat format (default: false) + * @param {object} body - The index settings to be updated + */ + return function indicesPutSettings (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesPutSettings(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'master_timeout', + 'timeout', + 'preserve_existing', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'flat_settings', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'masterTimeout', + 'timeout', + 'preserveExisting', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'flatSettings', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_settings'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesPutSettings diff --git a/api/api/indices.put_template.js b/api/api/indices.put_template.js new file mode 100644 index 000000000..c67845977 --- /dev/null +++ b/api/api/indices.put_template.js @@ -0,0 +1,122 @@ +'use strict' + +function buildIndicesPutTemplate (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.put_template](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html) request + * + * @param {string} name - The name of the template + * @param {number} order - The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers) + * @param {boolean} create - Whether the index template should only be added if new or can also replace an existing one + * @param {time} timeout - Explicit operation timeout + * @param {time} master_timeout - Specify timeout for connection to master + * @param {boolean} flat_settings - Return settings in flat format (default: false) + * @param {object} body - The template definition + */ + return function indicesPutTemplate (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesPutTemplate(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['name'] == null) { + return callback( + new ConfigurationError('Missing required parameter: name'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'order', + 'create', + 'timeout', + 'master_timeout', + 'flat_settings', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'order', + 'create', + 'timeout', + 'masterTimeout', + 'flatSettings', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_template', params['name']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesPutTemplate diff --git a/api/api/indices.recovery.js b/api/api/indices.recovery.js new file mode 100644 index 000000000..4b28d9914 --- /dev/null +++ b/api/api/indices.recovery.js @@ -0,0 +1,106 @@ +'use strict' + +function buildIndicesRecovery (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.recovery](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-recovery.html) request + * + * @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @param {boolean} detailed - Whether to display detailed information about shard recovery + * @param {boolean} active_only - Display only those recoveries that are currently on-going + */ + return function indicesRecovery (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesRecovery(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'detailed', + 'active_only', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'detailed', + 'activeOnly', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_recovery'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesRecovery diff --git a/api/api/indices.refresh.js b/api/api/indices.refresh.js new file mode 100644 index 000000000..aeb999575 --- /dev/null +++ b/api/api/indices.refresh.js @@ -0,0 +1,109 @@ +'use strict' + +function buildIndicesRefresh (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.refresh](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-refresh.html) request + * + * @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @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. + */ + return function indicesRefresh (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesRefresh(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_refresh'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesRefresh diff --git a/api/api/indices.rollover.js b/api/api/indices.rollover.js new file mode 100644 index 000000000..47a9af22f --- /dev/null +++ b/api/api/indices.rollover.js @@ -0,0 +1,122 @@ +'use strict' + +function buildIndicesRollover (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.rollover](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html) request + * + * @param {string} alias - The name of the alias to rollover + * @param {string} new_index - The name of the rollover index + * @param {time} timeout - Explicit operation timeout + * @param {boolean} dry_run - If set to true the rollover action will only be validated but not actually performed even if a condition matches. The default is false + * @param {time} master_timeout - Specify timeout for connection to master + * @param {string} wait_for_active_shards - Set the number of active shards to wait for on the newly created rollover index before the operation returns. + * @param {object} body - The conditions that needs to be met for executing rollover + */ + return function indicesRollover (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesRollover(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['alias'] == null) { + return callback( + new ConfigurationError('Missing required parameter: alias'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if ((params['new_index'] != null || params['newIndex'] != null) && (params['alias'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: alias'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'timeout', + 'dry_run', + 'master_timeout', + 'wait_for_active_shards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'timeout', + 'dryRun', + 'masterTimeout', + 'waitForActiveShards', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['alias'], '_rollover', params['new_index'] || params['newIndex']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesRollover diff --git a/api/api/indices.segments.js b/api/api/indices.segments.js new file mode 100644 index 000000000..7d719c375 --- /dev/null +++ b/api/api/indices.segments.js @@ -0,0 +1,112 @@ +'use strict' + +function buildIndicesSegments (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.segments](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-segments.html) request + * + * @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @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} verbose - Includes detailed memory usage by Lucene. + */ + return function indicesSegments (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesSegments(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'verbose', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'verbose', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_segments'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesSegments diff --git a/api/api/indices.shard_stores.js b/api/api/indices.shard_stores.js new file mode 100644 index 000000000..4cc39dea4 --- /dev/null +++ b/api/api/indices.shard_stores.js @@ -0,0 +1,112 @@ +'use strict' + +function buildIndicesShardStores (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.shard_stores](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shards-stores.html) request + * + * @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @param {list} status - A comma-separated list of statuses used to filter on shards to get store information for + * @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. + */ + return function indicesShardStores (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesShardStores(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'status', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'status', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_shard_stores'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesShardStores diff --git a/api/api/indices.shrink.js b/api/api/indices.shrink.js new file mode 100644 index 000000000..9981a1eec --- /dev/null +++ b/api/api/indices.shrink.js @@ -0,0 +1,128 @@ +'use strict' + +function buildIndicesShrink (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.shrink](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shrink-index.html) request + * + * @param {string} index - The name of the source index to shrink + * @param {string} target - The name of the target index to shrink into + * @param {boolean} copy_settings - whether or not to copy settings from the source index (defaults to false) + * @param {time} timeout - Explicit operation timeout + * @param {time} master_timeout - Specify timeout for connection to master + * @param {string} wait_for_active_shards - Set the number of active shards to wait for on the shrunken index before the operation returns. + * @param {object} body - The configuration for the target index (`settings` and `aliases`) + */ + return function indicesShrink (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesShrink(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['target'] == null) { + return callback( + new ConfigurationError('Missing required parameter: target'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['target'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'copy_settings', + 'timeout', + 'master_timeout', + 'wait_for_active_shards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'copySettings', + 'timeout', + 'masterTimeout', + 'waitForActiveShards', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_shrink', params['target']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesShrink diff --git a/api/api/indices.split.js b/api/api/indices.split.js new file mode 100644 index 000000000..a40db9b25 --- /dev/null +++ b/api/api/indices.split.js @@ -0,0 +1,128 @@ +'use strict' + +function buildIndicesSplit (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.split](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-split-index.html) request + * + * @param {string} index - The name of the source index to split + * @param {string} target - The name of the target index to split into + * @param {boolean} copy_settings - whether or not to copy settings from the source index (defaults to false) + * @param {time} timeout - Explicit operation timeout + * @param {time} master_timeout - Specify timeout for connection to master + * @param {string} wait_for_active_shards - Set the number of active shards to wait for on the shrunken index before the operation returns. + * @param {object} body - The configuration for the target index (`settings` and `aliases`) + */ + return function indicesSplit (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesSplit(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['target'] == null) { + return callback( + new ConfigurationError('Missing required parameter: target'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['target'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'copy_settings', + 'timeout', + 'master_timeout', + 'wait_for_active_shards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'copySettings', + 'timeout', + 'masterTimeout', + 'waitForActiveShards', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_split', params['target']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesSplit diff --git a/api/api/indices.stats.js b/api/api/indices.stats.js new file mode 100644 index 000000000..00f43b6ad --- /dev/null +++ b/api/api/indices.stats.js @@ -0,0 +1,122 @@ +'use strict' + +function buildIndicesStats (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.stats](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-stats.html) request + * + * @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @param {list} metric - Limit the information returned the specific metrics. + * @param {list} completion_fields - A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) + * @param {list} fielddata_fields - A comma-separated list of fields for `fielddata` index metric (supports wildcards) + * @param {list} fields - A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) + * @param {list} groups - A comma-separated list of search groups for `search` index metric + * @param {enum} level - Return stats aggregated at cluster, index or shard level + * @param {list} types - A comma-separated list of document types for the `indexing` index metric + * @param {boolean} include_segment_file_sizes - Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) + */ + return function indicesStats (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesStats(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'completion_fields', + 'fielddata_fields', + 'fields', + 'groups', + 'level', + 'types', + 'include_segment_file_sizes', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'completionFields', + 'fielddataFields', + 'fields', + 'groups', + 'level', + 'types', + 'includeSegmentFileSizes', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_stats', params['metric']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesStats diff --git a/api/api/indices.update_aliases.js b/api/api/indices.update_aliases.js new file mode 100644 index 000000000..7ec44ccdb --- /dev/null +++ b/api/api/indices.update_aliases.js @@ -0,0 +1,106 @@ +'use strict' + +function buildIndicesUpdateAliases (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.update_aliases](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html) request + * + * @param {time} timeout - Request timeout + * @param {time} master_timeout - Specify timeout for connection to master + * @param {object} body - The definition of `actions` to perform + */ + return function indicesUpdateAliases (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesUpdateAliases(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'timeout', + 'masterTimeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_aliases'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesUpdateAliases diff --git a/api/api/indices.upgrade.js b/api/api/indices.upgrade.js new file mode 100644 index 000000000..1259ee440 --- /dev/null +++ b/api/api/indices.upgrade.js @@ -0,0 +1,115 @@ +'use strict' + +function buildIndicesUpgrade (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.upgrade](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-upgrade.html) request + * + * @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @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} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {boolean} wait_for_completion - Specify whether the request should block until the all segments are upgraded (default: false) + * @param {boolean} only_ancient_segments - If true, only ancient (an older Lucene major release) segments will be upgraded + */ + return function indicesUpgrade (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesUpgrade(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'allow_no_indices', + 'expand_wildcards', + 'ignore_unavailable', + 'wait_for_completion', + 'only_ancient_segments', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'allowNoIndices', + 'expandWildcards', + 'ignoreUnavailable', + 'waitForCompletion', + 'onlyAncientSegments', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_upgrade'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesUpgrade diff --git a/api/api/indices.validate_query.js b/api/api/indices.validate_query.js new file mode 100644 index 000000000..ca27a5990 --- /dev/null +++ b/api/api/indices.validate_query.js @@ -0,0 +1,138 @@ +'use strict' + +function buildIndicesValidateQuery (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [indices.validate_query](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-validate.html) request + * + * @param {list} index - A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices + * @param {list} type - A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types + * @param {boolean} explain - Return detailed information about the error + * @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 {string} q - Query in the Lucene query string syntax + * @param {string} analyzer - The analyzer to use for the query string + * @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) + * @param {enum} default_operator - The default operator for query string query (AND or OR) + * @param {string} df - The field to use as default where no field prefix is given in the query string + * @param {boolean} lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * @param {boolean} rewrite - Provide a more detailed explanation showing the actual Lucene query that will be executed. + * @param {boolean} all_shards - Execute validation on all shards instead of one random shard per index + * @param {object} body - The query definition specified with the Query DSL + */ + return function indicesValidateQuery (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesValidateQuery(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'explain', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'q', + 'analyzer', + 'analyze_wildcard', + 'default_operator', + 'df', + 'lenient', + 'rewrite', + 'all_shards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'explain', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'q', + 'analyzer', + 'analyzeWildcard', + 'defaultOperator', + 'df', + 'lenient', + 'rewrite', + 'allShards', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], '_validate', 'query'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIndicesValidateQuery diff --git a/api/api/info.js b/api/api/info.js new file mode 100644 index 000000000..59cb80341 --- /dev/null +++ b/api/api/info.js @@ -0,0 +1,99 @@ +'use strict' + +function buildInfo (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [info](http://www.elastic.co/guide/) request + * + */ + return function info (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + info(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildInfo diff --git a/api/api/ingest.delete_pipeline.js b/api/api/ingest.delete_pipeline.js new file mode 100644 index 000000000..ace43057e --- /dev/null +++ b/api/api/ingest.delete_pipeline.js @@ -0,0 +1,112 @@ +'use strict' + +function buildIngestDeletePipeline (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [ingest.delete_pipeline](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request + * + * @param {string} id - Pipeline ID + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {time} timeout - Explicit operation timeout + */ + return function ingestDeletePipeline (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ingestDeletePipeline(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['id'] == null) { + return callback( + new ConfigurationError('Missing required parameter: id'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'master_timeout', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'masterTimeout', + 'timeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_ingest', 'pipeline', params['id']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIngestDeletePipeline diff --git a/api/api/ingest.get_pipeline.js b/api/api/ingest.get_pipeline.js new file mode 100644 index 000000000..176a24abe --- /dev/null +++ b/api/api/ingest.get_pipeline.js @@ -0,0 +1,103 @@ +'use strict' + +function buildIngestGetPipeline (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [ingest.get_pipeline](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request + * + * @param {string} id - Comma separated list of pipeline ids. Wildcards supported + * @param {time} master_timeout - Explicit operation timeout for connection to master node + */ + return function ingestGetPipeline (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ingestGetPipeline(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'master_timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'masterTimeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_ingest', 'pipeline', params['id']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIngestGetPipeline diff --git a/api/api/ingest.processor_grok.js b/api/api/ingest.processor_grok.js new file mode 100644 index 000000000..a8b93a6cd --- /dev/null +++ b/api/api/ingest.processor_grok.js @@ -0,0 +1,99 @@ +'use strict' + +function buildIngestProcessorGrok (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [ingest.processor_grok](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request + * + */ + return function ingestProcessorGrok (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ingestProcessorGrok(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_ingest', 'processor', 'grok'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIngestProcessorGrok diff --git a/api/api/ingest.put_pipeline.js b/api/api/ingest.put_pipeline.js new file mode 100644 index 000000000..02e6841c3 --- /dev/null +++ b/api/api/ingest.put_pipeline.js @@ -0,0 +1,113 @@ +'use strict' + +function buildIngestPutPipeline (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [ingest.put_pipeline](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request + * + * @param {string} id - Pipeline ID + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {time} timeout - Explicit operation timeout + * @param {object} body - The ingest definition + */ + return function ingestPutPipeline (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ingestPutPipeline(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['id'] == null) { + return callback( + new ConfigurationError('Missing required parameter: id'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'master_timeout', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'masterTimeout', + 'timeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_ingest', 'pipeline', params['id']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIngestPutPipeline diff --git a/api/api/ingest.simulate.js b/api/api/ingest.simulate.js new file mode 100644 index 000000000..14ff6c3c9 --- /dev/null +++ b/api/api/ingest.simulate.js @@ -0,0 +1,104 @@ +'use strict' + +function buildIngestSimulate (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [ingest.simulate](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request + * + * @param {string} id - Pipeline ID + * @param {boolean} verbose - Verbose mode. Display data output for each processor in executed pipeline + * @param {object} body - The simulate definition + */ + return function ingestSimulate (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ingestSimulate(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'verbose', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'verbose', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_ingest', 'pipeline', params['id'], '_simulate'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildIngestSimulate diff --git a/api/api/mget.js b/api/api/mget.js new file mode 100644 index 000000000..54890e994 --- /dev/null +++ b/api/api/mget.js @@ -0,0 +1,134 @@ +'use strict' + +function buildMget (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [mget](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-get.html) request + * + * @param {string} index - The name of the index + * @param {string} type - The type of the document + * @param {list} stored_fields - A comma-separated list of stored fields to return in the response + * @param {string} preference - Specify the node or shard the operation should be performed on (default: random) + * @param {boolean} realtime - Specify whether to perform the operation in realtime or search mode + * @param {boolean} refresh - Refresh the shard containing the document before performing the operation + * @param {string} routing - Specific routing value + * @param {list} _source - True or false to return the _source field or not, or a list of fields to return + * @param {list} _source_exclude - A list of fields to exclude from the returned _source field + * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {object} body - Document identifiers; can be either `docs` (containing full document information) or `ids` (when index and type is provided in the URL. + */ + return function mget (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mget(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'stored_fields', + 'preference', + 'realtime', + 'refresh', + 'routing', + '_source', + '_source_exclude', + '_source_include', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'storedFields', + 'preference', + 'realtime', + 'refresh', + 'routing', + '_source', + '_sourceExclude', + '_sourceInclude', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], '_mget'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildMget diff --git a/api/api/msearch.js b/api/api/msearch.js new file mode 100644 index 000000000..1319b246a --- /dev/null +++ b/api/api/msearch.js @@ -0,0 +1,122 @@ +'use strict' + +function buildMsearch (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [msearch](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-multi-search.html) request + * + * @param {list} index - A comma-separated list of index names to use as default + * @param {list} type - A comma-separated list of document types to use as default + * @param {enum} search_type - Search operation type + * @param {number} max_concurrent_searches - Controls the maximum number of concurrent searches the multi search api will execute + * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * @param {number} pre_filter_shard_size - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on it's rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. + * @param {object} body - The request definitions (metadata-search request definition pairs), separated by newlines + */ + return function msearch (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + msearch(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'search_type', + 'max_concurrent_searches', + 'typed_keys', + 'pre_filter_shard_size', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'searchType', + 'maxConcurrentSearches', + 'typedKeys', + 'preFilterShardSize', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], '_msearch'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + bulkBody: params.body, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildMsearch diff --git a/api/api/msearch_template.js b/api/api/msearch_template.js new file mode 100644 index 000000000..62f0a6754 --- /dev/null +++ b/api/api/msearch_template.js @@ -0,0 +1,119 @@ +'use strict' + +function buildMsearchTemplate (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [msearch_template](http://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html) request + * + * @param {list} index - A comma-separated list of index names to use as default + * @param {list} type - A comma-separated list of document types to use as default + * @param {enum} search_type - Search operation type + * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * @param {number} max_concurrent_searches - Controls the maximum number of concurrent searches the multi search api will execute + * @param {object} body - The request definitions (metadata-search request definition pairs), separated by newlines + */ + return function msearchTemplate (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + msearchTemplate(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'search_type', + 'typed_keys', + 'max_concurrent_searches', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'searchType', + 'typedKeys', + 'maxConcurrentSearches', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], '_msearch', 'template'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + bulkBody: params.body, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildMsearchTemplate diff --git a/api/api/mtermvectors.js b/api/api/mtermvectors.js new file mode 100644 index 000000000..1cceaa317 --- /dev/null +++ b/api/api/mtermvectors.js @@ -0,0 +1,141 @@ +'use strict' + +function buildMtermvectors (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [mtermvectors](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-termvectors.html) request + * + * @param {string} index - The index in which the document resides. + * @param {string} type - The type of the document. + * @param {list} ids - A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body + * @param {boolean} term_statistics - Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {boolean} field_statistics - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {list} fields - A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {boolean} offsets - Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {boolean} positions - Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {boolean} payloads - Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {string} preference - Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {string} routing - Specific routing value. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {string} parent - Parent id of documents. Applies to all returned documents unless otherwise specified in body "params" or "docs". + * @param {boolean} realtime - Specifies if requests are real-time as opposed to near-real-time (default: true). + * @param {number} version - Explicit version number for concurrency control + * @param {enum} version_type - Specific version type + * @param {object} body - Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation. + */ + return function mtermvectors (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mtermvectors(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'ids', + 'term_statistics', + 'field_statistics', + 'fields', + 'offsets', + 'positions', + 'payloads', + 'preference', + 'routing', + 'parent', + 'realtime', + 'version', + 'version_type', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'ids', + 'termStatistics', + 'fieldStatistics', + 'fields', + 'offsets', + 'positions', + 'payloads', + 'preference', + 'routing', + 'parent', + 'realtime', + 'version', + 'versionType', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], '_mtermvectors'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildMtermvectors diff --git a/api/api/nodes.hot_threads.js b/api/api/nodes.hot_threads.js new file mode 100644 index 000000000..6dcf89610 --- /dev/null +++ b/api/api/nodes.hot_threads.js @@ -0,0 +1,120 @@ +'use strict' + +function buildNodesHotThreads (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [nodes.hot_threads](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-hot-threads.html) request + * + * @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * @param {time} interval - The interval for the second sampling of threads + * @param {number} snapshots - Number of samples of thread stacktrace (default: 10) + * @param {number} threads - Specify the number of threads to provide information for (default: 3) + * @param {boolean} ignore_idle_threads - Don't show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue (default: true) + * @param {enum} type - The type to sample (default: cpu) + * @param {time} timeout - Explicit operation timeout + */ + return function nodesHotThreads (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + nodesHotThreads(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'interval', + 'snapshots', + 'threads', + 'ignore_idle_threads', + 'type', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'interval', + 'snapshots', + 'threads', + 'ignoreIdleThreads', + 'type', + 'timeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_cluster', 'nodes', params['node_id'] || params['nodeId'], 'hot_threads'] + const request = { + method, + path: (params['node_id'] || params['nodeId']) != null + ? '/' + parts.filter(Boolean).join('/') + : '/_nodes/hot_threads', + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildNodesHotThreads diff --git a/api/api/nodes.info.js b/api/api/nodes.info.js new file mode 100644 index 000000000..c48200a32 --- /dev/null +++ b/api/api/nodes.info.js @@ -0,0 +1,107 @@ +'use strict' + +function buildNodesInfo (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [nodes.info](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-info.html) request + * + * @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * @param {list} metric - A comma-separated list of metrics you wish returned. Leave empty to return all. + * @param {boolean} flat_settings - Return settings in flat format (default: false) + * @param {time} timeout - Explicit operation timeout + */ + return function nodesInfo (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + nodesInfo(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'flat_settings', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'flatSettings', + 'timeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_nodes', params['node_id'] || params['nodeId'], params['metric']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildNodesInfo diff --git a/api/api/nodes.stats.js b/api/api/nodes.stats.js new file mode 100644 index 000000000..176556a83 --- /dev/null +++ b/api/api/nodes.stats.js @@ -0,0 +1,126 @@ +'use strict' + +function buildNodesStats (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [nodes.stats](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-stats.html) request + * + * @param {list} metric - Limit the information returned to the specified metrics + * @param {list} index_metric - Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified. + * @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * @param {list} completion_fields - A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) + * @param {list} fielddata_fields - A comma-separated list of fields for `fielddata` index metric (supports wildcards) + * @param {list} fields - A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) + * @param {boolean} groups - A comma-separated list of search groups for `search` index metric + * @param {enum} level - Return indices stats aggregated at index, node or shard level + * @param {list} types - A comma-separated list of document types for the `indexing` index metric + * @param {time} timeout - Explicit operation timeout + * @param {boolean} include_segment_file_sizes - Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) + */ + return function nodesStats (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + nodesStats(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'completion_fields', + 'fielddata_fields', + 'fields', + 'groups', + 'level', + 'types', + 'timeout', + 'include_segment_file_sizes', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'completionFields', + 'fielddataFields', + 'fields', + 'groups', + 'level', + 'types', + 'timeout', + 'includeSegmentFileSizes', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_nodes', params['node_id'] || params['nodeId'], 'stats', params['metric'], params['index_metric'] || params['indexMetric']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildNodesStats diff --git a/api/api/nodes.usage.js b/api/api/nodes.usage.js new file mode 100644 index 000000000..11a4055ee --- /dev/null +++ b/api/api/nodes.usage.js @@ -0,0 +1,104 @@ +'use strict' + +function buildNodesUsage (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [nodes.usage](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html) request + * + * @param {list} metric - Limit the information returned to the specified metrics + * @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * @param {time} timeout - Explicit operation timeout + */ + return function nodesUsage (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + nodesUsage(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'timeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_nodes', params['node_id'] || params['nodeId'], 'usage', params['metric']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildNodesUsage diff --git a/api/api/ping.js b/api/api/ping.js new file mode 100644 index 000000000..8dc4f43ad --- /dev/null +++ b/api/api/ping.js @@ -0,0 +1,99 @@ +'use strict' + +function buildPing (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [ping](http://www.elastic.co/guide/) request + * + */ + return function ping (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ping(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'HEAD' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildPing diff --git a/api/api/put_script.js b/api/api/put_script.js new file mode 100644 index 000000000..ce07d3210 --- /dev/null +++ b/api/api/put_script.js @@ -0,0 +1,125 @@ +'use strict' + +function buildPutScript (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [put_script](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html) request + * + * @param {string} id - Script ID + * @param {string} context - Script context + * @param {time} timeout - Explicit operation timeout + * @param {time} master_timeout - Specify timeout for connection to master + * @param {string} context - Context name to compile script against + * @param {object} body - The document + */ + return function putScript (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + putScript(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['id'] == null) { + return callback( + new ConfigurationError('Missing required parameter: id'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['context'] != null && (params['id'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: id'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'context', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'timeout', + 'masterTimeout', + 'context', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_scripts', params['id'], params['context']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildPutScript diff --git a/api/api/rank_eval.js b/api/api/rank_eval.js new file mode 100644 index 000000000..8b22dad2b --- /dev/null +++ b/api/api/rank_eval.js @@ -0,0 +1,110 @@ +'use strict' + +function buildRankEval (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [rank_eval](https://www.elastic.co/guide/en/elasticsearch/reference/master/search-rank-eval.html) request + * + * @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @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 {object} body - The ranking evaluation search definition, including search requests, document ratings and ranking metric definition. + */ + return function rankEval (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + rankEval(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_rank_eval'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildRankEval diff --git a/api/api/reindex.js b/api/api/reindex.js new file mode 100644 index 000000000..6764bb563 --- /dev/null +++ b/api/api/reindex.js @@ -0,0 +1,118 @@ +'use strict' + +function buildReindex (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [reindex](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html) request + * + * @param {boolean} refresh - Should the effected indexes be refreshed? + * @param {time} timeout - Time each individual bulk request should wait for shards that are unavailable. + * @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {boolean} wait_for_completion - Should the request should block until the reindex is complete. + * @param {number} requests_per_second - The throttle to set on this request in sub-requests per second. -1 means no throttle. + * @param {number} slices - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. + * @param {object} body - The search definition using the Query DSL and the prototype for the index request. + */ + return function reindex (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + reindex(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'refresh', + 'timeout', + 'wait_for_active_shards', + 'wait_for_completion', + 'requests_per_second', + 'slices', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'refresh', + 'timeout', + 'waitForActiveShards', + 'waitForCompletion', + 'requestsPerSecond', + 'slices', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_reindex'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildReindex diff --git a/api/api/reindex_rethrottle.js b/api/api/reindex_rethrottle.js new file mode 100644 index 000000000..caa50c151 --- /dev/null +++ b/api/api/reindex_rethrottle.js @@ -0,0 +1,117 @@ +'use strict' + +function buildReindexRethrottle (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [reindex_rethrottle](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html) request + * + * @param {string} task_id - The task id to rethrottle + * @param {number} requests_per_second - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. + */ + return function reindexRethrottle (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + reindexRethrottle(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['task_id'] == null && params['taskId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: task_id or taskId'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) { + return callback( + new ConfigurationError('Missing required parameter: requests_per_second or requestsPerSecond'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'requests_per_second', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'requestsPerSecond', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_delete_by_query', params['task_id'] || params['taskId'], '_rethrottle'] + const request = { + method, + path: (params['task_id'] || params['taskId']) != null + ? '/' + parts.filter(Boolean).join('/') + : '/_reindex/{task_id}/_rethrottle', + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildReindexRethrottle diff --git a/api/api/render_search_template.js b/api/api/render_search_template.js new file mode 100644 index 000000000..94b6a3c5a --- /dev/null +++ b/api/api/render_search_template.js @@ -0,0 +1,93 @@ +'use strict' + +function buildRenderSearchTemplate (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [render_search_template](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-template.html) request + * + * @param {string} id - The id of the stored search template + * @param {object} body - The search definition template and its params + */ + return function renderSearchTemplate (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + renderSearchTemplate(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_render', 'template', params['id']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildRenderSearchTemplate diff --git a/api/api/scripts_painless_execute.js b/api/api/scripts_painless_execute.js new file mode 100644 index 000000000..7a08082c2 --- /dev/null +++ b/api/api/scripts_painless_execute.js @@ -0,0 +1,92 @@ +'use strict' + +function buildScriptsPainlessExecute (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [scripts_painless_execute](https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html) request + * + * @param {object} body - The script to execute + */ + return function scriptsPainlessExecute (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + scriptsPainlessExecute(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_scripts', 'painless', '_execute'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildScriptsPainlessExecute diff --git a/api/api/scroll.js b/api/api/scroll.js new file mode 100644 index 000000000..f5f5bf575 --- /dev/null +++ b/api/api/scroll.js @@ -0,0 +1,99 @@ +'use strict' + +function buildScroll (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [scroll](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-scroll.html) request + * + * @param {string} scroll_id - The scroll ID + * @param {time} scroll - Specify how long a consistent view of the index should be maintained for scrolled search + * @param {string} scroll_id - The scroll ID for scrolled search + * @param {object} body - The scroll ID if not passed by URL or query parameter. + */ + return function scroll (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + scroll(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'scroll', + 'scroll_id', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'scroll', + 'scrollId', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_search', 'scroll', params['scroll_id'] || params['scrollId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildScroll diff --git a/api/api/search.js b/api/api/search.js new file mode 100644 index 000000000..1a29f8427 --- /dev/null +++ b/api/api/search.js @@ -0,0 +1,216 @@ +'use strict' + +function buildSearch (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [search](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html) request + * + * @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types + * @param {string} analyzer - The analyzer to use for the query string + * @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) + * @param {enum} default_operator - The default operator for query string query (AND or OR) + * @param {string} df - The field to use as default where no field prefix is given in the query string + * @param {boolean} explain - Specify whether to return detailed information about score computation as part of a hit + * @param {list} stored_fields - A comma-separated list of stored fields to return as part of a hit + * @param {list} docvalue_fields - A comma-separated list of fields to return as the docvalue representation of a field for each hit + * @param {number} from - Starting offset (default: 0) + * @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} lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * @param {string} preference - Specify the node or shard the operation should be performed on (default: random) + * @param {string} q - Query in the Lucene query string syntax + * @param {list} routing - A comma-separated list of specific routing values + * @param {time} scroll - Specify how long a consistent view of the index should be maintained for scrolled search + * @param {enum} search_type - Search operation type + * @param {number} size - Number of hits to return (default: 10) + * @param {list} sort - A comma-separated list of : pairs + * @param {list} _source - True or false to return the _source field or not, or a list of fields to return + * @param {list} _source_exclude - A list of fields to exclude from the returned _source field + * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {number} terminate_after - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + * @param {list} stats - Specific 'tag' of the request for logging and statistical purposes + * @param {string} suggest_field - Specify which field to use for suggestions + * @param {enum} suggest_mode - Specify suggest mode + * @param {number} suggest_size - How many suggestions to return in response + * @param {string} suggest_text - The source text for which the suggestions should be returned + * @param {time} timeout - Explicit operation timeout + * @param {boolean} track_scores - Whether to calculate and return scores even if they are not used for sorting + * @param {boolean} track_total_hits - Indicate if the number of documents that match the query should be tracked + * @param {boolean} allow_partial_search_results - Indicate if an error should be returned if there is a partial search failure or timeout + * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * @param {boolean} version - Specify whether to return document version as part of a hit + * @param {boolean} request_cache - Specify if request cache should be used for this request or not, defaults to index level setting + * @param {number} batched_reduce_size - The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. + * @param {number} max_concurrent_shard_requests - The number of concurrent shard requests this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + * @param {number} pre_filter_shard_size - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on it's rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. + * @param {object} body - The search definition using the Query DSL + */ + return function search (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + search(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'analyzer', + 'analyze_wildcard', + 'default_operator', + 'df', + 'explain', + 'stored_fields', + 'docvalue_fields', + 'from', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'lenient', + 'preference', + 'q', + 'routing', + 'scroll', + 'search_type', + 'size', + 'sort', + '_source', + '_source_exclude', + '_source_include', + 'terminate_after', + 'stats', + 'suggest_field', + 'suggest_mode', + 'suggest_size', + 'suggest_text', + 'timeout', + 'track_scores', + 'track_total_hits', + 'allow_partial_search_results', + 'typed_keys', + 'version', + 'request_cache', + 'batched_reduce_size', + 'max_concurrent_shard_requests', + 'pre_filter_shard_size', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'analyzer', + 'analyzeWildcard', + 'defaultOperator', + 'df', + 'explain', + 'storedFields', + 'docvalueFields', + 'from', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'lenient', + 'preference', + 'q', + 'routing', + 'scroll', + 'searchType', + 'size', + 'sort', + '_source', + '_sourceExclude', + '_sourceInclude', + 'terminateAfter', + 'stats', + 'suggestField', + 'suggestMode', + 'suggestSize', + 'suggestText', + 'timeout', + 'trackScores', + 'trackTotalHits', + 'allowPartialSearchResults', + 'typedKeys', + 'version', + 'requestCache', + 'batchedReduceSize', + 'maxConcurrentShardRequests', + 'preFilterShardSize', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], '_search'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildSearch diff --git a/api/api/search_shards.js b/api/api/search_shards.js new file mode 100644 index 000000000..62a2fa783 --- /dev/null +++ b/api/api/search_shards.js @@ -0,0 +1,118 @@ +'use strict' + +function buildSearchShards (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [search_shards](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-shards.html) request + * + * @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @param {string} preference - Specify the node or shard the operation should be performed on (default: random) + * @param {string} routing - Specific routing value + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + * @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. + */ + return function searchShards (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + searchShards(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'preference', + 'routing', + 'local', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'preference', + 'routing', + 'local', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_search_shards'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildSearchShards diff --git a/api/api/search_template.js b/api/api/search_template.js new file mode 100644 index 000000000..7d42e6b62 --- /dev/null +++ b/api/api/search_template.js @@ -0,0 +1,140 @@ +'use strict' + +function buildSearchTemplate (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [search_template](http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html) request + * + * @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types + * @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 {string} preference - Specify the node or shard the operation should be performed on (default: random) + * @param {list} routing - A comma-separated list of specific routing values + * @param {time} scroll - Specify how long a consistent view of the index should be maintained for scrolled search + * @param {enum} search_type - Search operation type + * @param {boolean} explain - Specify whether to return detailed information about score computation as part of a hit + * @param {boolean} profile - Specify whether to profile the query execution + * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * @param {object} body - The search definition template and its params + */ + return function searchTemplate (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + searchTemplate(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'preference', + 'routing', + 'scroll', + 'search_type', + 'explain', + 'profile', + 'typed_keys', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'preference', + 'routing', + 'scroll', + 'searchType', + 'explain', + 'profile', + 'typedKeys', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], '_search', 'template'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildSearchTemplate diff --git a/api/api/snapshot.create.js b/api/api/snapshot.create.js new file mode 100644 index 000000000..18dc40192 --- /dev/null +++ b/api/api/snapshot.create.js @@ -0,0 +1,122 @@ +'use strict' + +function buildSnapshotCreate (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [snapshot.create](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request + * + * @param {string} repository - A repository name + * @param {string} snapshot - A snapshot name + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {boolean} wait_for_completion - Should this request wait until the operation has completed before returning + * @param {object} body - The snapshot definition + */ + return function snapshotCreate (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + snapshotCreate(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['repository'] == null) { + return callback( + new ConfigurationError('Missing required parameter: repository'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['snapshot'] == null) { + return callback( + new ConfigurationError('Missing required parameter: snapshot'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['snapshot'] != null && (params['repository'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: repository'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'master_timeout', + 'wait_for_completion', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'masterTimeout', + 'waitForCompletion', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_snapshot', params['repository'], params['snapshot']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildSnapshotCreate diff --git a/api/api/snapshot.create_repository.js b/api/api/snapshot.create_repository.js new file mode 100644 index 000000000..7458bea79 --- /dev/null +++ b/api/api/snapshot.create_repository.js @@ -0,0 +1,116 @@ +'use strict' + +function buildSnapshotCreateRepository (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [snapshot.create_repository](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request + * + * @param {string} repository - A repository name + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {time} timeout - Explicit operation timeout + * @param {boolean} verify - Whether to verify the repository after creation + * @param {object} body - The repository definition + */ + return function snapshotCreateRepository (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + snapshotCreateRepository(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['repository'] == null) { + return callback( + new ConfigurationError('Missing required parameter: repository'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'master_timeout', + 'timeout', + 'verify', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'masterTimeout', + 'timeout', + 'verify', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_snapshot', params['repository']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildSnapshotCreateRepository diff --git a/api/api/snapshot.delete.js b/api/api/snapshot.delete.js new file mode 100644 index 000000000..949f4d2e6 --- /dev/null +++ b/api/api/snapshot.delete.js @@ -0,0 +1,124 @@ +'use strict' + +function buildSnapshotDelete (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [snapshot.delete](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request + * + * @param {string} repository - A repository name + * @param {string} snapshot - A snapshot name + * @param {time} master_timeout - Explicit operation timeout for connection to master node + */ + return function snapshotDelete (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + snapshotDelete(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['repository'] == null) { + return callback( + new ConfigurationError('Missing required parameter: repository'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['snapshot'] == null) { + return callback( + new ConfigurationError('Missing required parameter: snapshot'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['snapshot'] != null && (params['repository'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: repository'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'master_timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'masterTimeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_snapshot', params['repository'], params['snapshot']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildSnapshotDelete diff --git a/api/api/snapshot.delete_repository.js b/api/api/snapshot.delete_repository.js new file mode 100644 index 000000000..d42bc2113 --- /dev/null +++ b/api/api/snapshot.delete_repository.js @@ -0,0 +1,112 @@ +'use strict' + +function buildSnapshotDeleteRepository (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [snapshot.delete_repository](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request + * + * @param {list} repository - A comma-separated list of repository names + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {time} timeout - Explicit operation timeout + */ + return function snapshotDeleteRepository (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + snapshotDeleteRepository(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['repository'] == null) { + return callback( + new ConfigurationError('Missing required parameter: repository'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'master_timeout', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'masterTimeout', + 'timeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_snapshot', params['repository']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildSnapshotDeleteRepository diff --git a/api/api/snapshot.get.js b/api/api/snapshot.get.js new file mode 100644 index 000000000..91b54005f --- /dev/null +++ b/api/api/snapshot.get.js @@ -0,0 +1,130 @@ +'use strict' + +function buildSnapshotGet (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [snapshot.get](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request + * + * @param {string} repository - A repository name + * @param {list} snapshot - A comma-separated list of snapshot names + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {boolean} ignore_unavailable - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown + * @param {boolean} verbose - Whether to show verbose snapshot info or only show the basic info found in the repository index blob + */ + return function snapshotGet (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + snapshotGet(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['repository'] == null) { + return callback( + new ConfigurationError('Missing required parameter: repository'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['snapshot'] == null) { + return callback( + new ConfigurationError('Missing required parameter: snapshot'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['snapshot'] != null && (params['repository'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: repository'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'master_timeout', + 'ignore_unavailable', + 'verbose', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'masterTimeout', + 'ignoreUnavailable', + 'verbose', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_snapshot', params['repository'], params['snapshot']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildSnapshotGet diff --git a/api/api/snapshot.get_repository.js b/api/api/snapshot.get_repository.js new file mode 100644 index 000000000..0c91cf26d --- /dev/null +++ b/api/api/snapshot.get_repository.js @@ -0,0 +1,106 @@ +'use strict' + +function buildSnapshotGetRepository (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [snapshot.get_repository](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request + * + * @param {list} repository - A comma-separated list of repository names + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + */ + return function snapshotGetRepository (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + snapshotGetRepository(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'master_timeout', + 'local', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'masterTimeout', + 'local', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_snapshot', params['repository']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildSnapshotGetRepository diff --git a/api/api/snapshot.restore.js b/api/api/snapshot.restore.js new file mode 100644 index 000000000..d5f2e445d --- /dev/null +++ b/api/api/snapshot.restore.js @@ -0,0 +1,122 @@ +'use strict' + +function buildSnapshotRestore (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [snapshot.restore](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request + * + * @param {string} repository - A repository name + * @param {string} snapshot - A snapshot name + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {boolean} wait_for_completion - Should this request wait until the operation has completed before returning + * @param {object} body - Details of what to restore + */ + return function snapshotRestore (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + snapshotRestore(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['repository'] == null) { + return callback( + new ConfigurationError('Missing required parameter: repository'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['snapshot'] == null) { + return callback( + new ConfigurationError('Missing required parameter: snapshot'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['snapshot'] != null && (params['repository'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: repository'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'master_timeout', + 'wait_for_completion', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'masterTimeout', + 'waitForCompletion', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_snapshot', params['repository'], params['snapshot'], '_restore'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildSnapshotRestore diff --git a/api/api/snapshot.status.js b/api/api/snapshot.status.js new file mode 100644 index 000000000..50959dd95 --- /dev/null +++ b/api/api/snapshot.status.js @@ -0,0 +1,115 @@ +'use strict' + +function buildSnapshotStatus (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [snapshot.status](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request + * + * @param {string} repository - A repository name + * @param {list} snapshot - A comma-separated list of snapshot names + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {boolean} ignore_unavailable - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown + */ + return function snapshotStatus (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + snapshotStatus(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['snapshot'] != null && (params['repository'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: repository'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'master_timeout', + 'ignore_unavailable', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'masterTimeout', + 'ignoreUnavailable', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_snapshot', params['repository'], params['snapshot'], '_status'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildSnapshotStatus diff --git a/api/api/snapshot.verify_repository.js b/api/api/snapshot.verify_repository.js new file mode 100644 index 000000000..ff605606c --- /dev/null +++ b/api/api/snapshot.verify_repository.js @@ -0,0 +1,112 @@ +'use strict' + +function buildSnapshotVerifyRepository (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [snapshot.verify_repository](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request + * + * @param {string} repository - A repository name + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {time} timeout - Explicit operation timeout + */ + return function snapshotVerifyRepository (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + snapshotVerifyRepository(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['repository'] == null) { + return callback( + new ConfigurationError('Missing required parameter: repository'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'master_timeout', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'masterTimeout', + 'timeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_snapshot', params['repository'], '_verify'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildSnapshotVerifyRepository diff --git a/api/api/tasks.cancel.js b/api/api/tasks.cancel.js new file mode 100644 index 000000000..5b53505e0 --- /dev/null +++ b/api/api/tasks.cancel.js @@ -0,0 +1,109 @@ +'use strict' + +function buildTasksCancel (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [tasks.cancel](http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html) request + * + * @param {string} task_id - Cancel the task with specified task id (node_id:task_number) + * @param {list} nodes - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * @param {list} actions - A comma-separated list of actions that should be cancelled. Leave empty to cancel all. + * @param {string} parent_task_id - Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all. + */ + return function tasksCancel (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + tasksCancel(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'nodes', + 'actions', + 'parent_task_id', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'nodes', + 'actions', + 'parentTaskId', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_tasks', params['task_id'] || params['taskId'], '_cancel'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildTasksCancel diff --git a/api/api/tasks.get.js b/api/api/tasks.get.js new file mode 100644 index 000000000..f3d574b0e --- /dev/null +++ b/api/api/tasks.get.js @@ -0,0 +1,112 @@ +'use strict' + +function buildTasksGet (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [tasks.get](http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html) request + * + * @param {string} task_id - Return the task with specified id (node_id:task_number) + * @param {boolean} wait_for_completion - Wait for the matching tasks to complete (default: false) + * @param {time} timeout - Explicit operation timeout + */ + return function tasksGet (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + tasksGet(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['task_id'] == null && params['taskId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: task_id or taskId'), + { body: null, headers: null, statusCode: null } + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'wait_for_completion', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'waitForCompletion', + 'timeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_tasks', params['task_id'] || params['taskId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildTasksGet diff --git a/api/api/tasks.list.js b/api/api/tasks.list.js new file mode 100644 index 000000000..a9d70eb49 --- /dev/null +++ b/api/api/tasks.list.js @@ -0,0 +1,120 @@ +'use strict' + +function buildTasksList (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [tasks.list](http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html) request + * + * @param {list} nodes - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * @param {list} actions - A comma-separated list of actions that should be returned. Leave empty to return all. + * @param {boolean} detailed - Return detailed task information (default: false) + * @param {string} parent_task_id - Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all. + * @param {boolean} wait_for_completion - Wait for the matching tasks to complete (default: false) + * @param {enum} group_by - Group tasks by nodes or parent/child relationships + * @param {time} timeout - Explicit operation timeout + */ + return function tasksList (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + tasksList(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'nodes', + 'actions', + 'detailed', + 'parent_task_id', + 'wait_for_completion', + 'group_by', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'nodes', + 'actions', + 'detailed', + 'parentTaskId', + 'waitForCompletion', + 'groupBy', + 'timeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_tasks'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildTasksList diff --git a/api/api/termvectors.js b/api/api/termvectors.js new file mode 100644 index 000000000..6caf19bf2 --- /dev/null +++ b/api/api/termvectors.js @@ -0,0 +1,158 @@ +'use strict' + +function buildTermvectors (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [termvectors](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-termvectors.html) request + * + * @param {string} index - The index in which the document resides. + * @param {string} type - The type of the document. + * @param {string} id - The id of the document, when not specified a doc param should be supplied. + * @param {boolean} term_statistics - Specifies if total term frequency and document frequency should be returned. + * @param {boolean} field_statistics - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. + * @param {list} fields - A comma-separated list of fields to return. + * @param {boolean} offsets - Specifies if term offsets should be returned. + * @param {boolean} positions - Specifies if term positions should be returned. + * @param {boolean} payloads - Specifies if term payloads should be returned. + * @param {string} preference - Specify the node or shard the operation should be performed on (default: random). + * @param {string} routing - Specific routing value. + * @param {string} parent - Parent id of documents. + * @param {boolean} realtime - Specifies if request is real-time as opposed to near-real-time (default: true). + * @param {number} version - Explicit version number for concurrency control + * @param {enum} version_type - Specific version type + * @param {object} body - Define parameters and or supply a document to get termvectors for. See documentation. + */ + return function termvectors (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + termvectors(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['type'] == null) { + return callback( + new ConfigurationError('Missing required parameter: type'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['id'] != null && (params['type'] == null || params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: type, index'), + { body: null, headers: null, statusCode: null } + ) + } else if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'term_statistics', + 'field_statistics', + 'fields', + 'offsets', + 'positions', + 'payloads', + 'preference', + 'routing', + 'parent', + 'realtime', + 'version', + 'version_type', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'termStatistics', + 'fieldStatistics', + 'fields', + 'offsets', + 'positions', + 'payloads', + 'preference', + 'routing', + 'parent', + 'realtime', + 'version', + 'versionType', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], params['id'], '_termvectors'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildTermvectors diff --git a/api/api/update.js b/api/api/update.js new file mode 100644 index 000000000..0c65b4ada --- /dev/null +++ b/api/api/update.js @@ -0,0 +1,173 @@ +'use strict' + +function buildUpdate (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [update](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update.html) request + * + * @param {string} id - Document ID + * @param {string} index - The name of the index + * @param {string} type - The type of the document + * @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {list} fields - A comma-separated list of fields to return in the response + * @param {list} _source - True or false to return the _source field or not, or a list of fields to return + * @param {list} _source_exclude - A list of fields to exclude from the returned _source field + * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {string} lang - The script language (default: painless) + * @param {string} parent - ID of the parent document. Is is only used for routing and when for the upsert request + * @param {enum} refresh - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + * @param {number} retry_on_conflict - Specify how many times should the operation be retried when a conflict occurs (default: 0) + * @param {string} routing - Specific routing value + * @param {time} timeout - Explicit operation timeout + * @param {number} version - Explicit version number for concurrency control + * @param {enum} version_type - Specific version type + * @param {object} body - The request definition requires either `script` or partial `doc` + */ + return function update (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + update(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['id'] == null) { + return callback( + new ConfigurationError('Missing required parameter: id'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['type'] == null) { + return callback( + new ConfigurationError('Missing required parameter: type'), + { body: null, headers: null, statusCode: null } + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['id'] != null && (params['type'] == null || params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: type, index'), + { body: null, headers: null, statusCode: null } + ) + } else if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'wait_for_active_shards', + 'fields', + '_source', + '_source_exclude', + '_source_include', + 'lang', + 'parent', + 'refresh', + 'retry_on_conflict', + 'routing', + 'timeout', + 'version', + 'version_type', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'waitForActiveShards', + 'fields', + '_source', + '_sourceExclude', + '_sourceInclude', + 'lang', + 'parent', + 'refresh', + 'retryOnConflict', + 'routing', + 'timeout', + 'version', + 'versionType', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], params['id'], '_update'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildUpdate diff --git a/api/api/update_by_query.js b/api/api/update_by_query.js new file mode 100644 index 000000000..7e3a2ec1c --- /dev/null +++ b/api/api/update_by_query.js @@ -0,0 +1,212 @@ +'use strict' + +function buildUpdateByQuery (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError } = opts + /** + * Perform a [update_by_query](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html) request + * + * @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types + * @param {string} analyzer - The analyzer to use for the query string + * @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) + * @param {enum} default_operator - The default operator for query string query (AND or OR) + * @param {string} df - The field to use as default where no field prefix is given in the query string + * @param {number} from - Starting offset (default: 0) + * @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} conflicts - What to do when the update by query hits version conflicts? + * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {boolean} lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + * @param {string} pipeline - Ingest pipeline to set on index requests made by this action. (default: none) + * @param {string} preference - Specify the node or shard the operation should be performed on (default: random) + * @param {string} q - Query in the Lucene query string syntax + * @param {list} routing - A comma-separated list of specific routing values + * @param {time} scroll - Specify how long a consistent view of the index should be maintained for scrolled search + * @param {enum} search_type - Search operation type + * @param {time} search_timeout - Explicit timeout for each search request. Defaults to no timeout. + * @param {number} size - Number of hits to return (default: 10) + * @param {list} sort - A comma-separated list of : pairs + * @param {list} _source - True or false to return the _source field or not, or a list of fields to return + * @param {list} _source_exclude - A list of fields to exclude from the returned _source field + * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {number} terminate_after - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + * @param {list} stats - Specific 'tag' of the request for logging and statistical purposes + * @param {boolean} version - Specify whether to return document version as part of a hit + * @param {boolean} version_type - Should the document increment the version number (internal) on hit or not (reindex) + * @param {boolean} request_cache - Specify if request cache should be used for this request or not, defaults to index level setting + * @param {boolean} refresh - Should the effected indexes be refreshed? + * @param {time} timeout - Time each individual bulk request should wait for shards that are unavailable. + * @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {number} scroll_size - Size on the scroll request powering the update by query + * @param {boolean} wait_for_completion - Should the request should block until the update by query operation is complete. + * @param {number} requests_per_second - The throttle to set on this request in sub-requests per second. -1 means no throttle. + * @param {number} slices - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. + * @param {object} body - The search definition using the Query DSL + */ + return function updateByQuery (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + updateByQuery(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + { body: null, headers: null, statusCode: null } + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'analyzer', + 'analyze_wildcard', + 'default_operator', + 'df', + 'from', + 'ignore_unavailable', + 'allow_no_indices', + 'conflicts', + 'expand_wildcards', + 'lenient', + 'pipeline', + 'preference', + 'q', + 'routing', + 'scroll', + 'search_type', + 'search_timeout', + 'size', + 'sort', + '_source', + '_source_exclude', + '_source_include', + 'terminate_after', + 'stats', + 'version', + 'version_type', + 'request_cache', + 'refresh', + 'timeout', + 'wait_for_active_shards', + 'scroll_size', + 'wait_for_completion', + 'requests_per_second', + 'slices', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'analyzer', + 'analyzeWildcard', + 'defaultOperator', + 'df', + 'from', + 'ignoreUnavailable', + 'allowNoIndices', + 'conflicts', + 'expandWildcards', + 'lenient', + 'pipeline', + 'preference', + 'q', + 'routing', + 'scroll', + 'searchType', + 'searchTimeout', + 'size', + 'sort', + '_source', + '_sourceExclude', + '_sourceInclude', + 'terminateAfter', + 'stats', + 'version', + 'versionType', + 'requestCache', + 'refresh', + 'timeout', + 'waitForActiveShards', + 'scrollSize', + 'waitForCompletion', + 'requestsPerSecond', + 'slices', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + { body: null, headers: null, statusCode: null } + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], '_update_by_query'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildUpdateByQuery diff --git a/api/index.js b/api/index.js new file mode 100644 index 000000000..da91b8259 --- /dev/null +++ b/api/index.js @@ -0,0 +1,379 @@ +'use strict' + +const assert = require('assert') + +function ESAPI (opts) { + assert(opts.makeRequest, 'Missing makeRequest function') + assert(opts.ConfigurationError, 'Missing ConfigurationError class') + + const apis = { + bulk: require('./api/bulk.js')(opts), + cat: { + aliases: require('./api/cat.aliases.js')(opts), + allocation: require('./api/cat.allocation.js')(opts), + count: require('./api/cat.count.js')(opts), + fielddata: require('./api/cat.fielddata.js')(opts), + health: require('./api/cat.health.js')(opts), + help: require('./api/cat.help.js')(opts), + indices: require('./api/cat.indices.js')(opts), + master: require('./api/cat.master.js')(opts), + nodeattrs: require('./api/cat.nodeattrs.js')(opts), + nodes: require('./api/cat.nodes.js')(opts), + pending_tasks: require('./api/cat.pending_tasks.js')(opts), + plugins: require('./api/cat.plugins.js')(opts), + recovery: require('./api/cat.recovery.js')(opts), + repositories: require('./api/cat.repositories.js')(opts), + segments: require('./api/cat.segments.js')(opts), + shards: require('./api/cat.shards.js')(opts), + snapshots: require('./api/cat.snapshots.js')(opts), + tasks: require('./api/cat.tasks.js')(opts), + templates: require('./api/cat.templates.js')(opts), + thread_pool: require('./api/cat.thread_pool.js')(opts) + }, + clear_scroll: require('./api/clear_scroll.js')(opts), + cluster: { + allocation_explain: require('./api/cluster.allocation_explain.js')(opts), + get_settings: require('./api/cluster.get_settings.js')(opts), + health: require('./api/cluster.health.js')(opts), + pending_tasks: require('./api/cluster.pending_tasks.js')(opts), + put_settings: require('./api/cluster.put_settings.js')(opts), + remote_info: require('./api/cluster.remote_info.js')(opts), + reroute: require('./api/cluster.reroute.js')(opts), + state: require('./api/cluster.state.js')(opts), + stats: require('./api/cluster.stats.js')(opts) + }, + count: require('./api/count.js')(opts), + create: require('./api/create.js')(opts), + delete: require('./api/delete.js')(opts), + delete_by_query: require('./api/delete_by_query.js')(opts), + delete_script: require('./api/delete_script.js')(opts), + exists: require('./api/exists.js')(opts), + exists_source: require('./api/exists_source.js')(opts), + explain: require('./api/explain.js')(opts), + field_caps: require('./api/field_caps.js')(opts), + get: require('./api/get.js')(opts), + get_script: require('./api/get_script.js')(opts), + get_source: require('./api/get_source.js')(opts), + index: require('./api/index.js')(opts), + indices: { + analyze: require('./api/indices.analyze.js')(opts), + clear_cache: require('./api/indices.clear_cache.js')(opts), + close: require('./api/indices.close.js')(opts), + create: require('./api/indices.create.js')(opts), + delete: require('./api/indices.delete.js')(opts), + delete_alias: require('./api/indices.delete_alias.js')(opts), + delete_template: require('./api/indices.delete_template.js')(opts), + exists: require('./api/indices.exists.js')(opts), + exists_alias: require('./api/indices.exists_alias.js')(opts), + exists_template: require('./api/indices.exists_template.js')(opts), + exists_type: require('./api/indices.exists_type.js')(opts), + flush: require('./api/indices.flush.js')(opts), + flush_synced: require('./api/indices.flush_synced.js')(opts), + forcemerge: require('./api/indices.forcemerge.js')(opts), + get: require('./api/indices.get.js')(opts), + get_alias: require('./api/indices.get_alias.js')(opts), + get_field_mapping: require('./api/indices.get_field_mapping.js')(opts), + get_mapping: require('./api/indices.get_mapping.js')(opts), + get_settings: require('./api/indices.get_settings.js')(opts), + get_template: require('./api/indices.get_template.js')(opts), + get_upgrade: require('./api/indices.get_upgrade.js')(opts), + open: require('./api/indices.open.js')(opts), + put_alias: require('./api/indices.put_alias.js')(opts), + put_mapping: require('./api/indices.put_mapping.js')(opts), + put_settings: require('./api/indices.put_settings.js')(opts), + put_template: require('./api/indices.put_template.js')(opts), + recovery: require('./api/indices.recovery.js')(opts), + refresh: require('./api/indices.refresh.js')(opts), + rollover: require('./api/indices.rollover.js')(opts), + segments: require('./api/indices.segments.js')(opts), + shard_stores: require('./api/indices.shard_stores.js')(opts), + shrink: require('./api/indices.shrink.js')(opts), + split: require('./api/indices.split.js')(opts), + stats: require('./api/indices.stats.js')(opts), + update_aliases: require('./api/indices.update_aliases.js')(opts), + upgrade: require('./api/indices.upgrade.js')(opts), + validate_query: require('./api/indices.validate_query.js')(opts) + }, + info: require('./api/info.js')(opts), + ingest: { + delete_pipeline: require('./api/ingest.delete_pipeline.js')(opts), + get_pipeline: require('./api/ingest.get_pipeline.js')(opts), + processor_grok: require('./api/ingest.processor_grok.js')(opts), + put_pipeline: require('./api/ingest.put_pipeline.js')(opts), + simulate: require('./api/ingest.simulate.js')(opts) + }, + mget: require('./api/mget.js')(opts), + msearch: require('./api/msearch.js')(opts), + msearch_template: require('./api/msearch_template.js')(opts), + mtermvectors: require('./api/mtermvectors.js')(opts), + nodes: { + hot_threads: require('./api/nodes.hot_threads.js')(opts), + info: require('./api/nodes.info.js')(opts), + stats: require('./api/nodes.stats.js')(opts), + usage: require('./api/nodes.usage.js')(opts) + }, + ping: require('./api/ping.js')(opts), + put_script: require('./api/put_script.js')(opts), + rank_eval: require('./api/rank_eval.js')(opts), + reindex: require('./api/reindex.js')(opts), + reindex_rethrottle: require('./api/reindex_rethrottle.js')(opts), + render_search_template: require('./api/render_search_template.js')(opts), + scripts_painless_execute: require('./api/scripts_painless_execute.js')(opts), + scroll: require('./api/scroll.js')(opts), + search: require('./api/search.js')(opts), + search_shards: require('./api/search_shards.js')(opts), + search_template: require('./api/search_template.js')(opts), + snapshot: { + create: require('./api/snapshot.create.js')(opts), + create_repository: require('./api/snapshot.create_repository.js')(opts), + delete: require('./api/snapshot.delete.js')(opts), + delete_repository: require('./api/snapshot.delete_repository.js')(opts), + get: require('./api/snapshot.get.js')(opts), + get_repository: require('./api/snapshot.get_repository.js')(opts), + restore: require('./api/snapshot.restore.js')(opts), + status: require('./api/snapshot.status.js')(opts), + verify_repository: require('./api/snapshot.verify_repository.js')(opts) + }, + tasks: { + cancel: require('./api/tasks.cancel.js')(opts), + get: require('./api/tasks.get.js')(opts), + list: require('./api/tasks.list.js')(opts) + }, + termvectors: require('./api/termvectors.js')(opts), + update: require('./api/update.js')(opts), + update_by_query: require('./api/update_by_query.js')(opts) + } + + Object.defineProperties(apis.cat, { + pendingTasks: { + get: function () { return this.pending_tasks }, + enumerable: true + }, + threadPool: { + get: function () { return this.thread_pool }, + enumerable: true + } + }) + + Object.defineProperties(apis, { + clearScroll: { + get: function () { return this.clear_scroll }, + enumerable: true + }, + deleteByQuery: { + get: function () { return this.delete_by_query }, + enumerable: true + }, + deleteScript: { + get: function () { return this.delete_script }, + enumerable: true + }, + existsSource: { + get: function () { return this.exists_source }, + enumerable: true + }, + fieldCaps: { + get: function () { return this.field_caps }, + enumerable: true + }, + getScript: { + get: function () { return this.get_script }, + enumerable: true + }, + getSource: { + get: function () { return this.get_source }, + enumerable: true + }, + msearchTemplate: { + get: function () { return this.msearch_template }, + enumerable: true + }, + putScript: { + get: function () { return this.put_script }, + enumerable: true + }, + rankEval: { + get: function () { return this.rank_eval }, + enumerable: true + }, + reindexRethrottle: { + get: function () { return this.reindex_rethrottle }, + enumerable: true + }, + renderSearchTemplate: { + get: function () { return this.render_search_template }, + enumerable: true + }, + scriptsPainlessExecute: { + get: function () { return this.scripts_painless_execute }, + enumerable: true + }, + searchShards: { + get: function () { return this.search_shards }, + enumerable: true + }, + searchTemplate: { + get: function () { return this.search_template }, + enumerable: true + }, + updateByQuery: { + get: function () { return this.update_by_query }, + enumerable: true + } + }) + + Object.defineProperties(apis.cluster, { + allocationExplain: { + get: function () { return this.allocation_explain }, + enumerable: true + }, + getSettings: { + get: function () { return this.get_settings }, + enumerable: true + }, + pendingTasks: { + get: function () { return this.pending_tasks }, + enumerable: true + }, + putSettings: { + get: function () { return this.put_settings }, + enumerable: true + }, + remoteInfo: { + get: function () { return this.remote_info }, + enumerable: true + } + }) + + Object.defineProperties(apis.indices, { + clearCache: { + get: function () { return this.clear_cache }, + enumerable: true + }, + deleteAlias: { + get: function () { return this.delete_alias }, + enumerable: true + }, + deleteTemplate: { + get: function () { return this.delete_template }, + enumerable: true + }, + existsAlias: { + get: function () { return this.exists_alias }, + enumerable: true + }, + existsTemplate: { + get: function () { return this.exists_template }, + enumerable: true + }, + existsType: { + get: function () { return this.exists_type }, + enumerable: true + }, + flushSynced: { + get: function () { return this.flush_synced }, + enumerable: true + }, + getAlias: { + get: function () { return this.get_alias }, + enumerable: true + }, + getFieldMapping: { + get: function () { return this.get_field_mapping }, + enumerable: true + }, + getMapping: { + get: function () { return this.get_mapping }, + enumerable: true + }, + getSettings: { + get: function () { return this.get_settings }, + enumerable: true + }, + getTemplate: { + get: function () { return this.get_template }, + enumerable: true + }, + getUpgrade: { + get: function () { return this.get_upgrade }, + enumerable: true + }, + putAlias: { + get: function () { return this.put_alias }, + enumerable: true + }, + putMapping: { + get: function () { return this.put_mapping }, + enumerable: true + }, + putSettings: { + get: function () { return this.put_settings }, + enumerable: true + }, + putTemplate: { + get: function () { return this.put_template }, + enumerable: true + }, + shardStores: { + get: function () { return this.shard_stores }, + enumerable: true + }, + updateAliases: { + get: function () { return this.update_aliases }, + enumerable: true + }, + validateQuery: { + get: function () { return this.validate_query }, + enumerable: true + } + }) + + Object.defineProperties(apis.ingest, { + deletePipeline: { + get: function () { return this.delete_pipeline }, + enumerable: true + }, + getPipeline: { + get: function () { return this.get_pipeline }, + enumerable: true + }, + processorGrok: { + get: function () { return this.processor_grok }, + enumerable: true + }, + putPipeline: { + get: function () { return this.put_pipeline }, + enumerable: true + } + }) + + Object.defineProperties(apis.nodes, { + hotThreads: { + get: function () { return this.hot_threads }, + enumerable: true + } + }) + + Object.defineProperties(apis.snapshot, { + createRepository: { + get: function () { return this.create_repository }, + enumerable: true + }, + deleteRepository: { + get: function () { return this.delete_repository }, + enumerable: true + }, + getRepository: { + get: function () { return this.get_repository }, + enumerable: true + }, + verifyRepository: { + get: function () { return this.verify_repository }, + enumerable: true + } + }) + + return apis +} + +module.exports = ESAPI diff --git a/index.js b/index.js index 25cf37cff..da531097e 100644 --- a/index.js +++ b/index.js @@ -9,7 +9,7 @@ const selectors = require('./lib/Selectors') const symbols = require('./lib/symbols') const { ConfigurationError } = require('./lib/errors') -// const buildApi = require('../monorepo/packages/es-api-6') +const buildApi = require('./api') const { kTransport, @@ -85,14 +85,14 @@ class Client extends EventEmitter { this.request = this[kTransport].request.bind(this[kTransport]) - // const apis = buildApi({ - // makeRequest: this[kTransport].request.bind(this[kTransport]) - // }) - - // Object.keys(apis).forEach(api => { - // this[api] = apis[api] - // }) + const apis = buildApi({ + makeRequest: this[kTransport].request.bind(this[kTransport]), + ConfigurationError + }) + Object.keys(apis).forEach(api => { + this[api] = apis[api] + }) } } From 3962e2c031354776c92da4e1d697cb333b8b35e1 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 30 Oct 2018 17:27:07 +0100 Subject: [PATCH 019/172] Added integration test --- package.json | 4 +- test/integration/README.md | 52 +++ test/integration/index.js | 251 ++++++++++++ test/integration/test-runner.js | 676 ++++++++++++++++++++++++++++++++ 4 files changed, 981 insertions(+), 2 deletions(-) create mode 100644 test/integration/README.md create mode 100644 test/integration/index.js create mode 100644 test/integration/test-runner.js diff --git a/package.json b/package.json index ab933f5db..c67f1e845 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,8 @@ "search" ], "scripts": { - "test": "npm run test:unit && npm run test:integration", - "test:unit": "tap test/unit/*.test.js -J -T --harmony", + "test": "npm run lint && npm run test:unit", + "test:unit": "tap test/unit/*.test.js -J -T", "test:integration": "tap test/integration/index.js -T --harmony", "lint": "standard", "lint:fix": "standard --fix", diff --git a/test/integration/README.md b/test/integration/README.md new file mode 100644 index 000000000..0861dd8b9 --- /dev/null +++ b/test/integration/README.md @@ -0,0 +1,52 @@ +# `elasticsearch-js` integration test suite + +> What? A README to explain how the integration test work?? + +Yes. + +## Background +Elasticsearch offers its entire API via HTTP REST endpoints. You can find the whole API specification for every version [here](https://github.com/elastic/elasticsearch/tree/master/rest-api-spec/src/main/resources/rest-api-spec/api).
+To support different languages at the same time, the Elasticsearch team decided to provide a [YAML specification](https://github.com/elastic/elasticsearch/tree/master/rest-api-spec/src/main/resources/rest-api-spec/test) to test every endpoint, body, headers, warning, error and so on.
+This testing suite uses that specification to generate the test for the specified version of Elasticsearch on the fly. + +## Run +Run the testing suite is very easy, you just need to run the preconfigured npm script: +```sh +npm run test:integration +``` + +The first time you run this command, the Elasticsearch repository will be cloned inside the integration test folder, to be able to access the YAML specification, so it might take some time *(luckily, only the first time)*.
+Once the Elasticsearch repository has been cloned, the testing suite will connect to the provided Elasticsearch instance and then checkout the build hash in the repository. Finally, it will start running every test. + +The specification does not allow the test to be run in parallel, so it might take a while to run the entire testing suite; on my machine, `MacBookPro15,2 core i7 2.7GHz 16GB of RAM` it takes around four minutes. + +### Exit on the first failure +Bu default the suite will run all the test, even if one assertion has failed. If you want to stop the test at the first failure, use the bailout option: +```sh +npm run test:integration -- --bail +``` + +### Calculate the code coverage +If you want to calculate the code coverage just run the testing suite with the following parameters, once the test ends, it will open a browser window with the results. +```sh +npm run test:integration -- --cov --coverage-report=html +``` + +## How does this thing work? +At first sight, it might seem complicated, but once you understand what the moving parts are, it's quite easy. +1. Connects to the given Elasticsearch instance +1. Gets the ES version and build hash +1. Checkout to the given hash (and clone the repository if it is not present) +1. Reads the folder list and for each folder the yaml file list +1. Starts running folder by folder every file + 1. Read and parse the yaml files + 1. Creates a subtest structure to have a cleaner output + 1. Runs the assertions + 1. Repeat! + +Inside the `index.js` file, you will find the connection, cloning, reading and parsing part of the test, while inside the `test-runner.js` file you will find the function to handle the assertions. Inside `test-runner.js`, we use a [queue](https://github.com/delvedor/workq) to be sure that everything is run in the correct order. + +Checkout the [rest-api-spec readme](https://github.com/elastic/elasticsearch/blob/master/rest-api-spec/src/main/resources/rest-api-spec/test/README.asciidoc) if you want to know more about how the assertions work. + +#### Why are we running the test with the `--harmony` flag? +Because on Node v6 the regex lookbehinds are not supported. diff --git a/test/integration/index.js b/test/integration/index.js new file mode 100644 index 000000000..6492e18a1 --- /dev/null +++ b/test/integration/index.js @@ -0,0 +1,251 @@ +'use strict' + +const assert = require('assert') +const { readFileSync, accessSync, mkdirSync, readdirSync } = require('fs') +const { join } = require('path') +const yaml = require('js-yaml') +const Git = require('simple-git') +const ora = require('ora') +const minimist = require('minimist') +const tap = require('tap') +const elasticsearch = require('../../index') +const TestRunner = require('./test-runner') + +const esRepo = 'https://github.com/elastic/elasticsearch.git' +const esFolder = join(__dirname, '..', '..', 'elasticsearch') +const yamlFolder = join(esFolder, 'rest-api-spec', 'src', 'main', 'resources', 'rest-api-spec', 'test') + +function Runner (opts) { + if (!(this instanceof Runner)) { + return new Runner(opts) + } + opts = opts || {} + + assert(opts.host, 'Missing host') + this.bailout = opts.bailout + this.client = new elasticsearch.Client({ + host: opts.host + }) + this.log = ora('Loading yaml suite').start() +} + +/** + * Runs the test suite + */ +Runner.prototype.start = function () { + const getTest = this.getTest.bind(this) + const parse = this.parse.bind(this) + const client = this.client + + // client.on('response', (request, response) => { + // console.log('\n\n') + // console.log('REQUEST', request) + // console.log('\n') + // console.log('RESPONSE', response) + // }) + + // Get the build hash of Elasticsearch + client.info((err, { body }) => { + if (err) { + this.log.fail(err.message) + return + } + const { number: version, build_hash: sha } = body.version + // Set the repository to the given sha and run the test suite + this.withSHA(sha, () => { + this.log.succeed('Done!') + runTest.call(this, version) + }) + }) + + function runTest (version) { + const testFolders = getTest() + testFolders.forEach(runTestFolder.bind(this)) + function runTestFolder (testFolder) { + // if (testFolder !== 'tasks.get') return + // create a subtest for the specific folder + tap.test(testFolder, { jobs: 1 }, tap1 => { + const files = getTest(testFolder) + files.forEach(file => { + // if (file !== '20_typed_keys.yml') return + // create a subtest for the specific folder + test file + tap1.test(file.slice(0, -4), { jobs: 1 }, tap2 => { + const path = join(yamlFolder, testFolder, file) + // read the yaml file + const data = readFileSync(path, 'utf8') + // get the test yaml (as object), some file has multiple yaml documents inside, + // every document is separated by '---', so we split on the separator + // and then we remove the empty strings, finally we parse them + const tests = data + .split('---') + .map(s => s.trim()) + .filter(Boolean) + .map(parse) + + // get setup and teardown if present + var setupTest = null + var teardownTest = null + tests.forEach(test => { + if (test.setup) setupTest = test.setup + if (test.teardown) teardownTest = test.teardown + }) + + // run the tests + tests.forEach(test => { + const name = Object.keys(test)[0] + if (name === 'setup' || name === 'teardown') return + // create a subtest for the specific folder + test file + test name + tap2.test(name, { jobs: 1, bail: this.bailout }, tap3 => { + const testRunner = TestRunner({ client, version, tap: tap3 }) + testRunner.run(setupTest, test[name], teardownTest, () => tap3.end()) + }) + }) + + tap2.end() + }) + }) + + tap1.end() + }) + } + } +} + +/** + * Parses a given yaml document + * @param {string} yaml document + * @returns {object} + */ +Runner.prototype.parse = function (data) { + try { + var doc = yaml.safeLoad(data) + } catch (err) { + this.log.fail(err.message) + return + } + return doc +} + +/** + * Returns the content of the `yamlFolder`. + * If a folder name is given as parameter, it will return + * the content of join(yamlFolder, folder) + * @param {string} folder + * @returns {Array} The content of the given folder + */ +Runner.prototype.getTest = function (folder) { + const tests = readdirSync(join(yamlFolder, folder || '')) + return tests.filter(t => !/(README|TODO)/g.test(t)) +} + +/** + * Sets the elasticsearch repository to the given sha. + * If the repository is not present in `esFolder` it will + * clone the repository and the checkout the sha. + * If the repository is already present but it cannot checkout to + * the given sha, it will perform a pull and then try again. + * @param {string} sha + * @param {function} callback + */ +Runner.prototype.withSHA = function (sha, callback) { + var fresh = false + var retry = 0 + var log = this.log + + if (!this.pathExist(esFolder)) { + if (!this.createFolder(esFolder)) { + log.fail('Failed folder creation') + return + } + fresh = true + } + + const git = Git(esFolder) + + if (fresh) { + clone(checkout) + } else { + checkout() + } + + function checkout () { + log.text = `Checking out sha '${sha}'` + git.checkout(sha, err => { + if (err) { + if (retry++ > 0) { + log.fail(`Cannot checkout sha '${sha}'`) + return + } + return pull(checkout) + } + callback() + }) + } + + function pull (cb) { + log.text = 'Pulling elasticsearch repository...' + git.pull(err => { + if (err) { + log.fail(err.message) + return + } + cb() + }) + } + + function clone (cb) { + log.text = 'Cloning elasticsearch repository...' + git.clone(esRepo, esFolder, err => { + if (err) { + log.fail(err.message) + return + } + cb() + }) + } +} + +/** + * Checks if the given path exists + * @param {string} path + * @returns {boolean} true if exists, false if not + */ +Runner.prototype.pathExist = function (path) { + try { + accessSync(path) + return true + } catch (err) { + return false + } +} + +/** + * Creates the given folder + * @param {string} name + * @returns {boolean} true on success, false on failure + */ +Runner.prototype.createFolder = function (name) { + try { + mkdirSync(name) + return true + } catch (err) { + return false + } +} + +if (require.main === module) { + const opts = minimist(process.argv.slice(2), { + string: ['host', 'version'], + boolean: ['bailout'], + default: { + host: 'http://localhost:9200', + version: '6.4', + bailout: false + } + }) + + const runner = Runner(opts) + runner.start() +} + +module.exports = Runner diff --git a/test/integration/test-runner.js b/test/integration/test-runner.js new file mode 100644 index 000000000..de076c023 --- /dev/null +++ b/test/integration/test-runner.js @@ -0,0 +1,676 @@ +'use strict' + +const t = require('tap') +const semver = require('semver') +const workq = require('workq') +const { ConfigurationError } = require('../../lib/errors') + +const supportedFeatures = [ + // 'gtelte', + // 'regex', + // 'benchmark', + // 'stash_in_path', + // 'groovy_scripting', + // 'headers' +] + +function TestRunner (opts) { + if (!(this instanceof TestRunner)) { + return new TestRunner(opts) + } + opts = opts || {} + + this.client = opts.client + this.esVersion = opts.version + this.response = null + this.stash = new Map() + this.tap = opts.tap || t + this.q = opts.q || workq() +} + +/** + * Runs a cleanup, removes all indices and templates + * @param {queue} + * @param {function} done + */ +TestRunner.prototype.cleanup = function (q, done) { + this.tap.comment('Cleanup') + + this.response = null + this.stash = new Map() + + q.add((q, done) => { + this.client.indices.delete({ index: '*', ignore: 404 }, err => { + this.tap.error(err, 'should not error: indices.delete') + done() + }) + }) + + q.add((q, done) => { + this.client.indices.deleteTemplate({ name: '*', ignore: 404 }, err => { + this.tap.error(err, 'should not error: indices.deleteTemplate') + done() + }) + }) + + done() +} + +/** + * Runs the given test. + * It runs the test components in the following order: + * - setup + * - the actual test + * - teardown + * - cleanup + * Internally uses a queue to guarantee the order of the test sections. + * @param {object} setup (null if not needed) + * @param {object} test + * @oaram {object} teardown (null if not needed) + * @param {function} end + */ +TestRunner.prototype.run = function (setup, test, teardown, end) { + // if we should skip a feature in the setup/teardown section + // we should skip the entire test file + const skip = getSkip(setup) || getSkip(teardown) + if (skip && this.shouldSkip(skip)) { + this.skip(skip) + return end() + } + + if (setup) { + this.q.add((q, done) => { + this.exec('Setup', setup, q, done) + }) + } + + this.q.add((q, done) => { + this.exec('Test', test, q, done) + }) + + if (teardown) { + this.q.add((q, done) => { + this.exec('Teardown', teardown, q, done) + }) + } + + this.q.add((q, done) => { + this.cleanup(q, done) + }) + + this.q.add((q, done) => end() && done()) +} + +/** + * Logs a skip + * @param {object} the actions + * @returns {TestRunner} + */ +TestRunner.prototype.skip = function (action) { + if (action.reason && action.version) { + this.tap.skip(`Skip: ${action.reason} (${action.version})`) + } else if (action.features) { + this.tap.skip(`Skip: ${JSON.stringify(action.features)})`) + } else { + this.tap.skip('Skipped') + } + return this +} + +/** + * Decides if a test should be skipped + * @param {object} the actions + * @returns {boolean} + */ +TestRunner.prototype.shouldSkip = function (action) { + var shouldSkip = false + // skip based on the version + if (action.version) { + if (action.version.trim() === 'all') return true + const [min, max] = action.version.split('-').map(v => v.trim()) + // if both `min` and `max` are specified + if (min && max) { + shouldSkip = semver.satisfies(this.esVersion, action.version) + // if only `min` is specified + } else if (min) { + shouldSkip = semver.gte(this.esVersion, min) + // if only `max` is specified + } else if (max) { + shouldSkip = semver.lte(this.esVersion, max) + // something went wrong! + } else { + throw new Error(`skip: Bad version range: ${action.version}`) + } + } + + if (shouldSkip) return true + + if (action.features) { + if (!Array.isArray(action.features)) action.features = [action.features] + // returns true if one of the features is not present in the supportedFeatures + shouldSkip = !!action.features.filter(f => !~supportedFeatures.indexOf(f)).length + } + + if (shouldSkip) return true + + return false +} + +/** + * Updates the array syntax of keys and values + * eg: 'hits.hits.1.stuff' to 'hits.hits[1].stuff' + * @param {object} the action to update + * @returns {obj} the updated action + */ +TestRunner.prototype.updateArraySyntax = function (obj) { + const newObj = {} + + for (const key in obj) { + const newKey = key.replace(/\.\d{1,}\./g, v => `[${v.slice(1, -1)}].`) + const val = obj[key] + + if (typeof val === 'string') { + newObj[newKey] = val.replace(/\.\d{1,}\./g, v => `[${v.slice(1, -1)}].`) + } else if (val !== null && typeof val === 'object') { + newObj[newKey] = this.updateArraySyntax(val) + } else { + newObj[newKey] = val + } + } + + return newObj +} + +/** + * Fill the stashed values of a command + * let's say the we have stashed the `master` value, + * is_true: nodes.$master.transport.profiles + * becomes + * is_true: nodes.new_value.transport.profiles + * @param {object|string} the action to update + * @returns {object|string} the updated action + */ +TestRunner.prototype.fillStashedValues = function (obj) { + if (typeof obj === 'string') { + return getStashedValues.call(this, obj) + } + // iterate every key of the object + for (const key in obj) { + const val = obj[key] + // if the key value is a string, and the string includes '$' + // we run the "update value" code + if (typeof val === 'string' && val.includes('$')) { + // update the key value + obj[key] = getStashedValues.call(this, val) + } + + // go deep in the object + if (val !== null && typeof val === 'object') { + this.fillStashedValues(val) + } + } + + return obj + + function getStashedValues (str) { + return str + // we split the string on the dots + // handle the key with a dot inside that is not a part of the path + .split(/(? { + if (part[0] === '$') { + const stashed = this.stash.get(part.slice(1)) + if (stashed == null) { + throw new Error(`Cannot find stashed value '${part}' for '${JSON.stringify(obj)}'`) + } + return stashed + } + return part + }) + // recreate the string value + .join('.') + } +} + +/** + * Stashes a value + * @param {string} the key to search in the previous response + * @param {string} the name to identify the stashed value + * @returns {TestRunner} + */ +TestRunner.prototype.set = function (key, name) { + this.stash.set(name, delve(this.response, key)) + return this +} + +/** + * Runs a client command + * TODO: handle `action.warning`, `action.catch`... + * @param {object} the action to perform + * @param {Queue} + */ +TestRunner.prototype.do = function (action, done) { + const cmd = this.parseDo(action) + const api = delve(this.client, cmd.method).bind(this.client) + api(cmd.params, (err, { body }) => { + if (action.catch) { + this.tap.true( + parseDoError(err, action.catch), + `the error should be: ${action.catch}` + ) + try { + this.response = JSON.parse(err.body) + } catch (e) { + this.response = err.body + } + } else { + this.tap.error(err, `should not error: ${cmd.method}`, action) + this.response = body + } + + if (action.warning) { + this.tap.todo('Handle warnings') + } + + done() + }) +} + +/** + * Runs an actual test + * @param {string} the name of the test + * @param {object} the actions to perform + * @param {Queue} + */ +TestRunner.prototype.exec = function (name, actions, q, done) { + this.tap.comment(name) + for (var i = 0; i < actions.length; i++) { + const action = actions[i] + + if (action.skip) { + if (this.shouldSkip(action.skip)) { + this.skip(this.fillStashedValues(action.skip)) + break + } + } + + if (action.do) { + q.add((q, done) => { + this.do(this.fillStashedValues(action.do), done) + }) + } + + if (action.set) { + q.add((q, done) => { + const key = Object.keys(action.set)[0] + this.set(key, action.set[key]) + done() + }) + } + + if (action.match) { + q.add((q, done) => { + const key = Object.keys(action.match)[0] + this.match( + // in some cases, the yaml refers to the body with an empty string + key === '$body' || key === '' + ? this.response + : delve(this.response, this.fillStashedValues(key)), + key === '$body' + ? action.match[key] + : this.fillStashedValues(action.match)[key] + ) + done() + }) + } + + if (action.lt) { + q.add((q, done) => { + const key = Object.keys(action.lt)[0] + this.lt( + delve(this.response, this.fillStashedValues(key)), + this.fillStashedValues(action.lt)[key] + ) + done() + }) + } + + if (action.gt) { + q.add((q, done) => { + const key = Object.keys(action.gt)[0] + this.gt( + delve(this.response, this.fillStashedValues(key)), + this.fillStashedValues(action.gt)[key] + ) + done() + }) + } + + if (action.lte) { + q.add((q, done) => { + const key = Object.keys(action.lte)[0] + this.lte( + delve(this.response, this.fillStashedValues(key)), + this.fillStashedValues(action.lte)[key] + ) + done() + }) + } + + if (action.gte) { + q.add((q, done) => { + const key = Object.keys(action.gte)[0] + this.gte( + delve(this.response, this.fillStashedValues(key)), + this.fillStashedValues(action.gte)[key] + ) + done() + }) + } + + if (action.length) { + q.add((q, done) => { + const key = Object.keys(action.length)[0] + this.length( + delve(this.response, this.fillStashedValues(key)), + this.fillStashedValues(action.length)[key] + ) + done() + }) + } + + if (action.is_true) { + q.add((q, done) => { + const isTrue = this.fillStashedValues(action.is_true) + this.is_true( + delve(this.response, isTrue), + isTrue + ) + done() + }) + } + + if (action.is_false) { + q.add((q, done) => { + const isFalse = this.fillStashedValues(action.is_false) + this.is_false( + delve(this.response, isFalse), + isFalse + ) + done() + }) + } + } + done() +} + +/** + * Asserts that the given value is truthy + * @param {any} the value to check + * @param {string} an optional message + */ +TestRunner.prototype.is_true = function (val, msg) { + this.tap.true(val, `expect truthy value: ${msg} - value: ${JSON.stringify(val)}`) + return this +} + +/** + * Asserts that the given value is falsey + * @param {any} the value to check + * @param {string} an optional message + */ +TestRunner.prototype.is_false = function (val, msg) { + this.tap.false(val, `expect falsey value: ${msg} - value: ${JSON.stringify(val)}`) + return this +} + +/** + * Asserts that two values are the same + * @param {any} the first value + * @param {any} the second value + * @returns {TestRunner} + */ +TestRunner.prototype.match = function (val1, val2) { + // both values are objects + if (typeof val1 === 'object' && typeof val2 === 'object') { + this.tap.strictDeepEqual(val1, val2) + // the first value is the body as string and the second a pattern string + } else if ( + typeof val1 === 'string' && typeof val2 === 'string' && + val2.startsWith('/') && (val2.endsWith('/\n') || val2.endsWith('/')) + ) { + const regStr = val2 + // match all comments within a "regexp" match arg + .replace(/([\S\s]?)#[^\n]*\n/g, (match, prevChar) => { + return prevChar === '\\' ? match : `${prevChar}\n` + }) + // remove all whitespace from the expression, all meaningful + // whitespace is represented with \s + .replace(/\s/g, '') + .slice(1, -1) + // 'm' adds the support for multiline regex + this.tap.match(val1, new RegExp(regStr, 'm'), `should match pattern provided: ${val2}`) + // everything else + } else { + this.tap.strictEqual(val1, val2, `should be equal: ${val1} - ${val2}`) + } + return this +} + +/** + * Asserts that the first value is less than the second + * It also verifies that the two values are numbers + * @param {any} the first value + * @param {any} the second value + * @returns {TestRunner} + */ +TestRunner.prototype.lt = function (val1, val2) { + ;[val1, val2] = getNumbers(val1, val2) + this.tap.true(val1 < val2) + return this +} + +/** + * Asserts that the first value is greater than the second + * It also verifies that the two values are numbers + * @param {any} the first value + * @param {any} the second value + * @returns {TestRunner} + */ +TestRunner.prototype.gt = function (val1, val2) { + ;[val1, val2] = getNumbers(val1, val2) + this.tap.true(val1 > val2) + return this +} + +/** + * Asserts that the first value is less than or equal the second + * It also verifies that the two values are numbers + * @param {any} the first value + * @param {any} the second value + * @returns {TestRunner} + */ +TestRunner.prototype.lte = function (val1, val2) { + ;[val1, val2] = getNumbers(val1, val2) + this.tap.true(val1 <= val2) + return this +} + +/** + * Asserts that the first value is greater than or equal the second + * It also verifies that the two values are numbers + * @param {any} the first value + * @param {any} the second value + * @returns {TestRunner} +*/ +TestRunner.prototype.gte = function (val1, val2) { + ;[val1, val2] = getNumbers(val1, val2) + this.tap.true(val1 >= val2) + return this +} + +/** + * Asserts that the given value has the specified length + * @param {string|object|array} the object to check + * @param {number} the expected length + * @returns {TestRunner} + */ +TestRunner.prototype.length = function (val, len) { + if (typeof val === 'string' || Array.isArray(val)) { + this.tap.strictEqual(val.length, len) + } else if (typeof val === 'object' && val !== null) { + this.tap.strictEqual(Object.keys(val).length, len) + } else { + this.tap.fail(`length: the given value is invalid: ${val}`) + } + return this +} + +/** + * Gets a `do` action object and returns a structured object, + * where the action is the key and the parameter is the value. + * Eg: + * { + * 'indices.create': { + * 'index': 'test' + * }, + * 'warnings': [ + * '[index] is deprecated' + * ] + * } + * becomes + * { + * method: 'indices.create', + * params: { + * index: 'test' + * }, + * warnings: [ + * '[index] is deprecated' + * ] + * } + * @param {object} + * @returns {object} + */ +TestRunner.prototype.parseDo = function (action) { + return Object.keys(action).reduce((acc, val) => { + switch (val) { + case 'catch': + acc.catch = action.catch + break + case 'warnings': + acc.warnings = action.warnings + break + case 'node_selector': + acc.node_selector = action.node_selector + break + default: + // converts underscore to camelCase + // eg: put_mapping => putMapping + acc.method = val.replace(/_([a-z])/g, g => g[1].toUpperCase()) + acc.params = camelify(action[val]) + } + return acc + }, {}) + + function camelify (obj) { + const newObj = {} + + // TODO: add camelCase support for this fields + const doNotCamelify = ['copy_settings'] + + for (const key in obj) { + const val = obj[key] + var newKey = key + if (!~doNotCamelify.indexOf(key)) { + // if the key starts with `_` we should not camelify the first occurence + // eg: _source_include => _sourceInclude + newKey = key[0] === '_' + ? '_' + key.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase()) + : key.replace(/_([a-z])/g, k => k[1].toUpperCase()) + } + + if ( + val !== null && + typeof val === 'object' && + !Array.isArray(val) && + key !== 'body' + ) { + newObj[newKey] = camelify(val) + } else { + newObj[newKey] = val + } + } + + return newObj + } +} + +function parseDoError (err, spec) { + const httpErrors = { + bad_request: 400, + unauthorized: 401, + forbidden: 403, + missing: 404, + request_timeout: 408, + conflict: 409, + unavailable: 503 + } + + if (httpErrors[spec]) { + return err.statusCode === httpErrors[spec] + } + + if (spec === 'request') { + return err.statusCode >= 400 && err.statusCode < 600 + } + + if (spec.startsWith('/') && spec.endsWith('/')) { + return new RegExp(spec.slice(1, -1), 'g').test(JSON.stringify(err.body)) + } + + if (spec === 'param') { + return err instanceof ConfigurationError + } + + return false +} + +function getSkip (arr) { + if (!Array.isArray(arr)) return null + for (var i = 0; i < arr.length; i++) { + if (arr[i].skip) return arr[i].skip + } + return null +} + +// code from https://github.com/developit/dlv +// needed to support an edge case: `a\.b` +// where `a.b` is a single field: { 'a.b': true } +function delve (obj, key, def, p) { + p = 0 + // handle the key with a dot inside that is not a part of the path + // and removes the backslashes from the key + key = key.split + ? key.split(/(? k.replace(/\\/g, '')) + : key.replace(/\\/g, '') + while (obj && p < key.length) obj = obj[key[p++]] + return (obj === undefined || p < key.length) ? def : obj +} + +// Gets two *maybe* numbers and returns two valida numbers +// it throws if one or both are not a valid number +// the returned value is an array with the new values +function getNumbers (val1, val2) { + const val1Numeric = Number(val1) + if (isNaN(val1Numeric)) { + throw new TypeError(`val1 is not a valid number: ${val1}`) + } + const val2Numeric = Number(val2) + if (isNaN(val2Numeric)) { + throw new TypeError(`val2 is not a valid number: ${val2}`) + } + return [val1Numeric, val2Numeric] +} + +module.exports = TestRunner From a60ac39aa6f5c0961d53dfb9b500d1c810085ac3 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 30 Oct 2018 18:36:04 +0100 Subject: [PATCH 020/172] Added wait-cluster script --- scripts/wait-cluster.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 scripts/wait-cluster.sh diff --git a/scripts/wait-cluster.sh b/scripts/wait-cluster.sh new file mode 100755 index 000000000..f94c333ed --- /dev/null +++ b/scripts/wait-cluster.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +attempt_counter=0 +max_attempts=5 +url='http://localhost:9200/_cluster/health?wait_for_status=green&timeout=50s' + +echo "Waiting for Elasticsearch..." +while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' --max-time 55 "$url")" != "200" ]]; do + if [ ${attempt_counter} -eq ${max_attempts} ];then + echo "\nCouldn't connect to Elasticsearch" + exit 1 + fi + + printf '.' + attempt_counter=$(($attempt_counter+1)) + sleep 5 +done + +echo "\nReady" From 99fe53fbca81d86545edb83a34b31da8aa28d990 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 30 Oct 2018 18:36:41 +0100 Subject: [PATCH 021/172] Added .travis.yml --- .travis.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..9ba174b40 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,32 @@ +dist: trusty + +sudo: required + +language: node_js + +node_js: + - "10" + - "8" + - "6" + +env: + global: + - ELASTICSEARCH_VERSION=6.4.0 + - QUIET=true + +before_install: + - wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz + - tar -xzf elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz + - ./elasticsearch-${ELASTICSEARCH_VERSION}/bin/elasticsearch -Enode.attr.testattr=test -Epath.repo=/tmp -Erepositories.url.allowed_urls='http://snapshot.*' &> /dev/null & + - ./scripts/wait-cluster.sh + +install: + - npm install + +script: + - npm run lint && npm run test:unit && npm run test:integration + +notifications: + email: + on_success: never + on_failure: always From 42fd15d54c116c13a67e382e8ae6d2df362a19cc Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 2 Nov 2018 11:46:00 +0100 Subject: [PATCH 022/172] API generation --- api/api/cluster.stats.js | 2 +- api/api/indices.delete_alias.js | 2 +- api/api/indices.put_alias.js | 2 +- api/api/nodes.hot_threads.js | 2 +- api/api/reindex_rethrottle.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api/api/cluster.stats.js b/api/api/cluster.stats.js index efc361d97..d674a491d 100644 --- a/api/api/cluster.stats.js +++ b/api/api/cluster.stats.js @@ -90,7 +90,7 @@ function buildClusterStats (opts) { const request = { method, path: (params['node_id'] || params['nodeId']) != null - ? '/' + parts.filter(Boolean).join('/') + ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') : '/_cluster/stats', querystring, body: null, diff --git a/api/api/indices.delete_alias.js b/api/api/indices.delete_alias.js index 7da283f68..b876b8eec 100644 --- a/api/api/indices.delete_alias.js +++ b/api/api/indices.delete_alias.js @@ -111,7 +111,7 @@ function buildIndicesDeleteAlias (opts) { const request = { method, path: params['index'] != null && params['name'] != null - ? '/' + parts.filter(Boolean).join('/') + ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') : '/{index}/_alias/{name}', querystring, body: '', diff --git a/api/api/indices.put_alias.js b/api/api/indices.put_alias.js index fce99f4cb..d0efccf94 100644 --- a/api/api/indices.put_alias.js +++ b/api/api/indices.put_alias.js @@ -106,7 +106,7 @@ function buildIndicesPutAlias (opts) { const request = { method, path: params['index'] != null && params['name'] != null - ? '/' + parts.filter(Boolean).join('/') + ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') : '/{index}/_alias/{name}', querystring, body: params.body || '', diff --git a/api/api/nodes.hot_threads.js b/api/api/nodes.hot_threads.js index 6dcf89610..23ac7e02d 100644 --- a/api/api/nodes.hot_threads.js +++ b/api/api/nodes.hot_threads.js @@ -102,7 +102,7 @@ function buildNodesHotThreads (opts) { const request = { method, path: (params['node_id'] || params['nodeId']) != null - ? '/' + parts.filter(Boolean).join('/') + ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') : '/_nodes/hot_threads', querystring, body: null, diff --git a/api/api/reindex_rethrottle.js b/api/api/reindex_rethrottle.js index caa50c151..396dff3d1 100644 --- a/api/api/reindex_rethrottle.js +++ b/api/api/reindex_rethrottle.js @@ -99,7 +99,7 @@ function buildReindexRethrottle (opts) { const request = { method, path: (params['task_id'] || params['taskId']) != null - ? '/' + parts.filter(Boolean).join('/') + ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') : '/_reindex/{task_id}/_rethrottle', querystring, body: '', From 99e9568b5832b4915fe43732ddd04ce5009bf3fb Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 2 Nov 2018 11:47:40 +0100 Subject: [PATCH 023/172] Enable all features in integration test --- test/integration/test-runner.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/integration/test-runner.js b/test/integration/test-runner.js index de076c023..1ee0f5260 100644 --- a/test/integration/test-runner.js +++ b/test/integration/test-runner.js @@ -6,12 +6,12 @@ const workq = require('workq') const { ConfigurationError } = require('../../lib/errors') const supportedFeatures = [ - // 'gtelte', - // 'regex', - // 'benchmark', - // 'stash_in_path', - // 'groovy_scripting', - // 'headers' + 'gtelte', + 'regex', + 'benchmark', + 'stash_in_path', + 'groovy_scripting', + 'headers' ] function TestRunner (opts) { From 49cff40e9602498fdd820a7ea65ea5f66831090b Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 2 Nov 2018 11:48:12 +0100 Subject: [PATCH 024/172] Updated api generation script --- scripts/utils/generate.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/utils/generate.js b/scripts/utils/generate.js index aa5c012d6..cc2d1008e 100644 --- a/scripts/utils/generate.js +++ b/scripts/utils/generate.js @@ -254,11 +254,11 @@ function generate (spec, common) { if (dynamicParts.length) { return ` path: ${dynamicParts} - ? '/' + parts.filter(Boolean).join('/') + ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') : '${path}', `.trim() } else { - return `path: '/' + parts.filter(Boolean).join('/'),`.trim() + return `path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),`.trim() } } From 2d3701d7e9a49eaf5831a4e43fae012a7789d8d7 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 5 Nov 2018 19:17:55 +0100 Subject: [PATCH 025/172] API generation --- api/api/bulk.js | 8 ++++---- api/api/cat.aliases.js | 6 +++--- api/api/cat.allocation.js | 6 +++--- api/api/cat.count.js | 6 +++--- api/api/cat.fielddata.js | 6 +++--- api/api/cat.health.js | 6 +++--- api/api/cat.help.js | 6 +++--- api/api/cat.indices.js | 6 +++--- api/api/cat.master.js | 6 +++--- api/api/cat.nodeattrs.js | 6 +++--- api/api/cat.nodes.js | 6 +++--- api/api/cat.pending_tasks.js | 6 +++--- api/api/cat.plugins.js | 6 +++--- api/api/cat.recovery.js | 6 +++--- api/api/cat.repositories.js | 6 +++--- api/api/cat.segments.js | 6 +++--- api/api/cat.shards.js | 6 +++--- api/api/cat.snapshots.js | 6 +++--- api/api/cat.tasks.js | 6 +++--- api/api/cat.templates.js | 6 +++--- api/api/cat.thread_pool.js | 6 +++--- api/api/clear_scroll.js | 4 ++-- api/api/cluster.allocation_explain.js | 4 ++-- api/api/cluster.get_settings.js | 6 +++--- api/api/cluster.health.js | 6 +++--- api/api/cluster.pending_tasks.js | 6 +++--- api/api/cluster.put_settings.js | 6 +++--- api/api/cluster.remote_info.js | 6 +++--- api/api/cluster.reroute.js | 4 ++-- api/api/cluster.state.js | 8 ++++---- api/api/cluster.stats.js | 6 +++--- api/api/count.js | 6 +++--- api/api/create.js | 16 ++++++++-------- api/api/delete.js | 16 ++++++++-------- api/api/delete_by_query.js | 10 +++++----- api/api/delete_script.js | 8 ++++---- api/api/exists.js | 16 ++++++++-------- api/api/exists_source.js | 16 ++++++++-------- api/api/explain.js | 14 +++++++------- api/api/field_caps.js | 4 ++-- api/api/get.js | 16 ++++++++-------- api/api/get_script.js | 8 ++++---- api/api/get_source.js | 16 ++++++++-------- api/api/index.js | 14 +++++++------- api/api/indices.analyze.js | 4 ++-- api/api/indices.clear_cache.js | 6 +++--- api/api/indices.close.js | 8 ++++---- api/api/indices.create.js | 6 +++--- api/api/indices.delete.js | 8 ++++---- api/api/indices.delete_alias.js | 12 ++++++------ api/api/indices.delete_template.js | 8 ++++---- api/api/indices.exists.js | 8 ++++---- api/api/indices.exists_alias.js | 8 ++++---- api/api/indices.exists_template.js | 8 ++++---- api/api/indices.exists_type.js | 12 ++++++------ api/api/indices.flush.js | 6 +++--- api/api/indices.flush_synced.js | 6 +++--- api/api/indices.forcemerge.js | 6 +++--- api/api/indices.get.js | 8 ++++---- api/api/indices.get_alias.js | 6 +++--- api/api/indices.get_field_mapping.js | 8 ++++---- api/api/indices.get_mapping.js | 6 +++--- api/api/indices.get_settings.js | 6 +++--- api/api/indices.get_template.js | 6 +++--- api/api/indices.get_upgrade.js | 6 +++--- api/api/indices.open.js | 8 ++++---- api/api/indices.put_alias.js | 10 +++++----- api/api/indices.put_mapping.js | 8 ++++---- api/api/indices.put_settings.js | 6 +++--- api/api/indices.put_template.js | 8 ++++---- api/api/indices.recovery.js | 6 +++--- api/api/indices.refresh.js | 6 +++--- api/api/indices.rollover.js | 8 ++++---- api/api/indices.segments.js | 6 +++--- api/api/indices.shard_stores.js | 6 +++--- api/api/indices.shrink.js | 10 +++++----- api/api/indices.split.js | 10 +++++----- api/api/indices.stats.js | 6 +++--- api/api/indices.update_aliases.js | 6 +++--- api/api/indices.upgrade.js | 6 +++--- api/api/indices.validate_query.js | 6 +++--- api/api/info.js | 6 +++--- api/api/ingest.delete_pipeline.js | 8 ++++---- api/api/ingest.get_pipeline.js | 6 +++--- api/api/ingest.processor_grok.js | 6 +++--- api/api/ingest.put_pipeline.js | 8 ++++---- api/api/ingest.simulate.js | 6 +++--- api/api/mget.js | 8 ++++---- api/api/msearch.js | 8 ++++---- api/api/msearch_template.js | 8 ++++---- api/api/mtermvectors.js | 6 +++--- api/api/nodes.hot_threads.js | 6 +++--- api/api/nodes.info.js | 6 +++--- api/api/nodes.stats.js | 6 +++--- api/api/nodes.usage.js | 6 +++--- api/api/ping.js | 6 +++--- api/api/put_script.js | 10 +++++----- api/api/rank_eval.js | 6 +++--- api/api/reindex.js | 6 +++--- api/api/reindex_rethrottle.js | 10 +++++----- api/api/render_search_template.js | 4 ++-- api/api/scripts_painless_execute.js | 4 ++-- api/api/scroll.js | 4 ++-- api/api/search.js | 6 +++--- api/api/search_shards.js | 6 +++--- api/api/search_template.js | 8 ++++---- api/api/snapshot.create.js | 10 +++++----- api/api/snapshot.create_repository.js | 8 ++++---- api/api/snapshot.delete.js | 12 ++++++------ api/api/snapshot.delete_repository.js | 8 ++++---- api/api/snapshot.get.js | 12 ++++++------ api/api/snapshot.get_repository.js | 6 +++--- api/api/snapshot.restore.js | 10 +++++----- api/api/snapshot.status.js | 8 ++++---- api/api/snapshot.verify_repository.js | 8 ++++---- api/api/tasks.cancel.js | 6 +++--- api/api/tasks.get.js | 8 ++++---- api/api/tasks.list.js | 6 +++--- api/api/termvectors.js | 12 ++++++------ api/api/update.js | 16 ++++++++-------- api/api/update_by_query.js | 8 ++++---- api/index.js | 1 + 122 files changed, 458 insertions(+), 457 deletions(-) diff --git a/api/api/bulk.js b/api/api/bulk.js index bba62c2bd..78f57f8e2 100644 --- a/api/api/bulk.js +++ b/api/api/bulk.js @@ -2,7 +2,7 @@ function buildBulk (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [bulk](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html) request * @@ -38,7 +38,7 @@ function buildBulk (opts) { if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -46,7 +46,7 @@ function buildBulk (opts) { if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -110,7 +110,7 @@ function buildBulk (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cat.aliases.js b/api/api/cat.aliases.js index 24e48fa8c..d06f0c901 100644 --- a/api/api/cat.aliases.js +++ b/api/api/cat.aliases.js @@ -2,7 +2,7 @@ function buildCatAliases (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cat.aliases](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-alias.html) request * @@ -33,7 +33,7 @@ function buildCatAliases (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -91,7 +91,7 @@ function buildCatAliases (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cat.allocation.js b/api/api/cat.allocation.js index 1abd0c58b..82d8557ab 100644 --- a/api/api/cat.allocation.js +++ b/api/api/cat.allocation.js @@ -2,7 +2,7 @@ function buildCatAllocation (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cat.allocation](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-allocation.html) request * @@ -34,7 +34,7 @@ function buildCatAllocation (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -94,7 +94,7 @@ function buildCatAllocation (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cat.count.js b/api/api/cat.count.js index 87136212c..bae0d16ea 100644 --- a/api/api/cat.count.js +++ b/api/api/cat.count.js @@ -2,7 +2,7 @@ function buildCatCount (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cat.count](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-count.html) request * @@ -33,7 +33,7 @@ function buildCatCount (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -91,7 +91,7 @@ function buildCatCount (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cat.fielddata.js b/api/api/cat.fielddata.js index 3c1476ba2..c05d217a2 100644 --- a/api/api/cat.fielddata.js +++ b/api/api/cat.fielddata.js @@ -2,7 +2,7 @@ function buildCatFielddata (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cat.fielddata](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-fielddata.html) request * @@ -35,7 +35,7 @@ function buildCatFielddata (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -97,7 +97,7 @@ function buildCatFielddata (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cat.health.js b/api/api/cat.health.js index 738895a6a..90993b0fc 100644 --- a/api/api/cat.health.js +++ b/api/api/cat.health.js @@ -2,7 +2,7 @@ function buildCatHealth (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cat.health](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-health.html) request * @@ -33,7 +33,7 @@ function buildCatHealth (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -93,7 +93,7 @@ function buildCatHealth (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cat.help.js b/api/api/cat.help.js index 3c25f7b00..00dbd5478 100644 --- a/api/api/cat.help.js +++ b/api/api/cat.help.js @@ -2,7 +2,7 @@ function buildCatHelp (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cat.help](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat.html) request * @@ -27,7 +27,7 @@ function buildCatHelp (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -75,7 +75,7 @@ function buildCatHelp (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cat.indices.js b/api/api/cat.indices.js index 0d3bcfea0..1a9652752 100644 --- a/api/api/cat.indices.js +++ b/api/api/cat.indices.js @@ -2,7 +2,7 @@ function buildCatIndices (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cat.indices](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-indices.html) request * @@ -36,7 +36,7 @@ function buildCatIndices (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -100,7 +100,7 @@ function buildCatIndices (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cat.master.js b/api/api/cat.master.js index 184bd06ca..9863e42e1 100644 --- a/api/api/cat.master.js +++ b/api/api/cat.master.js @@ -2,7 +2,7 @@ function buildCatMaster (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cat.master](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-master.html) request * @@ -32,7 +32,7 @@ function buildCatMaster (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -90,7 +90,7 @@ function buildCatMaster (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cat.nodeattrs.js b/api/api/cat.nodeattrs.js index bca45c397..1beafdd64 100644 --- a/api/api/cat.nodeattrs.js +++ b/api/api/cat.nodeattrs.js @@ -2,7 +2,7 @@ function buildCatNodeattrs (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cat.nodeattrs](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodeattrs.html) request * @@ -32,7 +32,7 @@ function buildCatNodeattrs (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -90,7 +90,7 @@ function buildCatNodeattrs (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cat.nodes.js b/api/api/cat.nodes.js index 4a45dd5f5..08a799cd8 100644 --- a/api/api/cat.nodes.js +++ b/api/api/cat.nodes.js @@ -2,7 +2,7 @@ function buildCatNodes (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cat.nodes](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodes.html) request * @@ -33,7 +33,7 @@ function buildCatNodes (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -93,7 +93,7 @@ function buildCatNodes (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cat.pending_tasks.js b/api/api/cat.pending_tasks.js index 8b9caa342..023065d70 100644 --- a/api/api/cat.pending_tasks.js +++ b/api/api/cat.pending_tasks.js @@ -2,7 +2,7 @@ function buildCatPendingTasks (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cat.pending_tasks](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-pending-tasks.html) request * @@ -32,7 +32,7 @@ function buildCatPendingTasks (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -90,7 +90,7 @@ function buildCatPendingTasks (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cat.plugins.js b/api/api/cat.plugins.js index 2b9d3a336..6b7eb577b 100644 --- a/api/api/cat.plugins.js +++ b/api/api/cat.plugins.js @@ -2,7 +2,7 @@ function buildCatPlugins (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cat.plugins](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-plugins.html) request * @@ -32,7 +32,7 @@ function buildCatPlugins (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -90,7 +90,7 @@ function buildCatPlugins (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cat.recovery.js b/api/api/cat.recovery.js index 11850a0d5..be17917c1 100644 --- a/api/api/cat.recovery.js +++ b/api/api/cat.recovery.js @@ -2,7 +2,7 @@ function buildCatRecovery (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cat.recovery](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-recovery.html) request * @@ -33,7 +33,7 @@ function buildCatRecovery (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -91,7 +91,7 @@ function buildCatRecovery (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cat.repositories.js b/api/api/cat.repositories.js index a736f6380..981ecc704 100644 --- a/api/api/cat.repositories.js +++ b/api/api/cat.repositories.js @@ -2,7 +2,7 @@ function buildCatRepositories (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cat.repositories](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-repositories.html) request * @@ -32,7 +32,7 @@ function buildCatRepositories (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -90,7 +90,7 @@ function buildCatRepositories (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cat.segments.js b/api/api/cat.segments.js index b7e6eecbb..b6fa888f7 100644 --- a/api/api/cat.segments.js +++ b/api/api/cat.segments.js @@ -2,7 +2,7 @@ function buildCatSegments (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cat.segments](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-segments.html) request * @@ -32,7 +32,7 @@ function buildCatSegments (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -88,7 +88,7 @@ function buildCatSegments (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cat.shards.js b/api/api/cat.shards.js index 3313d3d50..c87ede6da 100644 --- a/api/api/cat.shards.js +++ b/api/api/cat.shards.js @@ -2,7 +2,7 @@ function buildCatShards (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cat.shards](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-shards.html) request * @@ -34,7 +34,7 @@ function buildCatShards (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -94,7 +94,7 @@ function buildCatShards (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cat.snapshots.js b/api/api/cat.snapshots.js index 455a0488e..60a0e6797 100644 --- a/api/api/cat.snapshots.js +++ b/api/api/cat.snapshots.js @@ -2,7 +2,7 @@ function buildCatSnapshots (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cat.snapshots](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-snapshots.html) request * @@ -33,7 +33,7 @@ function buildCatSnapshots (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -91,7 +91,7 @@ function buildCatSnapshots (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cat.tasks.js b/api/api/cat.tasks.js index bed6b98b8..170fe567c 100644 --- a/api/api/cat.tasks.js +++ b/api/api/cat.tasks.js @@ -2,7 +2,7 @@ function buildCatTasks (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cat.tasks](http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html) request * @@ -34,7 +34,7 @@ function buildCatTasks (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -96,7 +96,7 @@ function buildCatTasks (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cat.templates.js b/api/api/cat.templates.js index c49f9901e..62e542b3c 100644 --- a/api/api/cat.templates.js +++ b/api/api/cat.templates.js @@ -2,7 +2,7 @@ function buildCatTemplates (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cat.templates](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-templates.html) request * @@ -33,7 +33,7 @@ function buildCatTemplates (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -91,7 +91,7 @@ function buildCatTemplates (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cat.thread_pool.js b/api/api/cat.thread_pool.js index a37473d5d..59d97ee50 100644 --- a/api/api/cat.thread_pool.js +++ b/api/api/cat.thread_pool.js @@ -2,7 +2,7 @@ function buildCatThreadPool (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cat.thread_pool](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-thread-pool.html) request * @@ -34,7 +34,7 @@ function buildCatThreadPool (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -94,7 +94,7 @@ function buildCatThreadPool (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/clear_scroll.js b/api/api/clear_scroll.js index 51668e8da..331e7bfe5 100644 --- a/api/api/clear_scroll.js +++ b/api/api/clear_scroll.js @@ -2,7 +2,7 @@ function buildClearScroll (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [clear_scroll](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-scroll.html) request * @@ -63,7 +63,7 @@ function buildClearScroll (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cluster.allocation_explain.js b/api/api/cluster.allocation_explain.js index 2a2e9a541..d8c934dbe 100644 --- a/api/api/cluster.allocation_explain.js +++ b/api/api/cluster.allocation_explain.js @@ -2,7 +2,7 @@ function buildClusterAllocationExplain (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cluster.allocation_explain](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-allocation-explain.html) request * @@ -68,7 +68,7 @@ function buildClusterAllocationExplain (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cluster.get_settings.js b/api/api/cluster.get_settings.js index b99e539c9..db046d645 100644 --- a/api/api/cluster.get_settings.js +++ b/api/api/cluster.get_settings.js @@ -2,7 +2,7 @@ function buildClusterGetSettings (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cluster.get_settings](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html) request * @@ -29,7 +29,7 @@ function buildClusterGetSettings (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -81,7 +81,7 @@ function buildClusterGetSettings (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cluster.health.js b/api/api/cluster.health.js index a318a1a53..5f3526f88 100644 --- a/api/api/cluster.health.js +++ b/api/api/cluster.health.js @@ -2,7 +2,7 @@ function buildClusterHealth (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cluster.health](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-health.html) request * @@ -36,7 +36,7 @@ function buildClusterHealth (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -100,7 +100,7 @@ function buildClusterHealth (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cluster.pending_tasks.js b/api/api/cluster.pending_tasks.js index e9ff7e10f..dfc9df2e6 100644 --- a/api/api/cluster.pending_tasks.js +++ b/api/api/cluster.pending_tasks.js @@ -2,7 +2,7 @@ function buildClusterPendingTasks (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cluster.pending_tasks](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-pending.html) request * @@ -27,7 +27,7 @@ function buildClusterPendingTasks (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -75,7 +75,7 @@ function buildClusterPendingTasks (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cluster.put_settings.js b/api/api/cluster.put_settings.js index d161d20d1..275dcd800 100644 --- a/api/api/cluster.put_settings.js +++ b/api/api/cluster.put_settings.js @@ -2,7 +2,7 @@ function buildClusterPutSettings (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cluster.put_settings](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html) request * @@ -29,7 +29,7 @@ function buildClusterPutSettings (opts) { if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -79,7 +79,7 @@ function buildClusterPutSettings (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cluster.remote_info.js b/api/api/cluster.remote_info.js index 6626f0530..8445b4e44 100644 --- a/api/api/cluster.remote_info.js +++ b/api/api/cluster.remote_info.js @@ -2,7 +2,7 @@ function buildClusterRemoteInfo (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cluster.remote_info](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-remote-info.html) request * @@ -25,7 +25,7 @@ function buildClusterRemoteInfo (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -69,7 +69,7 @@ function buildClusterRemoteInfo (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cluster.reroute.js b/api/api/cluster.reroute.js index 04e7d39a9..fc7fc927d 100644 --- a/api/api/cluster.reroute.js +++ b/api/api/cluster.reroute.js @@ -2,7 +2,7 @@ function buildClusterReroute (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cluster.reroute](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-reroute.html) request * @@ -80,7 +80,7 @@ function buildClusterReroute (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cluster.state.js b/api/api/cluster.state.js index 1a47ce670..98df3eb07 100644 --- a/api/api/cluster.state.js +++ b/api/api/cluster.state.js @@ -2,7 +2,7 @@ function buildClusterState (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cluster.state](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-state.html) request * @@ -33,7 +33,7 @@ function buildClusterState (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -41,7 +41,7 @@ function buildClusterState (opts) { if (params['index'] != null && (params['metric'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: metric'), - { body: null, headers: null, statusCode: null } + result ) } @@ -97,7 +97,7 @@ function buildClusterState (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/cluster.stats.js b/api/api/cluster.stats.js index d674a491d..f48a3420e 100644 --- a/api/api/cluster.stats.js +++ b/api/api/cluster.stats.js @@ -2,7 +2,7 @@ function buildClusterStats (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [cluster.stats](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-stats.html) request * @@ -28,7 +28,7 @@ function buildClusterStats (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -76,7 +76,7 @@ function buildClusterStats (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/count.js b/api/api/count.js index d955bdd0b..bafcd080d 100644 --- a/api/api/count.js +++ b/api/api/count.js @@ -2,7 +2,7 @@ function buildCount (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [count](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-count.html) request * @@ -41,7 +41,7 @@ function buildCount (opts) { if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -111,7 +111,7 @@ function buildCount (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/create.js b/api/api/create.js index 034243834..d44c77bf8 100644 --- a/api/api/create.js +++ b/api/api/create.js @@ -2,7 +2,7 @@ function buildCreate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [create](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html) request * @@ -37,25 +37,25 @@ function buildCreate (opts) { if (params['id'] == null) { return callback( new ConfigurationError('Missing required parameter: id'), - { body: null, headers: null, statusCode: null } + result ) } if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } if (params['type'] == null) { return callback( new ConfigurationError('Missing required parameter: type'), - { body: null, headers: null, statusCode: null } + result ) } if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -63,12 +63,12 @@ function buildCreate (opts) { if (params['id'] != null && (params['type'] == null || params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: type, index'), - { body: null, headers: null, statusCode: null } + result ) } else if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -128,7 +128,7 @@ function buildCreate (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/delete.js b/api/api/delete.js index 884a213f6..2a25363df 100644 --- a/api/api/delete.js +++ b/api/api/delete.js @@ -2,7 +2,7 @@ function buildDelete (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [delete](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete.html) request * @@ -35,25 +35,25 @@ function buildDelete (opts) { if (params['id'] == null) { return callback( new ConfigurationError('Missing required parameter: id'), - { body: null, headers: null, statusCode: null } + result ) } if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } if (params['type'] == null) { return callback( new ConfigurationError('Missing required parameter: type'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -61,12 +61,12 @@ function buildDelete (opts) { if (params['id'] != null && (params['type'] == null || params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: type, index'), - { body: null, headers: null, statusCode: null } + result ) } else if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -124,7 +124,7 @@ function buildDelete (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/delete_by_query.js b/api/api/delete_by_query.js index 65796dcfe..7207af5b7 100644 --- a/api/api/delete_by_query.js +++ b/api/api/delete_by_query.js @@ -2,7 +2,7 @@ function buildDeleteByQuery (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [delete_by_query](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html) request * @@ -60,13 +60,13 @@ function buildDeleteByQuery (opts) { if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -74,7 +74,7 @@ function buildDeleteByQuery (opts) { if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -182,7 +182,7 @@ function buildDeleteByQuery (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/delete_script.js b/api/api/delete_script.js index f1945790c..338432402 100644 --- a/api/api/delete_script.js +++ b/api/api/delete_script.js @@ -2,7 +2,7 @@ function buildDeleteScript (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [delete_script](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html) request * @@ -28,13 +28,13 @@ function buildDeleteScript (opts) { if (params['id'] == null) { return callback( new ConfigurationError('Missing required parameter: id'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -82,7 +82,7 @@ function buildDeleteScript (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/exists.js b/api/api/exists.js index f2e229dc2..7be0f4898 100644 --- a/api/api/exists.js +++ b/api/api/exists.js @@ -2,7 +2,7 @@ function buildExists (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [exists](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request * @@ -39,25 +39,25 @@ function buildExists (opts) { if (params['id'] == null) { return callback( new ConfigurationError('Missing required parameter: id'), - { body: null, headers: null, statusCode: null } + result ) } if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } if (params['type'] == null) { return callback( new ConfigurationError('Missing required parameter: type'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -65,12 +65,12 @@ function buildExists (opts) { if (params['id'] != null && (params['type'] == null || params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: type, index'), - { body: null, headers: null, statusCode: null } + result ) } else if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -136,7 +136,7 @@ function buildExists (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/exists_source.js b/api/api/exists_source.js index 1d17db7be..4fc17e5e6 100644 --- a/api/api/exists_source.js +++ b/api/api/exists_source.js @@ -2,7 +2,7 @@ function buildExistsSource (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [exists_source](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request * @@ -38,25 +38,25 @@ function buildExistsSource (opts) { if (params['id'] == null) { return callback( new ConfigurationError('Missing required parameter: id'), - { body: null, headers: null, statusCode: null } + result ) } if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } if (params['type'] == null) { return callback( new ConfigurationError('Missing required parameter: type'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -64,12 +64,12 @@ function buildExistsSource (opts) { if (params['id'] != null && (params['type'] == null || params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: type, index'), - { body: null, headers: null, statusCode: null } + result ) } else if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -133,7 +133,7 @@ function buildExistsSource (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/explain.js b/api/api/explain.js index 1f342b291..d270bf0e4 100644 --- a/api/api/explain.js +++ b/api/api/explain.js @@ -2,7 +2,7 @@ function buildExplain (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [explain](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-explain.html) request * @@ -42,19 +42,19 @@ function buildExplain (opts) { if (params['id'] == null) { return callback( new ConfigurationError('Missing required parameter: id'), - { body: null, headers: null, statusCode: null } + result ) } if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } if (params['type'] == null) { return callback( new ConfigurationError('Missing required parameter: type'), - { body: null, headers: null, statusCode: null } + result ) } @@ -62,12 +62,12 @@ function buildExplain (opts) { if (params['id'] != null && (params['type'] == null || params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: type, index'), - { body: null, headers: null, statusCode: null } + result ) } else if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -137,7 +137,7 @@ function buildExplain (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/field_caps.js b/api/api/field_caps.js index d415fb509..f398dc57b 100644 --- a/api/api/field_caps.js +++ b/api/api/field_caps.js @@ -2,7 +2,7 @@ function buildFieldCaps (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [field_caps](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html) request * @@ -75,7 +75,7 @@ function buildFieldCaps (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/get.js b/api/api/get.js index d234e65df..9c2d737bf 100644 --- a/api/api/get.js +++ b/api/api/get.js @@ -2,7 +2,7 @@ function buildGet (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [get](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request * @@ -39,25 +39,25 @@ function buildGet (opts) { if (params['id'] == null) { return callback( new ConfigurationError('Missing required parameter: id'), - { body: null, headers: null, statusCode: null } + result ) } if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } if (params['type'] == null) { return callback( new ConfigurationError('Missing required parameter: type'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -65,12 +65,12 @@ function buildGet (opts) { if (params['id'] != null && (params['type'] == null || params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: type, index'), - { body: null, headers: null, statusCode: null } + result ) } else if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -136,7 +136,7 @@ function buildGet (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/get_script.js b/api/api/get_script.js index bebd680bc..39bd7e54a 100644 --- a/api/api/get_script.js +++ b/api/api/get_script.js @@ -2,7 +2,7 @@ function buildGetScript (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [get_script](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html) request * @@ -27,13 +27,13 @@ function buildGetScript (opts) { if (params['id'] == null) { return callback( new ConfigurationError('Missing required parameter: id'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -79,7 +79,7 @@ function buildGetScript (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/get_source.js b/api/api/get_source.js index 6a4fc5d55..bac64bb3b 100644 --- a/api/api/get_source.js +++ b/api/api/get_source.js @@ -2,7 +2,7 @@ function buildGetSource (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [get_source](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request * @@ -38,25 +38,25 @@ function buildGetSource (opts) { if (params['id'] == null) { return callback( new ConfigurationError('Missing required parameter: id'), - { body: null, headers: null, statusCode: null } + result ) } if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } if (params['type'] == null) { return callback( new ConfigurationError('Missing required parameter: type'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -64,12 +64,12 @@ function buildGetSource (opts) { if (params['id'] != null && (params['type'] == null || params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: type, index'), - { body: null, headers: null, statusCode: null } + result ) } else if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -133,7 +133,7 @@ function buildGetSource (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/index.js b/api/api/index.js index f9a4835f8..7d259cfa0 100644 --- a/api/api/index.js +++ b/api/api/index.js @@ -2,7 +2,7 @@ function buildIndex (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [index](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html) request * @@ -38,19 +38,19 @@ function buildIndex (opts) { if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } if (params['type'] == null) { return callback( new ConfigurationError('Missing required parameter: type'), - { body: null, headers: null, statusCode: null } + result ) } if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -58,12 +58,12 @@ function buildIndex (opts) { if (params['id'] != null && (params['type'] == null || params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: type, index'), - { body: null, headers: null, statusCode: null } + result ) } else if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -125,7 +125,7 @@ function buildIndex (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.analyze.js b/api/api/indices.analyze.js index d8068bbfa..cdd0866b0 100644 --- a/api/api/indices.analyze.js +++ b/api/api/indices.analyze.js @@ -2,7 +2,7 @@ function buildIndicesAnalyze (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.analyze](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-analyze.html) request * @@ -66,7 +66,7 @@ function buildIndicesAnalyze (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.clear_cache.js b/api/api/indices.clear_cache.js index cc38b7ecd..705aedb30 100644 --- a/api/api/indices.clear_cache.js +++ b/api/api/indices.clear_cache.js @@ -2,7 +2,7 @@ function buildIndicesClearCache (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.clear_cache](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clearcache.html) request * @@ -36,7 +36,7 @@ function buildIndicesClearCache (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -100,7 +100,7 @@ function buildIndicesClearCache (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.close.js b/api/api/indices.close.js index a33e70dec..3f6be4ad4 100644 --- a/api/api/indices.close.js +++ b/api/api/indices.close.js @@ -2,7 +2,7 @@ function buildIndicesClose (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.close](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html) request * @@ -31,13 +31,13 @@ function buildIndicesClose (opts) { if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -91,7 +91,7 @@ function buildIndicesClose (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.create.js b/api/api/indices.create.js index c6868d0ea..2433d1fbc 100644 --- a/api/api/indices.create.js +++ b/api/api/indices.create.js @@ -2,7 +2,7 @@ function buildIndicesCreate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.create](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-index.html) request * @@ -31,7 +31,7 @@ function buildIndicesCreate (opts) { if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -83,7 +83,7 @@ function buildIndicesCreate (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.delete.js b/api/api/indices.delete.js index ffa02d65d..fe51f0448 100644 --- a/api/api/indices.delete.js +++ b/api/api/indices.delete.js @@ -2,7 +2,7 @@ function buildIndicesDelete (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.delete](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-index.html) request * @@ -31,13 +31,13 @@ function buildIndicesDelete (opts) { if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -91,7 +91,7 @@ function buildIndicesDelete (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.delete_alias.js b/api/api/indices.delete_alias.js index b876b8eec..0b4679fb4 100644 --- a/api/api/indices.delete_alias.js +++ b/api/api/indices.delete_alias.js @@ -2,7 +2,7 @@ function buildIndicesDeleteAlias (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.delete_alias](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html) request * @@ -29,19 +29,19 @@ function buildIndicesDeleteAlias (opts) { if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } if (params['name'] == null) { return callback( new ConfigurationError('Missing required parameter: name'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -49,7 +49,7 @@ function buildIndicesDeleteAlias (opts) { if (params['name'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -97,7 +97,7 @@ function buildIndicesDeleteAlias (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.delete_template.js b/api/api/indices.delete_template.js index 3259a896f..f25ec411d 100644 --- a/api/api/indices.delete_template.js +++ b/api/api/indices.delete_template.js @@ -2,7 +2,7 @@ function buildIndicesDeleteTemplate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.delete_template](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html) request * @@ -28,13 +28,13 @@ function buildIndicesDeleteTemplate (opts) { if (params['name'] == null) { return callback( new ConfigurationError('Missing required parameter: name'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -82,7 +82,7 @@ function buildIndicesDeleteTemplate (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.exists.js b/api/api/indices.exists.js index 436c1656e..b6fdf9f89 100644 --- a/api/api/indices.exists.js +++ b/api/api/indices.exists.js @@ -2,7 +2,7 @@ function buildIndicesExists (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.exists](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-exists.html) request * @@ -32,13 +32,13 @@ function buildIndicesExists (opts) { if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -94,7 +94,7 @@ function buildIndicesExists (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.exists_alias.js b/api/api/indices.exists_alias.js index a076c8fcb..8e90ba851 100644 --- a/api/api/indices.exists_alias.js +++ b/api/api/indices.exists_alias.js @@ -2,7 +2,7 @@ function buildIndicesExistsAlias (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.exists_alias](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html) request * @@ -31,13 +31,13 @@ function buildIndicesExistsAlias (opts) { if (params['name'] == null) { return callback( new ConfigurationError('Missing required parameter: name'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -89,7 +89,7 @@ function buildIndicesExistsAlias (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.exists_template.js b/api/api/indices.exists_template.js index b2c459c43..943b545b8 100644 --- a/api/api/indices.exists_template.js +++ b/api/api/indices.exists_template.js @@ -2,7 +2,7 @@ function buildIndicesExistsTemplate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.exists_template](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html) request * @@ -29,13 +29,13 @@ function buildIndicesExistsTemplate (opts) { if (params['name'] == null) { return callback( new ConfigurationError('Missing required parameter: name'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -85,7 +85,7 @@ function buildIndicesExistsTemplate (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.exists_type.js b/api/api/indices.exists_type.js index 7e104eefb..2e40c05ac 100644 --- a/api/api/indices.exists_type.js +++ b/api/api/indices.exists_type.js @@ -2,7 +2,7 @@ function buildIndicesExistsType (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.exists_type](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-types-exists.html) request * @@ -31,19 +31,19 @@ function buildIndicesExistsType (opts) { if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } if (params['type'] == null) { return callback( new ConfigurationError('Missing required parameter: type'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -51,7 +51,7 @@ function buildIndicesExistsType (opts) { if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -103,7 +103,7 @@ function buildIndicesExistsType (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.flush.js b/api/api/indices.flush.js index 54834a222..47a8d2201 100644 --- a/api/api/indices.flush.js +++ b/api/api/indices.flush.js @@ -2,7 +2,7 @@ function buildIndicesFlush (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.flush](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-flush.html) request * @@ -31,7 +31,7 @@ function buildIndicesFlush (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -85,7 +85,7 @@ function buildIndicesFlush (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.flush_synced.js b/api/api/indices.flush_synced.js index 1c76858f7..7d1f95a09 100644 --- a/api/api/indices.flush_synced.js +++ b/api/api/indices.flush_synced.js @@ -2,7 +2,7 @@ function buildIndicesFlushSynced (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.flush_synced](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-synced-flush.html) request * @@ -29,7 +29,7 @@ function buildIndicesFlushSynced (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -79,7 +79,7 @@ function buildIndicesFlushSynced (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.forcemerge.js b/api/api/indices.forcemerge.js index 5cf5a3e06..89f0b9310 100644 --- a/api/api/indices.forcemerge.js +++ b/api/api/indices.forcemerge.js @@ -2,7 +2,7 @@ function buildIndicesForcemerge (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.forcemerge](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-forcemerge.html) request * @@ -32,7 +32,7 @@ function buildIndicesForcemerge (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -88,7 +88,7 @@ function buildIndicesForcemerge (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.get.js b/api/api/indices.get.js index d6bcafa73..3215012be 100644 --- a/api/api/indices.get.js +++ b/api/api/indices.get.js @@ -2,7 +2,7 @@ function buildIndicesGet (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.get](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-index.html) request * @@ -33,13 +33,13 @@ function buildIndicesGet (opts) { if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -97,7 +97,7 @@ function buildIndicesGet (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.get_alias.js b/api/api/indices.get_alias.js index 7925d5238..45f8ff747 100644 --- a/api/api/indices.get_alias.js +++ b/api/api/indices.get_alias.js @@ -2,7 +2,7 @@ function buildIndicesGetAlias (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.get_alias](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html) request * @@ -31,7 +31,7 @@ function buildIndicesGetAlias (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -83,7 +83,7 @@ function buildIndicesGetAlias (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.get_field_mapping.js b/api/api/indices.get_field_mapping.js index 3af4964ab..13fd55563 100644 --- a/api/api/indices.get_field_mapping.js +++ b/api/api/indices.get_field_mapping.js @@ -2,7 +2,7 @@ function buildIndicesGetFieldMapping (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.get_field_mapping](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-field-mapping.html) request * @@ -33,13 +33,13 @@ function buildIndicesGetFieldMapping (opts) { if (params['fields'] == null) { return callback( new ConfigurationError('Missing required parameter: fields'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -93,7 +93,7 @@ function buildIndicesGetFieldMapping (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.get_mapping.js b/api/api/indices.get_mapping.js index de130c8ab..c077f9a43 100644 --- a/api/api/indices.get_mapping.js +++ b/api/api/indices.get_mapping.js @@ -2,7 +2,7 @@ function buildIndicesGetMapping (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.get_mapping](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-mapping.html) request * @@ -32,7 +32,7 @@ function buildIndicesGetMapping (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -86,7 +86,7 @@ function buildIndicesGetMapping (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.get_settings.js b/api/api/indices.get_settings.js index c53e859fd..e29b58a28 100644 --- a/api/api/indices.get_settings.js +++ b/api/api/indices.get_settings.js @@ -2,7 +2,7 @@ function buildIndicesGetSettings (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.get_settings](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-settings.html) request * @@ -34,7 +34,7 @@ function buildIndicesGetSettings (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -92,7 +92,7 @@ function buildIndicesGetSettings (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.get_template.js b/api/api/indices.get_template.js index 55beaa599..6824d30d8 100644 --- a/api/api/indices.get_template.js +++ b/api/api/indices.get_template.js @@ -2,7 +2,7 @@ function buildIndicesGetTemplate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.get_template](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html) request * @@ -29,7 +29,7 @@ function buildIndicesGetTemplate (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -79,7 +79,7 @@ function buildIndicesGetTemplate (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.get_upgrade.js b/api/api/indices.get_upgrade.js index 8bffcf0e5..7c144538c 100644 --- a/api/api/indices.get_upgrade.js +++ b/api/api/indices.get_upgrade.js @@ -2,7 +2,7 @@ function buildIndicesGetUpgrade (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.get_upgrade](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-upgrade.html) request * @@ -29,7 +29,7 @@ function buildIndicesGetUpgrade (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -79,7 +79,7 @@ function buildIndicesGetUpgrade (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.open.js b/api/api/indices.open.js index 2cb459eee..0a2361e15 100644 --- a/api/api/indices.open.js +++ b/api/api/indices.open.js @@ -2,7 +2,7 @@ function buildIndicesOpen (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.open](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html) request * @@ -32,13 +32,13 @@ function buildIndicesOpen (opts) { if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -94,7 +94,7 @@ function buildIndicesOpen (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.put_alias.js b/api/api/indices.put_alias.js index d0efccf94..fc9f30e41 100644 --- a/api/api/indices.put_alias.js +++ b/api/api/indices.put_alias.js @@ -2,7 +2,7 @@ function buildIndicesPutAlias (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.put_alias](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html) request * @@ -30,13 +30,13 @@ function buildIndicesPutAlias (opts) { if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } if (params['name'] == null) { return callback( new ConfigurationError('Missing required parameter: name'), - { body: null, headers: null, statusCode: null } + result ) } @@ -44,7 +44,7 @@ function buildIndicesPutAlias (opts) { if (params['name'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -92,7 +92,7 @@ function buildIndicesPutAlias (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.put_mapping.js b/api/api/indices.put_mapping.js index bf403dc7a..fd0cb2420 100644 --- a/api/api/indices.put_mapping.js +++ b/api/api/indices.put_mapping.js @@ -2,7 +2,7 @@ function buildIndicesPutMapping (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.put_mapping](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-put-mapping.html) request * @@ -34,13 +34,13 @@ function buildIndicesPutMapping (opts) { if (params['type'] == null) { return callback( new ConfigurationError('Missing required parameter: type'), - { body: null, headers: null, statusCode: null } + result ) } if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -96,7 +96,7 @@ function buildIndicesPutMapping (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.put_settings.js b/api/api/indices.put_settings.js index c9eb3b0e4..a8d24ce60 100644 --- a/api/api/indices.put_settings.js +++ b/api/api/indices.put_settings.js @@ -2,7 +2,7 @@ function buildIndicesPutSettings (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.put_settings](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-update-settings.html) request * @@ -34,7 +34,7 @@ function buildIndicesPutSettings (opts) { if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -92,7 +92,7 @@ function buildIndicesPutSettings (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.put_template.js b/api/api/indices.put_template.js index c67845977..02d12841a 100644 --- a/api/api/indices.put_template.js +++ b/api/api/indices.put_template.js @@ -2,7 +2,7 @@ function buildIndicesPutTemplate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.put_template](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html) request * @@ -32,13 +32,13 @@ function buildIndicesPutTemplate (opts) { if (params['name'] == null) { return callback( new ConfigurationError('Missing required parameter: name'), - { body: null, headers: null, statusCode: null } + result ) } if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -92,7 +92,7 @@ function buildIndicesPutTemplate (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.recovery.js b/api/api/indices.recovery.js index 4b28d9914..82215416c 100644 --- a/api/api/indices.recovery.js +++ b/api/api/indices.recovery.js @@ -2,7 +2,7 @@ function buildIndicesRecovery (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.recovery](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-recovery.html) request * @@ -28,7 +28,7 @@ function buildIndicesRecovery (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -76,7 +76,7 @@ function buildIndicesRecovery (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.refresh.js b/api/api/indices.refresh.js index aeb999575..c9bee4420 100644 --- a/api/api/indices.refresh.js +++ b/api/api/indices.refresh.js @@ -2,7 +2,7 @@ function buildIndicesRefresh (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.refresh](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-refresh.html) request * @@ -29,7 +29,7 @@ function buildIndicesRefresh (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -79,7 +79,7 @@ function buildIndicesRefresh (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.rollover.js b/api/api/indices.rollover.js index 47a9af22f..71cc44f2c 100644 --- a/api/api/indices.rollover.js +++ b/api/api/indices.rollover.js @@ -2,7 +2,7 @@ function buildIndicesRollover (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.rollover](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html) request * @@ -32,7 +32,7 @@ function buildIndicesRollover (opts) { if (params['alias'] == null) { return callback( new ConfigurationError('Missing required parameter: alias'), - { body: null, headers: null, statusCode: null } + result ) } @@ -40,7 +40,7 @@ function buildIndicesRollover (opts) { if ((params['new_index'] != null || params['newIndex'] != null) && (params['alias'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: alias'), - { body: null, headers: null, statusCode: null } + result ) } @@ -92,7 +92,7 @@ function buildIndicesRollover (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.segments.js b/api/api/indices.segments.js index 7d719c375..1942d3253 100644 --- a/api/api/indices.segments.js +++ b/api/api/indices.segments.js @@ -2,7 +2,7 @@ function buildIndicesSegments (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.segments](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-segments.html) request * @@ -30,7 +30,7 @@ function buildIndicesSegments (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -82,7 +82,7 @@ function buildIndicesSegments (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.shard_stores.js b/api/api/indices.shard_stores.js index 4cc39dea4..b3452cff7 100644 --- a/api/api/indices.shard_stores.js +++ b/api/api/indices.shard_stores.js @@ -2,7 +2,7 @@ function buildIndicesShardStores (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.shard_stores](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shards-stores.html) request * @@ -30,7 +30,7 @@ function buildIndicesShardStores (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -82,7 +82,7 @@ function buildIndicesShardStores (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.shrink.js b/api/api/indices.shrink.js index 9981a1eec..8f7afbebd 100644 --- a/api/api/indices.shrink.js +++ b/api/api/indices.shrink.js @@ -2,7 +2,7 @@ function buildIndicesShrink (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.shrink](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shrink-index.html) request * @@ -32,13 +32,13 @@ function buildIndicesShrink (opts) { if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } if (params['target'] == null) { return callback( new ConfigurationError('Missing required parameter: target'), - { body: null, headers: null, statusCode: null } + result ) } @@ -46,7 +46,7 @@ function buildIndicesShrink (opts) { if (params['target'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -98,7 +98,7 @@ function buildIndicesShrink (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.split.js b/api/api/indices.split.js index a40db9b25..b6362db21 100644 --- a/api/api/indices.split.js +++ b/api/api/indices.split.js @@ -2,7 +2,7 @@ function buildIndicesSplit (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.split](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-split-index.html) request * @@ -32,13 +32,13 @@ function buildIndicesSplit (opts) { if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } if (params['target'] == null) { return callback( new ConfigurationError('Missing required parameter: target'), - { body: null, headers: null, statusCode: null } + result ) } @@ -46,7 +46,7 @@ function buildIndicesSplit (opts) { if (params['target'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -98,7 +98,7 @@ function buildIndicesSplit (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.stats.js b/api/api/indices.stats.js index 00f43b6ad..5ef5f2590 100644 --- a/api/api/indices.stats.js +++ b/api/api/indices.stats.js @@ -2,7 +2,7 @@ function buildIndicesStats (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.stats](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-stats.html) request * @@ -34,7 +34,7 @@ function buildIndicesStats (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -92,7 +92,7 @@ function buildIndicesStats (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.update_aliases.js b/api/api/indices.update_aliases.js index 7ec44ccdb..23c8a3f1c 100644 --- a/api/api/indices.update_aliases.js +++ b/api/api/indices.update_aliases.js @@ -2,7 +2,7 @@ function buildIndicesUpdateAliases (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.update_aliases](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html) request * @@ -28,7 +28,7 @@ function buildIndicesUpdateAliases (opts) { if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -76,7 +76,7 @@ function buildIndicesUpdateAliases (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.upgrade.js b/api/api/indices.upgrade.js index 1259ee440..5dbd9d62a 100644 --- a/api/api/indices.upgrade.js +++ b/api/api/indices.upgrade.js @@ -2,7 +2,7 @@ function buildIndicesUpgrade (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.upgrade](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-upgrade.html) request * @@ -31,7 +31,7 @@ function buildIndicesUpgrade (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -85,7 +85,7 @@ function buildIndicesUpgrade (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/indices.validate_query.js b/api/api/indices.validate_query.js index ca27a5990..eac6cc301 100644 --- a/api/api/indices.validate_query.js +++ b/api/api/indices.validate_query.js @@ -2,7 +2,7 @@ function buildIndicesValidateQuery (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [indices.validate_query](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-validate.html) request * @@ -40,7 +40,7 @@ function buildIndicesValidateQuery (opts) { if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -108,7 +108,7 @@ function buildIndicesValidateQuery (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/info.js b/api/api/info.js index 59cb80341..adf968cd9 100644 --- a/api/api/info.js +++ b/api/api/info.js @@ -2,7 +2,7 @@ function buildInfo (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [info](http://www.elastic.co/guide/) request * @@ -25,7 +25,7 @@ function buildInfo (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -69,7 +69,7 @@ function buildInfo (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/ingest.delete_pipeline.js b/api/api/ingest.delete_pipeline.js index ace43057e..5c09102c7 100644 --- a/api/api/ingest.delete_pipeline.js +++ b/api/api/ingest.delete_pipeline.js @@ -2,7 +2,7 @@ function buildIngestDeletePipeline (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [ingest.delete_pipeline](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request * @@ -28,13 +28,13 @@ function buildIngestDeletePipeline (opts) { if (params['id'] == null) { return callback( new ConfigurationError('Missing required parameter: id'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -82,7 +82,7 @@ function buildIngestDeletePipeline (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/ingest.get_pipeline.js b/api/api/ingest.get_pipeline.js index 176a24abe..c4ed71d6b 100644 --- a/api/api/ingest.get_pipeline.js +++ b/api/api/ingest.get_pipeline.js @@ -2,7 +2,7 @@ function buildIngestGetPipeline (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [ingest.get_pipeline](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request * @@ -27,7 +27,7 @@ function buildIngestGetPipeline (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -73,7 +73,7 @@ function buildIngestGetPipeline (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/ingest.processor_grok.js b/api/api/ingest.processor_grok.js index a8b93a6cd..c94f51b76 100644 --- a/api/api/ingest.processor_grok.js +++ b/api/api/ingest.processor_grok.js @@ -2,7 +2,7 @@ function buildIngestProcessorGrok (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [ingest.processor_grok](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request * @@ -25,7 +25,7 @@ function buildIngestProcessorGrok (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -69,7 +69,7 @@ function buildIngestProcessorGrok (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/ingest.put_pipeline.js b/api/api/ingest.put_pipeline.js index 02e6841c3..e87f3b732 100644 --- a/api/api/ingest.put_pipeline.js +++ b/api/api/ingest.put_pipeline.js @@ -2,7 +2,7 @@ function buildIngestPutPipeline (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [ingest.put_pipeline](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request * @@ -29,13 +29,13 @@ function buildIngestPutPipeline (opts) { if (params['id'] == null) { return callback( new ConfigurationError('Missing required parameter: id'), - { body: null, headers: null, statusCode: null } + result ) } if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -83,7 +83,7 @@ function buildIngestPutPipeline (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/ingest.simulate.js b/api/api/ingest.simulate.js index 14ff6c3c9..df95e7b8b 100644 --- a/api/api/ingest.simulate.js +++ b/api/api/ingest.simulate.js @@ -2,7 +2,7 @@ function buildIngestSimulate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [ingest.simulate](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request * @@ -28,7 +28,7 @@ function buildIngestSimulate (opts) { if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -74,7 +74,7 @@ function buildIngestSimulate (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/mget.js b/api/api/mget.js index 54890e994..cc6dbe375 100644 --- a/api/api/mget.js +++ b/api/api/mget.js @@ -2,7 +2,7 @@ function buildMget (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [mget](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-get.html) request * @@ -36,7 +36,7 @@ function buildMget (opts) { if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -44,7 +44,7 @@ function buildMget (opts) { if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -104,7 +104,7 @@ function buildMget (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/msearch.js b/api/api/msearch.js index 1319b246a..b8312360a 100644 --- a/api/api/msearch.js +++ b/api/api/msearch.js @@ -2,7 +2,7 @@ function buildMsearch (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [msearch](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-multi-search.html) request * @@ -32,7 +32,7 @@ function buildMsearch (opts) { if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -40,7 +40,7 @@ function buildMsearch (opts) { if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -92,7 +92,7 @@ function buildMsearch (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/msearch_template.js b/api/api/msearch_template.js index 62f0a6754..4e6e18ef9 100644 --- a/api/api/msearch_template.js +++ b/api/api/msearch_template.js @@ -2,7 +2,7 @@ function buildMsearchTemplate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [msearch_template](http://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html) request * @@ -31,7 +31,7 @@ function buildMsearchTemplate (opts) { if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -39,7 +39,7 @@ function buildMsearchTemplate (opts) { if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -89,7 +89,7 @@ function buildMsearchTemplate (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/mtermvectors.js b/api/api/mtermvectors.js index 1cceaa317..5a9d0d902 100644 --- a/api/api/mtermvectors.js +++ b/api/api/mtermvectors.js @@ -2,7 +2,7 @@ function buildMtermvectors (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [mtermvectors](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-termvectors.html) request * @@ -41,7 +41,7 @@ function buildMtermvectors (opts) { if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -111,7 +111,7 @@ function buildMtermvectors (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/nodes.hot_threads.js b/api/api/nodes.hot_threads.js index 23ac7e02d..e2c9ea3fe 100644 --- a/api/api/nodes.hot_threads.js +++ b/api/api/nodes.hot_threads.js @@ -2,7 +2,7 @@ function buildNodesHotThreads (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [nodes.hot_threads](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-hot-threads.html) request * @@ -32,7 +32,7 @@ function buildNodesHotThreads (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -88,7 +88,7 @@ function buildNodesHotThreads (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/nodes.info.js b/api/api/nodes.info.js index c48200a32..414d93a99 100644 --- a/api/api/nodes.info.js +++ b/api/api/nodes.info.js @@ -2,7 +2,7 @@ function buildNodesInfo (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [nodes.info](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-info.html) request * @@ -29,7 +29,7 @@ function buildNodesInfo (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -77,7 +77,7 @@ function buildNodesInfo (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/nodes.stats.js b/api/api/nodes.stats.js index 176556a83..3819d2e62 100644 --- a/api/api/nodes.stats.js +++ b/api/api/nodes.stats.js @@ -2,7 +2,7 @@ function buildNodesStats (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [nodes.stats](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-stats.html) request * @@ -36,7 +36,7 @@ function buildNodesStats (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -96,7 +96,7 @@ function buildNodesStats (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/nodes.usage.js b/api/api/nodes.usage.js index 11a4055ee..17853295f 100644 --- a/api/api/nodes.usage.js +++ b/api/api/nodes.usage.js @@ -2,7 +2,7 @@ function buildNodesUsage (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [nodes.usage](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html) request * @@ -28,7 +28,7 @@ function buildNodesUsage (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -74,7 +74,7 @@ function buildNodesUsage (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/ping.js b/api/api/ping.js index 8dc4f43ad..8351bf512 100644 --- a/api/api/ping.js +++ b/api/api/ping.js @@ -2,7 +2,7 @@ function buildPing (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [ping](http://www.elastic.co/guide/) request * @@ -25,7 +25,7 @@ function buildPing (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -69,7 +69,7 @@ function buildPing (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/put_script.js b/api/api/put_script.js index ce07d3210..87c4c4464 100644 --- a/api/api/put_script.js +++ b/api/api/put_script.js @@ -2,7 +2,7 @@ function buildPutScript (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [put_script](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html) request * @@ -31,13 +31,13 @@ function buildPutScript (opts) { if (params['id'] == null) { return callback( new ConfigurationError('Missing required parameter: id'), - { body: null, headers: null, statusCode: null } + result ) } if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -45,7 +45,7 @@ function buildPutScript (opts) { if (params['context'] != null && (params['id'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: id'), - { body: null, headers: null, statusCode: null } + result ) } @@ -95,7 +95,7 @@ function buildPutScript (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/rank_eval.js b/api/api/rank_eval.js index 8b22dad2b..e54102e62 100644 --- a/api/api/rank_eval.js +++ b/api/api/rank_eval.js @@ -2,7 +2,7 @@ function buildRankEval (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [rank_eval](https://www.elastic.co/guide/en/elasticsearch/reference/master/search-rank-eval.html) request * @@ -30,7 +30,7 @@ function buildRankEval (opts) { if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -80,7 +80,7 @@ function buildRankEval (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/reindex.js b/api/api/reindex.js index 6764bb563..453d7eed2 100644 --- a/api/api/reindex.js +++ b/api/api/reindex.js @@ -2,7 +2,7 @@ function buildReindex (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [reindex](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html) request * @@ -32,7 +32,7 @@ function buildReindex (opts) { if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -88,7 +88,7 @@ function buildReindex (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/reindex_rethrottle.js b/api/api/reindex_rethrottle.js index 396dff3d1..54d8de9e4 100644 --- a/api/api/reindex_rethrottle.js +++ b/api/api/reindex_rethrottle.js @@ -2,7 +2,7 @@ function buildReindexRethrottle (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [reindex_rethrottle](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html) request * @@ -27,19 +27,19 @@ function buildReindexRethrottle (opts) { if (params['task_id'] == null && params['taskId'] == null) { return callback( new ConfigurationError('Missing required parameter: task_id or taskId'), - { body: null, headers: null, statusCode: null } + result ) } if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) { return callback( new ConfigurationError('Missing required parameter: requests_per_second or requestsPerSecond'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -85,7 +85,7 @@ function buildReindexRethrottle (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/render_search_template.js b/api/api/render_search_template.js index 94b6a3c5a..35faf765a 100644 --- a/api/api/render_search_template.js +++ b/api/api/render_search_template.js @@ -2,7 +2,7 @@ function buildRenderSearchTemplate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [render_search_template](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-template.html) request * @@ -63,7 +63,7 @@ function buildRenderSearchTemplate (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/scripts_painless_execute.js b/api/api/scripts_painless_execute.js index 7a08082c2..b3f871e75 100644 --- a/api/api/scripts_painless_execute.js +++ b/api/api/scripts_painless_execute.js @@ -2,7 +2,7 @@ function buildScriptsPainlessExecute (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [scripts_painless_execute](https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html) request * @@ -62,7 +62,7 @@ function buildScriptsPainlessExecute (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/scroll.js b/api/api/scroll.js index f5f5bf575..32e4c7010 100644 --- a/api/api/scroll.js +++ b/api/api/scroll.js @@ -2,7 +2,7 @@ function buildScroll (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [scroll](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-scroll.html) request * @@ -69,7 +69,7 @@ function buildScroll (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/search.js b/api/api/search.js index 1a29f8427..8f75d2ad5 100644 --- a/api/api/search.js +++ b/api/api/search.js @@ -2,7 +2,7 @@ function buildSearch (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [search](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html) request * @@ -66,7 +66,7 @@ function buildSearch (opts) { if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -186,7 +186,7 @@ function buildSearch (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/search_shards.js b/api/api/search_shards.js index 62a2fa783..bf341c32d 100644 --- a/api/api/search_shards.js +++ b/api/api/search_shards.js @@ -2,7 +2,7 @@ function buildSearchShards (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [search_shards](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-shards.html) request * @@ -32,7 +32,7 @@ function buildSearchShards (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -88,7 +88,7 @@ function buildSearchShards (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/search_template.js b/api/api/search_template.js index 7d42e6b62..e6d2b1e00 100644 --- a/api/api/search_template.js +++ b/api/api/search_template.js @@ -2,7 +2,7 @@ function buildSearchTemplate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [search_template](http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html) request * @@ -38,7 +38,7 @@ function buildSearchTemplate (opts) { if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -46,7 +46,7 @@ function buildSearchTemplate (opts) { if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -110,7 +110,7 @@ function buildSearchTemplate (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/snapshot.create.js b/api/api/snapshot.create.js index 18dc40192..ab12c54cf 100644 --- a/api/api/snapshot.create.js +++ b/api/api/snapshot.create.js @@ -2,7 +2,7 @@ function buildSnapshotCreate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [snapshot.create](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request * @@ -30,13 +30,13 @@ function buildSnapshotCreate (opts) { if (params['repository'] == null) { return callback( new ConfigurationError('Missing required parameter: repository'), - { body: null, headers: null, statusCode: null } + result ) } if (params['snapshot'] == null) { return callback( new ConfigurationError('Missing required parameter: snapshot'), - { body: null, headers: null, statusCode: null } + result ) } @@ -44,7 +44,7 @@ function buildSnapshotCreate (opts) { if (params['snapshot'] != null && (params['repository'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: repository'), - { body: null, headers: null, statusCode: null } + result ) } @@ -92,7 +92,7 @@ function buildSnapshotCreate (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/snapshot.create_repository.js b/api/api/snapshot.create_repository.js index 7458bea79..52012fb38 100644 --- a/api/api/snapshot.create_repository.js +++ b/api/api/snapshot.create_repository.js @@ -2,7 +2,7 @@ function buildSnapshotCreateRepository (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [snapshot.create_repository](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request * @@ -30,13 +30,13 @@ function buildSnapshotCreateRepository (opts) { if (params['repository'] == null) { return callback( new ConfigurationError('Missing required parameter: repository'), - { body: null, headers: null, statusCode: null } + result ) } if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -86,7 +86,7 @@ function buildSnapshotCreateRepository (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/snapshot.delete.js b/api/api/snapshot.delete.js index 949f4d2e6..ca5060144 100644 --- a/api/api/snapshot.delete.js +++ b/api/api/snapshot.delete.js @@ -2,7 +2,7 @@ function buildSnapshotDelete (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [snapshot.delete](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request * @@ -28,19 +28,19 @@ function buildSnapshotDelete (opts) { if (params['repository'] == null) { return callback( new ConfigurationError('Missing required parameter: repository'), - { body: null, headers: null, statusCode: null } + result ) } if (params['snapshot'] == null) { return callback( new ConfigurationError('Missing required parameter: snapshot'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -48,7 +48,7 @@ function buildSnapshotDelete (opts) { if (params['snapshot'] != null && (params['repository'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: repository'), - { body: null, headers: null, statusCode: null } + result ) } @@ -94,7 +94,7 @@ function buildSnapshotDelete (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/snapshot.delete_repository.js b/api/api/snapshot.delete_repository.js index d42bc2113..1291f1767 100644 --- a/api/api/snapshot.delete_repository.js +++ b/api/api/snapshot.delete_repository.js @@ -2,7 +2,7 @@ function buildSnapshotDeleteRepository (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [snapshot.delete_repository](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request * @@ -28,13 +28,13 @@ function buildSnapshotDeleteRepository (opts) { if (params['repository'] == null) { return callback( new ConfigurationError('Missing required parameter: repository'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -82,7 +82,7 @@ function buildSnapshotDeleteRepository (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/snapshot.get.js b/api/api/snapshot.get.js index 91b54005f..8ffe9ab50 100644 --- a/api/api/snapshot.get.js +++ b/api/api/snapshot.get.js @@ -2,7 +2,7 @@ function buildSnapshotGet (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [snapshot.get](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request * @@ -30,19 +30,19 @@ function buildSnapshotGet (opts) { if (params['repository'] == null) { return callback( new ConfigurationError('Missing required parameter: repository'), - { body: null, headers: null, statusCode: null } + result ) } if (params['snapshot'] == null) { return callback( new ConfigurationError('Missing required parameter: snapshot'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -50,7 +50,7 @@ function buildSnapshotGet (opts) { if (params['snapshot'] != null && (params['repository'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: repository'), - { body: null, headers: null, statusCode: null } + result ) } @@ -100,7 +100,7 @@ function buildSnapshotGet (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/snapshot.get_repository.js b/api/api/snapshot.get_repository.js index 0c91cf26d..fa83c11f4 100644 --- a/api/api/snapshot.get_repository.js +++ b/api/api/snapshot.get_repository.js @@ -2,7 +2,7 @@ function buildSnapshotGetRepository (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [snapshot.get_repository](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request * @@ -28,7 +28,7 @@ function buildSnapshotGetRepository (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -76,7 +76,7 @@ function buildSnapshotGetRepository (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/snapshot.restore.js b/api/api/snapshot.restore.js index d5f2e445d..92059a1d7 100644 --- a/api/api/snapshot.restore.js +++ b/api/api/snapshot.restore.js @@ -2,7 +2,7 @@ function buildSnapshotRestore (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [snapshot.restore](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request * @@ -30,13 +30,13 @@ function buildSnapshotRestore (opts) { if (params['repository'] == null) { return callback( new ConfigurationError('Missing required parameter: repository'), - { body: null, headers: null, statusCode: null } + result ) } if (params['snapshot'] == null) { return callback( new ConfigurationError('Missing required parameter: snapshot'), - { body: null, headers: null, statusCode: null } + result ) } @@ -44,7 +44,7 @@ function buildSnapshotRestore (opts) { if (params['snapshot'] != null && (params['repository'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: repository'), - { body: null, headers: null, statusCode: null } + result ) } @@ -92,7 +92,7 @@ function buildSnapshotRestore (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/snapshot.status.js b/api/api/snapshot.status.js index 50959dd95..7d65a5a5c 100644 --- a/api/api/snapshot.status.js +++ b/api/api/snapshot.status.js @@ -2,7 +2,7 @@ function buildSnapshotStatus (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [snapshot.status](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request * @@ -29,7 +29,7 @@ function buildSnapshotStatus (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -37,7 +37,7 @@ function buildSnapshotStatus (opts) { if (params['snapshot'] != null && (params['repository'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: repository'), - { body: null, headers: null, statusCode: null } + result ) } @@ -85,7 +85,7 @@ function buildSnapshotStatus (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/snapshot.verify_repository.js b/api/api/snapshot.verify_repository.js index ff605606c..095eb0bac 100644 --- a/api/api/snapshot.verify_repository.js +++ b/api/api/snapshot.verify_repository.js @@ -2,7 +2,7 @@ function buildSnapshotVerifyRepository (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [snapshot.verify_repository](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request * @@ -28,13 +28,13 @@ function buildSnapshotVerifyRepository (opts) { if (params['repository'] == null) { return callback( new ConfigurationError('Missing required parameter: repository'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -82,7 +82,7 @@ function buildSnapshotVerifyRepository (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/tasks.cancel.js b/api/api/tasks.cancel.js index 5b53505e0..f403dfdaf 100644 --- a/api/api/tasks.cancel.js +++ b/api/api/tasks.cancel.js @@ -2,7 +2,7 @@ function buildTasksCancel (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [tasks.cancel](http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html) request * @@ -29,7 +29,7 @@ function buildTasksCancel (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -79,7 +79,7 @@ function buildTasksCancel (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/tasks.get.js b/api/api/tasks.get.js index f3d574b0e..38951667c 100644 --- a/api/api/tasks.get.js +++ b/api/api/tasks.get.js @@ -2,7 +2,7 @@ function buildTasksGet (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [tasks.get](http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html) request * @@ -28,13 +28,13 @@ function buildTasksGet (opts) { if (params['task_id'] == null && params['taskId'] == null) { return callback( new ConfigurationError('Missing required parameter: task_id or taskId'), - { body: null, headers: null, statusCode: null } + result ) } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -82,7 +82,7 @@ function buildTasksGet (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/tasks.list.js b/api/api/tasks.list.js index a9d70eb49..68e38707f 100644 --- a/api/api/tasks.list.js +++ b/api/api/tasks.list.js @@ -2,7 +2,7 @@ function buildTasksList (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [tasks.list](http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html) request * @@ -32,7 +32,7 @@ function buildTasksList (opts) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -90,7 +90,7 @@ function buildTasksList (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/termvectors.js b/api/api/termvectors.js index 6caf19bf2..af07ddd34 100644 --- a/api/api/termvectors.js +++ b/api/api/termvectors.js @@ -2,7 +2,7 @@ function buildTermvectors (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [termvectors](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-termvectors.html) request * @@ -41,13 +41,13 @@ function buildTermvectors (opts) { if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } if (params['type'] == null) { return callback( new ConfigurationError('Missing required parameter: type'), - { body: null, headers: null, statusCode: null } + result ) } @@ -55,12 +55,12 @@ function buildTermvectors (opts) { if (params['id'] != null && (params['type'] == null || params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: type, index'), - { body: null, headers: null, statusCode: null } + result ) } else if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -128,7 +128,7 @@ function buildTermvectors (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/update.js b/api/api/update.js index 0c65b4ada..b0140d158 100644 --- a/api/api/update.js +++ b/api/api/update.js @@ -2,7 +2,7 @@ function buildUpdate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [update](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update.html) request * @@ -42,25 +42,25 @@ function buildUpdate (opts) { if (params['id'] == null) { return callback( new ConfigurationError('Missing required parameter: id'), - { body: null, headers: null, statusCode: null } + result ) } if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } if (params['type'] == null) { return callback( new ConfigurationError('Missing required parameter: type'), - { body: null, headers: null, statusCode: null } + result ) } if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), - { body: null, headers: null, statusCode: null } + result ) } @@ -68,12 +68,12 @@ function buildUpdate (opts) { if (params['id'] != null && (params['type'] == null || params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: type, index'), - { body: null, headers: null, statusCode: null } + result ) } else if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -143,7 +143,7 @@ function buildUpdate (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/api/update_by_query.js b/api/api/update_by_query.js index 7e3a2ec1c..56c53fdce 100644 --- a/api/api/update_by_query.js +++ b/api/api/update_by_query.js @@ -2,7 +2,7 @@ function buildUpdateByQuery (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts /** * Perform a [update_by_query](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html) request * @@ -62,7 +62,7 @@ function buildUpdateByQuery (opts) { if (params['index'] == null) { return callback( new ConfigurationError('Missing required parameter: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -70,7 +70,7 @@ function buildUpdateByQuery (opts) { if (params['type'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), - { body: null, headers: null, statusCode: null } + result ) } @@ -182,7 +182,7 @@ function buildUpdateByQuery (opts) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - { body: null, headers: null, statusCode: null } + result ) } diff --git a/api/index.js b/api/index.js index da91b8259..4d88a2504 100644 --- a/api/index.js +++ b/api/index.js @@ -5,6 +5,7 @@ const assert = require('assert') function ESAPI (opts) { assert(opts.makeRequest, 'Missing makeRequest function') assert(opts.ConfigurationError, 'Missing ConfigurationError class') + assert(opts.result, 'Missing default result object') const apis = { bulk: require('./api/bulk.js')(opts), From d77d97d301cd3ecdc61cb371e6cbe4bf9ce5005b Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 5 Nov 2018 19:19:39 +0100 Subject: [PATCH 026/172] WIP: initial prototype - Use plain node http.request - WIP: connection closing procedure - Updated ConnectionPool.getConnection - Removed Selector class and expose a single configuration parameter - Added compression handling - Improved code documentation --- index.js | 30 ++++++---- lib/Connection.js | 124 ++++++++++++++++++++++++++++++++++++++---- lib/ConnectionPool.js | 65 ++++++++++++++++++++-- lib/Selectors.js | 23 -------- lib/Transport.js | 46 +++++++++++++--- 5 files changed, 230 insertions(+), 58 deletions(-) delete mode 100644 lib/Selectors.js diff --git a/index.js b/index.js index da531097e..9896f59be 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,6 @@ const Transport = require('./lib/Transport') const Connection = require('./lib/Connection') const ConnectionPool = require('./lib/ConnectionPool') const Serializer = require('./lib/Serializer') -const selectors = require('./lib/Selectors') const symbols = require('./lib/symbols') const { ConfigurationError } = require('./lib/errors') @@ -14,8 +13,7 @@ const buildApi = require('./api') const { kTransport, kConnectionPool, - kSerializer, - kSelector + kSerializer } = symbols class Client extends EventEmitter { @@ -37,13 +35,11 @@ class Client extends EventEmitter { // the "unhandled error event" error. this.on('error', () => {}) - const Selector = selectors.RoundRobinSelector const options = Object.assign({}, { Connection, ConnectionPool, Transport, Serializer, - Selector, maxRetries: 3, requestTimeout: 30000, pingTimeout: 3000, @@ -53,19 +49,24 @@ class Client extends EventEmitter { sniffOnConnectionFault: false, resurrectStrategy: 'ping', randomizeHost: true, + suggestCompression: false, ssl: null, - agent: null + agent: null, + nodeFilter: null, + nodeWeighter: null, + nodeSelector: 'round-robin' }, opts) - this[kSelector] = new options.Selector() this[kSerializer] = new options.Serializer() this[kConnectionPool] = new options.ConnectionPool({ pingTimeout: opts.pingTimeout, resurrectStrategy: opts.resurrectStrategy, randomizeHost: opts.randomizeHost, - selector: this[kSelector], ssl: options.ssl, - agent: null + agent: null, + nodeFilter: opts.nodeFilter, + nodeWeighter: opts.nodeWeighter, + nodeSelector: opts.nodeSelector }) // Add the connections before initialize the Transport @@ -80,13 +81,15 @@ class Client extends EventEmitter { sniffInterval: options.sniffInterval, sniffOnStart: options.sniffOnStart, sniffOnConnectionFault: options.sniffOnConnectionFault, - sniffEndpoint: options.sniffEndpoint + sniffEndpoint: options.sniffEndpoint, + suggestCompression: options.suggestCompression }) this.request = this[kTransport].request.bind(this[kTransport]) const apis = buildApi({ makeRequest: this[kTransport].request.bind(this[kTransport]), + result: { body: null, statusCode: null, headers: null, warnings: null }, ConfigurationError }) @@ -96,11 +99,16 @@ class Client extends EventEmitter { } } +Client.events = { + RESPONSE: 'response', + REQUEST: 'request', + ERROR: 'error' +} + module.exports = { Client, Transport, ConnectionPool, Serializer, - selectors, symbols } diff --git a/lib/Connection.js b/lib/Connection.js index a51c51aa9..5d16d0d58 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -1,21 +1,23 @@ 'use strict' const assert = require('assert') -const { Agent: HttpAgent } = require('http') -const { Agent: HttpsAgent } = require('https') +const http = require('http') +const https = require('https') const debug = require('debug')('elasticsearch') -const makeRequest = require('simple-get') +const decompressResponse = require('decompress-response') +const { TimeoutError } = require('./errors') class Connection { constructor (opts = {}) { assert(opts.host, 'Missing host data') - this.host = opts.host + this.host = urlToOptions(opts.host) this.ssl = opts.host.ssl || opts.ssl || null this.id = opts.id || opts.host.href this.deadCount = 0 this.resurrectTimeout = 0 + this._openRequests = 0 this._status = opts.status || Connection.statuses.ALIVE this.roles = opts.roles || defaultRoles @@ -26,23 +28,67 @@ class Connection { maxFreeSockets: 256 }, opts.host.agent || opts.agent) this._agent = this.host.protocol === 'http:' - ? new HttpAgent(agentOptions) - : new HttpsAgent(Object.assign({}, agentOptions, this.ssl)) + ? new http.Agent(agentOptions) + : new https.Agent(Object.assign({}, agentOptions, this.ssl)) + + this.makeRequest = this.host.protocol === 'http:' + ? http.request + : https.request } request (params, callback) { - params.url = resolve(this.host.href, params.path) - if (params.querystring != null && params.querystring.length > 0) { - params.url += '?' + params.querystring - } + this._openRequests++ + var ended = false params.agent = this._agent + debug('Starting a new request', params) - return makeRequest(params, callback) + const request = this.makeRequest(buildRequestObject(this.host, params)) + + // listen for the response event + // TODO: handle redirects? + request.on('response', response => { + if (ended === false) { + ended = true + this._openRequests-- + callback(null, decompressResponse(response)) + } + }) + + // handles request timeout + request.on('timeout', () => { + if (ended === false) { + ended = true + this._openRequests-- + request.abort() + callback(new TimeoutError('Request timed out', params)) + } + }) + + // handles request error + request.on('error', err => { + if (ended === false) { + ended = true + this._openRequests-- + callback(err) + } + }) + + // Disables the Nagle algorithm + request.setNoDelay(true) + + // starts the request + request.end(params.body) + + return request } close () { debug('Closing connection', this.id) - this._agent.destroy() + if (this._openRequests > 0) { + setTimeout(() => this.close(), 1000) + } else { + this._agent.destroy() + } } setRole (role, enabled) { @@ -110,4 +156,58 @@ function resolve (host, path) { } } +function buildRequestObject (host, request) { + var merged = {} + var hostKeys = Object.keys(host) + var requestKeys = Object.keys(request) + + for (var i = 0, len = hostKeys.length; i < len; i++) { + var key = hostKeys[i] + merged[key] = host[key] + } + + for (i = 0, len = requestKeys.length; i < len; i++) { + key = requestKeys[i] + if (key === 'path') { + merged.pathname = resolve(merged.pathname, request[key]) + } else if (key === 'querystring' && !!request[key] === true) { + if (merged.search === '') { + merged.search = '?' + request[key] + } else { + merged.search += '&' + request[key] + } + } else { + merged[key] = request[key] + } + } + + merged.path = merged.pathname + merged.search + + return merged +} + +// Utility function that converts a URL object into an ordinary +// options object as expected by the http.request and https.request APIs. +// https://github.com/nodejs/node/blob/v11.0.0/lib/internal/url.js#L1324 +function urlToOptions (url) { + var options = { + protocol: url.protocol, + hostname: url.hostname.startsWith('[') + ? url.hostname.slice(1, -1) + : url.hostname, + hash: url.hash, + search: url.search, + pathname: url.pathname, + path: `${url.pathname}${url.search}`, + href: url.href + } + if (url.port !== '') { + options.port = Number(url.port) + } + if (url.username || url.password) { + options.auth = `${url.username}:${url.password}` + } + return options +} + module.exports = Connection diff --git a/lib/ConnectionPool.js b/lib/ConnectionPool.js index 8f52a1a77..2ed3cc9f0 100644 --- a/lib/ConnectionPool.js +++ b/lib/ConnectionPool.js @@ -9,6 +9,8 @@ const noop = () => {} class ConnectionPool { constructor (opts = {}) { this.connections = new Map() + // TODO: do we need those queue? (or find a better use) + // can we use just the connections map? this.alive = [] this.dead = [] this.selector = opts.selector @@ -24,7 +26,19 @@ class ConnectionPool { // the timeout doesn't increase this.resurrectTimeoutCutoff = 5 this.pingTimeout = opts.pingTimeout - this.randomizeHost = opts.randomizeHost + this.randomizeHost = opts.randomizeHost === true + this.nodeFilter = opts.nodeFilter || defaultNodeFilter + this.nodeWeighter = opts.nodeWeighter || noop + + if (typeof opts.nodeSelector === 'function') { + this.nodeSelector = opts.nodeSelector + } else if (opts.nodeSelector === 'round-robin') { + this.nodeSelector = roundRobinSelector() + } else if (opts.nodeSelector === 'random') { + this.nodeSelector = randomSelector + } else { + this.nodeSelector = roundRobinSelector() + } const resurrectStrategy = opts.resurrectStrategy || 'ping' this.resurrectStrategy = ConnectionPool.resurrectStrategies[resurrectStrategy] @@ -150,18 +164,35 @@ class ConnectionPool { /** * Returns an alive connection if present, * otherwise returns null. + * By default it does not apply a weighter to the node list, + * and filters the `master` only nodes * It uses the selector to choose which * connection return. * + * @param {object} options (weighter, filter and selector) * @returns {object|null} connection */ - getConnection () { + getConnection (opts = {}) { if (this.alive.length === 0) { return null } - const id = this.selector.select(this.alive) - return this.connections.get(id) + const filter = opts.filter || this.nodeFilter + const weighter = opts.weighter || this.nodeWeighter + const selector = opts.selector || this.nodeSelector + + // TODO: can we cache this? + const connections = [] + for (var connection of this.connections.values()) { + if (connection.status === Connection.statuses.ALIVE) { + if (filter(connection) === true) { + connections.push(connection) + } + } + } + connections.sort(weighter) + + return selector(connections) } /** @@ -285,4 +316,30 @@ const shuffleArray = arr => arr .sort((a, b) => a[0] - b[0]) .map(a => a[1]) +function defaultNodeFilter (node) { + // avoid master only nodes + if (!!node.master === true && + !!node.data === false && + !!node.ingest === false) { + return false + } + return true +} + +function roundRobinSelector () { + var current = -1 + return function _roundRobinSelector (connections) { + if (++current >= connections.length) { + current = 0 + } + return connections[current] + } +} + +function randomSelector (connections) { + const index = Math.floor(Math.random() * connections.length) + return connections[index] +} + module.exports = ConnectionPool +module.exports.internals = { defaultNodeFilter, roundRobinSelector, randomSelector } diff --git a/lib/Selectors.js b/lib/Selectors.js deleted file mode 100644 index 3da41a6de..000000000 --- a/lib/Selectors.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict' - -class RoundRobinSelector { - constructor () { - this.current = -1 - } - - select (connections) { - if (++this.current >= connections.length) { - this.current = 0 - } - return connections[this.current] - } -} - -class RandomSelector { - select (connections) { - const index = Math.floor(Math.random() * connections.length) - return connections[index] - } -} - -module.exports = { RoundRobinSelector, RandomSelector } diff --git a/lib/Transport.js b/lib/Transport.js index 58e697008..0673df7e5 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -20,6 +20,7 @@ class Transport { this.serializer = opts.serializer this.maxRetries = opts.maxRetries this.requestTimeout = toMs(opts.requestTimeout) + this.suggestCompression = opts.suggestCompression === true this.sniffInterval = opts.sniffInterval this.sniffOnConnectionFault = opts.sniffOnConnectionFault this.sniffEndpoint = opts.sniffEndpoint @@ -35,13 +36,14 @@ class Transport { request (params, callback) { callback = once(callback) - const result = { body: null, statusCode: null, headers: null } + const result = { body: null, statusCode: null, headers: null, warnings: null } const attempts = params[kRemainingAttempts] || params.maxRetries || this.maxRetries const connection = this.getConnection() if (connection === null) { return callback(new NoLivingConnectionsError('There are not living connections'), result) } + params.headers = params.headers || {} // handle json body if (params.body != null) { if (typeof params.body !== 'string') { @@ -51,7 +53,6 @@ class Transport { return callback(err, result) } } - params.headers = params.headers || {} params.headers['Content-Type'] = 'application/json' params.headers['Content-Length'] = '' + Buffer.byteLength(params.body) // handle ndjson body @@ -65,11 +66,14 @@ class Transport { } else { params.body = params.bulkBody } - params.headers = params.headers || {} params.headers['Content-Type'] = 'application/x-ndjson' params.headers['Content-Length'] = '' + Buffer.byteLength(params.body) } + if (this.suggestCompression === true) { + params.headers['Accept-Encoding'] = 'gzip,deflate' + } + // serializes the querystring params.querystring = this.serializer.qserialize(params.querystring) // handles request timeout @@ -77,21 +81,26 @@ class Transport { this.emit('request', params) + // perform the actual http request const request = connection.request(params, (err, response) => { if (err != null) { + // if there is an error in the connection + // let's mark the connection as dead this.connectionPool.markDead(connection) + if (this.sniffOnConnectionFault === true) { this.sniff() } + // retry logic if (attempts > 0) { debug(`Retrying request, there are still ${attempts} attempts`, params) params[kRemainingAttempts] = attempts - 1 return this.request(params, callback) } - const error = err.message === 'Request timed out' - ? new TimeoutError(err.message, params) + const error = err instanceof TimeoutError + ? err : new ConnectionError(err.message, params) this.emit('error', error, params) @@ -101,30 +110,47 @@ class Transport { const { statusCode, headers } = response result.statusCode = statusCode result.headers = headers + if (headers['warning'] != null) { + // split the string over the commas not inside quotes + result.warnings = headers['warning'].split(/(?!\B"[^"]*),(?![^"]*"\B)/) + } var payload = '' + // collect the payload response.setEncoding('utf8') response.on('data', chunk => { payload += chunk }) response.on('error', err => callback(new ConnectionError(err.message, params), result)) response.on('end', () => { const isHead = params.method === 'HEAD' - const shouldDeserialize = headers['content-type'] != null && isHead === false && payload !== '' - if (shouldDeserialize === true && headers['content-type'].indexOf('application/json') > -1) { + // we should attempt the payload deserialization only if: + // - a `content-type` is defined and is equal to `application/json` + // - the request is not a HEAD request + // - the payload is not an empty string + if (headers['content-type'] != null && + headers['content-type'].indexOf('application/json') > -1 && + isHead === false && + payload !== '' + ) { try { result.body = this.serializer.deserialize(payload) } catch (err) { - this.emit('error', err) + this.emit('error', err, params) return callback(err, result) } } else { + // cast to boolean if the request method was HEAD result.body = isHead === true ? true : payload } + // we should ignore the statusCode if the user has configured the `ignore` field with + // the statusCode we just got or if the request method is HEAD and the statusCode is 404 const ignoreStatusCode = (Array.isArray(params.ignore) && params.ignore.indexOf(statusCode) > -1) || (isHead === true && statusCode === 404) if (ignoreStatusCode === false && (statusCode === 502 || statusCode === 503 || statusCode === 504)) { + // if the statusCode is 502/3/4 we should run our retry strategy + // and mark the connection as dead this.connectionPool.markDead(connection) if (attempts > 0) { debug(`Retrying request, there are still ${attempts} attempts`, params) @@ -132,6 +158,8 @@ class Transport { return this.request(params, callback) } } else { + // everything has worked as expected, let's mark + // the connection as alive (or confirm it) this.connectionPool.markAlive(connection) } @@ -139,6 +167,7 @@ class Transport { if (ignoreStatusCode === false && statusCode >= 400) { callback(new ResponseError(result), result) } else { + // cast to boolean if the request method was HEAD if (isHead === true && statusCode === 404) { result.body = false } @@ -179,6 +208,7 @@ class Transport { } if (err != null) { + this.emit('error', err) debug('Sniffing errored', err) return callback(err) } From 40cb37b2e81035613fe82d8ee92e31f96a6ccd24 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 5 Nov 2018 19:22:36 +0100 Subject: [PATCH 027/172] Updated test --- test/integration/test-runner.js | 42 ++++- test/unit/api.test.js | 167 +++++++++++++++++++ test/unit/connection-pool.test.js | 120 ++++++++++++-- test/unit/connection.test.js | 186 +++++++++++++++++---- test/unit/selectors.test.js | 9 +- test/unit/transport.test.js | 266 +++++++++++++++++++----------- 6 files changed, 638 insertions(+), 152 deletions(-) create mode 100644 test/unit/api.test.js diff --git a/test/integration/test-runner.js b/test/integration/test-runner.js index 1ee0f5260..228eadf35 100644 --- a/test/integration/test-runner.js +++ b/test/integration/test-runner.js @@ -246,14 +246,48 @@ TestRunner.prototype.set = function (key, name) { /** * Runs a client command - * TODO: handle `action.warning`, `action.catch`... * @param {object} the action to perform * @param {Queue} */ TestRunner.prototype.do = function (action, done) { const cmd = this.parseDo(action) const api = delve(this.client, cmd.method).bind(this.client) - api(cmd.params, (err, { body }) => { + api(cmd.params, (err, { body, warnings }) => { + if (action.warnings && warnings === null) { + this.tap.fail('We should get a warning header', action.warnings) + } else if (!action.warnings && warnings !== null) { + // if there is only the 'default shard will change' + // warning we skip the check, because the yaml + // spec may not be updated + let hasDefaultShardsWarning = false + warnings.forEach(h => { + if (/default\snumber\sof\sshards/g.test(h)) { + hasDefaultShardsWarning = true + } + }) + + if (hasDefaultShardsWarning === true && warnings.length > 1) { + this.tap.fail('We are not expecting warnings', warnings) + } + } else if (action.warnings && warnings !== null) { + // if the yaml warnings do not contain the + // 'default shard will change' warning + // we do not check it presence in the warnings array + // because the yaml spec may not be updated + let hasDefaultShardsWarning = false + action.warnings.forEach(h => { + if (/default\snumber\sof\sshards/g.test(h)) { + hasDefaultShardsWarning = true + } + }) + + if (hasDefaultShardsWarning === false) { + warnings = warnings.filter(h => !h.test(/default\snumber\sof\sshards/g)) + } + + this.tap.deepEqual(warnings, action.warnings) + } + if (action.catch) { this.tap.true( parseDoError(err, action.catch), @@ -269,10 +303,6 @@ TestRunner.prototype.do = function (action, done) { this.response = body } - if (action.warning) { - this.tap.todo('Handle warnings') - } - done() }) } diff --git a/test/unit/api.test.js b/test/unit/api.test.js new file mode 100644 index 000000000..ad095a585 --- /dev/null +++ b/test/unit/api.test.js @@ -0,0 +1,167 @@ +'use strict' + +const { test } = require('tap') +const { Client } = require('../../index') +const { buildServer } = require('../utils') + +test('Basic (callback)', t => { + t.plan(2) + + function handler (req, res) { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const client = new Client({ + host: `http://localhost:${port}` + }) + + client.search({ + index: 'test', + type: 'doc', + query: { + match: { foo: 'bar' } + } + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + }) + }) +}) + +test('Basic (promises)', t => { + t.plan(1) + + function handler (req, res) { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const client = new Client({ + host: `http://localhost:${port}` + }) + + client + .search({ + index: 'test', + type: 'doc', + query: { + match: { foo: 'bar' } + } + }) + .then(({ body }) => t.deepEqual(body, { hello: 'world' })) + .catch(t.fail) + }) +}) + +test('Error (callback)', t => { + t.plan(1) + + function handler (req, res) { + res.statusCode = 500 + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const client = new Client({ + host: `http://localhost:${port}` + }) + + client.search({ + index: 'test', + type: 'doc', + query: { + match: { foo: 'bar' } + } + }, (err, { body }) => { + t.ok(err) + }) + }) +}) + +test('Error (promises)', t => { + t.plan(1) + + function handler (req, res) { + res.statusCode = 500 + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const client = new Client({ + host: `http://localhost:${port}` + }) + + client + .search({ + index: 'test', + type: 'doc', + query: { + match: { foo: 'bar' } + } + }) + .then(t.fail) + .catch(err => t.ok(err)) + }) +}) + +test('Abort method (callback)', t => { + t.plan(3) + + function handler (req, res) { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const client = new Client({ + host: `http://localhost:${port}` + }) + + const request = client.search({ + index: 'test', + type: 'doc', + query: { + match: { foo: 'bar' } + } + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + }) + + t.type(request.abort, 'function') + }) +}) + +test('Abort is not supported in promises', t => { + t.plan(2) + + function handler (req, res) { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const client = new Client({ + host: `http://localhost:${port}` + }) + + const request = client.search({ + index: 'test', + type: 'doc', + query: { + match: { foo: 'bar' } + } + }) + + request + .then(({ body }) => t.deepEqual(body, { hello: 'world' })) + .catch(t.fail) + + t.type(request.abort, 'undefined') + }) +}) diff --git a/test/unit/connection-pool.test.js b/test/unit/connection-pool.test.js index 9bd300edf..f435fffd2 100644 --- a/test/unit/connection-pool.test.js +++ b/test/unit/connection-pool.test.js @@ -4,12 +4,11 @@ const { test } = require('tap') const { URL } = require('url') const ConnectionPool = require('../../lib/ConnectionPool') const Connection = require('../../lib/Connection') -const { RoundRobinSelector } = require('../../lib/Selectors') const { buildServer } = require('../utils') test('API', t => { t.test('addConnection', t => { - const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) + const pool = new ConnectionPool() const href = 'http://localhost:9200/' pool.addConnection(href) t.ok(pool.connections.get(href) instanceof Connection) @@ -19,7 +18,7 @@ test('API', t => { }) t.test('addConnection should throw with two connections with the same id', t => { - const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) + const pool = new ConnectionPool() const href = 'http://localhost:9200/' pool.addConnection(href) try { @@ -32,7 +31,7 @@ test('API', t => { }) t.test('markDead', t => { - const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) + const pool = new ConnectionPool() const href = 'http://localhost:9200/' var connection = pool.addConnection(href) pool.markDead(connection) @@ -45,7 +44,7 @@ test('API', t => { }) t.test('markDead should sort the dead queue by deadTimeout', t => { - const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) + const pool = new ConnectionPool() const href1 = 'http://localhost:9200/1' const href2 = 'http://localhost:9200/2' const conn1 = pool.addConnection(href1) @@ -59,7 +58,7 @@ test('API', t => { }) t.test('markAlive', t => { - const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) + const pool = new ConnectionPool() const href = 'http://localhost:9200/' var connection = pool.addConnection(href) pool.markDead(connection) @@ -81,7 +80,6 @@ test('API', t => { buildServer(handler, ({ port }, server) => { const pool = new ConnectionPool({ - selector: new RoundRobinSelector(), resurrectStrategy: 'ping', pingTimeout: 3000 }) @@ -104,7 +102,6 @@ test('API', t => { buildServer(() => {}, ({ port }, server) => { server.close() const pool = new ConnectionPool({ - selector: new RoundRobinSelector(), resurrectStrategy: 'ping', pingTimeout: 3000 }) @@ -128,7 +125,6 @@ test('API', t => { t.test('optimistic strategy', t => { const pool = new ConnectionPool({ - selector: new RoundRobinSelector(), resurrectStrategy: 'optimistic' }) const href = 'http://localhost:9200/' @@ -147,7 +143,6 @@ test('API', t => { t.test('none strategy', t => { const pool = new ConnectionPool({ - selector: new RoundRobinSelector(), resurrectStrategy: 'none' }) const href = 'http://localhost:9200/' @@ -169,15 +164,104 @@ test('API', t => { }) t.test('getConnection', t => { - const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) - const href = 'http://localhost:9200/' - pool.addConnection(href) - t.ok(pool.getConnection() instanceof Connection) + t.test('Should return a connection', t => { + const pool = new ConnectionPool() + const href = 'http://localhost:9200/' + pool.addConnection(href) + t.ok(pool.getConnection() instanceof Connection) + t.end() + }) + + t.test('filter option', t => { + const pool = new ConnectionPool() + const href1 = 'http://localhost:9200/' + const href2 = 'http://localhost:9200/other' + pool.addConnection([href1, href2]) + + const filter = node => node.id === href1 + t.strictEqual(pool.getConnection({ filter }).id, href1) + t.end() + }) + + t.test('weighter option', t => { + const pool = new ConnectionPool() + const href1 = 'http://localhost:9200/' + const href2 = 'http://localhost:9200/other' + pool.addConnection([href1, href2]) + + const weighter = node => node.id === href1 + t.strictEqual(pool.getConnection({ weighter }).id, href2) + t.end() + }) + + t.test('filter should be run before the weighter', t => { + const pool = new ConnectionPool() + const href1 = 'http://localhost:9200/' + const href2 = 'http://localhost:9200/other' + pool.addConnection([href1, href2]) + + const filter = node => node.id === href1 + const weighter = node => node.id !== href2 + t.strictEqual(pool.getConnection({ weighter, filter }).id, href1) + t.end() + }) + + t.test('filter and weighter should get Connection objects', t => { + t.plan(3) + const pool = new ConnectionPool() + const href1 = 'http://localhost:9200/' + const href2 = 'http://localhost:9200/other' + pool.addConnection([href1, href2]) + + const filter = node => { + t.ok(node instanceof Connection) + return true + } + const weighter = node => t.ok(node instanceof Connection) + pool.getConnection({ weighter, filter }) + }) + + t.test('filter and weighter should get alive connections', t => { + t.plan(3) + const pool = new ConnectionPool() + const href1 = 'http://localhost:9200/' + const href2 = 'http://localhost:9200/other' + const conn = pool.addConnection(href1) + pool.addConnection([href2, `${href2}/stuff`]) + pool.markDead(conn) + + const filter = node => { + t.strictEqual(node.status, Connection.statuses.ALIVE) + return true + } + const weighter = node => t.strictEqual(node.status, Connection.statuses.ALIVE) + pool.getConnection({ weighter, filter }) + }) + + t.test('filter and weighter as ConnectionPool option', t => { + t.plan(3) + + const href1 = 'http://localhost:9200/' + const href2 = 'http://localhost:9200/other' + const pool = new ConnectionPool({ + nodeFilter: node => { + t.ok('called') + return node.id === href1 + }, + nodeWeighter: node => { + t.ok('called') + return node.id !== href2 + } + }) + pool.addConnection([href1, href2]) + t.strictEqual(pool.getConnection().id, href1) + }) + t.end() }) t.test('removeConnection', t => { - const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) + const pool = new ConnectionPool() const href = 'http://localhost:9200/' var connection = pool.addConnection(href) t.ok(pool.getConnection() instanceof Connection) @@ -187,7 +271,7 @@ test('API', t => { }) t.test('empty', t => { - const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) + const pool = new ConnectionPool() pool.addConnection('http://localhost:9200/') pool.addConnection('http://localhost:9201/') pool.empty() @@ -198,7 +282,7 @@ test('API', t => { }) t.test('urlToHost', t => { - const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) + const pool = new ConnectionPool() const url = 'http://localhost:9200' t.deepEqual( pool.urlToHost(url), @@ -208,7 +292,7 @@ test('API', t => { }) t.test('nodesToHost', t => { - const pool = new ConnectionPool({ selector: new RoundRobinSelector() }) + const pool = new ConnectionPool() const nodes = { a1: { http: { diff --git a/test/unit/connection.test.js b/test/unit/connection.test.js index f08a1b2fe..67c752576 100644 --- a/test/unit/connection.test.js +++ b/test/unit/connection.test.js @@ -1,8 +1,12 @@ 'use strict' const { test } = require('tap') +const { createGzip, createDeflate } = require('zlib') +const { URL } = require('url') +const intoStream = require('into-stream') const { buildServer } = require('../utils') const Connection = require('../../lib/Connection') +const { TimeoutError } = require('../../lib/errors') test('Basic (http)', t => { t.plan(4) @@ -17,10 +21,7 @@ test('Basic (http)', t => { buildServer(handler, ({ port }, server) => { const connection = new Connection({ - host: { - href: `http://localhost:${port}`, - protocol: 'http:' - } + host: new URL(`http://localhost:${port}`) }) connection.request({ path: '/hello', @@ -59,10 +60,7 @@ test('Basic (https)', t => { buildServer(handler, { secure: true }, ({ port }, server) => { const connection = new Connection({ - host: { - href: `https://localhost:${port}`, - protocol: 'https:' - } + host: new URL(`https://localhost:${port}`) }) connection.request({ path: '/hello', @@ -101,10 +99,7 @@ test('Basic (https with ssl agent)', t => { buildServer(handler, { secure: true }, ({ port, key, cert }, server) => { const connection = new Connection({ - host: { - href: `https://localhost:${port}`, - protocol: 'https:' - }, + host: new URL(`https://localhost:${port}`), ssl: { key, cert } }) connection.request({ @@ -144,10 +139,7 @@ test('Disable keep alive', t => { buildServer(handler, ({ port }, server) => { const connection = new Connection({ - host: { - href: `http://localhost:${port}`, - protocol: 'http:' - }, + host: new URL(`http://localhost:${port}`), agent: { keepAlive: false } }) connection.request({ @@ -178,17 +170,14 @@ test('Timeout support', t => { buildServer(handler, ({ port }, server) => { const connection = new Connection({ - host: { - href: `http://localhost:${port}`, - protocol: 'http:' - } + host: new URL(`http://localhost:${port}`) }) connection.request({ path: '/hello', method: 'GET', timeout: 500 }, (err, res) => { - t.ok(err.message, 'Request timed out') + t.ok(err instanceof TimeoutError) }) }) }) @@ -204,10 +193,7 @@ test('querystring', t => { buildServer(handler, ({ port }, server) => { const connection = new Connection({ - host: { - href: `http://localhost:${port}`, - protocol: 'http:' - } + host: new URL(`http://localhost:${port}`) }) connection.request({ path: '/hello', @@ -229,10 +215,7 @@ test('querystring', t => { buildServer(handler, ({ port }, server) => { const connection = new Connection({ - host: { - href: `http://localhost:${port}`, - protocol: 'http:' - } + host: new URL(`http://localhost:${port}`) }) connection.request({ path: '/hello', @@ -246,3 +229,148 @@ test('querystring', t => { t.end() }) + +test('Body request', t => { + t.plan(2) + + function handler (req, res) { + var payload = '' + req.setEncoding('utf8') + req.on('data', chunk => { payload += chunk }) + req.on('error', err => t.fail(err)) + req.on('end', () => { + t.strictEqual(payload, 'hello') + res.end('ok') + }) + } + + buildServer(handler, ({ port }, server) => { + const connection = new Connection({ + host: new URL(`http://localhost:${port}`) + }) + connection.request({ + path: '/hello', + method: 'POST', + body: 'hello' + }, (err, res) => { + t.error(err) + }) + }) +}) + +test('Should handle compression', t => { + t.test('gzip', t => { + t.plan(3) + + function handler (req, res) { + res.writeHead(200, { + 'Content-Type': 'application/json;utf=8', + 'Content-Encoding': 'gzip' + }) + intoStream(JSON.stringify({ hello: 'world' })) + .pipe(createGzip()) + .pipe(res) + } + + buildServer(handler, ({ port }, server) => { + const connection = new Connection({ + host: new URL(`http://localhost:${port}`) + }) + connection.request({ + path: '/hello', + method: 'GET' + }, (err, res) => { + t.error(err) + + t.match(res.headers, { + 'content-type': 'application/json;utf=8', + 'content-encoding': 'gzip' + }) + + var payload = '' + res.setEncoding('utf8') + res.on('data', chunk => { payload += chunk }) + res.on('error', err => t.fail(err)) + res.on('end', () => { + t.deepEqual(JSON.parse(payload), { hello: 'world' }) + }) + }) + }) + }) + + t.test('deflate', t => { + t.plan(3) + + function handler (req, res) { + res.writeHead(200, { + 'Content-Type': 'application/json;utf=8', + 'Content-Encoding': 'deflate' + }) + intoStream(JSON.stringify({ hello: 'world' })) + .pipe(createDeflate()) + .pipe(res) + } + + buildServer(handler, ({ port }, server) => { + const connection = new Connection({ + host: new URL(`http://localhost:${port}`) + }) + connection.request({ + path: '/hello', + method: 'GET' + }, (err, res) => { + t.error(err) + + t.match(res.headers, { + 'content-type': 'application/json;utf=8', + 'content-encoding': 'deflate' + }) + + var payload = '' + res.setEncoding('utf8') + res.on('data', chunk => { payload += chunk }) + res.on('error', err => t.fail(err)) + res.on('end', () => { + t.deepEqual(JSON.parse(payload), { hello: 'world' }) + }) + }) + }) + }) + + t.end() +}) + +test('Should not close a connection if there are open requests', t => { + t.plan(4) + + function handler (req, res) { + setTimeout(() => res.end('ok'), 1000) + } + + buildServer(handler, ({ port }, server) => { + const connection = new Connection({ + host: new URL(`http://localhost:${port}`) + }) + + setTimeout(() => { + t.strictEqual(connection._openRequests, 1) + connection.close() + }, 500) + + connection.request({ + path: '/hello', + method: 'GET' + }, (err, res) => { + t.error(err) + t.strictEqual(connection._openRequests, 0) + + var payload = '' + res.setEncoding('utf8') + res.on('data', chunk => { payload += chunk }) + res.on('error', err => t.fail(err)) + res.on('end', () => { + t.strictEqual(payload, 'ok') + }) + }) + }) +}) diff --git a/test/unit/selectors.test.js b/test/unit/selectors.test.js index 2f1f18502..4ce57b581 100644 --- a/test/unit/selectors.test.js +++ b/test/unit/selectors.test.js @@ -1,16 +1,16 @@ 'use strict' const { test } = require('tap') -const { RoundRobinSelector, RandomSelector } = require('../../lib/Selectors') +const { roundRobinSelector, randomSelector } = require('../../lib/ConnectionPool').internals test('RoundRobinSelector', t => { - const s = new RoundRobinSelector() + const selector = roundRobinSelector() const arr = [0, 1, 2, 3, 4, 5] t.plan(arr.length + 1) for (var i = 0; i <= arr.length; i++) { t.strictEqual( - s.select(arr), + selector(arr), i === arr.length ? arr[0] : arr[i] ) } @@ -18,7 +18,6 @@ test('RoundRobinSelector', t => { test('RandomSelector', t => { t.plan(1) - const s = new RandomSelector() const arr = [0, 1, 2, 3, 4, 5] - t.type(s.select(arr), 'number') + t.type(randomSelector(arr), 'number') }) diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index 3acc9e8ba..e0464456c 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -15,7 +15,6 @@ const { const ConnectionPool = require('../../lib/ConnectionPool') const Serializer = require('../../lib/Serializer') const Transport = require('../../lib/Transport') -const { RoundRobinSelector } = require('../../lib/Selectors') test('Basic', t => { t.plan(2) @@ -25,9 +24,7 @@ test('Basic', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new ConnectionPool() pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -69,9 +66,7 @@ test('Send POST', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new ConnectionPool() pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -126,9 +121,7 @@ test('Send POST (ndjson)', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new ConnectionPool() pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -160,9 +153,7 @@ test('Not JSON payload from server', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new ConnectionPool() pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -187,9 +178,7 @@ test('Not JSON payload from server', t => { test('NoLivingConnectionsError', t => { t.plan(1) - const pool = new ConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new ConnectionPool() const transport = new Transport({ emit: () => {}, @@ -211,9 +200,7 @@ test('NoLivingConnectionsError', t => { test('SerializationError', t => { t.plan(1) - const pool = new ConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new ConnectionPool() pool.addConnection('http://localhost:9200') const transport = new Transport({ @@ -245,9 +232,7 @@ test('DeserializationError', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new ConnectionPool() pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -287,9 +272,7 @@ test('TimeoutError (should call markDead on the failing connection)', t => { } buildServer(handler, ({ port }, server) => { - const pool = new CustomConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new CustomConnectionPool() pool.addConnection({ host: new URL(`http://localhost:${port}`), id: 'node1' @@ -326,9 +309,7 @@ test('ConnectionError (should call markDead on the failing connection)', t => { buildServer(() => {}, ({ port }, server) => { server.close() - const pool = new CustomConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new CustomConnectionPool() pool.addConnection({ host: new URL(`http://localhost:${port}`), id: 'node1' @@ -370,9 +351,7 @@ test('Retry mechanism', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new ConnectionPool() pool.addConnection([{ host: new URL(`http://localhost:${port}`), id: 'node1' @@ -420,9 +399,7 @@ test('Should call markAlive with a successful response', t => { } buildServer(handler, ({ port }, server) => { - const pool = new CustomConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new CustomConnectionPool() pool.addConnection({ host: new URL(`http://localhost:${port}`), id: 'node1' @@ -463,9 +440,7 @@ test('Should call resurrect on every request', t => { } buildServer(handler, ({ port }, server) => { - const pool = new CustomConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new CustomConnectionPool() pool.addConnection({ host: new URL(`http://localhost:${port}`), id: 'node1' @@ -502,9 +477,7 @@ test('Should return a request aborter utility', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new ConnectionPool() pool.addConnection({ host: new URL(`http://localhost:${port}`), id: 'node1' @@ -542,9 +515,7 @@ test('ResponseError', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new ConnectionPool() pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -578,9 +549,7 @@ test('Override requestTimeout', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new ConnectionPool() pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -635,9 +604,7 @@ test('sniff', t => { } buildServer(handler, ({ port }, server) => { - const pool = new CustomConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new CustomConnectionPool() pool.addConnection(`http://localhost:${port}`) // eslint-disable-next-line @@ -688,9 +655,7 @@ test('sniff', t => { } buildServer(handler, ({ port }, server) => { - const pool = new CustomConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new CustomConnectionPool() pool.addConnection(`http://localhost:${port}`) pool.addConnection(`http://localhost:${port}/other`) @@ -742,9 +707,7 @@ test('sniff', t => { } buildServer(handler, ({ port }, server) => { - const pool = new CustomConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new CustomConnectionPool() pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -783,9 +746,7 @@ test('sniff', t => { buildServer(() => {}, ({ port }, server) => { server.close() - const pool = new CustomConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new CustomConnectionPool() pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -828,9 +789,7 @@ test(`Should mark as dead connections where the statusCode is 502/3/4 } buildServer(handler, ({ port }, server) => { - const pool = new CustomConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new CustomConnectionPool() pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -885,9 +844,7 @@ test('Should retry the request if the statusCode is 502/3/4', t => { } buildServer(handler, ({ port }, server) => { - const pool = new CustomConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new CustomConnectionPool() pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -923,9 +880,7 @@ test('Ignore status code', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new ConnectionPool() pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -973,9 +928,7 @@ test('Should serialize the querystring', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new ConnectionPool() pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -1014,9 +967,7 @@ test('timeout option', t => { t.plan(1) buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new ConnectionPool() pool.addConnection({ host: new URL(`http://localhost:${port}`), id: 'node1' @@ -1045,9 +996,7 @@ test('timeout option', t => { t.plan(1) buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new ConnectionPool() pool.addConnection({ host: new URL(`http://localhost:${port}`), id: 'node1' @@ -1081,9 +1030,7 @@ test('timeout option', t => { t.plan(1) buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new ConnectionPool() pool.addConnection({ host: new URL(`http://localhost:${port}`), id: 'node1' @@ -1112,9 +1059,7 @@ test('timeout option', t => { t.plan(1) buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new ConnectionPool() pool.addConnection({ host: new URL(`http://localhost:${port}`), id: 'node1' @@ -1155,9 +1100,7 @@ test('Should cast to boolean HEAD request', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new ConnectionPool() pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -1189,9 +1132,7 @@ test('Should cast to boolean HEAD request', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new ConnectionPool() pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -1223,9 +1164,7 @@ test('Should cast to boolean HEAD request', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new ConnectionPool() pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -1256,9 +1195,7 @@ test('Should cast to boolean HEAD request', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ - selector: new RoundRobinSelector() - }) + const pool = new ConnectionPool() pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -1282,3 +1219,144 @@ test('Should cast to boolean HEAD request', t => { t.end() }) + +test('Suggest compression', t => { + t.plan(2) + function handler (req, res) { + t.match(req.headers, { + 'accept-encoding': 'gzip,deflate' + }) + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool() + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false, + suggestCompression: true + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, { body }) => { + t.error(err) + }) + }) +}) + +test('Warning header', t => { + t.test('Single warning', t => { + t.plan(3) + + const warn = '112 - "cache down" "Wed, 21 Oct 2015 07:28:00 GMT"' + function handler (req, res) { + res.setHeader('Content-Type', 'application/json;utf=8') + res.setHeader('Warning', warn) + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool() + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, { warnings }) => { + t.error(err) + t.deepEqual(warnings, [warn]) + warnings.forEach(w => t.type(w, 'string')) + }) + }) + }) + + t.test('Multiple warnings', t => { + t.plan(4) + + const warn1 = '112 - "cache down" "Wed, 21 Oct 2015 07:28:00 GMT"' + const warn2 = '199 agent "Error message" "2015-01-01"' + function handler (req, res) { + res.setHeader('Content-Type', 'application/json;utf=8') + res.setHeader('Warning', warn1 + ',' + warn2) + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool() + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, { warnings }) => { + t.error(err) + t.deepEqual(warnings, [warn1, warn2]) + warnings.forEach(w => t.type(w, 'string')) + }) + }) + }) + + t.test('No warnings', t => { + t.plan(2) + + function handler (req, res) { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool() + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, { warnings }) => { + t.error(err) + t.strictEqual(warnings, null) + }) + }) + }) + + t.end() +}) From 15e13b21902f2945237b0ac537a4ab1fa9349631 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 5 Nov 2018 19:22:46 +0100 Subject: [PATCH 028/172] Updated api generation script --- scripts/utils/genMain.js | 1 + scripts/utils/generate.js | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/utils/genMain.js b/scripts/utils/genMain.js index 324bd0ad7..7d6bd00c3 100644 --- a/scripts/utils/genMain.js +++ b/scripts/utils/genMain.js @@ -50,6 +50,7 @@ function genFactory (folder) { function ESAPI (opts) { assert(opts.makeRequest, 'Missing makeRequest function') assert(opts.ConfigurationError, 'Missing ConfigurationError class') + assert(opts.result, 'Missing default result object') const apis = ${apisStr} diff --git a/scripts/utils/generate.js b/scripts/utils/generate.js index cc2d1008e..e143919e4 100644 --- a/scripts/utils/generate.js +++ b/scripts/utils/generate.js @@ -116,7 +116,7 @@ function generate (spec, common) { if (params.headers != null && typeof params.headers !== 'object') { return callback( new ConfigurationError(\`Headers should be an object, instead got: \${typeof params.headers}\`), - { body: null, headers: null, statusCode: null } + result ) } @@ -148,7 +148,7 @@ function generate (spec, common) { function build${name[0].toUpperCase() + name.slice(1)} (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError } = opts + const { makeRequest, ConfigurationError, result } = opts ${generateDocumentation(spec[api], api)} return ${code} } @@ -181,7 +181,7 @@ function generate (spec, common) { if (params['${param}'] == null) { return callback( new ConfigurationError('Missing required parameter: ${param}'), - { body: null, headers: null, statusCode: null } + result ) } ` @@ -191,7 +191,7 @@ function generate (spec, common) { if (params['${param}'] == null && params['${camelCased}'] == null) { return callback( new ConfigurationError('Missing required parameter: ${param} or ${camelCased}'), - { body: null, headers: null, statusCode: null } + result ) } ` @@ -204,7 +204,7 @@ function generate (spec, common) { if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), - { body: null, headers: null, statusCode: null } + result ) } ` @@ -416,7 +416,7 @@ function genUrlValidation (paths, api) { code += `)) { return callback( new ConfigurationError('Missing required parameter of the url: ${params.join(', ')}'), - { body: null, headers: null, statusCode: null } + result )` }) From c6b8665edd6d120b00371518bde354d7ae9d9837 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 5 Nov 2018 19:23:51 +0100 Subject: [PATCH 029/172] Updated dependencies --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c67f1e845..fcb3feaa3 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ }, "devDependencies": { "dedent": "^0.7.0", + "into-stream": "^4.0.0", "js-yaml": "^3.12.0", "minimist": "^1.2.0", "ora": "^3.0.0", @@ -46,9 +47,9 @@ }, "dependencies": { "debug": "^4.1.0", + "decompress-response": "^3.3.0", "ms": "^2.1.1", - "once": "^1.4.0", - "simple-get": "^3.0.3" + "once": "^1.4.0" }, "license": "Apache-2.0", "repository": { From e97f66b0c3d987d93eba9e6c65916c700c23270e Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 8 Nov 2018 19:34:12 +0100 Subject: [PATCH 030/172] WIP: initial prototype - Updated ConnectionPool internals - Added ConnectionPool.update api - Experimental: return http response in transform --- lib/ConnectionPool.js | 89 ++++++++++++++++++++++++------------------- lib/Transport.js | 12 ++++-- 2 files changed, 59 insertions(+), 42 deletions(-) diff --git a/lib/ConnectionPool.js b/lib/ConnectionPool.js index 2ed3cc9f0..fdf48e96e 100644 --- a/lib/ConnectionPool.js +++ b/lib/ConnectionPool.js @@ -9,9 +9,6 @@ const noop = () => {} class ConnectionPool { constructor (opts = {}) { this.connections = new Map() - // TODO: do we need those queue? (or find a better use) - // can we use just the connections map? - this.alive = [] this.dead = [] this.selector = opts.selector this._ssl = opts.ssl @@ -28,7 +25,6 @@ class ConnectionPool { this.pingTimeout = opts.pingTimeout this.randomizeHost = opts.randomizeHost === true this.nodeFilter = opts.nodeFilter || defaultNodeFilter - this.nodeWeighter = opts.nodeWeighter || noop if (typeof opts.nodeSelector === 'function') { this.nodeSelector = opts.nodeSelector @@ -50,29 +46,25 @@ class ConnectionPool { /** * Marks a connection as 'alive'. - * If needed moves the connection from the dead list - * to the alive list and then resets the `deadCount`. + * If needed removes the connection from the dead list + * and then resets the `deadCount`. * * @param {object} connection */ markAlive (connection) { const { id } = connection debug(`Marking as 'alive' connection '${id}'`) - if (this.alive.indexOf(id) === -1) { - this.alive.push(id) - const index = this.dead.indexOf(id) - if (index > -1) this.dead.splice(index, 1) - } + const index = this.dead.indexOf(id) + if (index > -1) this.dead.splice(index, 1) connection.status = Connection.statuses.ALIVE connection.deadCount = 0 connection.resurrectTimeout = 0 - this.connections.set(id, connection) } /** * Marks a connection as 'dead'. - * If needed moves the connection from the alive list - * to the dead list and then increments the `deadCount`. + * If needed adds the connection to the dead list + * and then increments the `deadCount`. * * @param {object} connection */ @@ -81,8 +73,6 @@ class ConnectionPool { debug(`Marking as 'dead' connection '${id}'`) if (this.dead.indexOf(id) === -1) { this.dead.push(id) - const index = this.alive.indexOf(id) - if (index > -1) this.alive.splice(index, 1) } connection.status = Connection.statuses.DEAD connection.deadCount++ @@ -97,7 +87,6 @@ class ConnectionPool { this.resurrectTimeoutCutoff ) ) - this.connections.set(id, connection) // sort the dead list in ascending order // based on the resurrectTimeout @@ -152,10 +141,8 @@ class ConnectionPool { // optimistic strategy } else { debug(`Resurrect: optimistic resurrection for connection '${id}'`) - this.alive.push(id) this.dead.splice(this.dead.indexOf(id), 1) connection.status = Connection.statuses.ALIVE - this.connections.set(id, connection) // eslint-disable-next-line standard/no-callback-literal callback(true, connection) } @@ -164,21 +151,15 @@ class ConnectionPool { /** * Returns an alive connection if present, * otherwise returns null. - * By default it does not apply a weighter to the node list, - * and filters the `master` only nodes + * By default it filters the `master` only nodes. * It uses the selector to choose which * connection return. * - * @param {object} options (weighter, filter and selector) + * @param {object} options (filter and selector) * @returns {object|null} connection */ getConnection (opts = {}) { - if (this.alive.length === 0) { - return null - } - const filter = opts.filter || this.nodeFilter - const weighter = opts.weighter || this.nodeWeighter const selector = opts.selector || this.nodeSelector // TODO: can we cache this? @@ -190,7 +171,8 @@ class ConnectionPool { } } } - connections.sort(weighter) + + if (connections.length === 0) return null return selector(connections) } @@ -219,10 +201,6 @@ class ConnectionPool { throw new Error(`Connection with id '${connection.id}' is already present`) } this.connections.set(connection.id, connection) - this.alive.push(connection.id) - if (this.randomizeHost === true) { - this.alive = shuffleArray(this.alive) - } return connection } @@ -239,8 +217,6 @@ class ConnectionPool { this.connections.delete(id) var index = this.dead.indexOf(id) if (index > -1) this.dead.splice(index, 1) - index = this.alive.indexOf(id) - if (index > -1) this.alive.splice(index, 1) return this } @@ -255,11 +231,46 @@ class ConnectionPool { connection.close() }) this.connections = new Map() - this.alive = [] this.dead = [] return this } + /** + * Update the ConnectionPool with new connections. + * + * @param {array} array of connections + * @returns {ConnectionPool} + */ + update (connections) { + debug('Updating the connection pool') + for (var i = 0; i < connections.length; i++) { + const connection = connections[i] + // if we already have a given connection in the pool + // we check its status, if is 'alive', we do nothing, + // if 'dead' we mark it as alive, we do not close the old + // one to avoid socket issues + if (this.connections.has(connection.id) === true) { + debug(`The connection with id '${connection.id}' is already present`) + const oldConnection = this.connections.get(connection.id) + if (oldConnection.status === Connection.statuses.DEAD) { + this.markAlive(oldConnection) + } + } else { + this.addConnection(connection) + } + } + + const ids = connections.map(c => c.id) + // remove all the dead connections and old connections + for (const connection of this.connections.values()) { + if (ids.indexOf(connection.id) === -1) { + this.removeConnection(connection) + } + } + + return this + } + /** * Transforms the nodes objects to a host object. * @@ -311,10 +322,10 @@ ConnectionPool.resurrectStrategies = { } // https://gist.github.com/guilhermepontes/17ae0cc71fa2b13ea8c20c94c5c35dc4 -const shuffleArray = arr => arr - .map(a => [Math.random(), a]) - .sort((a, b) => a[0] - b[0]) - .map(a => a[1]) +// const shuffleArray = arr => arr +// .map(a => [Math.random(), a]) +// .sort((a, b) => a[0] - b[0]) +// .map(a => a[1]) function defaultNodeFilter (node) { // avoid master only nodes diff --git a/lib/Transport.js b/lib/Transport.js index 0673df7e5..e957e94dc 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -34,6 +34,7 @@ class Transport { } } + // TODO: should be able to send a stream of json data request (params, callback) { callback = once(callback) const result = { body: null, statusCode: null, headers: null, warnings: null } @@ -115,6 +116,13 @@ class Transport { result.warnings = headers['warning'].split(/(?!\B"[^"]*),(?![^"]*"\B)/) } + // TODO: expose `asStream` option for returning the + // body already parsed? + if (params.asHttpResponse === true) { + callback(null, response) + return + } + var payload = '' // collect the payload response.setEncoding('utf8') @@ -215,9 +223,7 @@ class Transport { debug('Sniffing ended successfully', body) const hosts = this.connectionPool.nodesToHost(body.nodes) - this.connectionPool - .empty() - .addConnection(hosts) + this.connectionPool.update(hosts) callback(null, hosts) }) From 08e9ff398f3fb8be9c40c28a65e31347b43108a3 Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 8 Nov 2018 19:35:51 +0100 Subject: [PATCH 031/172] API generation --- api/api/xpack.graph.explore.js | 98 ++ api/api/xpack.info.js | 92 ++ api/api/xpack.license.delete.js | 91 ++ api/api/xpack.license.get.js | 92 ++ api/api/xpack.license.get_basic_status.js | 91 ++ api/api/xpack.license.get_trial_status.js | 91 ++ api/api/xpack.license.post.js | 85 ++ api/api/xpack.license.post_start_basic.js | 92 ++ api/api/xpack.license.post_start_trial.js | 95 ++ api/api/xpack.migration.deprecations.js | 92 ++ api/api/xpack.migration.get_assistance.js | 91 ++ api/api/xpack.migration.upgrade.js | 93 ++ api/api/xpack.ml.close_job.js | 99 ++ api/api/xpack.ml.delete_calendar.js | 98 ++ api/api/xpack.ml.delete_calendar_event.js | 113 +++ api/api/xpack.ml.delete_calendar_job.js | 113 +++ api/api/xpack.ml.delete_datafeed.js | 99 ++ api/api/xpack.ml.delete_expired_data.js | 91 ++ api/api/xpack.ml.delete_filter.js | 98 ++ api/api/xpack.ml.delete_job.js | 99 ++ api/api/xpack.ml.delete_model_snapshot.js | 113 +++ api/api/xpack.ml.flush_job.js | 106 ++ api/api/xpack.ml.forecast.js | 102 ++ api/api/xpack.ml.get_buckets.js | 127 +++ api/api/xpack.ml.get_calendar_events.js | 111 ++ api/api/xpack.ml.get_calendars.js | 96 ++ api/api/xpack.ml.get_categories.js | 100 ++ api/api/xpack.ml.get_datafeed_stats.js | 93 ++ api/api/xpack.ml.get_datafeeds.js | 93 ++ api/api/xpack.ml.get_filters.js | 96 ++ api/api/xpack.ml.get_influencers.js | 115 +++ api/api/xpack.ml.get_job_stats.js | 93 ++ api/api/xpack.ml.get_jobs.js | 93 ++ api/api/xpack.ml.get_model_snapshots.js | 118 +++ api/api/xpack.ml.get_overall_buckets.js | 112 +++ api/api/xpack.ml.get_records.js | 115 +++ api/api/xpack.ml.info.js | 83 ++ api/api/xpack.ml.open_job.js | 100 ++ api/api/xpack.ml.post_calendar_events.js | 99 ++ api/api/xpack.ml.post_data.js | 103 ++ api/api/xpack.ml.preview_datafeed.js | 98 ++ api/api/xpack.ml.put_calendar.js | 93 ++ api/api/xpack.ml.put_calendar_job.js | 113 +++ api/api/xpack.ml.put_datafeed.js | 99 ++ api/api/xpack.ml.put_filter.js | 99 ++ api/api/xpack.ml.put_job.js | 99 ++ api/api/xpack.ml.revert_model_snapshot.js | 109 ++ api/api/xpack.ml.start_datafeed.js | 100 ++ api/api/xpack.ml.stop_datafeed.js | 99 ++ api/api/xpack.ml.update_datafeed.js | 99 ++ api/api/xpack.ml.update_filter.js | 99 ++ api/api/xpack.ml.update_job.js | 99 ++ api/api/xpack.ml.update_model_snapshot.js | 114 +++ api/api/xpack.ml.validate.js | 92 ++ api/api/xpack.ml.validate_detector.js | 92 ++ api/api/xpack.monitoring.bulk.js | 100 ++ api/api/xpack.rollup.delete_job.js | 92 ++ api/api/xpack.rollup.get_jobs.js | 84 ++ api/api/xpack.rollup.get_rollup_caps.js | 84 ++ api/api/xpack.rollup.get_rollup_index_caps.js | 92 ++ api/api/xpack.rollup.put_job.js | 99 ++ api/api/xpack.rollup.rollup_search.js | 110 ++ api/api/xpack.rollup.start_job.js | 92 ++ api/api/xpack.rollup.stop_job.js | 92 ++ api/api/xpack.security.authenticate.js | 91 ++ api/api/xpack.security.change_password.js | 94 ++ api/api/xpack.security.clear_cached_realms.js | 99 ++ api/api/xpack.security.clear_cached_roles.js | 98 ++ api/api/xpack.security.delete_privileges.js | 114 +++ api/api/xpack.security.delete_role.js | 99 ++ api/api/xpack.security.delete_role_mapping.js | 99 ++ api/api/xpack.security.delete_user.js | 99 ++ api/api/xpack.security.disable_user.js | 93 ++ api/api/xpack.security.enable_user.js | 93 ++ api/api/xpack.security.get_privileges.js | 101 ++ api/api/xpack.security.get_role.js | 92 ++ api/api/xpack.security.get_role_mapping.js | 92 ++ api/api/xpack.security.get_token.js | 92 ++ api/api/xpack.security.get_user.js | 92 ++ api/api/xpack.security.has_privileges.js | 93 ++ api/api/xpack.security.invalidate_token.js | 92 ++ api/api/xpack.security.put_privileges.js | 93 ++ api/api/xpack.security.put_role.js | 100 ++ api/api/xpack.security.put_role_mapping.js | 100 ++ api/api/xpack.security.put_user.js | 100 ++ api/api/xpack.sql.clear_cursor.js | 92 ++ api/api/xpack.sql.query.js | 93 ++ api/api/xpack.sql.translate.js | 92 ++ api/api/xpack.ssl.certificates.js | 91 ++ api/api/xpack.usage.js | 92 ++ api/api/xpack.watcher.ack_watch.js | 108 ++ api/api/xpack.watcher.activate_watch.js | 99 ++ api/api/xpack.watcher.deactivate_watch.js | 99 ++ api/api/xpack.watcher.delete_watch.js | 99 ++ api/api/xpack.watcher.execute_watch.js | 86 ++ api/api/xpack.watcher.get_watch.js | 98 ++ api/api/xpack.watcher.put_watch.js | 100 ++ api/api/xpack.watcher.restart.js | 91 ++ api/api/xpack.watcher.start.js | 91 ++ api/api/xpack.watcher.stats.js | 96 ++ api/api/xpack.watcher.stop.js | 91 ++ api/index.js | 950 +++++++++++------- 102 files changed, 10474 insertions(+), 350 deletions(-) create mode 100644 api/api/xpack.graph.explore.js create mode 100644 api/api/xpack.info.js create mode 100644 api/api/xpack.license.delete.js create mode 100644 api/api/xpack.license.get.js create mode 100644 api/api/xpack.license.get_basic_status.js create mode 100644 api/api/xpack.license.get_trial_status.js create mode 100644 api/api/xpack.license.post.js create mode 100644 api/api/xpack.license.post_start_basic.js create mode 100644 api/api/xpack.license.post_start_trial.js create mode 100644 api/api/xpack.migration.deprecations.js create mode 100644 api/api/xpack.migration.get_assistance.js create mode 100644 api/api/xpack.migration.upgrade.js create mode 100644 api/api/xpack.ml.close_job.js create mode 100644 api/api/xpack.ml.delete_calendar.js create mode 100644 api/api/xpack.ml.delete_calendar_event.js create mode 100644 api/api/xpack.ml.delete_calendar_job.js create mode 100644 api/api/xpack.ml.delete_datafeed.js create mode 100644 api/api/xpack.ml.delete_expired_data.js create mode 100644 api/api/xpack.ml.delete_filter.js create mode 100644 api/api/xpack.ml.delete_job.js create mode 100644 api/api/xpack.ml.delete_model_snapshot.js create mode 100644 api/api/xpack.ml.flush_job.js create mode 100644 api/api/xpack.ml.forecast.js create mode 100644 api/api/xpack.ml.get_buckets.js create mode 100644 api/api/xpack.ml.get_calendar_events.js create mode 100644 api/api/xpack.ml.get_calendars.js create mode 100644 api/api/xpack.ml.get_categories.js create mode 100644 api/api/xpack.ml.get_datafeed_stats.js create mode 100644 api/api/xpack.ml.get_datafeeds.js create mode 100644 api/api/xpack.ml.get_filters.js create mode 100644 api/api/xpack.ml.get_influencers.js create mode 100644 api/api/xpack.ml.get_job_stats.js create mode 100644 api/api/xpack.ml.get_jobs.js create mode 100644 api/api/xpack.ml.get_model_snapshots.js create mode 100644 api/api/xpack.ml.get_overall_buckets.js create mode 100644 api/api/xpack.ml.get_records.js create mode 100644 api/api/xpack.ml.info.js create mode 100644 api/api/xpack.ml.open_job.js create mode 100644 api/api/xpack.ml.post_calendar_events.js create mode 100644 api/api/xpack.ml.post_data.js create mode 100644 api/api/xpack.ml.preview_datafeed.js create mode 100644 api/api/xpack.ml.put_calendar.js create mode 100644 api/api/xpack.ml.put_calendar_job.js create mode 100644 api/api/xpack.ml.put_datafeed.js create mode 100644 api/api/xpack.ml.put_filter.js create mode 100644 api/api/xpack.ml.put_job.js create mode 100644 api/api/xpack.ml.revert_model_snapshot.js create mode 100644 api/api/xpack.ml.start_datafeed.js create mode 100644 api/api/xpack.ml.stop_datafeed.js create mode 100644 api/api/xpack.ml.update_datafeed.js create mode 100644 api/api/xpack.ml.update_filter.js create mode 100644 api/api/xpack.ml.update_job.js create mode 100644 api/api/xpack.ml.update_model_snapshot.js create mode 100644 api/api/xpack.ml.validate.js create mode 100644 api/api/xpack.ml.validate_detector.js create mode 100644 api/api/xpack.monitoring.bulk.js create mode 100644 api/api/xpack.rollup.delete_job.js create mode 100644 api/api/xpack.rollup.get_jobs.js create mode 100644 api/api/xpack.rollup.get_rollup_caps.js create mode 100644 api/api/xpack.rollup.get_rollup_index_caps.js create mode 100644 api/api/xpack.rollup.put_job.js create mode 100644 api/api/xpack.rollup.rollup_search.js create mode 100644 api/api/xpack.rollup.start_job.js create mode 100644 api/api/xpack.rollup.stop_job.js create mode 100644 api/api/xpack.security.authenticate.js create mode 100644 api/api/xpack.security.change_password.js create mode 100644 api/api/xpack.security.clear_cached_realms.js create mode 100644 api/api/xpack.security.clear_cached_roles.js create mode 100644 api/api/xpack.security.delete_privileges.js create mode 100644 api/api/xpack.security.delete_role.js create mode 100644 api/api/xpack.security.delete_role_mapping.js create mode 100644 api/api/xpack.security.delete_user.js create mode 100644 api/api/xpack.security.disable_user.js create mode 100644 api/api/xpack.security.enable_user.js create mode 100644 api/api/xpack.security.get_privileges.js create mode 100644 api/api/xpack.security.get_role.js create mode 100644 api/api/xpack.security.get_role_mapping.js create mode 100644 api/api/xpack.security.get_token.js create mode 100644 api/api/xpack.security.get_user.js create mode 100644 api/api/xpack.security.has_privileges.js create mode 100644 api/api/xpack.security.invalidate_token.js create mode 100644 api/api/xpack.security.put_privileges.js create mode 100644 api/api/xpack.security.put_role.js create mode 100644 api/api/xpack.security.put_role_mapping.js create mode 100644 api/api/xpack.security.put_user.js create mode 100644 api/api/xpack.sql.clear_cursor.js create mode 100644 api/api/xpack.sql.query.js create mode 100644 api/api/xpack.sql.translate.js create mode 100644 api/api/xpack.ssl.certificates.js create mode 100644 api/api/xpack.usage.js create mode 100644 api/api/xpack.watcher.ack_watch.js create mode 100644 api/api/xpack.watcher.activate_watch.js create mode 100644 api/api/xpack.watcher.deactivate_watch.js create mode 100644 api/api/xpack.watcher.delete_watch.js create mode 100644 api/api/xpack.watcher.execute_watch.js create mode 100644 api/api/xpack.watcher.get_watch.js create mode 100644 api/api/xpack.watcher.put_watch.js create mode 100644 api/api/xpack.watcher.restart.js create mode 100644 api/api/xpack.watcher.start.js create mode 100644 api/api/xpack.watcher.stats.js create mode 100644 api/api/xpack.watcher.stop.js diff --git a/api/api/xpack.graph.explore.js b/api/api/xpack.graph.explore.js new file mode 100644 index 000000000..b8d593eb9 --- /dev/null +++ b/api/api/xpack.graph.explore.js @@ -0,0 +1,98 @@ +'use strict' + +function buildXpackGraphExplore (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.graph.explore](https://www.elastic.co/guide/en/elasticsearch/reference/current/graph-explore-api.html) request + * + * @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types + * @param {string} routing - Specific routing value + * @param {time} timeout - Explicit operation timeout + * @param {object} body - Graph Query DSL + */ + return function xpackGraphExplore (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackGraphExplore(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'routing', + 'timeout' + ] + const acceptedQuerystringCamelCased = [ + 'routing', + 'timeout' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], '_xpack', 'graph', '_explore'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackGraphExplore diff --git a/api/api/xpack.info.js b/api/api/xpack.info.js new file mode 100644 index 000000000..a70a56199 --- /dev/null +++ b/api/api/xpack.info.js @@ -0,0 +1,92 @@ +'use strict' + +function buildXpackInfo (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.info](https://www.elastic.co/guide/en/elasticsearch/reference/current/info-api.html) request + * + * @param {list} categories - Comma-separated list of info categories. Can be any of: build, license, features + */ + return function xpackInfo (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackInfo(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'categories' + ] + const acceptedQuerystringCamelCased = [ + 'categories' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackInfo diff --git a/api/api/xpack.license.delete.js b/api/api/xpack.license.delete.js new file mode 100644 index 000000000..426fed0da --- /dev/null +++ b/api/api/xpack.license.delete.js @@ -0,0 +1,91 @@ +'use strict' + +function buildXpackLicenseDelete (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.license.delete](https://www.elastic.co/guide/en/x-pack/current/license-management.html) request + * + */ + return function xpackLicenseDelete (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackLicenseDelete(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'license'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackLicenseDelete diff --git a/api/api/xpack.license.get.js b/api/api/xpack.license.get.js new file mode 100644 index 000000000..d0fd1956e --- /dev/null +++ b/api/api/xpack.license.get.js @@ -0,0 +1,92 @@ +'use strict' + +function buildXpackLicenseGet (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.license.get](https://www.elastic.co/guide/en/x-pack/current/license-management.html) request + * + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + */ + return function xpackLicenseGet (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackLicenseGet(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'local' + ] + const acceptedQuerystringCamelCased = [ + 'local' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'license'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackLicenseGet diff --git a/api/api/xpack.license.get_basic_status.js b/api/api/xpack.license.get_basic_status.js new file mode 100644 index 000000000..815d66869 --- /dev/null +++ b/api/api/xpack.license.get_basic_status.js @@ -0,0 +1,91 @@ +'use strict' + +function buildXpackLicenseGetBasicStatus (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.license.get_basic_status](https://www.elastic.co/guide/en/x-pack/current/license-management.html) request + * + */ + return function xpackLicenseGetBasicStatus (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackLicenseGetBasicStatus(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'license', 'basic_status'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackLicenseGetBasicStatus diff --git a/api/api/xpack.license.get_trial_status.js b/api/api/xpack.license.get_trial_status.js new file mode 100644 index 000000000..107541302 --- /dev/null +++ b/api/api/xpack.license.get_trial_status.js @@ -0,0 +1,91 @@ +'use strict' + +function buildXpackLicenseGetTrialStatus (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.license.get_trial_status](https://www.elastic.co/guide/en/x-pack/current/license-management.html) request + * + */ + return function xpackLicenseGetTrialStatus (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackLicenseGetTrialStatus(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'license', 'trial_status'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackLicenseGetTrialStatus diff --git a/api/api/xpack.license.post.js b/api/api/xpack.license.post.js new file mode 100644 index 000000000..7515db686 --- /dev/null +++ b/api/api/xpack.license.post.js @@ -0,0 +1,85 @@ +'use strict' + +function buildXpackLicensePost (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.license.post](https://www.elastic.co/guide/en/x-pack/current/license-management.html) request + * + * @param {boolean} acknowledge - whether the user has acknowledged acknowledge messages (default: false) + * @param {object} body - licenses to be installed + */ + return function xpackLicensePost (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackLicensePost(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'acknowledge' + ] + const acceptedQuerystringCamelCased = [ + 'acknowledge' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'license'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackLicensePost diff --git a/api/api/xpack.license.post_start_basic.js b/api/api/xpack.license.post_start_basic.js new file mode 100644 index 000000000..969690525 --- /dev/null +++ b/api/api/xpack.license.post_start_basic.js @@ -0,0 +1,92 @@ +'use strict' + +function buildXpackLicensePostStartBasic (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.license.post_start_basic](https://www.elastic.co/guide/en/x-pack/current/license-management.html) request + * + * @param {boolean} acknowledge - whether the user has acknowledged acknowledge messages (default: false) + */ + return function xpackLicensePostStartBasic (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackLicensePostStartBasic(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'acknowledge' + ] + const acceptedQuerystringCamelCased = [ + 'acknowledge' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'license', 'start_basic'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackLicensePostStartBasic diff --git a/api/api/xpack.license.post_start_trial.js b/api/api/xpack.license.post_start_trial.js new file mode 100644 index 000000000..43ae9b6f3 --- /dev/null +++ b/api/api/xpack.license.post_start_trial.js @@ -0,0 +1,95 @@ +'use strict' + +function buildXpackLicensePostStartTrial (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.license.post_start_trial](https://www.elastic.co/guide/en/x-pack/current/license-management.html) request + * + * @param {string} type - The type of trial license to generate (default: "trial") + * @param {boolean} acknowledge - whether the user has acknowledged acknowledge messages (default: false) + */ + return function xpackLicensePostStartTrial (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackLicensePostStartTrial(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'type', + 'acknowledge' + ] + const acceptedQuerystringCamelCased = [ + 'type', + 'acknowledge' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'license', 'start_trial'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackLicensePostStartTrial diff --git a/api/api/xpack.migration.deprecations.js b/api/api/xpack.migration.deprecations.js new file mode 100644 index 000000000..a507a9bd7 --- /dev/null +++ b/api/api/xpack.migration.deprecations.js @@ -0,0 +1,92 @@ +'use strict' + +function buildXpackMigrationDeprecations (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.migration.deprecations](http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html) request + * + * @param {string} index - Index pattern + */ + return function xpackMigrationDeprecations (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMigrationDeprecations(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_xpack', 'migration', 'deprecations'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMigrationDeprecations diff --git a/api/api/xpack.migration.get_assistance.js b/api/api/xpack.migration.get_assistance.js new file mode 100644 index 000000000..be8fddaac --- /dev/null +++ b/api/api/xpack.migration.get_assistance.js @@ -0,0 +1,91 @@ +'use strict' + +function buildXpackMigrationGetAssistance (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.migration.get_assistance](https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-assistance.html) request + * + * @param {list} index - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + * @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} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + */ + return function xpackMigrationGetAssistance (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMigrationGetAssistance(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'allow_no_indices', + 'expand_wildcards', + 'ignore_unavailable' + ] + const acceptedQuerystringCamelCased = [ + 'allowNoIndices', + 'expandWildcards', + 'ignoreUnavailable' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'migration', 'assistance', params['index']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMigrationGetAssistance diff --git a/api/api/xpack.migration.upgrade.js b/api/api/xpack.migration.upgrade.js new file mode 100644 index 000000000..555395a99 --- /dev/null +++ b/api/api/xpack.migration.upgrade.js @@ -0,0 +1,93 @@ +'use strict' + +function buildXpackMigrationUpgrade (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.migration.upgrade](https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-upgrade.html) request + * + * @param {string} index - The name of the index + * @param {boolean} wait_for_completion - Should the request block until the upgrade operation is completed + */ + return function xpackMigrationUpgrade (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMigrationUpgrade(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'wait_for_completion' + ] + const acceptedQuerystringCamelCased = [ + 'waitForCompletion' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'migration', 'upgrade', params['index']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMigrationUpgrade diff --git a/api/api/xpack.ml.close_job.js b/api/api/xpack.ml.close_job.js new file mode 100644 index 000000000..ea7393029 --- /dev/null +++ b/api/api/xpack.ml.close_job.js @@ -0,0 +1,99 @@ +'use strict' + +function buildXpackMlCloseJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.close_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-close-job.html) request + * + * @param {string} job_id - The name of the job to close + * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + * @param {boolean} force - True if the job should be forcefully closed + * @param {time} timeout - Controls the time to wait until a job has closed. Default to 30 minutes + */ + return function xpackMlCloseJob (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlCloseJob(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: job_id or jobId'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'allow_no_jobs', + 'force', + 'timeout' + ] + const acceptedQuerystringCamelCased = [ + 'allowNoJobs', + 'force', + 'timeout' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_close'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlCloseJob diff --git a/api/api/xpack.ml.delete_calendar.js b/api/api/xpack.ml.delete_calendar.js new file mode 100644 index 000000000..56aad8467 --- /dev/null +++ b/api/api/xpack.ml.delete_calendar.js @@ -0,0 +1,98 @@ +'use strict' + +function buildXpackMlDeleteCalendar (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.delete_calendar](undefined) request + * + * @param {string} calendar_id - The ID of the calendar to delete + */ + return function xpackMlDeleteCalendar (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlDeleteCalendar(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: calendar_id or calendarId'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlDeleteCalendar diff --git a/api/api/xpack.ml.delete_calendar_event.js b/api/api/xpack.ml.delete_calendar_event.js new file mode 100644 index 000000000..32e06da23 --- /dev/null +++ b/api/api/xpack.ml.delete_calendar_event.js @@ -0,0 +1,113 @@ +'use strict' + +function buildXpackMlDeleteCalendarEvent (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.delete_calendar_event](undefined) request + * + * @param {string} calendar_id - The ID of the calendar to modify + * @param {string} event_id - The ID of the event to remove from the calendar + */ + return function xpackMlDeleteCalendarEvent (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlDeleteCalendarEvent(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: calendar_id or calendarId'), + result + ) + } + if (params['event_id'] == null && params['eventId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: event_id or eventId'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // check required url components + if ((params['event_id'] != null || params['eventId'] != null) && ((params['calendar_id'] == null || params['calendarId']))) { + return callback( + new ConfigurationError('Missing required parameter of the url: calendar_id'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId'], 'events', params['event_id'] || params['eventId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlDeleteCalendarEvent diff --git a/api/api/xpack.ml.delete_calendar_job.js b/api/api/xpack.ml.delete_calendar_job.js new file mode 100644 index 000000000..635366ec2 --- /dev/null +++ b/api/api/xpack.ml.delete_calendar_job.js @@ -0,0 +1,113 @@ +'use strict' + +function buildXpackMlDeleteCalendarJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.delete_calendar_job](undefined) request + * + * @param {string} calendar_id - The ID of the calendar to modify + * @param {string} job_id - The ID of the job to remove from the calendar + */ + return function xpackMlDeleteCalendarJob (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlDeleteCalendarJob(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: calendar_id or calendarId'), + result + ) + } + if (params['job_id'] == null && params['jobId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: job_id or jobId'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // check required url components + if ((params['job_id'] != null || params['jobId'] != null) && ((params['calendar_id'] == null || params['calendarId']))) { + return callback( + new ConfigurationError('Missing required parameter of the url: calendar_id'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId'], 'jobs', params['job_id'] || params['jobId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlDeleteCalendarJob diff --git a/api/api/xpack.ml.delete_datafeed.js b/api/api/xpack.ml.delete_datafeed.js new file mode 100644 index 000000000..1e9b79b23 --- /dev/null +++ b/api/api/xpack.ml.delete_datafeed.js @@ -0,0 +1,99 @@ +'use strict' + +function buildXpackMlDeleteDatafeed (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.delete_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html) request + * + * @param {string} datafeed_id - The ID of the datafeed to delete + * @param {boolean} force - True if the datafeed should be forcefully deleted + */ + return function xpackMlDeleteDatafeed (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlDeleteDatafeed(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: datafeed_id or datafeedId'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'force' + ] + const acceptedQuerystringCamelCased = [ + 'force' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlDeleteDatafeed diff --git a/api/api/xpack.ml.delete_expired_data.js b/api/api/xpack.ml.delete_expired_data.js new file mode 100644 index 000000000..245ab4209 --- /dev/null +++ b/api/api/xpack.ml.delete_expired_data.js @@ -0,0 +1,91 @@ +'use strict' + +function buildXpackMlDeleteExpiredData (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.delete_expired_data](undefined) request + * + */ + return function xpackMlDeleteExpiredData (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlDeleteExpiredData(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', '_delete_expired_data'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlDeleteExpiredData diff --git a/api/api/xpack.ml.delete_filter.js b/api/api/xpack.ml.delete_filter.js new file mode 100644 index 000000000..5bb5c6bfc --- /dev/null +++ b/api/api/xpack.ml.delete_filter.js @@ -0,0 +1,98 @@ +'use strict' + +function buildXpackMlDeleteFilter (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.delete_filter](undefined) request + * + * @param {string} filter_id - The ID of the filter to delete + */ + return function xpackMlDeleteFilter (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlDeleteFilter(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['filter_id'] == null && params['filterId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: filter_id or filterId'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'filters', params['filter_id'] || params['filterId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlDeleteFilter diff --git a/api/api/xpack.ml.delete_job.js b/api/api/xpack.ml.delete_job.js new file mode 100644 index 000000000..43acbbcf1 --- /dev/null +++ b/api/api/xpack.ml.delete_job.js @@ -0,0 +1,99 @@ +'use strict' + +function buildXpackMlDeleteJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.delete_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html) request + * + * @param {string} job_id - The ID of the job to delete + * @param {boolean} force - True if the job should be forcefully deleted + */ + return function xpackMlDeleteJob (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlDeleteJob(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: job_id or jobId'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'force' + ] + const acceptedQuerystringCamelCased = [ + 'force' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlDeleteJob diff --git a/api/api/xpack.ml.delete_model_snapshot.js b/api/api/xpack.ml.delete_model_snapshot.js new file mode 100644 index 000000000..668838173 --- /dev/null +++ b/api/api/xpack.ml.delete_model_snapshot.js @@ -0,0 +1,113 @@ +'use strict' + +function buildXpackMlDeleteModelSnapshot (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.delete_model_snapshot](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-snapshot.html) request + * + * @param {string} job_id - The ID of the job to fetch + * @param {string} snapshot_id - The ID of the snapshot to delete + */ + return function xpackMlDeleteModelSnapshot (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlDeleteModelSnapshot(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: job_id or jobId'), + result + ) + } + if (params['snapshot_id'] == null && params['snapshotId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: snapshot_id or snapshotId'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // check required url components + if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null || params['jobId']))) { + return callback( + new ConfigurationError('Missing required parameter of the url: job_id'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'model_snapshots', params['snapshot_id'] || params['snapshotId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlDeleteModelSnapshot diff --git a/api/api/xpack.ml.flush_job.js b/api/api/xpack.ml.flush_job.js new file mode 100644 index 000000000..a44363b8b --- /dev/null +++ b/api/api/xpack.ml.flush_job.js @@ -0,0 +1,106 @@ +'use strict' + +function buildXpackMlFlushJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.flush_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-flush-job.html) request + * + * @param {string} job_id - The name of the job to flush + * @param {boolean} calc_interim - Calculates interim results for the most recent bucket or all buckets within the latency period + * @param {string} start - When used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results + * @param {string} end - When used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results + * @param {string} advance_time - Advances time to the given value generating results and updating the model for the advanced interval + * @param {string} skip_time - Skips time to the given value without generating results or updating the model for the skipped interval + * @param {object} body - Flush parameters + */ + return function xpackMlFlushJob (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlFlushJob(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: job_id or jobId'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'calc_interim', + 'start', + 'end', + 'advance_time', + 'skip_time' + ] + const acceptedQuerystringCamelCased = [ + 'calcInterim', + 'start', + 'end', + 'advanceTime', + 'skipTime' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_flush'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlFlushJob diff --git a/api/api/xpack.ml.forecast.js b/api/api/xpack.ml.forecast.js new file mode 100644 index 000000000..d30400f26 --- /dev/null +++ b/api/api/xpack.ml.forecast.js @@ -0,0 +1,102 @@ +'use strict' + +function buildXpackMlForecast (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.forecast](undefined) request + * + * @param {string} job_id - The ID of the job to forecast for + * @param {time} duration - The duration of the forecast + * @param {time} expires_in - The time interval after which the forecast expires. Expired forecasts will be deleted at the first opportunity. + */ + return function xpackMlForecast (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlForecast(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: job_id or jobId'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'duration', + 'expires_in' + ] + const acceptedQuerystringCamelCased = [ + 'duration', + 'expiresIn' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_forecast'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlForecast diff --git a/api/api/xpack.ml.get_buckets.js b/api/api/xpack.ml.get_buckets.js new file mode 100644 index 000000000..f9437281b --- /dev/null +++ b/api/api/xpack.ml.get_buckets.js @@ -0,0 +1,127 @@ +'use strict' + +function buildXpackMlGetBuckets (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.get_buckets](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-bucket.html) request + * + * @param {string} job_id - ID of the job to get bucket results from + * @param {string} timestamp - The timestamp of the desired single bucket result + * @param {boolean} expand - Include anomaly records + * @param {boolean} exclude_interim - Exclude interim results + * @param {int} from - skips a number of buckets + * @param {int} size - specifies a max number of buckets to get + * @param {string} start - Start time filter for buckets + * @param {string} end - End time filter for buckets + * @param {double} anomaly_score - Filter for the most anomalous buckets + * @param {string} sort - Sort buckets by a particular field + * @param {boolean} desc - Set the sort direction + * @param {object} body - Bucket selection details if not provided in URI + */ + return function xpackMlGetBuckets (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlGetBuckets(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: job_id or jobId'), + result + ) + } + + // check required url components + if (params['timestamp'] != null && ((params['job_id'] == null || params['jobId']))) { + return callback( + new ConfigurationError('Missing required parameter of the url: job_id'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'expand', + 'exclude_interim', + 'from', + 'size', + 'start', + 'end', + 'anomaly_score', + 'sort', + 'desc' + ] + const acceptedQuerystringCamelCased = [ + 'expand', + 'excludeInterim', + 'from', + 'size', + 'start', + 'end', + 'anomalyScore', + 'sort', + 'desc' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'results', 'buckets', params['timestamp']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlGetBuckets diff --git a/api/api/xpack.ml.get_calendar_events.js b/api/api/xpack.ml.get_calendar_events.js new file mode 100644 index 000000000..107de9318 --- /dev/null +++ b/api/api/xpack.ml.get_calendar_events.js @@ -0,0 +1,111 @@ +'use strict' + +function buildXpackMlGetCalendarEvents (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.get_calendar_events](undefined) request + * + * @param {string} calendar_id - The ID of the calendar containing the events + * @param {string} job_id - Get events for the job. When this option is used calendar_id must be '_all' + * @param {string} start - Get events after this time + * @param {date} end - Get events before this time + * @param {int} from - Skips a number of events + * @param {int} size - Specifies a max number of events to get + */ + return function xpackMlGetCalendarEvents (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlGetCalendarEvents(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: calendar_id or calendarId'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'job_id', + 'start', + 'end', + 'from', + 'size' + ] + const acceptedQuerystringCamelCased = [ + 'jobId', + 'start', + 'end', + 'from', + 'size' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId'], 'events'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlGetCalendarEvents diff --git a/api/api/xpack.ml.get_calendars.js b/api/api/xpack.ml.get_calendars.js new file mode 100644 index 000000000..c856066de --- /dev/null +++ b/api/api/xpack.ml.get_calendars.js @@ -0,0 +1,96 @@ +'use strict' + +function buildXpackMlGetCalendars (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.get_calendars](undefined) request + * + * @param {string} calendar_id - The ID of the calendar to fetch + * @param {int} from - skips a number of calendars + * @param {int} size - specifies a max number of calendars to get + */ + return function xpackMlGetCalendars (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlGetCalendars(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'from', + 'size' + ] + const acceptedQuerystringCamelCased = [ + 'from', + 'size' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlGetCalendars diff --git a/api/api/xpack.ml.get_categories.js b/api/api/xpack.ml.get_categories.js new file mode 100644 index 000000000..1cabd11c0 --- /dev/null +++ b/api/api/xpack.ml.get_categories.js @@ -0,0 +1,100 @@ +'use strict' + +function buildXpackMlGetCategories (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.get_categories](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-category.html) request + * + * @param {string} job_id - The name of the job + * @param {long} category_id - The identifier of the category definition of interest + * @param {int} from - skips a number of categories + * @param {int} size - specifies a max number of categories to get + * @param {object} body - Category selection details if not provided in URI + */ + return function xpackMlGetCategories (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlGetCategories(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: job_id or jobId'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'from', + 'size' + ] + const acceptedQuerystringCamelCased = [ + 'from', + 'size' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'results', 'categories'] + const request = { + method, + path: (params['job_id'] || params['jobId']) != null + ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') + : '/_xpack/ml/anomaly_detectors/{job_id}/results/categories/{category_id}', + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlGetCategories diff --git a/api/api/xpack.ml.get_datafeed_stats.js b/api/api/xpack.ml.get_datafeed_stats.js new file mode 100644 index 000000000..645fcba71 --- /dev/null +++ b/api/api/xpack.ml.get_datafeed_stats.js @@ -0,0 +1,93 @@ +'use strict' + +function buildXpackMlGetDatafeedStats (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.get_datafeed_stats](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed-stats.html) request + * + * @param {string} datafeed_id - The ID of the datafeeds stats to fetch + * @param {boolean} allow_no_datafeeds - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + */ + return function xpackMlGetDatafeedStats (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlGetDatafeedStats(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'allow_no_datafeeds' + ] + const acceptedQuerystringCamelCased = [ + 'allowNoDatafeeds' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId'], '_stats'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlGetDatafeedStats diff --git a/api/api/xpack.ml.get_datafeeds.js b/api/api/xpack.ml.get_datafeeds.js new file mode 100644 index 000000000..d491d3191 --- /dev/null +++ b/api/api/xpack.ml.get_datafeeds.js @@ -0,0 +1,93 @@ +'use strict' + +function buildXpackMlGetDatafeeds (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.get_datafeeds](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed.html) request + * + * @param {string} datafeed_id - The ID of the datafeeds to fetch + * @param {boolean} allow_no_datafeeds - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + */ + return function xpackMlGetDatafeeds (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlGetDatafeeds(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'allow_no_datafeeds' + ] + const acceptedQuerystringCamelCased = [ + 'allowNoDatafeeds' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlGetDatafeeds diff --git a/api/api/xpack.ml.get_filters.js b/api/api/xpack.ml.get_filters.js new file mode 100644 index 000000000..f1ff13d1d --- /dev/null +++ b/api/api/xpack.ml.get_filters.js @@ -0,0 +1,96 @@ +'use strict' + +function buildXpackMlGetFilters (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.get_filters](undefined) request + * + * @param {string} filter_id - The ID of the filter to fetch + * @param {int} from - skips a number of filters + * @param {int} size - specifies a max number of filters to get + */ + return function xpackMlGetFilters (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlGetFilters(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'from', + 'size' + ] + const acceptedQuerystringCamelCased = [ + 'from', + 'size' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'filters', params['filter_id'] || params['filterId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlGetFilters diff --git a/api/api/xpack.ml.get_influencers.js b/api/api/xpack.ml.get_influencers.js new file mode 100644 index 000000000..4dc4c7b89 --- /dev/null +++ b/api/api/xpack.ml.get_influencers.js @@ -0,0 +1,115 @@ +'use strict' + +function buildXpackMlGetInfluencers (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.get_influencers](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-influencer.html) request + * + * @param {string} job_id - + * @param {boolean} exclude_interim - Exclude interim results + * @param {int} from - skips a number of influencers + * @param {int} size - specifies a max number of influencers to get + * @param {string} start - start timestamp for the requested influencers + * @param {string} end - end timestamp for the requested influencers + * @param {double} influencer_score - influencer score threshold for the requested influencers + * @param {string} sort - sort field for the requested influencers + * @param {boolean} desc - whether the results should be sorted in decending order + * @param {object} body - Influencer selection criteria + */ + return function xpackMlGetInfluencers (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlGetInfluencers(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: job_id or jobId'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'exclude_interim', + 'from', + 'size', + 'start', + 'end', + 'influencer_score', + 'sort', + 'desc' + ] + const acceptedQuerystringCamelCased = [ + 'excludeInterim', + 'from', + 'size', + 'start', + 'end', + 'influencerScore', + 'sort', + 'desc' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'results', 'influencers'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlGetInfluencers diff --git a/api/api/xpack.ml.get_job_stats.js b/api/api/xpack.ml.get_job_stats.js new file mode 100644 index 000000000..7ee5f78c0 --- /dev/null +++ b/api/api/xpack.ml.get_job_stats.js @@ -0,0 +1,93 @@ +'use strict' + +function buildXpackMlGetJobStats (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.get_job_stats](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-stats.html) request + * + * @param {string} job_id - The ID of the jobs stats to fetch + * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + */ + return function xpackMlGetJobStats (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlGetJobStats(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'allow_no_jobs' + ] + const acceptedQuerystringCamelCased = [ + 'allowNoJobs' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_stats'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlGetJobStats diff --git a/api/api/xpack.ml.get_jobs.js b/api/api/xpack.ml.get_jobs.js new file mode 100644 index 000000000..bf4abf901 --- /dev/null +++ b/api/api/xpack.ml.get_jobs.js @@ -0,0 +1,93 @@ +'use strict' + +function buildXpackMlGetJobs (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.get_jobs](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job.html) request + * + * @param {string} job_id - The ID of the jobs to fetch + * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + */ + return function xpackMlGetJobs (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlGetJobs(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'allow_no_jobs' + ] + const acceptedQuerystringCamelCased = [ + 'allowNoJobs' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlGetJobs diff --git a/api/api/xpack.ml.get_model_snapshots.js b/api/api/xpack.ml.get_model_snapshots.js new file mode 100644 index 000000000..345daf48f --- /dev/null +++ b/api/api/xpack.ml.get_model_snapshots.js @@ -0,0 +1,118 @@ +'use strict' + +function buildXpackMlGetModelSnapshots (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.get_model_snapshots](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-snapshot.html) request + * + * @param {string} job_id - The ID of the job to fetch + * @param {string} snapshot_id - The ID of the snapshot to fetch + * @param {int} from - Skips a number of documents + * @param {int} size - The default number of documents returned in queries as a string. + * @param {date} start - The filter 'start' query parameter + * @param {date} end - The filter 'end' query parameter + * @param {string} sort - Name of the field to sort on + * @param {boolean} desc - True if the results should be sorted in descending order + * @param {object} body - Model snapshot selection criteria + */ + return function xpackMlGetModelSnapshots (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlGetModelSnapshots(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: job_id or jobId'), + result + ) + } + + // check required url components + if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null || params['jobId']))) { + return callback( + new ConfigurationError('Missing required parameter of the url: job_id'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'from', + 'size', + 'start', + 'end', + 'sort', + 'desc' + ] + const acceptedQuerystringCamelCased = [ + 'from', + 'size', + 'start', + 'end', + 'sort', + 'desc' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'model_snapshots', params['snapshot_id'] || params['snapshotId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlGetModelSnapshots diff --git a/api/api/xpack.ml.get_overall_buckets.js b/api/api/xpack.ml.get_overall_buckets.js new file mode 100644 index 000000000..20a13e767 --- /dev/null +++ b/api/api/xpack.ml.get_overall_buckets.js @@ -0,0 +1,112 @@ +'use strict' + +function buildXpackMlGetOverallBuckets (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.get_overall_buckets](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-overall-buckets.html) request + * + * @param {string} job_id - The job IDs for which to calculate overall bucket results + * @param {int} top_n - The number of top job bucket scores to be used in the overall_score calculation + * @param {string} bucket_span - The span of the overall buckets. Defaults to the longest job bucket_span + * @param {double} overall_score - Returns overall buckets with overall scores higher than this value + * @param {boolean} exclude_interim - If true overall buckets that include interim buckets will be excluded + * @param {string} start - Returns overall buckets with timestamps after this time + * @param {string} end - Returns overall buckets with timestamps earlier than this time + * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + * @param {object} body - Overall bucket selection details if not provided in URI + */ + return function xpackMlGetOverallBuckets (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlGetOverallBuckets(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: job_id or jobId'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'top_n', + 'bucket_span', + 'overall_score', + 'exclude_interim', + 'start', + 'end', + 'allow_no_jobs' + ] + const acceptedQuerystringCamelCased = [ + 'topN', + 'bucketSpan', + 'overallScore', + 'excludeInterim', + 'start', + 'end', + 'allowNoJobs' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'results', 'overall_buckets'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlGetOverallBuckets diff --git a/api/api/xpack.ml.get_records.js b/api/api/xpack.ml.get_records.js new file mode 100644 index 000000000..4717cbc9c --- /dev/null +++ b/api/api/xpack.ml.get_records.js @@ -0,0 +1,115 @@ +'use strict' + +function buildXpackMlGetRecords (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.get_records](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-record.html) request + * + * @param {string} job_id - + * @param {boolean} exclude_interim - Exclude interim results + * @param {int} from - skips a number of records + * @param {int} size - specifies a max number of records to get + * @param {string} start - Start time filter for records + * @param {string} end - End time filter for records + * @param {double} record_score - + * @param {string} sort - Sort records by a particular field + * @param {boolean} desc - Set the sort direction + * @param {object} body - Record selection criteria + */ + return function xpackMlGetRecords (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlGetRecords(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: job_id or jobId'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'exclude_interim', + 'from', + 'size', + 'start', + 'end', + 'record_score', + 'sort', + 'desc' + ] + const acceptedQuerystringCamelCased = [ + 'excludeInterim', + 'from', + 'size', + 'start', + 'end', + 'recordScore', + 'sort', + 'desc' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'results', 'records'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlGetRecords diff --git a/api/api/xpack.ml.info.js b/api/api/xpack.ml.info.js new file mode 100644 index 000000000..6691fbb1f --- /dev/null +++ b/api/api/xpack.ml.info.js @@ -0,0 +1,83 @@ +'use strict' + +function buildXpackMlInfo (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.info](undefined) request + * + */ + return function xpackMlInfo (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlInfo(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'info'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlInfo diff --git a/api/api/xpack.ml.open_job.js b/api/api/xpack.ml.open_job.js new file mode 100644 index 000000000..19a1febcb --- /dev/null +++ b/api/api/xpack.ml.open_job.js @@ -0,0 +1,100 @@ +'use strict' + +function buildXpackMlOpenJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.open_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html) request + * + * @param {string} job_id - The ID of the job to open + * @param {boolean} ignore_downtime - Controls if gaps in data are treated as anomalous or as a maintenance window after a job re-start + * @param {time} timeout - Controls the time to wait until a job has opened. Default to 30 minutes + */ + return function xpackMlOpenJob (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlOpenJob(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: job_id or jobId'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_open'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlOpenJob diff --git a/api/api/xpack.ml.post_calendar_events.js b/api/api/xpack.ml.post_calendar_events.js new file mode 100644 index 000000000..c9868a8e2 --- /dev/null +++ b/api/api/xpack.ml.post_calendar_events.js @@ -0,0 +1,99 @@ +'use strict' + +function buildXpackMlPostCalendarEvents (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.post_calendar_events](undefined) request + * + * @param {string} calendar_id - The ID of the calendar to modify + * @param {object} body - A list of events + */ + return function xpackMlPostCalendarEvents (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlPostCalendarEvents(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: calendar_id or calendarId'), + result + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId'], 'events'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlPostCalendarEvents diff --git a/api/api/xpack.ml.post_data.js b/api/api/xpack.ml.post_data.js new file mode 100644 index 000000000..f5a0fe3b6 --- /dev/null +++ b/api/api/xpack.ml.post_data.js @@ -0,0 +1,103 @@ +'use strict' + +function buildXpackMlPostData (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.post_data](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-data.html) request + * + * @param {string} job_id - The name of the job receiving the data + * @param {string} reset_start - Optional parameter to specify the start of the bucket resetting range + * @param {string} reset_end - Optional parameter to specify the end of the bucket resetting range + * @param {object} body - The data to process + */ + return function xpackMlPostData (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlPostData(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: job_id or jobId'), + result + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'reset_start', + 'reset_end' + ] + const acceptedQuerystringCamelCased = [ + 'resetStart', + 'resetEnd' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_data'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlPostData diff --git a/api/api/xpack.ml.preview_datafeed.js b/api/api/xpack.ml.preview_datafeed.js new file mode 100644 index 000000000..050790b32 --- /dev/null +++ b/api/api/xpack.ml.preview_datafeed.js @@ -0,0 +1,98 @@ +'use strict' + +function buildXpackMlPreviewDatafeed (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.preview_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html) request + * + * @param {string} datafeed_id - The ID of the datafeed to preview + */ + return function xpackMlPreviewDatafeed (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlPreviewDatafeed(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: datafeed_id or datafeedId'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId'], '_preview'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlPreviewDatafeed diff --git a/api/api/xpack.ml.put_calendar.js b/api/api/xpack.ml.put_calendar.js new file mode 100644 index 000000000..b4299a313 --- /dev/null +++ b/api/api/xpack.ml.put_calendar.js @@ -0,0 +1,93 @@ +'use strict' + +function buildXpackMlPutCalendar (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.put_calendar](undefined) request + * + * @param {string} calendar_id - The ID of the calendar to create + * @param {object} body - The calendar details + */ + return function xpackMlPutCalendar (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlPutCalendar(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: calendar_id or calendarId'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlPutCalendar diff --git a/api/api/xpack.ml.put_calendar_job.js b/api/api/xpack.ml.put_calendar_job.js new file mode 100644 index 000000000..3345d2e02 --- /dev/null +++ b/api/api/xpack.ml.put_calendar_job.js @@ -0,0 +1,113 @@ +'use strict' + +function buildXpackMlPutCalendarJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.put_calendar_job](undefined) request + * + * @param {string} calendar_id - The ID of the calendar to modify + * @param {string} job_id - The ID of the job to add to the calendar + */ + return function xpackMlPutCalendarJob (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlPutCalendarJob(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: calendar_id or calendarId'), + result + ) + } + if (params['job_id'] == null && params['jobId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: job_id or jobId'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // check required url components + if ((params['job_id'] != null || params['jobId'] != null) && ((params['calendar_id'] == null || params['calendarId']))) { + return callback( + new ConfigurationError('Missing required parameter of the url: calendar_id'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId'], 'jobs', params['job_id'] || params['jobId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlPutCalendarJob diff --git a/api/api/xpack.ml.put_datafeed.js b/api/api/xpack.ml.put_datafeed.js new file mode 100644 index 000000000..69b66d351 --- /dev/null +++ b/api/api/xpack.ml.put_datafeed.js @@ -0,0 +1,99 @@ +'use strict' + +function buildXpackMlPutDatafeed (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.put_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-datafeed.html) request + * + * @param {string} datafeed_id - The ID of the datafeed to create + * @param {object} body - The datafeed config + */ + return function xpackMlPutDatafeed (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlPutDatafeed(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: datafeed_id or datafeedId'), + result + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlPutDatafeed diff --git a/api/api/xpack.ml.put_filter.js b/api/api/xpack.ml.put_filter.js new file mode 100644 index 000000000..20e0788c1 --- /dev/null +++ b/api/api/xpack.ml.put_filter.js @@ -0,0 +1,99 @@ +'use strict' + +function buildXpackMlPutFilter (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.put_filter](undefined) request + * + * @param {string} filter_id - The ID of the filter to create + * @param {object} body - The filter details + */ + return function xpackMlPutFilter (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlPutFilter(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['filter_id'] == null && params['filterId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: filter_id or filterId'), + result + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'filters', params['filter_id'] || params['filterId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlPutFilter diff --git a/api/api/xpack.ml.put_job.js b/api/api/xpack.ml.put_job.js new file mode 100644 index 000000000..80753e7cc --- /dev/null +++ b/api/api/xpack.ml.put_job.js @@ -0,0 +1,99 @@ +'use strict' + +function buildXpackMlPutJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.put_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html) request + * + * @param {string} job_id - The ID of the job to create + * @param {object} body - The job + */ + return function xpackMlPutJob (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlPutJob(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: job_id or jobId'), + result + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlPutJob diff --git a/api/api/xpack.ml.revert_model_snapshot.js b/api/api/xpack.ml.revert_model_snapshot.js new file mode 100644 index 000000000..a4bd7cabc --- /dev/null +++ b/api/api/xpack.ml.revert_model_snapshot.js @@ -0,0 +1,109 @@ +'use strict' + +function buildXpackMlRevertModelSnapshot (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.revert_model_snapshot](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-revert-snapshot.html) request + * + * @param {string} job_id - The ID of the job to fetch + * @param {string} snapshot_id - The ID of the snapshot to revert to + * @param {boolean} delete_intervening_results - Should we reset the results back to the time of the snapshot? + * @param {object} body - Reversion options + */ + return function xpackMlRevertModelSnapshot (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlRevertModelSnapshot(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: job_id or jobId'), + result + ) + } + if (params['snapshot_id'] == null && params['snapshotId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: snapshot_id or snapshotId'), + result + ) + } + + // check required url components + if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null || params['jobId']))) { + return callback( + new ConfigurationError('Missing required parameter of the url: job_id'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'delete_intervening_results' + ] + const acceptedQuerystringCamelCased = [ + 'deleteInterveningResults' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'model_snapshots', params['snapshot_id'] || params['snapshotId'], '_revert'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlRevertModelSnapshot diff --git a/api/api/xpack.ml.start_datafeed.js b/api/api/xpack.ml.start_datafeed.js new file mode 100644 index 000000000..10f4d488d --- /dev/null +++ b/api/api/xpack.ml.start_datafeed.js @@ -0,0 +1,100 @@ +'use strict' + +function buildXpackMlStartDatafeed (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.start_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-start-datafeed.html) request + * + * @param {string} datafeed_id - The ID of the datafeed to start + * @param {string} start - The start time from where the datafeed should begin + * @param {string} end - The end time when the datafeed should stop. When not set, the datafeed continues in real time + * @param {time} timeout - Controls the time to wait until a datafeed has started. Default to 20 seconds + * @param {object} body - The start datafeed parameters + */ + return function xpackMlStartDatafeed (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlStartDatafeed(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: datafeed_id or datafeedId'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'start', + 'end', + 'timeout' + ] + const acceptedQuerystringCamelCased = [ + 'start', + 'end', + 'timeout' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId'], '_start'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlStartDatafeed diff --git a/api/api/xpack.ml.stop_datafeed.js b/api/api/xpack.ml.stop_datafeed.js new file mode 100644 index 000000000..4381a8b6a --- /dev/null +++ b/api/api/xpack.ml.stop_datafeed.js @@ -0,0 +1,99 @@ +'use strict' + +function buildXpackMlStopDatafeed (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.stop_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-stop-datafeed.html) request + * + * @param {string} datafeed_id - The ID of the datafeed to stop + * @param {boolean} allow_no_datafeeds - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + * @param {boolean} force - True if the datafeed should be forcefully stopped. + * @param {time} timeout - Controls the time to wait until a datafeed has stopped. Default to 20 seconds + */ + return function xpackMlStopDatafeed (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlStopDatafeed(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: datafeed_id or datafeedId'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'allow_no_datafeeds', + 'force', + 'timeout' + ] + const acceptedQuerystringCamelCased = [ + 'allowNoDatafeeds', + 'force', + 'timeout' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId'], '_stop'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlStopDatafeed diff --git a/api/api/xpack.ml.update_datafeed.js b/api/api/xpack.ml.update_datafeed.js new file mode 100644 index 000000000..f3d8d424b --- /dev/null +++ b/api/api/xpack.ml.update_datafeed.js @@ -0,0 +1,99 @@ +'use strict' + +function buildXpackMlUpdateDatafeed (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.update_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-datafeed.html) request + * + * @param {string} datafeed_id - The ID of the datafeed to update + * @param {object} body - The datafeed update settings + */ + return function xpackMlUpdateDatafeed (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlUpdateDatafeed(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: datafeed_id or datafeedId'), + result + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId'], '_update'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlUpdateDatafeed diff --git a/api/api/xpack.ml.update_filter.js b/api/api/xpack.ml.update_filter.js new file mode 100644 index 000000000..8ae999c72 --- /dev/null +++ b/api/api/xpack.ml.update_filter.js @@ -0,0 +1,99 @@ +'use strict' + +function buildXpackMlUpdateFilter (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.update_filter](undefined) request + * + * @param {string} filter_id - The ID of the filter to update + * @param {object} body - The filter update + */ + return function xpackMlUpdateFilter (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlUpdateFilter(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['filter_id'] == null && params['filterId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: filter_id or filterId'), + result + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'filters', params['filter_id'] || params['filterId'], '_update'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlUpdateFilter diff --git a/api/api/xpack.ml.update_job.js b/api/api/xpack.ml.update_job.js new file mode 100644 index 000000000..6e765d087 --- /dev/null +++ b/api/api/xpack.ml.update_job.js @@ -0,0 +1,99 @@ +'use strict' + +function buildXpackMlUpdateJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.update_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-job.html) request + * + * @param {string} job_id - The ID of the job to create + * @param {object} body - The job update settings + */ + return function xpackMlUpdateJob (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlUpdateJob(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: job_id or jobId'), + result + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_update'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlUpdateJob diff --git a/api/api/xpack.ml.update_model_snapshot.js b/api/api/xpack.ml.update_model_snapshot.js new file mode 100644 index 000000000..236c9e661 --- /dev/null +++ b/api/api/xpack.ml.update_model_snapshot.js @@ -0,0 +1,114 @@ +'use strict' + +function buildXpackMlUpdateModelSnapshot (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.update_model_snapshot](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-snapshot.html) request + * + * @param {string} job_id - The ID of the job to fetch + * @param {string} snapshot_id - The ID of the snapshot to update + * @param {object} body - The model snapshot properties to update + */ + return function xpackMlUpdateModelSnapshot (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlUpdateModelSnapshot(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: job_id or jobId'), + result + ) + } + if (params['snapshot_id'] == null && params['snapshotId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: snapshot_id or snapshotId'), + result + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // check required url components + if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null || params['jobId']))) { + return callback( + new ConfigurationError('Missing required parameter of the url: job_id'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'model_snapshots', params['snapshot_id'] || params['snapshotId'], '_update'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlUpdateModelSnapshot diff --git a/api/api/xpack.ml.validate.js b/api/api/xpack.ml.validate.js new file mode 100644 index 000000000..edcd81e14 --- /dev/null +++ b/api/api/xpack.ml.validate.js @@ -0,0 +1,92 @@ +'use strict' + +function buildXpackMlValidate (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.validate](undefined) request + * + * @param {object} body - The job config + */ + return function xpackMlValidate (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlValidate(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', '_validate'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlValidate diff --git a/api/api/xpack.ml.validate_detector.js b/api/api/xpack.ml.validate_detector.js new file mode 100644 index 000000000..312374e95 --- /dev/null +++ b/api/api/xpack.ml.validate_detector.js @@ -0,0 +1,92 @@ +'use strict' + +function buildXpackMlValidateDetector (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.validate_detector](undefined) request + * + * @param {object} body - The detector + */ + return function xpackMlValidateDetector (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlValidateDetector(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', '_validate', 'detector'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlValidateDetector diff --git a/api/api/xpack.monitoring.bulk.js b/api/api/xpack.monitoring.bulk.js new file mode 100644 index 000000000..543f9e2bc --- /dev/null +++ b/api/api/xpack.monitoring.bulk.js @@ -0,0 +1,100 @@ +'use strict' + +function buildXpackMonitoringBulk (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.monitoring.bulk](http://www.elastic.co/guide/en/monitoring/current/appendix-api-bulk.html) request + * + * @param {string} type - Default document type for items which don't provide one + * @param {string} system_id - Identifier of the monitored system + * @param {string} system_api_version - API Version of the monitored system + * @param {string} interval - Collection interval (e.g., '10s' or '10000ms') of the payload + * @param {object} body - The operation definition and data (action-data pairs), separated by newlines + */ + return function xpackMonitoringBulk (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMonitoringBulk(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'system_id', + 'system_api_version', + 'interval' + ] + const acceptedQuerystringCamelCased = [ + 'systemId', + 'systemApiVersion', + 'interval' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'monitoring', params['type'], '_bulk'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMonitoringBulk diff --git a/api/api/xpack.rollup.delete_job.js b/api/api/xpack.rollup.delete_job.js new file mode 100644 index 000000000..0bac5a235 --- /dev/null +++ b/api/api/xpack.rollup.delete_job.js @@ -0,0 +1,92 @@ +'use strict' + +function buildXpackRollupDeleteJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.rollup.delete_job]() request + * + * @param {string} id - The ID of the job to delete + */ + return function xpackRollupDeleteJob (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackRollupDeleteJob(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['id'] == null) { + return callback( + new ConfigurationError('Missing required parameter: id'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'rollup', 'job', params['id']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackRollupDeleteJob diff --git a/api/api/xpack.rollup.get_jobs.js b/api/api/xpack.rollup.get_jobs.js new file mode 100644 index 000000000..80ee35fd7 --- /dev/null +++ b/api/api/xpack.rollup.get_jobs.js @@ -0,0 +1,84 @@ +'use strict' + +function buildXpackRollupGetJobs (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.rollup.get_jobs]() request + * + * @param {string} id - The ID of the job(s) to fetch. Accepts glob patterns, or left blank for all jobs + */ + return function xpackRollupGetJobs (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackRollupGetJobs(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'rollup', 'job'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackRollupGetJobs diff --git a/api/api/xpack.rollup.get_rollup_caps.js b/api/api/xpack.rollup.get_rollup_caps.js new file mode 100644 index 000000000..3aa0130b5 --- /dev/null +++ b/api/api/xpack.rollup.get_rollup_caps.js @@ -0,0 +1,84 @@ +'use strict' + +function buildXpackRollupGetRollupCaps (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.rollup.get_rollup_caps]() request + * + * @param {string} id - The ID of the index to check rollup capabilities on, or left blank for all jobs + */ + return function xpackRollupGetRollupCaps (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackRollupGetRollupCaps(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'rollup', 'data'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackRollupGetRollupCaps diff --git a/api/api/xpack.rollup.get_rollup_index_caps.js b/api/api/xpack.rollup.get_rollup_index_caps.js new file mode 100644 index 000000000..20dda135c --- /dev/null +++ b/api/api/xpack.rollup.get_rollup_index_caps.js @@ -0,0 +1,92 @@ +'use strict' + +function buildXpackRollupGetRollupIndexCaps (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.rollup.get_rollup_index_caps]() request + * + * @param {string} index - The rollup index or index pattern to obtain rollup capabilities from. + */ + return function xpackRollupGetRollupIndexCaps (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackRollupGetRollupIndexCaps(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_xpack', 'rollup', 'data'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackRollupGetRollupIndexCaps diff --git a/api/api/xpack.rollup.put_job.js b/api/api/xpack.rollup.put_job.js new file mode 100644 index 000000000..2cb46a5bd --- /dev/null +++ b/api/api/xpack.rollup.put_job.js @@ -0,0 +1,99 @@ +'use strict' + +function buildXpackRollupPutJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.rollup.put_job]() request + * + * @param {string} id - The ID of the job to create + * @param {object} body - The job configuration + */ + return function xpackRollupPutJob (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackRollupPutJob(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['id'] == null) { + return callback( + new ConfigurationError('Missing required parameter: id'), + result + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'rollup', 'job', params['id']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackRollupPutJob diff --git a/api/api/xpack.rollup.rollup_search.js b/api/api/xpack.rollup.rollup_search.js new file mode 100644 index 000000000..2cb90065f --- /dev/null +++ b/api/api/xpack.rollup.rollup_search.js @@ -0,0 +1,110 @@ +'use strict' + +function buildXpackRollupRollupSearch (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.rollup.rollup_search]() request + * + * @param {string} index - The index or index-pattern (containing rollup or regular data) that should be searched + * @param {string} type - The doc type inside the index + * @param {object} body - The search request body + */ + return function xpackRollupRollupSearch (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackRollupRollupSearch(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + result + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: index'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], params['type'], '_rollup_search'] + const request = { + method, + path: params['index'] != null && params['type'] != null + ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') + : '/{index}/_rollup_search', + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackRollupRollupSearch diff --git a/api/api/xpack.rollup.start_job.js b/api/api/xpack.rollup.start_job.js new file mode 100644 index 000000000..b513b7dce --- /dev/null +++ b/api/api/xpack.rollup.start_job.js @@ -0,0 +1,92 @@ +'use strict' + +function buildXpackRollupStartJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.rollup.start_job]() request + * + * @param {string} id - The ID of the job to start + */ + return function xpackRollupStartJob (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackRollupStartJob(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['id'] == null) { + return callback( + new ConfigurationError('Missing required parameter: id'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'rollup', 'job', params['id'], '_start'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackRollupStartJob diff --git a/api/api/xpack.rollup.stop_job.js b/api/api/xpack.rollup.stop_job.js new file mode 100644 index 000000000..0a1e4340a --- /dev/null +++ b/api/api/xpack.rollup.stop_job.js @@ -0,0 +1,92 @@ +'use strict' + +function buildXpackRollupStopJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.rollup.stop_job]() request + * + * @param {string} id - The ID of the job to stop + */ + return function xpackRollupStopJob (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackRollupStopJob(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['id'] == null) { + return callback( + new ConfigurationError('Missing required parameter: id'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'rollup', 'job', params['id'], '_stop'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackRollupStopJob diff --git a/api/api/xpack.security.authenticate.js b/api/api/xpack.security.authenticate.js new file mode 100644 index 000000000..5355caab5 --- /dev/null +++ b/api/api/xpack.security.authenticate.js @@ -0,0 +1,91 @@ +'use strict' + +function buildXpackSecurityAuthenticate (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.authenticate](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-authenticate.html) request + * + */ + return function xpackSecurityAuthenticate (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityAuthenticate(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', '_authenticate'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityAuthenticate diff --git a/api/api/xpack.security.change_password.js b/api/api/xpack.security.change_password.js new file mode 100644 index 000000000..69e7fb40e --- /dev/null +++ b/api/api/xpack.security.change_password.js @@ -0,0 +1,94 @@ +'use strict' + +function buildXpackSecurityChangePassword (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.change_password](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-change-password.html) request + * + * @param {string} username - The username of the user to change the password for + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * @param {object} body - the new password for the user + */ + return function xpackSecurityChangePassword (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityChangePassword(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'refresh' + ] + const acceptedQuerystringCamelCased = [ + 'refresh' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', 'user', params['username'], '_password'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityChangePassword diff --git a/api/api/xpack.security.clear_cached_realms.js b/api/api/xpack.security.clear_cached_realms.js new file mode 100644 index 000000000..8b3821303 --- /dev/null +++ b/api/api/xpack.security.clear_cached_realms.js @@ -0,0 +1,99 @@ +'use strict' + +function buildXpackSecurityClearCachedRealms (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.clear_cached_realms](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-cache.html) request + * + * @param {list} realms - Comma-separated list of realms to clear + * @param {list} usernames - Comma-separated list of usernames to clear from the cache + */ + return function xpackSecurityClearCachedRealms (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityClearCachedRealms(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['realms'] == null) { + return callback( + new ConfigurationError('Missing required parameter: realms'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'usernames' + ] + const acceptedQuerystringCamelCased = [ + 'usernames' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', 'realm', params['realms'], '_clear_cache'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityClearCachedRealms diff --git a/api/api/xpack.security.clear_cached_roles.js b/api/api/xpack.security.clear_cached_roles.js new file mode 100644 index 000000000..f9058cb6b --- /dev/null +++ b/api/api/xpack.security.clear_cached_roles.js @@ -0,0 +1,98 @@ +'use strict' + +function buildXpackSecurityClearCachedRoles (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.clear_cached_roles](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-role-cache.html) request + * + * @param {list} name - Role name + */ + return function xpackSecurityClearCachedRoles (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityClearCachedRoles(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['name'] == null) { + return callback( + new ConfigurationError('Missing required parameter: name'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', 'role', params['name'], '_clear_cache'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityClearCachedRoles diff --git a/api/api/xpack.security.delete_privileges.js b/api/api/xpack.security.delete_privileges.js new file mode 100644 index 000000000..c8320fde7 --- /dev/null +++ b/api/api/xpack.security.delete_privileges.js @@ -0,0 +1,114 @@ +'use strict' + +function buildXpackSecurityDeletePrivileges (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.delete_privileges](TODO) request + * + * @param {string} application - Application name + * @param {string} name - Privilege name + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + */ + return function xpackSecurityDeletePrivileges (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityDeletePrivileges(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['application'] == null) { + return callback( + new ConfigurationError('Missing required parameter: application'), + result + ) + } + if (params['name'] == null) { + return callback( + new ConfigurationError('Missing required parameter: name'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // check required url components + if (params['name'] != null && (params['application'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: application'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'refresh' + ] + const acceptedQuerystringCamelCased = [ + 'refresh' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', 'privilege', params['application'], params['name']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityDeletePrivileges diff --git a/api/api/xpack.security.delete_role.js b/api/api/xpack.security.delete_role.js new file mode 100644 index 000000000..c24732e11 --- /dev/null +++ b/api/api/xpack.security.delete_role.js @@ -0,0 +1,99 @@ +'use strict' + +function buildXpackSecurityDeleteRole (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.delete_role](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role.html) request + * + * @param {string} name - Role name + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + */ + return function xpackSecurityDeleteRole (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityDeleteRole(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['name'] == null) { + return callback( + new ConfigurationError('Missing required parameter: name'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'refresh' + ] + const acceptedQuerystringCamelCased = [ + 'refresh' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', 'role', params['name']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityDeleteRole diff --git a/api/api/xpack.security.delete_role_mapping.js b/api/api/xpack.security.delete_role_mapping.js new file mode 100644 index 000000000..d59fbdfe8 --- /dev/null +++ b/api/api/xpack.security.delete_role_mapping.js @@ -0,0 +1,99 @@ +'use strict' + +function buildXpackSecurityDeleteRoleMapping (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.delete_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-role-mapping.html#security-api-delete-role-mapping) request + * + * @param {string} name - Role-mapping name + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + */ + return function xpackSecurityDeleteRoleMapping (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityDeleteRoleMapping(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['name'] == null) { + return callback( + new ConfigurationError('Missing required parameter: name'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'refresh' + ] + const acceptedQuerystringCamelCased = [ + 'refresh' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', 'role_mapping', params['name']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityDeleteRoleMapping diff --git a/api/api/xpack.security.delete_user.js b/api/api/xpack.security.delete_user.js new file mode 100644 index 000000000..f985efe06 --- /dev/null +++ b/api/api/xpack.security.delete_user.js @@ -0,0 +1,99 @@ +'use strict' + +function buildXpackSecurityDeleteUser (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.delete_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-users.html#security-api-delete-user) request + * + * @param {string} username - username + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + */ + return function xpackSecurityDeleteUser (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityDeleteUser(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['username'] == null) { + return callback( + new ConfigurationError('Missing required parameter: username'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'refresh' + ] + const acceptedQuerystringCamelCased = [ + 'refresh' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', 'user', params['username']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityDeleteUser diff --git a/api/api/xpack.security.disable_user.js b/api/api/xpack.security.disable_user.js new file mode 100644 index 000000000..6d6a7c0ca --- /dev/null +++ b/api/api/xpack.security.disable_user.js @@ -0,0 +1,93 @@ +'use strict' + +function buildXpackSecurityDisableUser (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.disable_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-users.html#security-api-disable-user) request + * + * @param {string} username - The username of the user to disable + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + */ + return function xpackSecurityDisableUser (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityDisableUser(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'refresh' + ] + const acceptedQuerystringCamelCased = [ + 'refresh' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', 'user', params['username'], '_disable'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityDisableUser diff --git a/api/api/xpack.security.enable_user.js b/api/api/xpack.security.enable_user.js new file mode 100644 index 000000000..ce96b8ae8 --- /dev/null +++ b/api/api/xpack.security.enable_user.js @@ -0,0 +1,93 @@ +'use strict' + +function buildXpackSecurityEnableUser (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.enable_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-users.html#security-api-enable-user) request + * + * @param {string} username - The username of the user to enable + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + */ + return function xpackSecurityEnableUser (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityEnableUser(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'refresh' + ] + const acceptedQuerystringCamelCased = [ + 'refresh' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', 'user', params['username'], '_enable'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityEnableUser diff --git a/api/api/xpack.security.get_privileges.js b/api/api/xpack.security.get_privileges.js new file mode 100644 index 000000000..0bb42c912 --- /dev/null +++ b/api/api/xpack.security.get_privileges.js @@ -0,0 +1,101 @@ +'use strict' + +function buildXpackSecurityGetPrivileges (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.get_privileges](TODO) request + * + * @param {string} application - Application name + * @param {string} name - Privilege name + */ + return function xpackSecurityGetPrivileges (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityGetPrivileges(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // check required url components + if (params['name'] != null && (params['application'] == null)) { + return callback( + new ConfigurationError('Missing required parameter of the url: application'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', 'privilege', params['application'], params['name']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityGetPrivileges diff --git a/api/api/xpack.security.get_role.js b/api/api/xpack.security.get_role.js new file mode 100644 index 000000000..52748befd --- /dev/null +++ b/api/api/xpack.security.get_role.js @@ -0,0 +1,92 @@ +'use strict' + +function buildXpackSecurityGetRole (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.get_role](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html) request + * + * @param {string} name - Role name + */ + return function xpackSecurityGetRole (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityGetRole(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', 'role', params['name']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityGetRole diff --git a/api/api/xpack.security.get_role_mapping.js b/api/api/xpack.security.get_role_mapping.js new file mode 100644 index 000000000..cf007ca38 --- /dev/null +++ b/api/api/xpack.security.get_role_mapping.js @@ -0,0 +1,92 @@ +'use strict' + +function buildXpackSecurityGetRoleMapping (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.get_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-role-mapping.html#security-api-get-role-mapping) request + * + * @param {string} name - Role-Mapping name + */ + return function xpackSecurityGetRoleMapping (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityGetRoleMapping(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', 'role_mapping', params['name']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityGetRoleMapping diff --git a/api/api/xpack.security.get_token.js b/api/api/xpack.security.get_token.js new file mode 100644 index 000000000..26d25904f --- /dev/null +++ b/api/api/xpack.security.get_token.js @@ -0,0 +1,92 @@ +'use strict' + +function buildXpackSecurityGetToken (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.get_token](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-tokens.html#security-api-get-token) request + * + * @param {object} body - The token request to get + */ + return function xpackSecurityGetToken (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityGetToken(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', 'oauth2', 'token'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityGetToken diff --git a/api/api/xpack.security.get_user.js b/api/api/xpack.security.get_user.js new file mode 100644 index 000000000..938c3502a --- /dev/null +++ b/api/api/xpack.security.get_user.js @@ -0,0 +1,92 @@ +'use strict' + +function buildXpackSecurityGetUser (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.get_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-users.html#security-api-get-user) request + * + * @param {list} username - A comma-separated list of usernames + */ + return function xpackSecurityGetUser (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityGetUser(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', 'user', params['username']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityGetUser diff --git a/api/api/xpack.security.has_privileges.js b/api/api/xpack.security.has_privileges.js new file mode 100644 index 000000000..7c2b046d5 --- /dev/null +++ b/api/api/xpack.security.has_privileges.js @@ -0,0 +1,93 @@ +'use strict' + +function buildXpackSecurityHasPrivileges (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.has_privileges](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-privileges.html) request + * + * @param {string} user - Username + * @param {object} body - The privileges to test + */ + return function xpackSecurityHasPrivileges (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityHasPrivileges(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', 'user', params['user'], '_has_privileges'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityHasPrivileges diff --git a/api/api/xpack.security.invalidate_token.js b/api/api/xpack.security.invalidate_token.js new file mode 100644 index 000000000..a6e7304ea --- /dev/null +++ b/api/api/xpack.security.invalidate_token.js @@ -0,0 +1,92 @@ +'use strict' + +function buildXpackSecurityInvalidateToken (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.invalidate_token](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-tokens.html#security-api-invalidate-token) request + * + * @param {object} body - The token to invalidate + */ + return function xpackSecurityInvalidateToken (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityInvalidateToken(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', 'oauth2', 'token'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityInvalidateToken diff --git a/api/api/xpack.security.put_privileges.js b/api/api/xpack.security.put_privileges.js new file mode 100644 index 000000000..210a15f2b --- /dev/null +++ b/api/api/xpack.security.put_privileges.js @@ -0,0 +1,93 @@ +'use strict' + +function buildXpackSecurityPutPrivileges (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.put_privileges](TODO) request + * + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * @param {object} body - The privilege(s) to add + */ + return function xpackSecurityPutPrivileges (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityPutPrivileges(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'refresh' + ] + const acceptedQuerystringCamelCased = [ + 'refresh' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', 'privilege'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityPutPrivileges diff --git a/api/api/xpack.security.put_role.js b/api/api/xpack.security.put_role.js new file mode 100644 index 000000000..045e7dbc4 --- /dev/null +++ b/api/api/xpack.security.put_role.js @@ -0,0 +1,100 @@ +'use strict' + +function buildXpackSecurityPutRole (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.put_role](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html) request + * + * @param {string} name - Role name + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * @param {object} body - The role to add + */ + return function xpackSecurityPutRole (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityPutRole(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['name'] == null) { + return callback( + new ConfigurationError('Missing required parameter: name'), + result + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'refresh' + ] + const acceptedQuerystringCamelCased = [ + 'refresh' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', 'role', params['name']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityPutRole diff --git a/api/api/xpack.security.put_role_mapping.js b/api/api/xpack.security.put_role_mapping.js new file mode 100644 index 000000000..d0a0c42bf --- /dev/null +++ b/api/api/xpack.security.put_role_mapping.js @@ -0,0 +1,100 @@ +'use strict' + +function buildXpackSecurityPutRoleMapping (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.put_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-role-mapping.html#security-api-put-role-mapping) request + * + * @param {string} name - Role-mapping name + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * @param {object} body - The role to add + */ + return function xpackSecurityPutRoleMapping (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityPutRoleMapping(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['name'] == null) { + return callback( + new ConfigurationError('Missing required parameter: name'), + result + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'refresh' + ] + const acceptedQuerystringCamelCased = [ + 'refresh' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', 'role_mapping', params['name']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityPutRoleMapping diff --git a/api/api/xpack.security.put_user.js b/api/api/xpack.security.put_user.js new file mode 100644 index 000000000..466ebd4e7 --- /dev/null +++ b/api/api/xpack.security.put_user.js @@ -0,0 +1,100 @@ +'use strict' + +function buildXpackSecurityPutUser (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.put_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-users.html#security-api-put-user) request + * + * @param {string} username - The username of the User + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * @param {object} body - The user to add + */ + return function xpackSecurityPutUser (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityPutUser(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['username'] == null) { + return callback( + new ConfigurationError('Missing required parameter: username'), + result + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'refresh' + ] + const acceptedQuerystringCamelCased = [ + 'refresh' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', 'user', params['username']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityPutUser diff --git a/api/api/xpack.sql.clear_cursor.js b/api/api/xpack.sql.clear_cursor.js new file mode 100644 index 000000000..a93a52d99 --- /dev/null +++ b/api/api/xpack.sql.clear_cursor.js @@ -0,0 +1,92 @@ +'use strict' + +function buildXpackSqlClearCursor (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.sql.clear_cursor](Clear SQL cursor) request + * + * @param {object} body - Specify the cursor value in the `cursor` element to clean the cursor. + */ + return function xpackSqlClearCursor (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSqlClearCursor(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'sql', 'close'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSqlClearCursor diff --git a/api/api/xpack.sql.query.js b/api/api/xpack.sql.query.js new file mode 100644 index 000000000..917a341e7 --- /dev/null +++ b/api/api/xpack.sql.query.js @@ -0,0 +1,93 @@ +'use strict' + +function buildXpackSqlQuery (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.sql.query](Execute SQL) request + * + * @param {string} format - a short version of the Accept header, e.g. json, yaml + * @param {object} body - Use the `query` element to start a query. Use the `cursor` element to continue a query. + */ + return function xpackSqlQuery (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSqlQuery(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'format' + ] + const acceptedQuerystringCamelCased = [ + 'format' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'sql'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSqlQuery diff --git a/api/api/xpack.sql.translate.js b/api/api/xpack.sql.translate.js new file mode 100644 index 000000000..bc4c8929d --- /dev/null +++ b/api/api/xpack.sql.translate.js @@ -0,0 +1,92 @@ +'use strict' + +function buildXpackSqlTranslate (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.sql.translate](Translate SQL into Elasticsearch queries) request + * + * @param {object} body - Specify the query in the `query` element. + */ + return function xpackSqlTranslate (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSqlTranslate(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = params.body == null ? 'GET' : 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'sql', 'translate'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSqlTranslate diff --git a/api/api/xpack.ssl.certificates.js b/api/api/xpack.ssl.certificates.js new file mode 100644 index 000000000..6f588cc1f --- /dev/null +++ b/api/api/xpack.ssl.certificates.js @@ -0,0 +1,91 @@ +'use strict' + +function buildXpackSslCertificates (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ssl.certificates](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-ssl.html) request + * + */ + return function xpackSslCertificates (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSslCertificates(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ssl', 'certificates'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSslCertificates diff --git a/api/api/xpack.usage.js b/api/api/xpack.usage.js new file mode 100644 index 000000000..2b989e752 --- /dev/null +++ b/api/api/xpack.usage.js @@ -0,0 +1,92 @@ +'use strict' + +function buildXpackUsage (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.usage](Retrieve information about xpack features usage) request + * + * @param {time} master_timeout - Specify timeout for watch write operation + */ + return function xpackUsage (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackUsage(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'master_timeout' + ] + const acceptedQuerystringCamelCased = [ + 'masterTimeout' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'usage'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackUsage diff --git a/api/api/xpack.watcher.ack_watch.js b/api/api/xpack.watcher.ack_watch.js new file mode 100644 index 000000000..6bbb92a74 --- /dev/null +++ b/api/api/xpack.watcher.ack_watch.js @@ -0,0 +1,108 @@ +'use strict' + +function buildXpackWatcherAckWatch (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.watcher.ack_watch](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-ack-watch.html) request + * + * @param {string} watch_id - Watch ID + * @param {list} action_id - A comma-separated list of the action ids to be acked + * @param {time} master_timeout - Explicit operation timeout for connection to master node + */ + return function xpackWatcherAckWatch (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackWatcherAckWatch(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['watch_id'] == null && params['watchId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: watch_id or watchId'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // check required url components + if ((params['action_id'] != null || params['actionId'] != null) && ((params['watch_id'] == null || params['watchId']))) { + return callback( + new ConfigurationError('Missing required parameter of the url: watch_id'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'master_timeout' + ] + const acceptedQuerystringCamelCased = [ + 'masterTimeout' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'watcher', 'watch', params['watch_id'] || params['watchId'], '_ack', params['action_id'] || params['actionId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackWatcherAckWatch diff --git a/api/api/xpack.watcher.activate_watch.js b/api/api/xpack.watcher.activate_watch.js new file mode 100644 index 000000000..2669b8c39 --- /dev/null +++ b/api/api/xpack.watcher.activate_watch.js @@ -0,0 +1,99 @@ +'use strict' + +function buildXpackWatcherActivateWatch (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.watcher.activate_watch](https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-activate-watch.html) request + * + * @param {string} watch_id - Watch ID + * @param {time} master_timeout - Explicit operation timeout for connection to master node + */ + return function xpackWatcherActivateWatch (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackWatcherActivateWatch(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['watch_id'] == null && params['watchId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: watch_id or watchId'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'master_timeout' + ] + const acceptedQuerystringCamelCased = [ + 'masterTimeout' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'watcher', 'watch', params['watch_id'] || params['watchId'], '_activate'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackWatcherActivateWatch diff --git a/api/api/xpack.watcher.deactivate_watch.js b/api/api/xpack.watcher.deactivate_watch.js new file mode 100644 index 000000000..4e48a6ac5 --- /dev/null +++ b/api/api/xpack.watcher.deactivate_watch.js @@ -0,0 +1,99 @@ +'use strict' + +function buildXpackWatcherDeactivateWatch (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.watcher.deactivate_watch](https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-deactivate-watch.html) request + * + * @param {string} watch_id - Watch ID + * @param {time} master_timeout - Explicit operation timeout for connection to master node + */ + return function xpackWatcherDeactivateWatch (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackWatcherDeactivateWatch(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['watch_id'] == null && params['watchId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: watch_id or watchId'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'master_timeout' + ] + const acceptedQuerystringCamelCased = [ + 'masterTimeout' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'watcher', 'watch', params['watch_id'] || params['watchId'], '_deactivate'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackWatcherDeactivateWatch diff --git a/api/api/xpack.watcher.delete_watch.js b/api/api/xpack.watcher.delete_watch.js new file mode 100644 index 000000000..25a83f816 --- /dev/null +++ b/api/api/xpack.watcher.delete_watch.js @@ -0,0 +1,99 @@ +'use strict' + +function buildXpackWatcherDeleteWatch (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.watcher.delete_watch](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-delete-watch.html) request + * + * @param {string} id - Watch ID + * @param {time} master_timeout - Explicit operation timeout for connection to master node + */ + return function xpackWatcherDeleteWatch (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackWatcherDeleteWatch(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['id'] == null) { + return callback( + new ConfigurationError('Missing required parameter: id'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'master_timeout' + ] + const acceptedQuerystringCamelCased = [ + 'masterTimeout' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'watcher', 'watch', params['id']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackWatcherDeleteWatch diff --git a/api/api/xpack.watcher.execute_watch.js b/api/api/xpack.watcher.execute_watch.js new file mode 100644 index 000000000..4fddc77b8 --- /dev/null +++ b/api/api/xpack.watcher.execute_watch.js @@ -0,0 +1,86 @@ +'use strict' + +function buildXpackWatcherExecuteWatch (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.watcher.execute_watch](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-execute-watch.html) request + * + * @param {string} id - Watch ID + * @param {boolean} debug - indicates whether the watch should execute in debug mode + * @param {object} body - Execution control + */ + return function xpackWatcherExecuteWatch (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackWatcherExecuteWatch(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'debug' + ] + const acceptedQuerystringCamelCased = [ + 'debug' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'watcher', 'watch', params['id'], '_execute'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackWatcherExecuteWatch diff --git a/api/api/xpack.watcher.get_watch.js b/api/api/xpack.watcher.get_watch.js new file mode 100644 index 000000000..7afda8433 --- /dev/null +++ b/api/api/xpack.watcher.get_watch.js @@ -0,0 +1,98 @@ +'use strict' + +function buildXpackWatcherGetWatch (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.watcher.get_watch](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-watch.html) request + * + * @param {string} id - Watch ID + */ + return function xpackWatcherGetWatch (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackWatcherGetWatch(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['id'] == null) { + return callback( + new ConfigurationError('Missing required parameter: id'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'watcher', 'watch', params['id']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackWatcherGetWatch diff --git a/api/api/xpack.watcher.put_watch.js b/api/api/xpack.watcher.put_watch.js new file mode 100644 index 000000000..29d33296a --- /dev/null +++ b/api/api/xpack.watcher.put_watch.js @@ -0,0 +1,100 @@ +'use strict' + +function buildXpackWatcherPutWatch (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.watcher.put_watch](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html) request + * + * @param {string} id - Watch ID + * @param {time} master_timeout - Explicit operation timeout for connection to master node + * @param {boolean} active - Specify whether the watch is in/active by default + * @param {number} version - Explicit version number for concurrency control + * @param {object} body - The watch + */ + return function xpackWatcherPutWatch (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackWatcherPutWatch(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['id'] == null) { + return callback( + new ConfigurationError('Missing required parameter: id'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'master_timeout', + 'active', + 'version' + ] + const acceptedQuerystringCamelCased = [ + 'masterTimeout', + 'active', + 'version' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'watcher', 'watch', params['id']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackWatcherPutWatch diff --git a/api/api/xpack.watcher.restart.js b/api/api/xpack.watcher.restart.js new file mode 100644 index 000000000..f89aaf2ea --- /dev/null +++ b/api/api/xpack.watcher.restart.js @@ -0,0 +1,91 @@ +'use strict' + +function buildXpackWatcherRestart (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.watcher.restart](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-restart.html) request + * + */ + return function xpackWatcherRestart (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackWatcherRestart(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'watcher', '_restart'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackWatcherRestart diff --git a/api/api/xpack.watcher.start.js b/api/api/xpack.watcher.start.js new file mode 100644 index 000000000..2169f1149 --- /dev/null +++ b/api/api/xpack.watcher.start.js @@ -0,0 +1,91 @@ +'use strict' + +function buildXpackWatcherStart (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.watcher.start](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-start.html) request + * + */ + return function xpackWatcherStart (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackWatcherStart(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'watcher', '_start'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackWatcherStart diff --git a/api/api/xpack.watcher.stats.js b/api/api/xpack.watcher.stats.js new file mode 100644 index 000000000..f5b53ca03 --- /dev/null +++ b/api/api/xpack.watcher.stats.js @@ -0,0 +1,96 @@ +'use strict' + +function buildXpackWatcherStats (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.watcher.stats](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stats.html) request + * + * @param {enum} metric - Controls what additional stat metrics should be include in the response + * @param {enum} metric - Controls what additional stat metrics should be include in the response + * @param {boolean} emit_stacktraces - Emits stack traces of currently running watches + */ + return function xpackWatcherStats (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackWatcherStats(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'metric', + 'emit_stacktraces' + ] + const acceptedQuerystringCamelCased = [ + 'metric', + 'emitStacktraces' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'watcher', 'stats', params['metric']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackWatcherStats diff --git a/api/api/xpack.watcher.stop.js b/api/api/xpack.watcher.stop.js new file mode 100644 index 000000000..22f5d582f --- /dev/null +++ b/api/api/xpack.watcher.stop.js @@ -0,0 +1,91 @@ +'use strict' + +function buildXpackWatcherStop (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.watcher.stop](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stop.html) request + * + */ + return function xpackWatcherStop (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackWatcherStop(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'watcher', '_stop'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null, + agent: null, + url: '' + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackWatcherStop diff --git a/api/index.js b/api/index.js index 4d88a2504..20603b0a3 100644 --- a/api/index.js +++ b/api/index.js @@ -2,378 +2,628 @@ const assert = require('assert') +const bulk = require('./api/bulk.js') +const catAliases = require('./api/cat.aliases.js') +const catAllocation = require('./api/cat.allocation.js') +const catCount = require('./api/cat.count.js') +const catFielddata = require('./api/cat.fielddata.js') +const catHealth = require('./api/cat.health.js') +const catHelp = require('./api/cat.help.js') +const catIndices = require('./api/cat.indices.js') +const catMaster = require('./api/cat.master.js') +const catNodeattrs = require('./api/cat.nodeattrs.js') +const catNodes = require('./api/cat.nodes.js') +const catPendingTasks = require('./api/cat.pending_tasks.js') +const catPlugins = require('./api/cat.plugins.js') +const catRecovery = require('./api/cat.recovery.js') +const catRepositories = require('./api/cat.repositories.js') +const catSegments = require('./api/cat.segments.js') +const catShards = require('./api/cat.shards.js') +const catSnapshots = require('./api/cat.snapshots.js') +const catTasks = require('./api/cat.tasks.js') +const catTemplates = require('./api/cat.templates.js') +const catThreadPool = require('./api/cat.thread_pool.js') +const clearScroll = require('./api/clear_scroll.js') +const clusterAllocationExplain = require('./api/cluster.allocation_explain.js') +const clusterGetSettings = require('./api/cluster.get_settings.js') +const clusterHealth = require('./api/cluster.health.js') +const clusterPendingTasks = require('./api/cluster.pending_tasks.js') +const clusterPutSettings = require('./api/cluster.put_settings.js') +const clusterRemoteInfo = require('./api/cluster.remote_info.js') +const clusterReroute = require('./api/cluster.reroute.js') +const clusterState = require('./api/cluster.state.js') +const clusterStats = require('./api/cluster.stats.js') +const count = require('./api/count.js') +const create = require('./api/create.js') +const _delete = require('./api/delete.js') +const deleteByQuery = require('./api/delete_by_query.js') +const deleteScript = require('./api/delete_script.js') +const exists = require('./api/exists.js') +const existsSource = require('./api/exists_source.js') +const explain = require('./api/explain.js') +const fieldCaps = require('./api/field_caps.js') +const get = require('./api/get.js') +const getScript = require('./api/get_script.js') +const getSource = require('./api/get_source.js') +const index = require('./api/index.js') +const indicesAnalyze = require('./api/indices.analyze.js') +const indicesClearCache = require('./api/indices.clear_cache.js') +const indicesClose = require('./api/indices.close.js') +const indicesCreate = require('./api/indices.create.js') +const indicesDelete = require('./api/indices.delete.js') +const indicesDeleteAlias = require('./api/indices.delete_alias.js') +const indicesDeleteTemplate = require('./api/indices.delete_template.js') +const indicesExists = require('./api/indices.exists.js') +const indicesExistsAlias = require('./api/indices.exists_alias.js') +const indicesExistsTemplate = require('./api/indices.exists_template.js') +const indicesExistsType = require('./api/indices.exists_type.js') +const indicesFlush = require('./api/indices.flush.js') +const indicesFlushSynced = require('./api/indices.flush_synced.js') +const indicesForcemerge = require('./api/indices.forcemerge.js') +const indicesGet = require('./api/indices.get.js') +const indicesGetAlias = require('./api/indices.get_alias.js') +const indicesGetFieldMapping = require('./api/indices.get_field_mapping.js') +const indicesGetMapping = require('./api/indices.get_mapping.js') +const indicesGetSettings = require('./api/indices.get_settings.js') +const indicesGetTemplate = require('./api/indices.get_template.js') +const indicesGetUpgrade = require('./api/indices.get_upgrade.js') +const indicesOpen = require('./api/indices.open.js') +const indicesPutAlias = require('./api/indices.put_alias.js') +const indicesPutMapping = require('./api/indices.put_mapping.js') +const indicesPutSettings = require('./api/indices.put_settings.js') +const indicesPutTemplate = require('./api/indices.put_template.js') +const indicesRecovery = require('./api/indices.recovery.js') +const indicesRefresh = require('./api/indices.refresh.js') +const indicesRollover = require('./api/indices.rollover.js') +const indicesSegments = require('./api/indices.segments.js') +const indicesShardStores = require('./api/indices.shard_stores.js') +const indicesShrink = require('./api/indices.shrink.js') +const indicesSplit = require('./api/indices.split.js') +const indicesStats = require('./api/indices.stats.js') +const indicesUpdateAliases = require('./api/indices.update_aliases.js') +const indicesUpgrade = require('./api/indices.upgrade.js') +const indicesValidateQuery = require('./api/indices.validate_query.js') +const info = require('./api/info.js') +const ingestDeletePipeline = require('./api/ingest.delete_pipeline.js') +const ingestGetPipeline = require('./api/ingest.get_pipeline.js') +const ingestProcessorGrok = require('./api/ingest.processor_grok.js') +const ingestPutPipeline = require('./api/ingest.put_pipeline.js') +const ingestSimulate = require('./api/ingest.simulate.js') +const mget = require('./api/mget.js') +const msearch = require('./api/msearch.js') +const msearchTemplate = require('./api/msearch_template.js') +const mtermvectors = require('./api/mtermvectors.js') +const nodesHotThreads = require('./api/nodes.hot_threads.js') +const nodesInfo = require('./api/nodes.info.js') +const nodesStats = require('./api/nodes.stats.js') +const nodesUsage = require('./api/nodes.usage.js') +const ping = require('./api/ping.js') +const putScript = require('./api/put_script.js') +const rankEval = require('./api/rank_eval.js') +const reindex = require('./api/reindex.js') +const reindexRethrottle = require('./api/reindex_rethrottle.js') +const renderSearchTemplate = require('./api/render_search_template.js') +const scriptsPainlessExecute = require('./api/scripts_painless_execute.js') +const scroll = require('./api/scroll.js') +const search = require('./api/search.js') +const searchShards = require('./api/search_shards.js') +const searchTemplate = require('./api/search_template.js') +const snapshotCreate = require('./api/snapshot.create.js') +const snapshotCreateRepository = require('./api/snapshot.create_repository.js') +const snapshotDelete = require('./api/snapshot.delete.js') +const snapshotDeleteRepository = require('./api/snapshot.delete_repository.js') +const snapshotGet = require('./api/snapshot.get.js') +const snapshotGetRepository = require('./api/snapshot.get_repository.js') +const snapshotRestore = require('./api/snapshot.restore.js') +const snapshotStatus = require('./api/snapshot.status.js') +const snapshotVerifyRepository = require('./api/snapshot.verify_repository.js') +const tasksCancel = require('./api/tasks.cancel.js') +const tasksGet = require('./api/tasks.get.js') +const tasksList = require('./api/tasks.list.js') +const termvectors = require('./api/termvectors.js') +const update = require('./api/update.js') +const updateByQuery = require('./api/update_by_query.js') +const xpackGraphExplore = require('./api/xpack.graph.explore.js') +const xpackInfo = require('./api/xpack.info.js') +const xpackLicenseDelete = require('./api/xpack.license.delete.js') +const xpackLicenseGet = require('./api/xpack.license.get.js') +const xpackLicenseGetBasicStatus = require('./api/xpack.license.get_basic_status.js') +const xpackLicenseGetTrialStatus = require('./api/xpack.license.get_trial_status.js') +const xpackLicensePost = require('./api/xpack.license.post.js') +const xpackLicensePostStartBasic = require('./api/xpack.license.post_start_basic.js') +const xpackLicensePostStartTrial = require('./api/xpack.license.post_start_trial.js') +const xpackMigrationDeprecations = require('./api/xpack.migration.deprecations.js') +const xpackMigrationGetAssistance = require('./api/xpack.migration.get_assistance.js') +const xpackMigrationUpgrade = require('./api/xpack.migration.upgrade.js') +const xpackMlCloseJob = require('./api/xpack.ml.close_job.js') +const xpackMlDeleteCalendar = require('./api/xpack.ml.delete_calendar.js') +const xpackMlDeleteCalendarEvent = require('./api/xpack.ml.delete_calendar_event.js') +const xpackMlDeleteCalendarJob = require('./api/xpack.ml.delete_calendar_job.js') +const xpackMlDeleteDatafeed = require('./api/xpack.ml.delete_datafeed.js') +const xpackMlDeleteExpiredData = require('./api/xpack.ml.delete_expired_data.js') +const xpackMlDeleteFilter = require('./api/xpack.ml.delete_filter.js') +const xpackMlDeleteJob = require('./api/xpack.ml.delete_job.js') +const xpackMlDeleteModelSnapshot = require('./api/xpack.ml.delete_model_snapshot.js') +const xpackMlFlushJob = require('./api/xpack.ml.flush_job.js') +const xpackMlForecast = require('./api/xpack.ml.forecast.js') +const xpackMlGetBuckets = require('./api/xpack.ml.get_buckets.js') +const xpackMlGetCalendarEvents = require('./api/xpack.ml.get_calendar_events.js') +const xpackMlGetCalendars = require('./api/xpack.ml.get_calendars.js') +const xpackMlGetCategories = require('./api/xpack.ml.get_categories.js') +const xpackMlGetDatafeedStats = require('./api/xpack.ml.get_datafeed_stats.js') +const xpackMlGetDatafeeds = require('./api/xpack.ml.get_datafeeds.js') +const xpackMlGetFilters = require('./api/xpack.ml.get_filters.js') +const xpackMlGetInfluencers = require('./api/xpack.ml.get_influencers.js') +const xpackMlGetJobStats = require('./api/xpack.ml.get_job_stats.js') +const xpackMlGetJobs = require('./api/xpack.ml.get_jobs.js') +const xpackMlGetModelSnapshots = require('./api/xpack.ml.get_model_snapshots.js') +const xpackMlGetOverallBuckets = require('./api/xpack.ml.get_overall_buckets.js') +const xpackMlGetRecords = require('./api/xpack.ml.get_records.js') +const xpackMlInfo = require('./api/xpack.ml.info.js') +const xpackMlOpenJob = require('./api/xpack.ml.open_job.js') +const xpackMlPostCalendarEvents = require('./api/xpack.ml.post_calendar_events.js') +const xpackMlPostData = require('./api/xpack.ml.post_data.js') +const xpackMlPreviewDatafeed = require('./api/xpack.ml.preview_datafeed.js') +const xpackMlPutCalendar = require('./api/xpack.ml.put_calendar.js') +const xpackMlPutCalendarJob = require('./api/xpack.ml.put_calendar_job.js') +const xpackMlPutDatafeed = require('./api/xpack.ml.put_datafeed.js') +const xpackMlPutFilter = require('./api/xpack.ml.put_filter.js') +const xpackMlPutJob = require('./api/xpack.ml.put_job.js') +const xpackMlRevertModelSnapshot = require('./api/xpack.ml.revert_model_snapshot.js') +const xpackMlStartDatafeed = require('./api/xpack.ml.start_datafeed.js') +const xpackMlStopDatafeed = require('./api/xpack.ml.stop_datafeed.js') +const xpackMlUpdateDatafeed = require('./api/xpack.ml.update_datafeed.js') +const xpackMlUpdateFilter = require('./api/xpack.ml.update_filter.js') +const xpackMlUpdateJob = require('./api/xpack.ml.update_job.js') +const xpackMlUpdateModelSnapshot = require('./api/xpack.ml.update_model_snapshot.js') +const xpackMlValidate = require('./api/xpack.ml.validate.js') +const xpackMlValidateDetector = require('./api/xpack.ml.validate_detector.js') +const xpackMonitoringBulk = require('./api/xpack.monitoring.bulk.js') +const xpackRollupDeleteJob = require('./api/xpack.rollup.delete_job.js') +const xpackRollupGetJobs = require('./api/xpack.rollup.get_jobs.js') +const xpackRollupGetRollupCaps = require('./api/xpack.rollup.get_rollup_caps.js') +const xpackRollupGetRollupIndexCaps = require('./api/xpack.rollup.get_rollup_index_caps.js') +const xpackRollupPutJob = require('./api/xpack.rollup.put_job.js') +const xpackRollupRollupSearch = require('./api/xpack.rollup.rollup_search.js') +const xpackRollupStartJob = require('./api/xpack.rollup.start_job.js') +const xpackRollupStopJob = require('./api/xpack.rollup.stop_job.js') +const xpackSecurityAuthenticate = require('./api/xpack.security.authenticate.js') +const xpackSecurityChangePassword = require('./api/xpack.security.change_password.js') +const xpackSecurityClearCachedRealms = require('./api/xpack.security.clear_cached_realms.js') +const xpackSecurityClearCachedRoles = require('./api/xpack.security.clear_cached_roles.js') +const xpackSecurityDeletePrivileges = require('./api/xpack.security.delete_privileges.js') +const xpackSecurityDeleteRole = require('./api/xpack.security.delete_role.js') +const xpackSecurityDeleteRoleMapping = require('./api/xpack.security.delete_role_mapping.js') +const xpackSecurityDeleteUser = require('./api/xpack.security.delete_user.js') +const xpackSecurityDisableUser = require('./api/xpack.security.disable_user.js') +const xpackSecurityEnableUser = require('./api/xpack.security.enable_user.js') +const xpackSecurityGetPrivileges = require('./api/xpack.security.get_privileges.js') +const xpackSecurityGetRole = require('./api/xpack.security.get_role.js') +const xpackSecurityGetRoleMapping = require('./api/xpack.security.get_role_mapping.js') +const xpackSecurityGetToken = require('./api/xpack.security.get_token.js') +const xpackSecurityGetUser = require('./api/xpack.security.get_user.js') +const xpackSecurityHasPrivileges = require('./api/xpack.security.has_privileges.js') +const xpackSecurityInvalidateToken = require('./api/xpack.security.invalidate_token.js') +const xpackSecurityPutPrivileges = require('./api/xpack.security.put_privileges.js') +const xpackSecurityPutRole = require('./api/xpack.security.put_role.js') +const xpackSecurityPutRoleMapping = require('./api/xpack.security.put_role_mapping.js') +const xpackSecurityPutUser = require('./api/xpack.security.put_user.js') +const xpackSqlClearCursor = require('./api/xpack.sql.clear_cursor.js') +const xpackSqlQuery = require('./api/xpack.sql.query.js') +const xpackSqlTranslate = require('./api/xpack.sql.translate.js') +const xpackSslCertificates = require('./api/xpack.ssl.certificates.js') +const xpackUsage = require('./api/xpack.usage.js') +const xpackWatcherAckWatch = require('./api/xpack.watcher.ack_watch.js') +const xpackWatcherActivateWatch = require('./api/xpack.watcher.activate_watch.js') +const xpackWatcherDeactivateWatch = require('./api/xpack.watcher.deactivate_watch.js') +const xpackWatcherDeleteWatch = require('./api/xpack.watcher.delete_watch.js') +const xpackWatcherExecuteWatch = require('./api/xpack.watcher.execute_watch.js') +const xpackWatcherGetWatch = require('./api/xpack.watcher.get_watch.js') +const xpackWatcherPutWatch = require('./api/xpack.watcher.put_watch.js') +const xpackWatcherRestart = require('./api/xpack.watcher.restart.js') +const xpackWatcherStart = require('./api/xpack.watcher.start.js') +const xpackWatcherStats = require('./api/xpack.watcher.stats.js') +const xpackWatcherStop = require('./api/xpack.watcher.stop.js') + function ESAPI (opts) { assert(opts.makeRequest, 'Missing makeRequest function') assert(opts.ConfigurationError, 'Missing ConfigurationError class') assert(opts.result, 'Missing default result object') const apis = { - bulk: require('./api/bulk.js')(opts), + bulk: bulk(opts), cat: { - aliases: require('./api/cat.aliases.js')(opts), - allocation: require('./api/cat.allocation.js')(opts), - count: require('./api/cat.count.js')(opts), - fielddata: require('./api/cat.fielddata.js')(opts), - health: require('./api/cat.health.js')(opts), - help: require('./api/cat.help.js')(opts), - indices: require('./api/cat.indices.js')(opts), - master: require('./api/cat.master.js')(opts), - nodeattrs: require('./api/cat.nodeattrs.js')(opts), - nodes: require('./api/cat.nodes.js')(opts), - pending_tasks: require('./api/cat.pending_tasks.js')(opts), - plugins: require('./api/cat.plugins.js')(opts), - recovery: require('./api/cat.recovery.js')(opts), - repositories: require('./api/cat.repositories.js')(opts), - segments: require('./api/cat.segments.js')(opts), - shards: require('./api/cat.shards.js')(opts), - snapshots: require('./api/cat.snapshots.js')(opts), - tasks: require('./api/cat.tasks.js')(opts), - templates: require('./api/cat.templates.js')(opts), - thread_pool: require('./api/cat.thread_pool.js')(opts) + aliases: catAliases(opts), + allocation: catAllocation(opts), + count: catCount(opts), + fielddata: catFielddata(opts), + health: catHealth(opts), + help: catHelp(opts), + indices: catIndices(opts), + master: catMaster(opts), + nodeattrs: catNodeattrs(opts), + nodes: catNodes(opts), + pending_tasks: catPendingTasks(opts), + pendingTasks: catPendingTasks(opts), + plugins: catPlugins(opts), + recovery: catRecovery(opts), + repositories: catRepositories(opts), + segments: catSegments(opts), + shards: catShards(opts), + snapshots: catSnapshots(opts), + tasks: catTasks(opts), + templates: catTemplates(opts), + thread_pool: catThreadPool(opts), + threadPool: catThreadPool(opts) }, - clear_scroll: require('./api/clear_scroll.js')(opts), + clear_scroll: clearScroll(opts), + clearScroll: clearScroll(opts), cluster: { - allocation_explain: require('./api/cluster.allocation_explain.js')(opts), - get_settings: require('./api/cluster.get_settings.js')(opts), - health: require('./api/cluster.health.js')(opts), - pending_tasks: require('./api/cluster.pending_tasks.js')(opts), - put_settings: require('./api/cluster.put_settings.js')(opts), - remote_info: require('./api/cluster.remote_info.js')(opts), - reroute: require('./api/cluster.reroute.js')(opts), - state: require('./api/cluster.state.js')(opts), - stats: require('./api/cluster.stats.js')(opts) + allocation_explain: clusterAllocationExplain(opts), + allocationExplain: clusterAllocationExplain(opts), + get_settings: clusterGetSettings(opts), + getSettings: clusterGetSettings(opts), + health: clusterHealth(opts), + pending_tasks: clusterPendingTasks(opts), + pendingTasks: clusterPendingTasks(opts), + put_settings: clusterPutSettings(opts), + putSettings: clusterPutSettings(opts), + remote_info: clusterRemoteInfo(opts), + remoteInfo: clusterRemoteInfo(opts), + reroute: clusterReroute(opts), + state: clusterState(opts), + stats: clusterStats(opts) }, - count: require('./api/count.js')(opts), - create: require('./api/create.js')(opts), - delete: require('./api/delete.js')(opts), - delete_by_query: require('./api/delete_by_query.js')(opts), - delete_script: require('./api/delete_script.js')(opts), - exists: require('./api/exists.js')(opts), - exists_source: require('./api/exists_source.js')(opts), - explain: require('./api/explain.js')(opts), - field_caps: require('./api/field_caps.js')(opts), - get: require('./api/get.js')(opts), - get_script: require('./api/get_script.js')(opts), - get_source: require('./api/get_source.js')(opts), - index: require('./api/index.js')(opts), + count: count(opts), + create: create(opts), + delete: _delete(opts), + delete_by_query: deleteByQuery(opts), + deleteByQuery: deleteByQuery(opts), + delete_script: deleteScript(opts), + deleteScript: deleteScript(opts), + exists: exists(opts), + exists_source: existsSource(opts), + existsSource: existsSource(opts), + explain: explain(opts), + field_caps: fieldCaps(opts), + fieldCaps: fieldCaps(opts), + get: get(opts), + get_script: getScript(opts), + getScript: getScript(opts), + get_source: getSource(opts), + getSource: getSource(opts), + index: index(opts), indices: { - analyze: require('./api/indices.analyze.js')(opts), - clear_cache: require('./api/indices.clear_cache.js')(opts), - close: require('./api/indices.close.js')(opts), - create: require('./api/indices.create.js')(opts), - delete: require('./api/indices.delete.js')(opts), - delete_alias: require('./api/indices.delete_alias.js')(opts), - delete_template: require('./api/indices.delete_template.js')(opts), - exists: require('./api/indices.exists.js')(opts), - exists_alias: require('./api/indices.exists_alias.js')(opts), - exists_template: require('./api/indices.exists_template.js')(opts), - exists_type: require('./api/indices.exists_type.js')(opts), - flush: require('./api/indices.flush.js')(opts), - flush_synced: require('./api/indices.flush_synced.js')(opts), - forcemerge: require('./api/indices.forcemerge.js')(opts), - get: require('./api/indices.get.js')(opts), - get_alias: require('./api/indices.get_alias.js')(opts), - get_field_mapping: require('./api/indices.get_field_mapping.js')(opts), - get_mapping: require('./api/indices.get_mapping.js')(opts), - get_settings: require('./api/indices.get_settings.js')(opts), - get_template: require('./api/indices.get_template.js')(opts), - get_upgrade: require('./api/indices.get_upgrade.js')(opts), - open: require('./api/indices.open.js')(opts), - put_alias: require('./api/indices.put_alias.js')(opts), - put_mapping: require('./api/indices.put_mapping.js')(opts), - put_settings: require('./api/indices.put_settings.js')(opts), - put_template: require('./api/indices.put_template.js')(opts), - recovery: require('./api/indices.recovery.js')(opts), - refresh: require('./api/indices.refresh.js')(opts), - rollover: require('./api/indices.rollover.js')(opts), - segments: require('./api/indices.segments.js')(opts), - shard_stores: require('./api/indices.shard_stores.js')(opts), - shrink: require('./api/indices.shrink.js')(opts), - split: require('./api/indices.split.js')(opts), - stats: require('./api/indices.stats.js')(opts), - update_aliases: require('./api/indices.update_aliases.js')(opts), - upgrade: require('./api/indices.upgrade.js')(opts), - validate_query: require('./api/indices.validate_query.js')(opts) + analyze: indicesAnalyze(opts), + clear_cache: indicesClearCache(opts), + clearCache: indicesClearCache(opts), + close: indicesClose(opts), + create: indicesCreate(opts), + delete: indicesDelete(opts), + delete_alias: indicesDeleteAlias(opts), + deleteAlias: indicesDeleteAlias(opts), + delete_template: indicesDeleteTemplate(opts), + deleteTemplate: indicesDeleteTemplate(opts), + exists: indicesExists(opts), + exists_alias: indicesExistsAlias(opts), + existsAlias: indicesExistsAlias(opts), + exists_template: indicesExistsTemplate(opts), + existsTemplate: indicesExistsTemplate(opts), + exists_type: indicesExistsType(opts), + existsType: indicesExistsType(opts), + flush: indicesFlush(opts), + flush_synced: indicesFlushSynced(opts), + flushSynced: indicesFlushSynced(opts), + forcemerge: indicesForcemerge(opts), + get: indicesGet(opts), + get_alias: indicesGetAlias(opts), + getAlias: indicesGetAlias(opts), + get_field_mapping: indicesGetFieldMapping(opts), + getFieldMapping: indicesGetFieldMapping(opts), + get_mapping: indicesGetMapping(opts), + getMapping: indicesGetMapping(opts), + get_settings: indicesGetSettings(opts), + getSettings: indicesGetSettings(opts), + get_template: indicesGetTemplate(opts), + getTemplate: indicesGetTemplate(opts), + get_upgrade: indicesGetUpgrade(opts), + getUpgrade: indicesGetUpgrade(opts), + open: indicesOpen(opts), + put_alias: indicesPutAlias(opts), + putAlias: indicesPutAlias(opts), + put_mapping: indicesPutMapping(opts), + putMapping: indicesPutMapping(opts), + put_settings: indicesPutSettings(opts), + putSettings: indicesPutSettings(opts), + put_template: indicesPutTemplate(opts), + putTemplate: indicesPutTemplate(opts), + recovery: indicesRecovery(opts), + refresh: indicesRefresh(opts), + rollover: indicesRollover(opts), + segments: indicesSegments(opts), + shard_stores: indicesShardStores(opts), + shardStores: indicesShardStores(opts), + shrink: indicesShrink(opts), + split: indicesSplit(opts), + stats: indicesStats(opts), + update_aliases: indicesUpdateAliases(opts), + updateAliases: indicesUpdateAliases(opts), + upgrade: indicesUpgrade(opts), + validate_query: indicesValidateQuery(opts), + validateQuery: indicesValidateQuery(opts) }, - info: require('./api/info.js')(opts), + info: info(opts), ingest: { - delete_pipeline: require('./api/ingest.delete_pipeline.js')(opts), - get_pipeline: require('./api/ingest.get_pipeline.js')(opts), - processor_grok: require('./api/ingest.processor_grok.js')(opts), - put_pipeline: require('./api/ingest.put_pipeline.js')(opts), - simulate: require('./api/ingest.simulate.js')(opts) + delete_pipeline: ingestDeletePipeline(opts), + deletePipeline: ingestDeletePipeline(opts), + get_pipeline: ingestGetPipeline(opts), + getPipeline: ingestGetPipeline(opts), + processor_grok: ingestProcessorGrok(opts), + processorGrok: ingestProcessorGrok(opts), + put_pipeline: ingestPutPipeline(opts), + putPipeline: ingestPutPipeline(opts), + simulate: ingestSimulate(opts) }, - mget: require('./api/mget.js')(opts), - msearch: require('./api/msearch.js')(opts), - msearch_template: require('./api/msearch_template.js')(opts), - mtermvectors: require('./api/mtermvectors.js')(opts), + mget: mget(opts), + msearch: msearch(opts), + msearch_template: msearchTemplate(opts), + msearchTemplate: msearchTemplate(opts), + mtermvectors: mtermvectors(opts), nodes: { - hot_threads: require('./api/nodes.hot_threads.js')(opts), - info: require('./api/nodes.info.js')(opts), - stats: require('./api/nodes.stats.js')(opts), - usage: require('./api/nodes.usage.js')(opts) + hot_threads: nodesHotThreads(opts), + hotThreads: nodesHotThreads(opts), + info: nodesInfo(opts), + stats: nodesStats(opts), + usage: nodesUsage(opts) }, - ping: require('./api/ping.js')(opts), - put_script: require('./api/put_script.js')(opts), - rank_eval: require('./api/rank_eval.js')(opts), - reindex: require('./api/reindex.js')(opts), - reindex_rethrottle: require('./api/reindex_rethrottle.js')(opts), - render_search_template: require('./api/render_search_template.js')(opts), - scripts_painless_execute: require('./api/scripts_painless_execute.js')(opts), - scroll: require('./api/scroll.js')(opts), - search: require('./api/search.js')(opts), - search_shards: require('./api/search_shards.js')(opts), - search_template: require('./api/search_template.js')(opts), + ping: ping(opts), + put_script: putScript(opts), + putScript: putScript(opts), + rank_eval: rankEval(opts), + rankEval: rankEval(opts), + reindex: reindex(opts), + reindex_rethrottle: reindexRethrottle(opts), + reindexRethrottle: reindexRethrottle(opts), + render_search_template: renderSearchTemplate(opts), + renderSearchTemplate: renderSearchTemplate(opts), + scripts_painless_execute: scriptsPainlessExecute(opts), + scriptsPainlessExecute: scriptsPainlessExecute(opts), + scroll: scroll(opts), + search: search(opts), + search_shards: searchShards(opts), + searchShards: searchShards(opts), + search_template: searchTemplate(opts), + searchTemplate: searchTemplate(opts), snapshot: { - create: require('./api/snapshot.create.js')(opts), - create_repository: require('./api/snapshot.create_repository.js')(opts), - delete: require('./api/snapshot.delete.js')(opts), - delete_repository: require('./api/snapshot.delete_repository.js')(opts), - get: require('./api/snapshot.get.js')(opts), - get_repository: require('./api/snapshot.get_repository.js')(opts), - restore: require('./api/snapshot.restore.js')(opts), - status: require('./api/snapshot.status.js')(opts), - verify_repository: require('./api/snapshot.verify_repository.js')(opts) + create: snapshotCreate(opts), + create_repository: snapshotCreateRepository(opts), + createRepository: snapshotCreateRepository(opts), + delete: snapshotDelete(opts), + delete_repository: snapshotDeleteRepository(opts), + deleteRepository: snapshotDeleteRepository(opts), + get: snapshotGet(opts), + get_repository: snapshotGetRepository(opts), + getRepository: snapshotGetRepository(opts), + restore: snapshotRestore(opts), + status: snapshotStatus(opts), + verify_repository: snapshotVerifyRepository(opts), + verifyRepository: snapshotVerifyRepository(opts) }, tasks: { - cancel: require('./api/tasks.cancel.js')(opts), - get: require('./api/tasks.get.js')(opts), - list: require('./api/tasks.list.js')(opts) + cancel: tasksCancel(opts), + get: tasksGet(opts), + list: tasksList(opts) }, - termvectors: require('./api/termvectors.js')(opts), - update: require('./api/update.js')(opts), - update_by_query: require('./api/update_by_query.js')(opts) + termvectors: termvectors(opts), + update: update(opts), + update_by_query: updateByQuery(opts), + updateByQuery: updateByQuery(opts), + xpack: { + graph: { + explore: xpackGraphExplore(opts) + }, + info: xpackInfo(opts), + license: { + delete: xpackLicenseDelete(opts), + get: xpackLicenseGet(opts), + get_basic_status: xpackLicenseGetBasicStatus(opts), + getBasicStatus: xpackLicenseGetBasicStatus(opts), + get_trial_status: xpackLicenseGetTrialStatus(opts), + getTrialStatus: xpackLicenseGetTrialStatus(opts), + post: xpackLicensePost(opts), + post_start_basic: xpackLicensePostStartBasic(opts), + postStartBasic: xpackLicensePostStartBasic(opts), + post_start_trial: xpackLicensePostStartTrial(opts), + postStartTrial: xpackLicensePostStartTrial(opts) + }, + migration: { + deprecations: xpackMigrationDeprecations(opts), + get_assistance: xpackMigrationGetAssistance(opts), + getAssistance: xpackMigrationGetAssistance(opts), + upgrade: xpackMigrationUpgrade(opts) + }, + ml: { + close_job: xpackMlCloseJob(opts), + closeJob: xpackMlCloseJob(opts), + delete_calendar: xpackMlDeleteCalendar(opts), + deleteCalendar: xpackMlDeleteCalendar(opts), + delete_calendar_event: xpackMlDeleteCalendarEvent(opts), + deleteCalendarEvent: xpackMlDeleteCalendarEvent(opts), + delete_calendar_job: xpackMlDeleteCalendarJob(opts), + deleteCalendarJob: xpackMlDeleteCalendarJob(opts), + delete_datafeed: xpackMlDeleteDatafeed(opts), + deleteDatafeed: xpackMlDeleteDatafeed(opts), + delete_expired_data: xpackMlDeleteExpiredData(opts), + deleteExpiredData: xpackMlDeleteExpiredData(opts), + delete_filter: xpackMlDeleteFilter(opts), + deleteFilter: xpackMlDeleteFilter(opts), + delete_job: xpackMlDeleteJob(opts), + deleteJob: xpackMlDeleteJob(opts), + delete_model_snapshot: xpackMlDeleteModelSnapshot(opts), + deleteModelSnapshot: xpackMlDeleteModelSnapshot(opts), + flush_job: xpackMlFlushJob(opts), + flushJob: xpackMlFlushJob(opts), + forecast: xpackMlForecast(opts), + get_buckets: xpackMlGetBuckets(opts), + getBuckets: xpackMlGetBuckets(opts), + get_calendar_events: xpackMlGetCalendarEvents(opts), + getCalendarEvents: xpackMlGetCalendarEvents(opts), + get_calendars: xpackMlGetCalendars(opts), + getCalendars: xpackMlGetCalendars(opts), + get_categories: xpackMlGetCategories(opts), + getCategories: xpackMlGetCategories(opts), + get_datafeed_stats: xpackMlGetDatafeedStats(opts), + getDatafeedStats: xpackMlGetDatafeedStats(opts), + get_datafeeds: xpackMlGetDatafeeds(opts), + getDatafeeds: xpackMlGetDatafeeds(opts), + get_filters: xpackMlGetFilters(opts), + getFilters: xpackMlGetFilters(opts), + get_influencers: xpackMlGetInfluencers(opts), + getInfluencers: xpackMlGetInfluencers(opts), + get_job_stats: xpackMlGetJobStats(opts), + getJobStats: xpackMlGetJobStats(opts), + get_jobs: xpackMlGetJobs(opts), + getJobs: xpackMlGetJobs(opts), + get_model_snapshots: xpackMlGetModelSnapshots(opts), + getModelSnapshots: xpackMlGetModelSnapshots(opts), + get_overall_buckets: xpackMlGetOverallBuckets(opts), + getOverallBuckets: xpackMlGetOverallBuckets(opts), + get_records: xpackMlGetRecords(opts), + getRecords: xpackMlGetRecords(opts), + info: xpackMlInfo(opts), + open_job: xpackMlOpenJob(opts), + openJob: xpackMlOpenJob(opts), + post_calendar_events: xpackMlPostCalendarEvents(opts), + postCalendarEvents: xpackMlPostCalendarEvents(opts), + post_data: xpackMlPostData(opts), + postData: xpackMlPostData(opts), + preview_datafeed: xpackMlPreviewDatafeed(opts), + previewDatafeed: xpackMlPreviewDatafeed(opts), + put_calendar: xpackMlPutCalendar(opts), + putCalendar: xpackMlPutCalendar(opts), + put_calendar_job: xpackMlPutCalendarJob(opts), + putCalendarJob: xpackMlPutCalendarJob(opts), + put_datafeed: xpackMlPutDatafeed(opts), + putDatafeed: xpackMlPutDatafeed(opts), + put_filter: xpackMlPutFilter(opts), + putFilter: xpackMlPutFilter(opts), + put_job: xpackMlPutJob(opts), + putJob: xpackMlPutJob(opts), + revert_model_snapshot: xpackMlRevertModelSnapshot(opts), + revertModelSnapshot: xpackMlRevertModelSnapshot(opts), + start_datafeed: xpackMlStartDatafeed(opts), + startDatafeed: xpackMlStartDatafeed(opts), + stop_datafeed: xpackMlStopDatafeed(opts), + stopDatafeed: xpackMlStopDatafeed(opts), + update_datafeed: xpackMlUpdateDatafeed(opts), + updateDatafeed: xpackMlUpdateDatafeed(opts), + update_filter: xpackMlUpdateFilter(opts), + updateFilter: xpackMlUpdateFilter(opts), + update_job: xpackMlUpdateJob(opts), + updateJob: xpackMlUpdateJob(opts), + update_model_snapshot: xpackMlUpdateModelSnapshot(opts), + updateModelSnapshot: xpackMlUpdateModelSnapshot(opts), + validate: xpackMlValidate(opts), + validate_detector: xpackMlValidateDetector(opts), + validateDetector: xpackMlValidateDetector(opts) + }, + monitoring: { + bulk: xpackMonitoringBulk(opts) + }, + rollup: { + delete_job: xpackRollupDeleteJob(opts), + deleteJob: xpackRollupDeleteJob(opts), + get_jobs: xpackRollupGetJobs(opts), + getJobs: xpackRollupGetJobs(opts), + get_rollup_caps: xpackRollupGetRollupCaps(opts), + getRollupCaps: xpackRollupGetRollupCaps(opts), + get_rollup_index_caps: xpackRollupGetRollupIndexCaps(opts), + getRollupIndexCaps: xpackRollupGetRollupIndexCaps(opts), + put_job: xpackRollupPutJob(opts), + putJob: xpackRollupPutJob(opts), + rollup_search: xpackRollupRollupSearch(opts), + rollupSearch: xpackRollupRollupSearch(opts), + start_job: xpackRollupStartJob(opts), + startJob: xpackRollupStartJob(opts), + stop_job: xpackRollupStopJob(opts), + stopJob: xpackRollupStopJob(opts) + }, + security: { + authenticate: xpackSecurityAuthenticate(opts), + change_password: xpackSecurityChangePassword(opts), + changePassword: xpackSecurityChangePassword(opts), + clear_cached_realms: xpackSecurityClearCachedRealms(opts), + clearCachedRealms: xpackSecurityClearCachedRealms(opts), + clear_cached_roles: xpackSecurityClearCachedRoles(opts), + clearCachedRoles: xpackSecurityClearCachedRoles(opts), + delete_privileges: xpackSecurityDeletePrivileges(opts), + deletePrivileges: xpackSecurityDeletePrivileges(opts), + delete_role: xpackSecurityDeleteRole(opts), + deleteRole: xpackSecurityDeleteRole(opts), + delete_role_mapping: xpackSecurityDeleteRoleMapping(opts), + deleteRoleMapping: xpackSecurityDeleteRoleMapping(opts), + delete_user: xpackSecurityDeleteUser(opts), + deleteUser: xpackSecurityDeleteUser(opts), + disable_user: xpackSecurityDisableUser(opts), + disableUser: xpackSecurityDisableUser(opts), + enable_user: xpackSecurityEnableUser(opts), + enableUser: xpackSecurityEnableUser(opts), + get_privileges: xpackSecurityGetPrivileges(opts), + getPrivileges: xpackSecurityGetPrivileges(opts), + get_role: xpackSecurityGetRole(opts), + getRole: xpackSecurityGetRole(opts), + get_role_mapping: xpackSecurityGetRoleMapping(opts), + getRoleMapping: xpackSecurityGetRoleMapping(opts), + get_token: xpackSecurityGetToken(opts), + getToken: xpackSecurityGetToken(opts), + get_user: xpackSecurityGetUser(opts), + getUser: xpackSecurityGetUser(opts), + has_privileges: xpackSecurityHasPrivileges(opts), + hasPrivileges: xpackSecurityHasPrivileges(opts), + invalidate_token: xpackSecurityInvalidateToken(opts), + invalidateToken: xpackSecurityInvalidateToken(opts), + put_privileges: xpackSecurityPutPrivileges(opts), + putPrivileges: xpackSecurityPutPrivileges(opts), + put_role: xpackSecurityPutRole(opts), + putRole: xpackSecurityPutRole(opts), + put_role_mapping: xpackSecurityPutRoleMapping(opts), + putRoleMapping: xpackSecurityPutRoleMapping(opts), + put_user: xpackSecurityPutUser(opts), + putUser: xpackSecurityPutUser(opts) + }, + sql: { + clear_cursor: xpackSqlClearCursor(opts), + clearCursor: xpackSqlClearCursor(opts), + query: xpackSqlQuery(opts), + translate: xpackSqlTranslate(opts) + }, + ssl: { + certificates: xpackSslCertificates(opts) + }, + usage: xpackUsage(opts), + watcher: { + ack_watch: xpackWatcherAckWatch(opts), + ackWatch: xpackWatcherAckWatch(opts), + activate_watch: xpackWatcherActivateWatch(opts), + activateWatch: xpackWatcherActivateWatch(opts), + deactivate_watch: xpackWatcherDeactivateWatch(opts), + deactivateWatch: xpackWatcherDeactivateWatch(opts), + delete_watch: xpackWatcherDeleteWatch(opts), + deleteWatch: xpackWatcherDeleteWatch(opts), + execute_watch: xpackWatcherExecuteWatch(opts), + executeWatch: xpackWatcherExecuteWatch(opts), + get_watch: xpackWatcherGetWatch(opts), + getWatch: xpackWatcherGetWatch(opts), + put_watch: xpackWatcherPutWatch(opts), + putWatch: xpackWatcherPutWatch(opts), + restart: xpackWatcherRestart(opts), + start: xpackWatcherStart(opts), + stats: xpackWatcherStats(opts), + stop: xpackWatcherStop(opts) + } + } } - Object.defineProperties(apis.cat, { - pendingTasks: { - get: function () { return this.pending_tasks }, - enumerable: true - }, - threadPool: { - get: function () { return this.thread_pool }, - enumerable: true - } - }) - - Object.defineProperties(apis, { - clearScroll: { - get: function () { return this.clear_scroll }, - enumerable: true - }, - deleteByQuery: { - get: function () { return this.delete_by_query }, - enumerable: true - }, - deleteScript: { - get: function () { return this.delete_script }, - enumerable: true - }, - existsSource: { - get: function () { return this.exists_source }, - enumerable: true - }, - fieldCaps: { - get: function () { return this.field_caps }, - enumerable: true - }, - getScript: { - get: function () { return this.get_script }, - enumerable: true - }, - getSource: { - get: function () { return this.get_source }, - enumerable: true - }, - msearchTemplate: { - get: function () { return this.msearch_template }, - enumerable: true - }, - putScript: { - get: function () { return this.put_script }, - enumerable: true - }, - rankEval: { - get: function () { return this.rank_eval }, - enumerable: true - }, - reindexRethrottle: { - get: function () { return this.reindex_rethrottle }, - enumerable: true - }, - renderSearchTemplate: { - get: function () { return this.render_search_template }, - enumerable: true - }, - scriptsPainlessExecute: { - get: function () { return this.scripts_painless_execute }, - enumerable: true - }, - searchShards: { - get: function () { return this.search_shards }, - enumerable: true - }, - searchTemplate: { - get: function () { return this.search_template }, - enumerable: true - }, - updateByQuery: { - get: function () { return this.update_by_query }, - enumerable: true - } - }) - - Object.defineProperties(apis.cluster, { - allocationExplain: { - get: function () { return this.allocation_explain }, - enumerable: true - }, - getSettings: { - get: function () { return this.get_settings }, - enumerable: true - }, - pendingTasks: { - get: function () { return this.pending_tasks }, - enumerable: true - }, - putSettings: { - get: function () { return this.put_settings }, - enumerable: true - }, - remoteInfo: { - get: function () { return this.remote_info }, - enumerable: true - } - }) - - Object.defineProperties(apis.indices, { - clearCache: { - get: function () { return this.clear_cache }, - enumerable: true - }, - deleteAlias: { - get: function () { return this.delete_alias }, - enumerable: true - }, - deleteTemplate: { - get: function () { return this.delete_template }, - enumerable: true - }, - existsAlias: { - get: function () { return this.exists_alias }, - enumerable: true - }, - existsTemplate: { - get: function () { return this.exists_template }, - enumerable: true - }, - existsType: { - get: function () { return this.exists_type }, - enumerable: true - }, - flushSynced: { - get: function () { return this.flush_synced }, - enumerable: true - }, - getAlias: { - get: function () { return this.get_alias }, - enumerable: true - }, - getFieldMapping: { - get: function () { return this.get_field_mapping }, - enumerable: true - }, - getMapping: { - get: function () { return this.get_mapping }, - enumerable: true - }, - getSettings: { - get: function () { return this.get_settings }, - enumerable: true - }, - getTemplate: { - get: function () { return this.get_template }, - enumerable: true - }, - getUpgrade: { - get: function () { return this.get_upgrade }, - enumerable: true - }, - putAlias: { - get: function () { return this.put_alias }, - enumerable: true - }, - putMapping: { - get: function () { return this.put_mapping }, - enumerable: true - }, - putSettings: { - get: function () { return this.put_settings }, - enumerable: true - }, - putTemplate: { - get: function () { return this.put_template }, - enumerable: true - }, - shardStores: { - get: function () { return this.shard_stores }, - enumerable: true - }, - updateAliases: { - get: function () { return this.update_aliases }, - enumerable: true - }, - validateQuery: { - get: function () { return this.validate_query }, - enumerable: true - } - }) - - Object.defineProperties(apis.ingest, { - deletePipeline: { - get: function () { return this.delete_pipeline }, - enumerable: true - }, - getPipeline: { - get: function () { return this.get_pipeline }, - enumerable: true - }, - processorGrok: { - get: function () { return this.processor_grok }, - enumerable: true - }, - putPipeline: { - get: function () { return this.put_pipeline }, - enumerable: true - } - }) - - Object.defineProperties(apis.nodes, { - hotThreads: { - get: function () { return this.hot_threads }, - enumerable: true - } - }) - - Object.defineProperties(apis.snapshot, { - createRepository: { - get: function () { return this.create_repository }, - enumerable: true - }, - deleteRepository: { - get: function () { return this.delete_repository }, - enumerable: true - }, - getRepository: { - get: function () { return this.get_repository }, - enumerable: true - }, - verifyRepository: { - get: function () { return this.verify_repository }, - enumerable: true - } - }) - return apis } From 869b50fca9012163fe7e142812ea360313830f07 Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 8 Nov 2018 19:36:05 +0100 Subject: [PATCH 032/172] Updated test --- test/integration/index.js | 101 ++++++++------- test/unit/connection-pool.test.js | 198 +++++++++++++++++++++++------- test/unit/connection.test.js | 45 +++++++ test/unit/transport.test.js | 77 +++++++----- 4 files changed, 301 insertions(+), 120 deletions(-) diff --git a/test/integration/index.js b/test/integration/index.js index 6492e18a1..0b498000c 100644 --- a/test/integration/index.js +++ b/test/integration/index.js @@ -1,8 +1,8 @@ 'use strict' const assert = require('assert') -const { readFileSync, accessSync, mkdirSync, readdirSync } = require('fs') -const { join } = require('path') +const { readFileSync, accessSync, mkdirSync, readdirSync, statSync } = require('fs') +const { join, sep } = require('path') const yaml = require('js-yaml') const Git = require('simple-git') const ora = require('ora') @@ -14,6 +14,7 @@ const TestRunner = require('./test-runner') const esRepo = 'https://github.com/elastic/elasticsearch.git' const esFolder = join(__dirname, '..', '..', 'elasticsearch') const yamlFolder = join(esFolder, 'rest-api-spec', 'src', 'main', 'resources', 'rest-api-spec', 'test') +// const xPackYamlFolder = join(esFolder, 'x-pack', 'plugin', 'src', 'test', 'resources', 'rest-api-spec', 'test') function Runner (opts) { if (!(this instanceof Runner)) { @@ -33,7 +34,6 @@ function Runner (opts) { * Runs the test suite */ Runner.prototype.start = function () { - const getTest = this.getTest.bind(this) const parse = this.parse.bind(this) const client = this.client @@ -51,57 +51,58 @@ Runner.prototype.start = function () { return } const { number: version, build_hash: sha } = body.version + // Set the repository to the given sha and run the test suite this.withSHA(sha, () => { this.log.succeed('Done!') runTest.call(this, version) }) + + // client.xpack.license.postStartTrial({ acknowledge: true }, (err, { body }) => { + // if (err) { + // this.log.fail(err.message) + // return + // } + // }) }) function runTest (version) { - const testFolders = getTest() - testFolders.forEach(runTestFolder.bind(this)) - function runTestFolder (testFolder) { - // if (testFolder !== 'tasks.get') return + const files = [] + .concat(getAllFiles(yamlFolder)) + // .concat(getAllFiles(xPackYamlFolder)) + .filter(t => !/(README|TODO)/g.test(t)) + + files.forEach(runTestFile.bind(this)) + function runTestFile (file) { // create a subtest for the specific folder - tap.test(testFolder, { jobs: 1 }, tap1 => { - const files = getTest(testFolder) - files.forEach(file => { - // if (file !== '20_typed_keys.yml') return - // create a subtest for the specific folder + test file - tap1.test(file.slice(0, -4), { jobs: 1 }, tap2 => { - const path = join(yamlFolder, testFolder, file) - // read the yaml file - const data = readFileSync(path, 'utf8') - // get the test yaml (as object), some file has multiple yaml documents inside, - // every document is separated by '---', so we split on the separator - // and then we remove the empty strings, finally we parse them - const tests = data - .split('---') - .map(s => s.trim()) - .filter(Boolean) - .map(parse) + tap.test(file.slice(file.indexOf(`${sep}elasticsearch${sep}`)), { jobs: 1 }, tap1 => { + // read the yaml file + const data = readFileSync(file, 'utf8') + // get the test yaml (as object), some file has multiple yaml documents inside, + // every document is separated by '---', so we split on the separator + // and then we remove the empty strings, finally we parse them + const tests = data + .split('---') + .map(s => s.trim()) + .filter(Boolean) + .map(parse) - // get setup and teardown if present - var setupTest = null - var teardownTest = null - tests.forEach(test => { - if (test.setup) setupTest = test.setup - if (test.teardown) teardownTest = test.teardown - }) + // get setup and teardown if present + var setupTest = null + var teardownTest = null + tests.forEach(test => { + if (test.setup) setupTest = test.setup + if (test.teardown) teardownTest = test.teardown + }) - // run the tests - tests.forEach(test => { - const name = Object.keys(test)[0] - if (name === 'setup' || name === 'teardown') return - // create a subtest for the specific folder + test file + test name - tap2.test(name, { jobs: 1, bail: this.bailout }, tap3 => { - const testRunner = TestRunner({ client, version, tap: tap3 }) - testRunner.run(setupTest, test[name], teardownTest, () => tap3.end()) - }) - }) - - tap2.end() + // run the tests + tests.forEach(test => { + const name = Object.keys(test)[0] + if (name === 'setup' || name === 'teardown') return + // create a subtest for the specific folder + test file + test name + tap1.test(name, { jobs: 1, bail: this.bailout }, tap2 => { + const testRunner = TestRunner({ client, version, tap: tap2 }) + testRunner.run(setupTest, test[name], teardownTest, () => tap2.end()) }) }) @@ -127,14 +128,12 @@ Runner.prototype.parse = function (data) { } /** - * Returns the content of the `yamlFolder`. - * If a folder name is given as parameter, it will return - * the content of join(yamlFolder, folder) + * Returns the filtered content of a given folder * @param {string} folder * @returns {Array} The content of the given folder */ Runner.prototype.getTest = function (folder) { - const tests = readdirSync(join(yamlFolder, folder || '')) + const tests = readdirSync(folder) return tests.filter(t => !/(README|TODO)/g.test(t)) } @@ -238,6 +237,7 @@ if (require.main === module) { string: ['host', 'version'], boolean: ['bailout'], default: { + // host: 'http://elastic:passw0rd@localhost:9200', host: 'http://localhost:9200', version: '6.4', bailout: false @@ -248,4 +248,11 @@ if (require.main === module) { runner.start() } +const getAllFiles = dir => + readdirSync(dir).reduce((files, file) => { + const name = join(dir, file) + const isDirectory = statSync(name).isDirectory() + return isDirectory ? [...files, ...getAllFiles(name)] : [...files, name] + }, []) + module.exports = Runner diff --git a/test/unit/connection-pool.test.js b/test/unit/connection-pool.test.js index f435fffd2..b0c1ce65b 100644 --- a/test/unit/connection-pool.test.js +++ b/test/unit/connection-pool.test.js @@ -12,7 +12,7 @@ test('API', t => { const href = 'http://localhost:9200/' pool.addConnection(href) t.ok(pool.connections.get(href) instanceof Connection) - t.deepEqual(pool.alive, [href]) + t.strictEqual(pool.connections.get(href).status, Connection.statuses.ALIVE) t.deepEqual(pool.dead, []) t.end() }) @@ -38,7 +38,6 @@ test('API', t => { connection = pool.connections.get(href) t.strictEqual(connection.deadCount, 1) t.true(connection.resurrectTimeout > 0) - t.deepEqual(pool.alive, []) t.deepEqual(pool.dead, [href]) t.end() }) @@ -66,7 +65,7 @@ test('API', t => { connection = pool.connections.get(href) t.strictEqual(connection.deadCount, 0) t.strictEqual(connection.resurrectTimeout, 0) - t.deepEqual(pool.alive, [href]) + t.strictEqual(connection.status, Connection.statuses.ALIVE) t.deepEqual(pool.dead, []) t.end() }) @@ -91,7 +90,7 @@ test('API', t => { connection = pool.connections.get(connection.id) t.strictEqual(connection.deadCount, 0) t.strictEqual(connection.resurrectTimeout, 0) - t.deepEqual(pool.alive, [href]) + t.strictEqual(connection.status, Connection.statuses.ALIVE) t.deepEqual(pool.dead, []) t.end() }) @@ -113,7 +112,7 @@ test('API', t => { connection = pool.connections.get(connection.id) t.strictEqual(connection.deadCount, 2) t.true(connection.resurrectTimeout > 0) - t.deepEqual(pool.alive, []) + t.strictEqual(connection.status, Connection.statuses.DEAD) t.deepEqual(pool.dead, [href]) t.end() }) @@ -135,7 +134,7 @@ test('API', t => { connection = pool.connections.get(connection.id) t.strictEqual(connection.deadCount, 1) t.true(connection.resurrectTimeout > 0) - t.deepEqual(pool.alive, [href]) + t.strictEqual(connection.status, Connection.statuses.ALIVE) t.deepEqual(pool.dead, []) t.end() }) @@ -154,7 +153,7 @@ test('API', t => { connection = pool.connections.get(href) t.strictEqual(connection.deadCount, 1) t.true(connection.resurrectTimeout > 0) - t.deepEqual(pool.alive, []) + t.strictEqual(connection.status, Connection.statuses.DEAD) t.deepEqual(pool.dead, [href]) t.end() }) @@ -183,31 +182,8 @@ test('API', t => { t.end() }) - t.test('weighter option', t => { - const pool = new ConnectionPool() - const href1 = 'http://localhost:9200/' - const href2 = 'http://localhost:9200/other' - pool.addConnection([href1, href2]) - - const weighter = node => node.id === href1 - t.strictEqual(pool.getConnection({ weighter }).id, href2) - t.end() - }) - - t.test('filter should be run before the weighter', t => { - const pool = new ConnectionPool() - const href1 = 'http://localhost:9200/' - const href2 = 'http://localhost:9200/other' - pool.addConnection([href1, href2]) - - const filter = node => node.id === href1 - const weighter = node => node.id !== href2 - t.strictEqual(pool.getConnection({ weighter, filter }).id, href1) - t.end() - }) - t.test('filter and weighter should get Connection objects', t => { - t.plan(3) + t.plan(2) const pool = new ConnectionPool() const href1 = 'http://localhost:9200/' const href2 = 'http://localhost:9200/other' @@ -217,12 +193,11 @@ test('API', t => { t.ok(node instanceof Connection) return true } - const weighter = node => t.ok(node instanceof Connection) - pool.getConnection({ weighter, filter }) + pool.getConnection({ filter }) }) - t.test('filter and weighter should get alive connections', t => { - t.plan(3) + t.test('filter should get alive connections', t => { + t.plan(2) const pool = new ConnectionPool() const href1 = 'http://localhost:9200/' const href2 = 'http://localhost:9200/other' @@ -234,11 +209,10 @@ test('API', t => { t.strictEqual(node.status, Connection.statuses.ALIVE) return true } - const weighter = node => t.strictEqual(node.status, Connection.statuses.ALIVE) - pool.getConnection({ weighter, filter }) + pool.getConnection({ filter }) }) - t.test('filter and weighter as ConnectionPool option', t => { + t.test('filter as ConnectionPool option', t => { t.plan(3) const href1 = 'http://localhost:9200/' @@ -246,11 +220,7 @@ test('API', t => { const pool = new ConnectionPool({ nodeFilter: node => { t.ok('called') - return node.id === href1 - }, - nodeWeighter: node => { - t.ok('called') - return node.id !== href2 + return true } }) pool.addConnection([href1, href2]) @@ -276,7 +246,6 @@ test('API', t => { pool.addConnection('http://localhost:9201/') pool.empty() t.strictEqual(pool.connections.size, 0) - t.deepEqual(pool.alive, []) t.deepEqual(pool.dead, []) t.end() }) @@ -328,5 +297,146 @@ test('API', t => { t.end() }) + t.test('update', t => { + t.test('Should not update existing connections', t => { + t.plan(2) + class CustomConnectionPool extends ConnectionPool { + markAlive () { + t.fail('Should not be called') + } + } + const pool = new CustomConnectionPool() + pool.addConnection([{ + host: new URL('http://127.0.0.1:9200'), + id: 'a1', + roles: { + master: true, + data: true, + ingest: true + } + }, { + host: new URL('http://127.0.0.1:9201'), + id: 'a2', + roles: { + master: true, + data: true, + ingest: true + } + }]) + + pool.update([{ + host: new URL('http://127.0.0.1:9200'), + id: 'a1', + roles: null + }, { + host: new URL('http://127.0.0.1:9201'), + id: 'a2', + roles: null + }]) + + t.ok(pool.connections.get('a1').roles !== null) + t.ok(pool.connections.get('a2').roles !== null) + }) + + t.test('Should not update existing connections (mark alive)', t => { + t.plan(4) + class CustomConnectionPool extends ConnectionPool { + markAlive (connection) { + t.ok('called') + super.markAlive(connection) + } + } + const pool = new CustomConnectionPool() + const conn1 = pool.addConnection({ + host: new URL('http://127.0.0.1:9200'), + id: 'a1', + roles: { + master: true, + data: true, + ingest: true + } + }) + + const conn2 = pool.addConnection({ + host: new URL('http://127.0.0.1:9201'), + id: 'a2', + roles: { + master: true, + data: true, + ingest: true + } + }) + + pool.markDead(conn1) + pool.markDead(conn2) + + pool.update([{ + host: new URL('http://127.0.0.1:9200'), + id: 'a1', + roles: null + }, { + host: new URL('http://127.0.0.1:9201'), + id: 'a2', + roles: null + }]) + + t.ok(pool.connections.get('a1').roles !== null) + t.ok(pool.connections.get('a2').roles !== null) + }) + + t.test('Add a new connection', t => { + t.plan(2) + const pool = new ConnectionPool() + pool.addConnection({ + host: new URL('http://127.0.0.1:9200'), + id: 'a1', + roles: { + master: true, + data: true, + ingest: true + } + }) + + pool.update([{ + host: new URL('http://127.0.0.1:9200'), + id: 'a1', + roles: null + }, { + host: new URL('http://127.0.0.1:9201'), + id: 'a2', + roles: null + }]) + + t.ok(pool.connections.get('a1').roles !== null) + t.true(pool.connections.has('a2')) + }) + + t.test('Remove old connections', t => { + t.plan(3) + const pool = new ConnectionPool() + pool.addConnection({ + host: new URL('http://127.0.0.1:9200'), + id: 'a1', + roles: null + }) + + pool.update([{ + host: new URL('http://127.0.0.1:9200'), + id: 'a2', + roles: null + }, { + host: new URL('http://127.0.0.1:9201'), + id: 'a3', + roles: null + }]) + + t.false(pool.connections.has('a1')) + t.true(pool.connections.has('a2')) + t.true(pool.connections.has('a3')) + }) + + t.end() + }) + t.end() }) diff --git a/test/unit/connection.test.js b/test/unit/connection.test.js index 67c752576..3ee6b8234 100644 --- a/test/unit/connection.test.js +++ b/test/unit/connection.test.js @@ -374,3 +374,48 @@ test('Should not close a connection if there are open requests', t => { }) }) }) + +test('Url with auth', t => { + t.plan(2) + + function handler (req, res) { + t.match(req.headers, { + authorization: 'Basic Zm9vOmJhcg==' + }) + res.end('ok') + } + + buildServer(handler, ({ port }, server) => { + const connection = new Connection({ + host: new URL(`http://foo:bar@localhost:${port}`) + }) + connection.request({ + path: '/hello', + method: 'GET' + }, (err, res) => { + t.error(err) + }) + }) +}) + +test('Url with querystring', t => { + t.plan(2) + + function handler (req, res) { + t.strictEqual(req.url, '/hello?foo=bar&baz=faz') + res.end('ok') + } + + buildServer(handler, ({ port }, server) => { + const connection = new Connection({ + host: new URL(`http://localhost:${port}?foo=bar`) + }) + connection.request({ + path: '/hello', + method: 'GET', + querystring: 'baz=faz' + }, (err, res) => { + t.error(err) + }) + }) +}) diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index e0464456c..c7bc712a6 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -575,22 +575,14 @@ test('Override requestTimeout', t => { test('sniff', t => { t.test('sniffOnStart', t => { - t.plan(4) + t.plan(3) class CustomConnectionPool extends ConnectionPool { - empty () { + update () { t.ok('called') return this } - addConnection (hosts) { - // the first `addConnection` call should work - if (typeof hosts === 'string') { - return super.addConnection(hosts) - } - t.true(Array.isArray(hosts)) - } - nodesToHost (nodes) { t.ok('called') return [] @@ -622,23 +614,14 @@ test('sniff', t => { }) t.test('sniffOnConnectionFault', t => { - t.plan(4) + t.plan(3) class CustomConnectionPool extends ConnectionPool { - empty () { + update () { t.ok('called') return this } - addConnection (hosts) { - // the first `addConnection` call should work - if (typeof hosts === 'string') { - return super.addConnection(hosts) - } - - t.true(Array.isArray(hosts)) - } - nodesToHost (nodes) { t.ok('called') return [] @@ -683,17 +666,10 @@ test('sniff', t => { t.plan(9) class CustomConnectionPool extends ConnectionPool { - empty () { + update () { return this } - addConnection (hosts) { - // the first `addConnection` call should work - if (typeof hosts === 'string') { - return super.addConnection(hosts) - } - } - nodesToHost (nodes) { return [] } @@ -1360,3 +1336,46 @@ test('Warning header', t => { t.end() }) + +test('asHttpResponse enabled', t => { + t.plan(3) + function handler (req, res) { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool() + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello', + asHttpResponse: true + }, (err, response) => { + t.error(err) + t.match(response.headers, { + connection: 'keep-alive', + 'content-type': 'application/json;utf=8' + }) + + var payload = '' + response.setEncoding('utf8') + response.on('data', chunk => { payload += chunk }) + response.on('error', err => t.fail(err)) + response.on('end', () => { + t.deepEqual(JSON.parse(payload), { hello: 'world' }) + }) + }) + }) +}) From 2d7dfdd7a054032169030e4e3a384389a464e1d6 Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 8 Nov 2018 19:36:24 +0100 Subject: [PATCH 033/172] Updated scripts --- package.json | 3 +- scripts/es-docker.sh | 12 +++++ scripts/run.js | 8 ++-- scripts/utils/clone-es.js | 3 +- scripts/utils/genMain.js | 99 ++++++++++++++++++--------------------- scripts/utils/generate.js | 11 +++-- 6 files changed, 74 insertions(+), 62 deletions(-) create mode 100755 scripts/es-docker.sh diff --git a/package.json b/package.json index fcb3feaa3..5fda757e3 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "lint": "standard", "lint:fix": "standard --fix", "generate": "node scripts/run.js", - "elasticsearch": "docker run --rm -e \"node.attr.testattr=test\" -e \"path.repo=/tmp\" -e \"repositories.url.allowed_urls=http://snapshot.*\" -p 9200:9200 docker.elastic.co/elasticsearch/elasticsearch:6.4.0" + "elasticsearch": "./scripts/es-docker.sh" }, "author": { "name": "Tomas Della Vedova", @@ -31,6 +31,7 @@ }, "devDependencies": { "dedent": "^0.7.0", + "deepmerge": "^2.2.1", "into-stream": "^4.0.0", "js-yaml": "^3.12.0", "minimist": "^1.2.0", diff --git a/scripts/es-docker.sh b/scripts/es-docker.sh new file mode 100755 index 000000000..655b09cce --- /dev/null +++ b/scripts/es-docker.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +exec docker run \ + --rm \ + -e "node.attr.testattr=test" \ + -e "path.repo=/tmp" \ + -e "repositories.url.allowed_urls=http://snapshot.*" \ + -p 9200:9200 \ + docker.elastic.co/elasticsearch/elasticsearch:6.4.0 + +# -e "xpack.security.enabled=true" \ +# -e "ELASTIC_PASSWORD=passw0rd" \ diff --git a/scripts/run.js b/scripts/run.js index 73af7f447..0dc1ec61b 100644 --- a/scripts/run.js +++ b/scripts/run.js @@ -26,13 +26,15 @@ function start (opts) { log.text = 'Cleaning API folder...' rimraf.sync(join(apiOutputFolder, '*.js')) - cloneAndCheckout({ log, tag: opts.tag }, (err, apiFolder) => { + cloneAndCheckout({ log, tag: opts.tag }, (err, { apiFolder, xPackFolder }) => { if (err) { log.fail(err.message) return } - const files = readdirSync(apiFolder) - files.forEach(generateApiFile(apiFolder, log)) + + readdirSync(apiFolder).forEach(generateApiFile(apiFolder, log)) + readdirSync(xPackFolder).forEach(generateApiFile(xPackFolder, log)) + writeFileSync( mainOutputFile, genFactory(apiOutputFolder), diff --git a/scripts/utils/clone-es.js b/scripts/utils/clone-es.js index 02452cda3..4d424c00a 100644 --- a/scripts/utils/clone-es.js +++ b/scripts/utils/clone-es.js @@ -7,6 +7,7 @@ const Git = require('simple-git') const esRepo = 'https://github.com/elastic/elasticsearch.git' const esFolder = join(__dirname, '..', '..', 'elasticsearch') const apiFolder = join(esFolder, 'rest-api-spec', 'src', 'main', 'resources', 'rest-api-spec', 'api') +const xPackFolder = join(esFolder, 'x-pack', 'plugin', 'src', 'test', 'resources', 'rest-api-spec', 'api') function cloneAndCheckout (opts, callback) { const { log, tag } = opts @@ -51,7 +52,7 @@ function cloneAndCheckout (opts, callback) { } return pull(checkout) } - callback(null, apiFolder) + callback(null, { apiFolder, xPackFolder }) }) } diff --git a/scripts/utils/genMain.js b/scripts/utils/genMain.js index 7d6bd00c3..350a5904f 100644 --- a/scripts/utils/genMain.js +++ b/scripts/utils/genMain.js @@ -2,37 +2,33 @@ const { readdirSync } = require('fs') const dedent = require('dedent') +const deepmerge = require('deepmerge') function genFactory (folder) { - const apiToCamel = {} // get all the API files - const apis = readdirSync(folder) + const apiFiles = readdirSync(folder) + const apis = apiFiles .map(file => { - const chunks = file.split('.') - // if the api has not a namespace - if (chunks.length === 2) { - return { name: chunks[0], group: null, file } - } else { - const [group, name] = chunks - return { name, group, file } - } + const name = format(file.slice(0, -3)) + return file + .slice(0, -3) // remove `.js` extension + .split('.') + .reverse() + .reduce((acc, val) => { + const obj = { + [val]: acc === null + ? `${name}(opts)` + : acc + } + if (isSnakeCased(val)) { + obj[camelify(val)] = acc === null + ? `${name}(opts)` + : acc + } + return obj + }, null) }) - .reduce((acc, obj) => { - const { group, name, file } = obj - // create a namespace if present - if (group) { - acc[group] = acc[group] || {} - acc[group][name] = `require('./api/${file}')(opts)` - } else { - acc[name] = `require('./api/${file}')(opts)` - } - // save the snake_cased APIs for later use - if (isSnakeCased(name)) { - apiToCamel[group || '__root'] = apiToCamel[group || '__root'] || [] - apiToCamel[group || '__root'].push(name) - } - return acc - }, {}) + .reduce((acc, val) => deepmerge(acc, val), {}) // serialize the API object const apisStr = JSON.stringify(apis, null, 2) @@ -47,6 +43,8 @@ function genFactory (folder) { const assert = require('assert') + ${generateApiRequire(apiFiles)} + function ESAPI (opts) { assert(opts.makeRequest, 'Missing makeRequest function') assert(opts.ConfigurationError, 'Missing ConfigurationError class') @@ -54,7 +52,6 @@ function genFactory (folder) { const apis = ${apisStr} - ${generateDefinedProperties(apiToCamel).join('\n\n ')} return apis } @@ -66,33 +63,13 @@ function genFactory (folder) { return fn + '\n' } -// generates an array of Object.defineProperties -// to allow the use of camelCase APIs -// instead of snake_cased -function generateDefinedProperties (apiToCamel) { - const arr = [] - for (const api in apiToCamel) { - const obj = api === '__root' - ? 'apis' - : `apis.${api}` - const code = ` - Object.defineProperties(${obj}, { - ${apiToCamel[api].map(createGetter).join(',\n ')} +function generateApiRequire (apiFiles) { + return apiFiles + .map(file => { + const name = format(file.slice(0, -3)) + return `const ${name} = require('./api/${file}')` }) - `.trim() - arr.push(code) - } - - return arr - - function createGetter (api) { - return ` - ${camelify(api)}: { - get: function () { return this.${api} }, - enumerable: true - } - `.trim() - } + .join('\n') } // from snake_case to camelCase @@ -100,6 +77,22 @@ function camelify (str) { return str.replace(/_([a-z])/g, k => k[1].toUpperCase()) } +// from 'hello.world to helloWorld +function undot (str) { + return str.replace(/\.([a-z])/g, k => k[1].toUpperCase()) +} + +function safeWords (str) { + if (str === 'delete') { + return '_delete' + } + return str +} + +function format (str) { + return safeWords(undot(camelify(str))) +} + function isSnakeCased (str) { return !!~str.indexOf('_') } diff --git a/scripts/utils/generate.js b/scripts/utils/generate.js index e143919e4..a6d09ad3f 100644 --- a/scripts/utils/generate.js +++ b/scripts/utils/generate.js @@ -410,7 +410,7 @@ function genUrlValidation (paths, api) { if (chunks[i] === camelCased) { code += `params['${chunks[i]}'] == null${i === len - 1 ? '' : ' || '}` } else { - code += `(params['${chunks[i]}'] == null || params['${camelCased}')${i === len - 1 ? '' : ' || '}` + code += `(params['${chunks[i]}'] == null || params['${camelCased}'])${i === len - 1 ? '' : ' || '}` } } code += `)) { @@ -442,16 +442,19 @@ function generateDocumentation (api, op) { doc += ` * Perform a [${op}](${api.documentation}) request\n *\n` Object.keys(parts).forEach(part => { const obj = parts[part] - doc += ` * @param {${obj.type}} ${part} - ${obj.description.replace(/\u00A0/g, ' ')}\n` + const description = obj.description || '' + doc += ` * @param {${obj.type}} ${part} - ${description.replace(/\u00A0/g, ' ')}\n` }) Object.keys(params).forEach(param => { const obj = params[param] - doc += ` * @param {${obj.type}} ${param} - ${obj.description.replace(/\u00A0/g, ' ')}\n` + const description = obj.description || '' + doc += ` * @param {${obj.type}} ${param} - ${description.replace(/\u00A0/g, ' ')}\n` }) if (body) { - doc += ` * @param {${body.type || 'object'}} body - ${body.description.replace(/\u00A0/g, ' ')}\n` + const description = body.description || '' + doc += ` * @param {${body.type || 'object'}} body - ${description.replace(/\u00A0/g, ' ')}\n` } doc += ' */' From 3dd4f013702f2812ad5c9776acbff9f4e801adaf Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 9 Nov 2018 17:15:29 +0100 Subject: [PATCH 034/172] WIP: initial prototype - Renamed host configuration, now we use node(s) - Updated Connection internals - Added custom headers for Connection --- index.js | 8 +-- lib/Connection.js | 113 +++++++++++++++++++----------------------- lib/ConnectionPool.js | 4 +- 3 files changed, 56 insertions(+), 69 deletions(-) diff --git a/index.js b/index.js index 9896f59be..4ddd5b67c 100644 --- a/index.js +++ b/index.js @@ -19,8 +19,8 @@ const { class Client extends EventEmitter { constructor (opts = {}) { super() - if (!opts.host) { - throw new ConfigurationError('Missing host option') + if (!opts.node && !opts.nodes) { + throw new ConfigurationError('Missing node(s) option') } if (opts.log === true) { @@ -70,7 +70,7 @@ class Client extends EventEmitter { }) // Add the connections before initialize the Transport - this[kConnectionPool].addConnection(options.host) + this[kConnectionPool].addConnection(options.node || options.nodes) this[kTransport] = new options.Transport({ emit: this.emit.bind(this), @@ -110,5 +110,5 @@ module.exports = { Transport, ConnectionPool, Serializer, - symbols + ...symbols } diff --git a/lib/Connection.js b/lib/Connection.js index 5d16d0d58..bb17190b6 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -9,11 +9,10 @@ const { TimeoutError } = require('./errors') class Connection { constructor (opts = {}) { - assert(opts.host, 'Missing host data') - - this.host = urlToOptions(opts.host) - this.ssl = opts.host.ssl || opts.ssl || null - this.id = opts.id || opts.host.href + this.url = opts.url + this.ssl = opts.ssl || null + this.id = opts.id || opts.url.href + this.headers = opts.headers || null this.deadCount = 0 this.resurrectTimeout = 0 @@ -26,12 +25,12 @@ class Connection { keepAliveMsecs: 1000, maxSockets: Infinity, maxFreeSockets: 256 - }, opts.host.agent || opts.agent) - this._agent = this.host.protocol === 'http:' + }, opts.agent || opts.agent) + this._agent = this.url.protocol === 'http:' ? new http.Agent(agentOptions) : new https.Agent(Object.assign({}, agentOptions, this.ssl)) - this.makeRequest = this.host.protocol === 'http:' + this.makeRequest = this.url.protocol === 'http:' ? http.request : https.request } @@ -42,7 +41,7 @@ class Connection { params.agent = this._agent debug('Starting a new request', params) - const request = this.makeRequest(buildRequestObject(this.host, params)) + const request = this.makeRequest(this.buildRequestObject(params)) // listen for the response event // TODO: handle redirects? @@ -115,6 +114,48 @@ class Connection { ) this._status = status } + + buildRequestObject (params) { + const url = this.url + const request = { + protocol: url.protocol, + hostname: url.hostname[0] === '[' + ? url.hostname.slice(1, -1) + : url.hostname, + hash: url.hash, + search: url.search, + pathname: url.pathname, + path: '', + href: url.href, + port: url.port, + headers: this.headers, + auth: !!url.username === true || !!url.password === true + ? `${url.username}:${url.password}` + : undefined + } + + const paramsKeys = Object.keys(params) + for (var i = 0, len = paramsKeys.length; i < len; i++) { + var key = paramsKeys[i] + if (key === 'path') { + request.pathname = resolve(request.pathname, params[key]) + } else if (key === 'querystring' && !!params[key] === true) { + if (request.search === '') { + request.search = '?' + params[key] + } else { + request.search += '&' + params[key] + } + } else if (key === 'headers') { + request.headers = Object.assign({}, request.headers, params.headers) + } else { + request[key] = params[key] + } + } + + request.path = request.pathname + request.search + + return request + } } Connection.statuses = { @@ -156,58 +197,4 @@ function resolve (host, path) { } } -function buildRequestObject (host, request) { - var merged = {} - var hostKeys = Object.keys(host) - var requestKeys = Object.keys(request) - - for (var i = 0, len = hostKeys.length; i < len; i++) { - var key = hostKeys[i] - merged[key] = host[key] - } - - for (i = 0, len = requestKeys.length; i < len; i++) { - key = requestKeys[i] - if (key === 'path') { - merged.pathname = resolve(merged.pathname, request[key]) - } else if (key === 'querystring' && !!request[key] === true) { - if (merged.search === '') { - merged.search = '?' + request[key] - } else { - merged.search += '&' + request[key] - } - } else { - merged[key] = request[key] - } - } - - merged.path = merged.pathname + merged.search - - return merged -} - -// Utility function that converts a URL object into an ordinary -// options object as expected by the http.request and https.request APIs. -// https://github.com/nodejs/node/blob/v11.0.0/lib/internal/url.js#L1324 -function urlToOptions (url) { - var options = { - protocol: url.protocol, - hostname: url.hostname.startsWith('[') - ? url.hostname.slice(1, -1) - : url.hostname, - hash: url.hash, - search: url.search, - pathname: url.pathname, - path: `${url.pathname}${url.search}`, - href: url.href - } - if (url.port !== '') { - options.port = Number(url.port) - } - if (url.username || url.password) { - options.auth = `${url.username}:${url.password}` - } - return options -} - module.exports = Connection diff --git a/lib/ConnectionPool.js b/lib/ConnectionPool.js index fdf48e96e..a42832ca0 100644 --- a/lib/ConnectionPool.js +++ b/lib/ConnectionPool.js @@ -290,7 +290,7 @@ class ConnectionPool { ? address : 'http://' + address hosts.push({ - host: new URL(address), + url: new URL(address), id: ids[i], roles: node.roles.reduce((acc, role) => { acc[role] = true @@ -310,7 +310,7 @@ class ConnectionPool { */ urlToHost (url) { return { - host: new URL(url) + url: new URL(url) } } } From 9df4fcbbb6016975f3e8dd910714e2e8f0539b70 Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 9 Nov 2018 17:17:05 +0100 Subject: [PATCH 035/172] Updated test --- test/integration/index.js | 10 +- test/unit/api.test.js | 36 +++---- test/unit/client.test.js | 167 ++++++++++++++++++++++++++++++ test/unit/connection-pool.test.js | 34 +++--- test/unit/connection.test.js | 56 +++++++--- test/unit/transport.test.js | 24 ++--- 6 files changed, 256 insertions(+), 71 deletions(-) create mode 100644 test/unit/client.test.js diff --git a/test/integration/index.js b/test/integration/index.js index 0b498000c..b20adb936 100644 --- a/test/integration/index.js +++ b/test/integration/index.js @@ -22,10 +22,10 @@ function Runner (opts) { } opts = opts || {} - assert(opts.host, 'Missing host') + assert(opts.node, 'Missing base node') this.bailout = opts.bailout this.client = new elasticsearch.Client({ - host: opts.host + node: opts.node }) this.log = ora('Loading yaml suite').start() } @@ -234,11 +234,11 @@ Runner.prototype.createFolder = function (name) { if (require.main === module) { const opts = minimist(process.argv.slice(2), { - string: ['host', 'version'], + string: ['node', 'version'], boolean: ['bailout'], default: { - // host: 'http://elastic:passw0rd@localhost:9200', - host: 'http://localhost:9200', + // node: 'http://elastic:passw0rd@localhost:9200', + node: 'http://localhost:9200', version: '6.4', bailout: false } diff --git a/test/unit/api.test.js b/test/unit/api.test.js index ad095a585..539aa2ee9 100644 --- a/test/unit/api.test.js +++ b/test/unit/api.test.js @@ -14,15 +14,13 @@ test('Basic (callback)', t => { buildServer(handler, ({ port }, server) => { const client = new Client({ - host: `http://localhost:${port}` + node: `http://localhost:${port}` }) client.search({ index: 'test', type: 'doc', - query: { - match: { foo: 'bar' } - } + q: 'foo:bar' }, (err, { body }) => { t.error(err) t.deepEqual(body, { hello: 'world' }) @@ -40,16 +38,14 @@ test('Basic (promises)', t => { buildServer(handler, ({ port }, server) => { const client = new Client({ - host: `http://localhost:${port}` + node: `http://localhost:${port}` }) client .search({ index: 'test', type: 'doc', - query: { - match: { foo: 'bar' } - } + q: 'foo:bar' }) .then(({ body }) => t.deepEqual(body, { hello: 'world' })) .catch(t.fail) @@ -67,15 +63,13 @@ test('Error (callback)', t => { buildServer(handler, ({ port }, server) => { const client = new Client({ - host: `http://localhost:${port}` + node: `http://localhost:${port}` }) client.search({ index: 'test', type: 'doc', - query: { - match: { foo: 'bar' } - } + q: 'foo:bar' }, (err, { body }) => { t.ok(err) }) @@ -93,16 +87,14 @@ test('Error (promises)', t => { buildServer(handler, ({ port }, server) => { const client = new Client({ - host: `http://localhost:${port}` + node: `http://localhost:${port}` }) client .search({ index: 'test', type: 'doc', - query: { - match: { foo: 'bar' } - } + q: 'foo:bar' }) .then(t.fail) .catch(err => t.ok(err)) @@ -119,15 +111,13 @@ test('Abort method (callback)', t => { buildServer(handler, ({ port }, server) => { const client = new Client({ - host: `http://localhost:${port}` + node: `http://localhost:${port}` }) const request = client.search({ index: 'test', type: 'doc', - query: { - match: { foo: 'bar' } - } + q: 'foo:bar' }, (err, { body }) => { t.error(err) t.deepEqual(body, { hello: 'world' }) @@ -147,15 +137,13 @@ test('Abort is not supported in promises', t => { buildServer(handler, ({ port }, server) => { const client = new Client({ - host: `http://localhost:${port}` + node: `http://localhost:${port}` }) const request = client.search({ index: 'test', type: 'doc', - query: { - match: { foo: 'bar' } - } + q: 'foo:bar' }) request diff --git a/test/unit/client.test.js b/test/unit/client.test.js new file mode 100644 index 000000000..8ab1a8359 --- /dev/null +++ b/test/unit/client.test.js @@ -0,0 +1,167 @@ +'use strict' + +const { test } = require('tap') +const { URL } = require('url') +const { Client, kConnectionPool } = require('../../index') + +test('Configure host', t => { + t.test('Single string', t => { + const client = new Client({ + node: 'http://localhost:9200' + }) + const pool = client[kConnectionPool] + t.match(pool.connections.get('http://localhost:9200/'), { + url: new URL('http://localhost:9200'), + id: 'http://localhost:9200/', + ssl: null, + deadCount: 0, + resurrectTimeout: 0, + roles: { + master: true, + data: true, + ingest: true, + coordinating: true, + machine_learning: true + } + }) + t.end() + }) + + t.test('Array of strings', t => { + const client = new Client({ + nodes: ['http://localhost:9200', 'http://localhost:9201'] + }) + const pool = client[kConnectionPool] + t.match(pool.connections.get('http://localhost:9200/'), { + url: new URL('http://localhost:9200'), + id: 'http://localhost:9200/', + ssl: null, + deadCount: 0, + resurrectTimeout: 0, + roles: { + master: true, + data: true, + ingest: true, + coordinating: true, + machine_learning: true + } + }) + t.match(pool.connections.get('http://localhost:9201/'), { + url: new URL('http://localhost:9201'), + id: 'http://localhost:9201/', + ssl: null, + deadCount: 0, + resurrectTimeout: 0, + roles: { + master: true, + data: true, + ingest: true, + coordinating: true, + machine_learning: true + } + }) + + t.end() + }) + + t.test('Single object', t => { + const client = new Client({ + node: { + url: new URL('http://localhost:9200'), + id: 'node', + roles: { + master: true, + data: false + }, + ssl: 'ssl' + } + }) + const pool = client[kConnectionPool] + t.match(pool.connections.get('node'), { + url: new URL('http://user@passwordlocalhost:9200'), + id: 'node', + ssl: 'ssl', + deadCount: 0, + resurrectTimeout: 0, + roles: { + master: true, + data: false + } + }) + t.end() + }) + + t.test('Array of objects', t => { + const client = new Client({ + nodes: [{ + url: new URL('http://localhost:9200'), + id: 'node1', + roles: { + master: true, + data: false + }, + ssl: 'ssl' + }, { + url: new URL('http://localhost:9200'), + id: 'node2', + roles: { + master: false, + data: true + }, + ssl: 'ssl' + }] + }) + const pool = client[kConnectionPool] + t.match(pool.connections.get('node1'), { + url: new URL('http://user@passwordlocalhost:9200'), + id: 'node1', + ssl: 'ssl', + deadCount: 0, + resurrectTimeout: 0, + roles: { + master: true, + data: false + } + }) + t.match(pool.connections.get('node2'), { + url: new URL('http://user@passwordlocalhost:9200'), + id: 'node2', + ssl: 'ssl', + deadCount: 0, + resurrectTimeout: 0, + roles: { + master: false, + data: true + } + }) + t.end() + }) + + t.test('Custom headers', t => { + const client = new Client({ + node: { + url: new URL('http://localhost:9200'), + headers: { 'x-foo': 'bar' }, + id: 'node' + } + }) + const pool = client[kConnectionPool] + t.match(pool.connections.get('node'), { + url: new URL('http://user@passwordlocalhost:9200'), + headers: { 'x-foo': 'bar' } + }) + t.end() + }) + + t.test('Missing node conf', t => { + try { + new Client() // eslint-disable-line + t.fail('Should fail') + } catch (err) { + t.ok(err) + } + t.end() + }) + + t.end() +}) diff --git a/test/unit/connection-pool.test.js b/test/unit/connection-pool.test.js index b0c1ce65b..8da8ae931 100644 --- a/test/unit/connection-pool.test.js +++ b/test/unit/connection-pool.test.js @@ -255,7 +255,7 @@ test('API', t => { const url = 'http://localhost:9200' t.deepEqual( pool.urlToHost(url), - { host: new URL(url) } + { url: new URL(url) } ) t.end() }) @@ -278,7 +278,7 @@ test('API', t => { } t.deepEqual(pool.nodesToHost(nodes), [{ - host: new URL('http://127.0.0.1:9200'), + url: new URL('http://127.0.0.1:9200'), id: 'a1', roles: { master: true, @@ -286,7 +286,7 @@ test('API', t => { ingest: true } }, { - host: new URL('http://127.0.0.1:9201'), + url: new URL('http://127.0.0.1:9201'), id: 'a2', roles: { master: true, @@ -307,7 +307,7 @@ test('API', t => { } const pool = new CustomConnectionPool() pool.addConnection([{ - host: new URL('http://127.0.0.1:9200'), + url: new URL('http://127.0.0.1:9200'), id: 'a1', roles: { master: true, @@ -315,7 +315,7 @@ test('API', t => { ingest: true } }, { - host: new URL('http://127.0.0.1:9201'), + url: new URL('http://127.0.0.1:9201'), id: 'a2', roles: { master: true, @@ -325,11 +325,11 @@ test('API', t => { }]) pool.update([{ - host: new URL('http://127.0.0.1:9200'), + url: new URL('http://127.0.0.1:9200'), id: 'a1', roles: null }, { - host: new URL('http://127.0.0.1:9201'), + url: new URL('http://127.0.0.1:9201'), id: 'a2', roles: null }]) @@ -348,7 +348,7 @@ test('API', t => { } const pool = new CustomConnectionPool() const conn1 = pool.addConnection({ - host: new URL('http://127.0.0.1:9200'), + url: new URL('http://127.0.0.1:9200'), id: 'a1', roles: { master: true, @@ -358,7 +358,7 @@ test('API', t => { }) const conn2 = pool.addConnection({ - host: new URL('http://127.0.0.1:9201'), + url: new URL('http://127.0.0.1:9201'), id: 'a2', roles: { master: true, @@ -371,11 +371,11 @@ test('API', t => { pool.markDead(conn2) pool.update([{ - host: new URL('http://127.0.0.1:9200'), + url: new URL('http://127.0.0.1:9200'), id: 'a1', roles: null }, { - host: new URL('http://127.0.0.1:9201'), + url: new URL('http://127.0.0.1:9201'), id: 'a2', roles: null }]) @@ -388,7 +388,7 @@ test('API', t => { t.plan(2) const pool = new ConnectionPool() pool.addConnection({ - host: new URL('http://127.0.0.1:9200'), + url: new URL('http://127.0.0.1:9200'), id: 'a1', roles: { master: true, @@ -398,11 +398,11 @@ test('API', t => { }) pool.update([{ - host: new URL('http://127.0.0.1:9200'), + url: new URL('http://127.0.0.1:9200'), id: 'a1', roles: null }, { - host: new URL('http://127.0.0.1:9201'), + url: new URL('http://127.0.0.1:9201'), id: 'a2', roles: null }]) @@ -415,17 +415,17 @@ test('API', t => { t.plan(3) const pool = new ConnectionPool() pool.addConnection({ - host: new URL('http://127.0.0.1:9200'), + url: new URL('http://127.0.0.1:9200'), id: 'a1', roles: null }) pool.update([{ - host: new URL('http://127.0.0.1:9200'), + url: new URL('http://127.0.0.1:9200'), id: 'a2', roles: null }, { - host: new URL('http://127.0.0.1:9201'), + url: new URL('http://127.0.0.1:9201'), id: 'a3', roles: null }]) diff --git a/test/unit/connection.test.js b/test/unit/connection.test.js index 3ee6b8234..fe9eaaf1c 100644 --- a/test/unit/connection.test.js +++ b/test/unit/connection.test.js @@ -21,7 +21,7 @@ test('Basic (http)', t => { buildServer(handler, ({ port }, server) => { const connection = new Connection({ - host: new URL(`http://localhost:${port}`) + url: new URL(`http://localhost:${port}`) }) connection.request({ path: '/hello', @@ -60,7 +60,7 @@ test('Basic (https)', t => { buildServer(handler, { secure: true }, ({ port }, server) => { const connection = new Connection({ - host: new URL(`https://localhost:${port}`) + url: new URL(`https://localhost:${port}`) }) connection.request({ path: '/hello', @@ -99,7 +99,7 @@ test('Basic (https with ssl agent)', t => { buildServer(handler, { secure: true }, ({ port, key, cert }, server) => { const connection = new Connection({ - host: new URL(`https://localhost:${port}`), + url: new URL(`https://localhost:${port}`), ssl: { key, cert } }) connection.request({ @@ -139,7 +139,7 @@ test('Disable keep alive', t => { buildServer(handler, ({ port }, server) => { const connection = new Connection({ - host: new URL(`http://localhost:${port}`), + url: new URL(`http://localhost:${port}`), agent: { keepAlive: false } }) connection.request({ @@ -170,7 +170,7 @@ test('Timeout support', t => { buildServer(handler, ({ port }, server) => { const connection = new Connection({ - host: new URL(`http://localhost:${port}`) + url: new URL(`http://localhost:${port}`) }) connection.request({ path: '/hello', @@ -193,7 +193,7 @@ test('querystring', t => { buildServer(handler, ({ port }, server) => { const connection = new Connection({ - host: new URL(`http://localhost:${port}`) + url: new URL(`http://localhost:${port}`) }) connection.request({ path: '/hello', @@ -215,7 +215,7 @@ test('querystring', t => { buildServer(handler, ({ port }, server) => { const connection = new Connection({ - host: new URL(`http://localhost:${port}`) + url: new URL(`http://localhost:${port}`) }) connection.request({ path: '/hello', @@ -246,7 +246,7 @@ test('Body request', t => { buildServer(handler, ({ port }, server) => { const connection = new Connection({ - host: new URL(`http://localhost:${port}`) + url: new URL(`http://localhost:${port}`) }) connection.request({ path: '/hello', @@ -274,7 +274,7 @@ test('Should handle compression', t => { buildServer(handler, ({ port }, server) => { const connection = new Connection({ - host: new URL(`http://localhost:${port}`) + url: new URL(`http://localhost:${port}`) }) connection.request({ path: '/hello', @@ -313,7 +313,7 @@ test('Should handle compression', t => { buildServer(handler, ({ port }, server) => { const connection = new Connection({ - host: new URL(`http://localhost:${port}`) + url: new URL(`http://localhost:${port}`) }) connection.request({ path: '/hello', @@ -349,7 +349,7 @@ test('Should not close a connection if there are open requests', t => { buildServer(handler, ({ port }, server) => { const connection = new Connection({ - host: new URL(`http://localhost:${port}`) + url: new URL(`http://localhost:${port}`) }) setTimeout(() => { @@ -387,7 +387,7 @@ test('Url with auth', t => { buildServer(handler, ({ port }, server) => { const connection = new Connection({ - host: new URL(`http://foo:bar@localhost:${port}`) + url: new URL(`http://foo:bar@localhost:${port}`) }) connection.request({ path: '/hello', @@ -408,7 +408,7 @@ test('Url with querystring', t => { buildServer(handler, ({ port }, server) => { const connection = new Connection({ - host: new URL(`http://localhost:${port}?foo=bar`) + url: new URL(`http://localhost:${port}?foo=bar`) }) connection.request({ path: '/hello', @@ -419,3 +419,33 @@ test('Url with querystring', t => { }) }) }) + +test('Custom headers for connection', t => { + t.plan(3) + + function handler (req, res) { + t.match(req.headers, { + 'x-custom-test': 'true', + 'x-foo': 'bar' + }) + res.end('ok') + } + + buildServer(handler, ({ port }, server) => { + const connection = new Connection({ + url: new URL(`http://localhost:${port}`), + headers: { 'x-foo': 'bar' } + }) + connection.request({ + path: '/hello', + method: 'GET', + headers: { + 'X-Custom-Test': true + } + }, (err, res) => { + t.error(err) + // should not update the default + t.deepEqual(connection.headers, { 'x-foo': 'bar' }) + }) + }) +}) diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index c7bc712a6..97fe60fc5 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -274,7 +274,7 @@ test('TimeoutError (should call markDead on the failing connection)', t => { buildServer(handler, ({ port }, server) => { const pool = new CustomConnectionPool() pool.addConnection({ - host: new URL(`http://localhost:${port}`), + url: new URL(`http://localhost:${port}`), id: 'node1' }) @@ -311,7 +311,7 @@ test('ConnectionError (should call markDead on the failing connection)', t => { server.close() const pool = new CustomConnectionPool() pool.addConnection({ - host: new URL(`http://localhost:${port}`), + url: new URL(`http://localhost:${port}`), id: 'node1' }) @@ -353,13 +353,13 @@ test('Retry mechanism', t => { buildServer(handler, ({ port }, server) => { const pool = new ConnectionPool() pool.addConnection([{ - host: new URL(`http://localhost:${port}`), + url: new URL(`http://localhost:${port}`), id: 'node1' }, { - host: new URL(`http://localhost:${port}`), + url: new URL(`http://localhost:${port}`), id: 'node2' }, { - host: new URL(`http://localhost:${port}`), + url: new URL(`http://localhost:${port}`), id: 'node3' }]) @@ -401,7 +401,7 @@ test('Should call markAlive with a successful response', t => { buildServer(handler, ({ port }, server) => { const pool = new CustomConnectionPool() pool.addConnection({ - host: new URL(`http://localhost:${port}`), + url: new URL(`http://localhost:${port}`), id: 'node1' }) @@ -442,7 +442,7 @@ test('Should call resurrect on every request', t => { buildServer(handler, ({ port }, server) => { const pool = new CustomConnectionPool() pool.addConnection({ - host: new URL(`http://localhost:${port}`), + url: new URL(`http://localhost:${port}`), id: 'node1' }) @@ -479,7 +479,7 @@ test('Should return a request aborter utility', t => { buildServer(handler, ({ port }, server) => { const pool = new ConnectionPool() pool.addConnection({ - host: new URL(`http://localhost:${port}`), + url: new URL(`http://localhost:${port}`), id: 'node1' }) @@ -945,7 +945,7 @@ test('timeout option', t => { buildServer(handler, ({ port }, server) => { const pool = new ConnectionPool() pool.addConnection({ - host: new URL(`http://localhost:${port}`), + url: new URL(`http://localhost:${port}`), id: 'node1' }) @@ -974,7 +974,7 @@ test('timeout option', t => { buildServer(handler, ({ port }, server) => { const pool = new ConnectionPool() pool.addConnection({ - host: new URL(`http://localhost:${port}`), + url: new URL(`http://localhost:${port}`), id: 'node1' }) @@ -1008,7 +1008,7 @@ test('timeout option', t => { buildServer(handler, ({ port }, server) => { const pool = new ConnectionPool() pool.addConnection({ - host: new URL(`http://localhost:${port}`), + url: new URL(`http://localhost:${port}`), id: 'node1' }) @@ -1037,7 +1037,7 @@ test('timeout option', t => { buildServer(handler, ({ port }, server) => { const pool = new ConnectionPool() pool.addConnection({ - host: new URL(`http://localhost:${port}`), + url: new URL(`http://localhost:${port}`), id: 'node1' }) From 0701a795c2c08e6b46839a556d94ce1e179b2788 Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 9 Nov 2018 17:32:29 +0100 Subject: [PATCH 036/172] Node v6 fix --- index.js | 2 +- test/unit/client.test.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 4ddd5b67c..644f32ece 100644 --- a/index.js +++ b/index.js @@ -110,5 +110,5 @@ module.exports = { Transport, ConnectionPool, Serializer, - ...symbols + symbols } diff --git a/test/unit/client.test.js b/test/unit/client.test.js index 8ab1a8359..a60476d48 100644 --- a/test/unit/client.test.js +++ b/test/unit/client.test.js @@ -2,7 +2,8 @@ const { test } = require('tap') const { URL } = require('url') -const { Client, kConnectionPool } = require('../../index') +const { Client, symbols } = require('../../index') +const { kConnectionPool } = symbols test('Configure host', t => { t.test('Single string', t => { From 6f08079953ee42fe757b6ec33371218094d69e29 Mon Sep 17 00:00:00 2001 From: Tomas Della Vedova Date: Fri, 9 Nov 2018 17:57:23 +0100 Subject: [PATCH 037/172] WIP: clients-ci (#723) clients-ci --- .ci/.dockerignore | 2 ++ .ci/Dockerfile | 13 +++++++++++++ .ci/docker-compose.yml | 38 ++++++++++++++++++++++++++++++++++++++ .ci/run-tests | 13 +++++++++++++ .ci/test-matrix.yml | 10 ++++++++++ package.json | 3 ++- scripts/wait-cluster.sh | 4 +++- test/integration/index.js | 2 +- 8 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 .ci/.dockerignore create mode 100644 .ci/Dockerfile create mode 100644 .ci/docker-compose.yml create mode 100755 .ci/run-tests create mode 100644 .ci/test-matrix.yml diff --git a/.ci/.dockerignore b/.ci/.dockerignore new file mode 100644 index 000000000..93f136199 --- /dev/null +++ b/.ci/.dockerignore @@ -0,0 +1,2 @@ +node_modules +npm-debug.log diff --git a/.ci/Dockerfile b/.ci/Dockerfile new file mode 100644 index 000000000..04ff3f55d --- /dev/null +++ b/.ci/Dockerfile @@ -0,0 +1,13 @@ +ARG NODE_JS_VERSION=8 +FROM node:${NODE_JS_VERSION} + +# Create app directory +WORKDIR /usr/src/app + +# Install app dependencies +COPY package*.json ./ +RUN npm install + +COPY . . + +CMD [ "npm", "run", "ci" ] diff --git a/.ci/docker-compose.yml b/.ci/docker-compose.yml new file mode 100644 index 000000000..541bb4898 --- /dev/null +++ b/.ci/docker-compose.yml @@ -0,0 +1,38 @@ +version: '3.2' +services: + client: + image: docker.elastic.co/clients/elasticsearch-js:${NODE_JS_VERSION:-8} + build: + context: .. + dockerfile: .ci/Dockerfile + args: + NODE_JS_VERSION: ${NODE_JS_VERSION:-8} + environment: + - "TEST_ES_SERVER=http://elasticsearch:9200" + volumes: + - ..:/usr/src/app + # This will mount the node_modules directory + # to the host machine using the buildtime directory. + - /usr/src/app/node_modules + - esvol:/tmp + networks: + - esnet + depends_on: + - elasticsearch + elasticsearch: + image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-6.4.0} + volumes: + - esvol:/tmp + networks: + - esnet + environment: + - path.repo=/tmp + - "repositories.url.allowed_urls=http://*" + - node.attr.testattr=test + - bootstrap.memory_lock=false + - "discovery.zen.ping.unicast.hosts=elasticsearch" + - "http.max_content_length=5mb" +networks: + esnet: +volumes: + esvol: diff --git a/.ci/run-tests b/.ci/run-tests new file mode 100755 index 000000000..e0deadb62 --- /dev/null +++ b/.ci/run-tests @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# +# Runs the client tests via Docker with the expectation that the required +# environment variables have already been exported before running this script. +# +# The required environment variables include: +# +# - $ELASTICSEARCH_VERSION +# - $NODE_JS_VERSION +# + +ELASTICSEARCH_VERSION=${ELASTICSEARCH_VERSION} NODE_JS_VERSION=${NODE_JS_VERSION} docker-compose -f .ci/docker-compose.yml run client diff --git a/.ci/test-matrix.yml b/.ci/test-matrix.yml new file mode 100644 index 000000000..9848e5c31 --- /dev/null +++ b/.ci/test-matrix.yml @@ -0,0 +1,10 @@ +--- +ELASTICSEARCH_VERSION: +- 6.4.0 + +NODE_JS_VERSION: +- 10 +- 8 +- 6 + +exclude: ~ diff --git a/package.json b/package.json index 5fda757e3..e29c8cf35 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "lint": "standard", "lint:fix": "standard --fix", "generate": "node scripts/run.js", - "elasticsearch": "./scripts/es-docker.sh" + "elasticsearch": "./scripts/es-docker.sh", + "ci": "./scripts/wait-cluster.sh && npm test && npm run test:integration" }, "author": { "name": "Tomas Della Vedova", diff --git a/scripts/wait-cluster.sh b/scripts/wait-cluster.sh index f94c333ed..4cacaa4b6 100755 --- a/scripts/wait-cluster.sh +++ b/scripts/wait-cluster.sh @@ -1,8 +1,10 @@ #!/bin/bash +TEST_ES_SERVER=${TEST_ES_SERVER:-"http://localhost:9200"} + attempt_counter=0 max_attempts=5 -url='http://localhost:9200/_cluster/health?wait_for_status=green&timeout=50s' +url="${TEST_ES_SERVER}/_cluster/health?wait_for_status=green&timeout=50s" echo "Waiting for Elasticsearch..." while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' --max-time 55 "$url")" != "200" ]]; do diff --git a/test/integration/index.js b/test/integration/index.js index b20adb936..afc72421f 100644 --- a/test/integration/index.js +++ b/test/integration/index.js @@ -238,7 +238,7 @@ if (require.main === module) { boolean: ['bailout'], default: { // node: 'http://elastic:passw0rd@localhost:9200', - node: 'http://localhost:9200', + node: process.env.TEST_ES_SERVER || 'http://localhost:9200', version: '6.4', bailout: false } From ca5e9ca743617bb8372669129834c782e494a474 Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 9 Nov 2018 18:09:29 +0100 Subject: [PATCH 038/172] Force close the server once the test is finished --- package.json | 1 + test/unit/api.test.js | 18 +++++++++++--- test/unit/connection-pool.test.js | 2 ++ test/unit/connection.test.js | 14 +++++++++++ test/unit/transport.test.js | 40 +++++++++++++++++++++++++++++++ test/utils/buildServer.js | 7 +++--- 6 files changed, 76 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 5fda757e3..93f539c36 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "simple-git": "^1.105.0", "sinon": "^6.1.5", "standard": "^12.0.0", + "stoppable": "^1.0.7", "string-to-stream": "^1.1.1", "tap": "^12.0.1", "workq": "^2.1.0" diff --git a/test/unit/api.test.js b/test/unit/api.test.js index 539aa2ee9..4ce2ca6e2 100644 --- a/test/unit/api.test.js +++ b/test/unit/api.test.js @@ -24,6 +24,7 @@ test('Basic (callback)', t => { }, (err, { body }) => { t.error(err) t.deepEqual(body, { hello: 'world' }) + server.stop() }) }) }) @@ -47,7 +48,10 @@ test('Basic (promises)', t => { type: 'doc', q: 'foo:bar' }) - .then(({ body }) => t.deepEqual(body, { hello: 'world' })) + .then(({ body }) => { + t.deepEqual(body, { hello: 'world' }) + server.stop() + }) .catch(t.fail) }) }) @@ -72,6 +76,7 @@ test('Error (callback)', t => { q: 'foo:bar' }, (err, { body }) => { t.ok(err) + server.stop() }) }) }) @@ -97,7 +102,10 @@ test('Error (promises)', t => { q: 'foo:bar' }) .then(t.fail) - .catch(err => t.ok(err)) + .catch(err => { + t.ok(err) + server.stop() + }) }) }) @@ -121,6 +129,7 @@ test('Abort method (callback)', t => { }, (err, { body }) => { t.error(err) t.deepEqual(body, { hello: 'world' }) + server.stop() }) t.type(request.abort, 'function') @@ -147,7 +156,10 @@ test('Abort is not supported in promises', t => { }) request - .then(({ body }) => t.deepEqual(body, { hello: 'world' })) + .then(({ body }) => { + t.deepEqual(body, { hello: 'world' }) + server.stop() + }) .catch(t.fail) t.type(request.abort, 'undefined') diff --git a/test/unit/connection-pool.test.js b/test/unit/connection-pool.test.js index 8da8ae931..460573630 100644 --- a/test/unit/connection-pool.test.js +++ b/test/unit/connection-pool.test.js @@ -92,6 +92,7 @@ test('API', t => { t.strictEqual(connection.resurrectTimeout, 0) t.strictEqual(connection.status, Connection.statuses.ALIVE) t.deepEqual(pool.dead, []) + server.stop() t.end() }) }) @@ -114,6 +115,7 @@ test('API', t => { t.true(connection.resurrectTimeout > 0) t.strictEqual(connection.status, Connection.statuses.DEAD) t.deepEqual(pool.dead, [href]) + server.stop() t.end() }) }) diff --git a/test/unit/connection.test.js b/test/unit/connection.test.js index fe9eaaf1c..b2b78910e 100644 --- a/test/unit/connection.test.js +++ b/test/unit/connection.test.js @@ -42,6 +42,7 @@ test('Basic (http)', t => { res.on('error', err => t.fail(err)) res.on('end', () => { t.strictEqual(payload, 'ok') + server.stop() }) }) }) @@ -81,6 +82,7 @@ test('Basic (https)', t => { res.on('error', err => t.fail(err)) res.on('end', () => { t.strictEqual(payload, 'ok') + server.stop() }) }) }) @@ -121,6 +123,7 @@ test('Basic (https with ssl agent)', t => { res.on('error', err => t.fail(err)) res.on('end', () => { t.strictEqual(payload, 'ok') + server.stop() }) }) }) @@ -154,6 +157,7 @@ test('Disable keep alive', t => { t.match(res.headers, { connection: 'close' }) + server.stop() }) }) }) @@ -178,6 +182,7 @@ test('Timeout support', t => { timeout: 500 }, (err, res) => { t.ok(err instanceof TimeoutError) + server.stop() }) }) }) @@ -201,6 +206,7 @@ test('querystring', t => { querystring: 'hello=world&you_know=for%20search' }, (err, res) => { t.error(err) + server.stop() }) }) }) @@ -223,6 +229,7 @@ test('querystring', t => { querystring: null }, (err, res) => { t.error(err) + server.stop() }) }) }) @@ -254,6 +261,7 @@ test('Body request', t => { body: 'hello' }, (err, res) => { t.error(err) + server.stop() }) }) }) @@ -293,6 +301,7 @@ test('Should handle compression', t => { res.on('error', err => t.fail(err)) res.on('end', () => { t.deepEqual(JSON.parse(payload), { hello: 'world' }) + server.stop() }) }) }) @@ -332,6 +341,7 @@ test('Should handle compression', t => { res.on('error', err => t.fail(err)) res.on('end', () => { t.deepEqual(JSON.parse(payload), { hello: 'world' }) + server.stop() }) }) }) @@ -370,6 +380,7 @@ test('Should not close a connection if there are open requests', t => { res.on('error', err => t.fail(err)) res.on('end', () => { t.strictEqual(payload, 'ok') + server.stop() }) }) }) @@ -394,6 +405,7 @@ test('Url with auth', t => { method: 'GET' }, (err, res) => { t.error(err) + server.stop() }) }) }) @@ -416,6 +428,7 @@ test('Url with querystring', t => { querystring: 'baz=faz' }, (err, res) => { t.error(err) + server.stop() }) }) }) @@ -446,6 +459,7 @@ test('Custom headers for connection', t => { t.error(err) // should not update the default t.deepEqual(connection.headers, { 'x-foo': 'bar' }) + server.stop() }) }) }) diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index 97fe60fc5..46c0ee614 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -43,6 +43,7 @@ test('Basic', t => { }, (err, { body }) => { t.error(err) t.deepEqual(body, { hello: 'world' }) + server.stop() }) }) }) @@ -86,6 +87,7 @@ test('Send POST', t => { }, (err, { body }) => { t.error(err) t.deepEqual(body, { hello: 'world' }) + server.stop() }) }) }) @@ -141,6 +143,7 @@ test('Send POST (ndjson)', t => { }, (err, { body }) => { t.error(err) t.deepEqual(body, { hello: 'world' }) + server.stop() }) }) }) @@ -172,6 +175,7 @@ test('Not JSON payload from server', t => { }, (err, { body }) => { t.error(err) t.strictEqual(body, 'hello!') + server.stop() }) }) }) @@ -250,6 +254,7 @@ test('DeserializationError', t => { path: '/hello' }, (err, { body }) => { t.ok(err instanceof DeserializationError) + server.stop() }) }) }) @@ -293,6 +298,7 @@ test('TimeoutError (should call markDead on the failing connection)', t => { path: '/hello' }, (err, { body }) => { t.ok(err instanceof TimeoutError) + server.stop() }) }) }) @@ -330,6 +336,7 @@ test('ConnectionError (should call markDead on the failing connection)', t => { path: '/hello' }, (err, { body }) => { t.ok(err instanceof ConnectionError) + server.stop() }) }) }) @@ -379,6 +386,7 @@ test('Retry mechanism', t => { }, (err, { body }) => { t.error(err) t.deepEqual(body, { hello: 'world' }) + server.stop() }) }) }) @@ -421,6 +429,7 @@ test('Should call markAlive with a successful response', t => { }, (err, { body }) => { t.error(err) t.deepEqual(body, { hello: 'world' }) + server.stop() }) }) }) @@ -462,6 +471,7 @@ test('Should call resurrect on every request', t => { }, (err, { body }) => { t.error(err) t.deepEqual(body, { hello: 'world' }) + server.stop() }) }) }) @@ -501,6 +511,7 @@ test('Should return a request aborter utility', t => { }) request.abort() + server.stop() t.pass('ok') }) }) @@ -535,6 +546,7 @@ test('ResponseError', t => { t.ok(err instanceof ResponseError) t.deepEqual(err.body, { status: 500 }) t.strictEqual(err.statusCode, 500) + server.stop() }) }) }) @@ -569,6 +581,7 @@ test('Override requestTimeout', t => { }, (err, { body }) => { t.error(err) t.deepEqual(body, { hello: 'world' }) + server.stop() }) }) }) @@ -610,6 +623,8 @@ test('sniff', t => { sniffOnStart: true, sniffEndpoint: '/sniff' }) + + setTimeout(() => server.stop(), 100) }) }) @@ -659,6 +674,8 @@ test('sniff', t => { }, (err, { body }) => { t.ok(err instanceof TimeoutError) }) + + setTimeout(() => server.stop(), 1100) }) }) @@ -708,6 +725,10 @@ test('sniff', t => { setTimeout(() => { transport.request(params, t.error) }, 300) + + setTimeout(() => { + server.stop() + }, 400) }) }) @@ -737,6 +758,7 @@ test('sniff', t => { transport.sniff((err, hosts) => { t.ok(err instanceof ConnectionError) + server.stop() }) }) }) @@ -788,6 +810,7 @@ test(`Should mark as dead connections where the statusCode is 502/3/4 headers: { 'content-type': 'application/json;utf=8' }, statusCode: statusCode }) + server.stop() }) }) }) @@ -839,6 +862,7 @@ test('Should retry the request if the statusCode is 502/3/4', t => { }, (err, { body }) => { t.error(err) t.deepEqual(body, { hello: 'world' }) + server.stop() }) }) }) @@ -892,6 +916,8 @@ test('Ignore status code', t => { }, (err, { body }) => { t.ok(err instanceof ResponseError) }) + + setTimeout(() => server.stop(), 100) }) }) @@ -926,6 +952,7 @@ test('Should serialize the querystring', t => { } }, (err, { body }) => { t.error(err) + server.stop() }) }) }) @@ -964,6 +991,7 @@ test('timeout option', t => { path: '/hello' }, (err, { body }) => { t.ok(err instanceof TimeoutError) + server.stop() }) }) }) @@ -994,6 +1022,7 @@ test('timeout option', t => { requestTimeout: 500 }, (err, { body }) => { t.ok(err instanceof TimeoutError) + server.stop() }) }) }) @@ -1027,6 +1056,7 @@ test('timeout option', t => { path: '/hello' }, (err, { body }) => { t.ok(err instanceof TimeoutError) + server.stop() }) }) }) @@ -1057,6 +1087,7 @@ test('timeout option', t => { requestTimeout: '0.5s' }, (err, { body }) => { t.ok(err instanceof TimeoutError) + server.stop() }) }) }) @@ -1095,6 +1126,7 @@ test('Should cast to boolean HEAD request', t => { }, (err, { body }) => { t.error(err) t.strictEqual(body, true) + server.stop() }) }) }) @@ -1127,6 +1159,7 @@ test('Should cast to boolean HEAD request', t => { }, (err, { body }) => { t.error(err) t.strictEqual(body, false) + server.stop() }) }) }) @@ -1158,6 +1191,7 @@ test('Should cast to boolean HEAD request', t => { path: '/hello' }, (err, { body }) => { t.ok(err instanceof ResponseError) + server.stop() }) }) }) @@ -1189,6 +1223,7 @@ test('Should cast to boolean HEAD request', t => { path: '/hello' }, (err, { body }) => { t.ok(err instanceof ResponseError) + server.stop() }) }) }) @@ -1226,6 +1261,7 @@ test('Suggest compression', t => { path: '/hello' }, (err, { body }) => { t.error(err) + server.stop() }) }) }) @@ -1262,6 +1298,7 @@ test('Warning header', t => { t.error(err) t.deepEqual(warnings, [warn]) warnings.forEach(w => t.type(w, 'string')) + server.stop() }) }) }) @@ -1298,6 +1335,7 @@ test('Warning header', t => { t.error(err) t.deepEqual(warnings, [warn1, warn2]) warnings.forEach(w => t.type(w, 'string')) + server.stop() }) }) }) @@ -1330,6 +1368,7 @@ test('Warning header', t => { }, (err, { warnings }) => { t.error(err) t.strictEqual(warnings, null) + server.stop() }) }) }) @@ -1375,6 +1414,7 @@ test('asHttpResponse enabled', t => { response.on('error', err => t.fail(err)) response.on('end', () => { t.deepEqual(JSON.parse(payload), { hello: 'world' }) + server.stop() }) }) }) diff --git a/test/utils/buildServer.js b/test/utils/buildServer.js index af038743e..3de966fcf 100644 --- a/test/utils/buildServer.js +++ b/test/utils/buildServer.js @@ -1,5 +1,7 @@ 'use strict' +const stoppable = require('stoppable') + // allow self signed certificates for testing purposes process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0 @@ -20,12 +22,11 @@ function buildServer (handler, opts, cb) { } const server = opts.secure - ? https.createServer(secureOpts) - : http.createServer() + ? stoppable(https.createServer(secureOpts)) + : stoppable(http.createServer()) server.on('request', handler) server.listen(0, () => { - server.unref() const port = server.address().port cb(Object.assign({}, secureOpts, { port }), server) }) From a57c8472c99cbe5fbc3275fee79dc4d254bdb55f Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 12 Nov 2018 18:39:43 +0100 Subject: [PATCH 039/172] Updated package.json --- package.json | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 5870223c3..4500ff986 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,9 @@ "kibana", "mapping", "REST", - "search" + "search", + "client", + "index" ], "scripts": { "test": "npm run lint && npm run test:unit", @@ -37,14 +39,11 @@ "js-yaml": "^3.12.0", "minimist": "^1.2.0", "ora": "^3.0.0", - "readable-stream": "^3.0.1", "rimraf": "^2.6.2", "semver": "^5.6.0", "simple-git": "^1.105.0", - "sinon": "^6.1.5", "standard": "^12.0.0", "stoppable": "^1.0.7", - "string-to-stream": "^1.1.1", "tap": "^12.0.1", "workq": "^2.1.0" }, From 95c7ca84278d8d3480e21905d2f63e7f05e67524 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 14 Nov 2018 08:46:24 +0100 Subject: [PATCH 040/172] Bumped v0.1.0-alpha.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4500ff986..88cebd6f0 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "The official Elasticsearch client for Node.js", "main": "index.js", "homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html", - "version": "0.1.0", + "version": "0.1.0-alpha.0", "keywords": [ "elasticsearch", "elastic", From 1d696ba0d648c8ce69f9c7aa951ec153fd3095f6 Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 15 Nov 2018 17:46:33 +0100 Subject: [PATCH 041/172] API generation --- api/api/bulk.js | 4 +--- api/api/cat.aliases.js | 4 +--- api/api/cat.allocation.js | 4 +--- api/api/cat.count.js | 4 +--- api/api/cat.fielddata.js | 4 +--- api/api/cat.health.js | 4 +--- api/api/cat.help.js | 4 +--- api/api/cat.indices.js | 4 +--- api/api/cat.master.js | 4 +--- api/api/cat.nodeattrs.js | 4 +--- api/api/cat.nodes.js | 4 +--- api/api/cat.pending_tasks.js | 4 +--- api/api/cat.plugins.js | 4 +--- api/api/cat.recovery.js | 4 +--- api/api/cat.repositories.js | 4 +--- api/api/cat.segments.js | 4 +--- api/api/cat.shards.js | 4 +--- api/api/cat.snapshots.js | 4 +--- api/api/cat.tasks.js | 4 +--- api/api/cat.templates.js | 4 +--- api/api/cat.thread_pool.js | 4 +--- api/api/clear_scroll.js | 4 +--- api/api/cluster.allocation_explain.js | 4 +--- api/api/cluster.get_settings.js | 4 +--- api/api/cluster.health.js | 4 +--- api/api/cluster.pending_tasks.js | 4 +--- api/api/cluster.put_settings.js | 4 +--- api/api/cluster.remote_info.js | 4 +--- api/api/cluster.reroute.js | 4 +--- api/api/cluster.state.js | 4 +--- api/api/cluster.stats.js | 4 +--- api/api/count.js | 4 +--- api/api/create.js | 4 +--- api/api/delete.js | 4 +--- api/api/delete_by_query.js | 4 +--- api/api/delete_script.js | 4 +--- api/api/exists.js | 4 +--- api/api/exists_source.js | 4 +--- api/api/explain.js | 4 +--- api/api/field_caps.js | 4 +--- api/api/get.js | 4 +--- api/api/get_script.js | 4 +--- api/api/get_source.js | 4 +--- api/api/index.js | 4 +--- api/api/indices.analyze.js | 4 +--- api/api/indices.clear_cache.js | 4 +--- api/api/indices.close.js | 4 +--- api/api/indices.create.js | 4 +--- api/api/indices.delete.js | 4 +--- api/api/indices.delete_alias.js | 4 +--- api/api/indices.delete_template.js | 4 +--- api/api/indices.exists.js | 4 +--- api/api/indices.exists_alias.js | 4 +--- api/api/indices.exists_template.js | 4 +--- api/api/indices.exists_type.js | 4 +--- api/api/indices.flush.js | 4 +--- api/api/indices.flush_synced.js | 4 +--- api/api/indices.forcemerge.js | 4 +--- api/api/indices.get.js | 4 +--- api/api/indices.get_alias.js | 4 +--- api/api/indices.get_field_mapping.js | 4 +--- api/api/indices.get_mapping.js | 4 +--- api/api/indices.get_settings.js | 4 +--- api/api/indices.get_template.js | 4 +--- api/api/indices.get_upgrade.js | 4 +--- api/api/indices.open.js | 4 +--- api/api/indices.put_alias.js | 4 +--- api/api/indices.put_mapping.js | 4 +--- api/api/indices.put_settings.js | 4 +--- api/api/indices.put_template.js | 4 +--- api/api/indices.recovery.js | 4 +--- api/api/indices.refresh.js | 4 +--- api/api/indices.rollover.js | 4 +--- api/api/indices.segments.js | 4 +--- api/api/indices.shard_stores.js | 4 +--- api/api/indices.shrink.js | 4 +--- api/api/indices.split.js | 4 +--- api/api/indices.stats.js | 4 +--- api/api/indices.update_aliases.js | 4 +--- api/api/indices.upgrade.js | 4 +--- api/api/indices.validate_query.js | 4 +--- api/api/info.js | 4 +--- api/api/ingest.delete_pipeline.js | 4 +--- api/api/ingest.get_pipeline.js | 4 +--- api/api/ingest.processor_grok.js | 4 +--- api/api/ingest.put_pipeline.js | 4 +--- api/api/ingest.simulate.js | 4 +--- api/api/mget.js | 4 +--- api/api/msearch.js | 4 +--- api/api/msearch_template.js | 4 +--- api/api/mtermvectors.js | 4 +--- api/api/nodes.hot_threads.js | 4 +--- api/api/nodes.info.js | 4 +--- api/api/nodes.stats.js | 4 +--- api/api/nodes.usage.js | 4 +--- api/api/ping.js | 4 +--- api/api/put_script.js | 4 +--- api/api/rank_eval.js | 4 +--- api/api/reindex.js | 4 +--- api/api/reindex_rethrottle.js | 4 +--- api/api/render_search_template.js | 4 +--- api/api/scripts_painless_execute.js | 4 +--- api/api/scroll.js | 4 +--- api/api/search.js | 4 +--- api/api/search_shards.js | 4 +--- api/api/search_template.js | 4 +--- api/api/snapshot.create.js | 4 +--- api/api/snapshot.create_repository.js | 4 +--- api/api/snapshot.delete.js | 4 +--- api/api/snapshot.delete_repository.js | 4 +--- api/api/snapshot.get.js | 4 +--- api/api/snapshot.get_repository.js | 4 +--- api/api/snapshot.restore.js | 4 +--- api/api/snapshot.status.js | 4 +--- api/api/snapshot.verify_repository.js | 4 +--- api/api/tasks.cancel.js | 4 +--- api/api/tasks.get.js | 4 +--- api/api/tasks.list.js | 4 +--- api/api/termvectors.js | 4 +--- api/api/update.js | 4 +--- api/api/update_by_query.js | 4 +--- api/api/xpack.graph.explore.js | 4 +--- api/api/xpack.info.js | 4 +--- api/api/xpack.license.delete.js | 4 +--- api/api/xpack.license.get.js | 4 +--- api/api/xpack.license.get_basic_status.js | 4 +--- api/api/xpack.license.get_trial_status.js | 4 +--- api/api/xpack.license.post.js | 4 +--- api/api/xpack.license.post_start_basic.js | 4 +--- api/api/xpack.license.post_start_trial.js | 4 +--- api/api/xpack.migration.deprecations.js | 4 +--- api/api/xpack.migration.get_assistance.js | 4 +--- api/api/xpack.migration.upgrade.js | 4 +--- api/api/xpack.ml.close_job.js | 4 +--- api/api/xpack.ml.delete_calendar.js | 4 +--- api/api/xpack.ml.delete_calendar_event.js | 4 +--- api/api/xpack.ml.delete_calendar_job.js | 4 +--- api/api/xpack.ml.delete_datafeed.js | 4 +--- api/api/xpack.ml.delete_expired_data.js | 4 +--- api/api/xpack.ml.delete_filter.js | 4 +--- api/api/xpack.ml.delete_job.js | 4 +--- api/api/xpack.ml.delete_model_snapshot.js | 4 +--- api/api/xpack.ml.flush_job.js | 4 +--- api/api/xpack.ml.forecast.js | 4 +--- api/api/xpack.ml.get_buckets.js | 4 +--- api/api/xpack.ml.get_calendar_events.js | 4 +--- api/api/xpack.ml.get_calendars.js | 4 +--- api/api/xpack.ml.get_categories.js | 4 +--- api/api/xpack.ml.get_datafeed_stats.js | 4 +--- api/api/xpack.ml.get_datafeeds.js | 4 +--- api/api/xpack.ml.get_filters.js | 4 +--- api/api/xpack.ml.get_influencers.js | 4 +--- api/api/xpack.ml.get_job_stats.js | 4 +--- api/api/xpack.ml.get_jobs.js | 4 +--- api/api/xpack.ml.get_model_snapshots.js | 4 +--- api/api/xpack.ml.get_overall_buckets.js | 4 +--- api/api/xpack.ml.get_records.js | 4 +--- api/api/xpack.ml.info.js | 4 +--- api/api/xpack.ml.open_job.js | 4 +--- api/api/xpack.ml.post_calendar_events.js | 4 +--- api/api/xpack.ml.post_data.js | 4 +--- api/api/xpack.ml.preview_datafeed.js | 4 +--- api/api/xpack.ml.put_calendar.js | 4 +--- api/api/xpack.ml.put_calendar_job.js | 4 +--- api/api/xpack.ml.put_datafeed.js | 4 +--- api/api/xpack.ml.put_filter.js | 4 +--- api/api/xpack.ml.put_job.js | 4 +--- api/api/xpack.ml.revert_model_snapshot.js | 4 +--- api/api/xpack.ml.start_datafeed.js | 4 +--- api/api/xpack.ml.stop_datafeed.js | 4 +--- api/api/xpack.ml.update_datafeed.js | 4 +--- api/api/xpack.ml.update_filter.js | 4 +--- api/api/xpack.ml.update_job.js | 4 +--- api/api/xpack.ml.update_model_snapshot.js | 4 +--- api/api/xpack.ml.validate.js | 4 +--- api/api/xpack.ml.validate_detector.js | 4 +--- api/api/xpack.monitoring.bulk.js | 4 +--- api/api/xpack.rollup.delete_job.js | 4 +--- api/api/xpack.rollup.get_jobs.js | 4 +--- api/api/xpack.rollup.get_rollup_caps.js | 4 +--- api/api/xpack.rollup.get_rollup_index_caps.js | 4 +--- api/api/xpack.rollup.put_job.js | 4 +--- api/api/xpack.rollup.rollup_search.js | 4 +--- api/api/xpack.rollup.start_job.js | 4 +--- api/api/xpack.rollup.stop_job.js | 4 +--- api/api/xpack.security.authenticate.js | 4 +--- api/api/xpack.security.change_password.js | 4 +--- api/api/xpack.security.clear_cached_realms.js | 4 +--- api/api/xpack.security.clear_cached_roles.js | 4 +--- api/api/xpack.security.delete_privileges.js | 4 +--- api/api/xpack.security.delete_role.js | 4 +--- api/api/xpack.security.delete_role_mapping.js | 4 +--- api/api/xpack.security.delete_user.js | 4 +--- api/api/xpack.security.disable_user.js | 4 +--- api/api/xpack.security.enable_user.js | 4 +--- api/api/xpack.security.get_privileges.js | 4 +--- api/api/xpack.security.get_role.js | 4 +--- api/api/xpack.security.get_role_mapping.js | 4 +--- api/api/xpack.security.get_token.js | 4 +--- api/api/xpack.security.get_user.js | 4 +--- api/api/xpack.security.has_privileges.js | 4 +--- api/api/xpack.security.invalidate_token.js | 4 +--- api/api/xpack.security.put_privileges.js | 4 +--- api/api/xpack.security.put_role.js | 4 +--- api/api/xpack.security.put_role_mapping.js | 4 +--- api/api/xpack.security.put_user.js | 4 +--- api/api/xpack.sql.clear_cursor.js | 4 +--- api/api/xpack.sql.query.js | 4 +--- api/api/xpack.sql.translate.js | 4 +--- api/api/xpack.ssl.certificates.js | 4 +--- api/api/xpack.usage.js | 4 +--- api/api/xpack.watcher.ack_watch.js | 4 +--- api/api/xpack.watcher.activate_watch.js | 4 +--- api/api/xpack.watcher.deactivate_watch.js | 4 +--- api/api/xpack.watcher.delete_watch.js | 4 +--- api/api/xpack.watcher.execute_watch.js | 4 +--- api/api/xpack.watcher.get_watch.js | 4 +--- api/api/xpack.watcher.put_watch.js | 4 +--- api/api/xpack.watcher.restart.js | 4 +--- api/api/xpack.watcher.start.js | 4 +--- api/api/xpack.watcher.stats.js | 4 +--- api/api/xpack.watcher.stop.js | 4 +--- 222 files changed, 222 insertions(+), 666 deletions(-) diff --git a/api/api/bulk.js b/api/api/bulk.js index 78f57f8e2..bef088340 100644 --- a/api/api/bulk.js +++ b/api/api/bulk.js @@ -128,9 +128,7 @@ function buildBulk (opts) { bulkBody: params.body, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cat.aliases.js b/api/api/cat.aliases.js index d06f0c901..0d3548c9e 100644 --- a/api/api/cat.aliases.js +++ b/api/api/cat.aliases.js @@ -109,9 +109,7 @@ function buildCatAliases (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cat.allocation.js b/api/api/cat.allocation.js index 82d8557ab..ba1228750 100644 --- a/api/api/cat.allocation.js +++ b/api/api/cat.allocation.js @@ -112,9 +112,7 @@ function buildCatAllocation (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cat.count.js b/api/api/cat.count.js index bae0d16ea..deb204ad8 100644 --- a/api/api/cat.count.js +++ b/api/api/cat.count.js @@ -109,9 +109,7 @@ function buildCatCount (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cat.fielddata.js b/api/api/cat.fielddata.js index c05d217a2..40fb7d402 100644 --- a/api/api/cat.fielddata.js +++ b/api/api/cat.fielddata.js @@ -115,9 +115,7 @@ function buildCatFielddata (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cat.health.js b/api/api/cat.health.js index 90993b0fc..df1d07a5a 100644 --- a/api/api/cat.health.js +++ b/api/api/cat.health.js @@ -111,9 +111,7 @@ function buildCatHealth (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cat.help.js b/api/api/cat.help.js index 00dbd5478..71f953e0a 100644 --- a/api/api/cat.help.js +++ b/api/api/cat.help.js @@ -93,9 +93,7 @@ function buildCatHelp (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cat.indices.js b/api/api/cat.indices.js index 1a9652752..b619582ca 100644 --- a/api/api/cat.indices.js +++ b/api/api/cat.indices.js @@ -118,9 +118,7 @@ function buildCatIndices (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cat.master.js b/api/api/cat.master.js index 9863e42e1..a20f8a393 100644 --- a/api/api/cat.master.js +++ b/api/api/cat.master.js @@ -108,9 +108,7 @@ function buildCatMaster (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cat.nodeattrs.js b/api/api/cat.nodeattrs.js index 1beafdd64..86252b0d7 100644 --- a/api/api/cat.nodeattrs.js +++ b/api/api/cat.nodeattrs.js @@ -108,9 +108,7 @@ function buildCatNodeattrs (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cat.nodes.js b/api/api/cat.nodes.js index 08a799cd8..3d326c147 100644 --- a/api/api/cat.nodes.js +++ b/api/api/cat.nodes.js @@ -111,9 +111,7 @@ function buildCatNodes (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cat.pending_tasks.js b/api/api/cat.pending_tasks.js index 023065d70..06b8c792f 100644 --- a/api/api/cat.pending_tasks.js +++ b/api/api/cat.pending_tasks.js @@ -108,9 +108,7 @@ function buildCatPendingTasks (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cat.plugins.js b/api/api/cat.plugins.js index 6b7eb577b..157fcd4cc 100644 --- a/api/api/cat.plugins.js +++ b/api/api/cat.plugins.js @@ -108,9 +108,7 @@ function buildCatPlugins (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cat.recovery.js b/api/api/cat.recovery.js index be17917c1..31f58751b 100644 --- a/api/api/cat.recovery.js +++ b/api/api/cat.recovery.js @@ -109,9 +109,7 @@ function buildCatRecovery (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cat.repositories.js b/api/api/cat.repositories.js index 981ecc704..c0c8146c7 100644 --- a/api/api/cat.repositories.js +++ b/api/api/cat.repositories.js @@ -108,9 +108,7 @@ function buildCatRepositories (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cat.segments.js b/api/api/cat.segments.js index b6fa888f7..32ba290cb 100644 --- a/api/api/cat.segments.js +++ b/api/api/cat.segments.js @@ -106,9 +106,7 @@ function buildCatSegments (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cat.shards.js b/api/api/cat.shards.js index c87ede6da..31b6ae138 100644 --- a/api/api/cat.shards.js +++ b/api/api/cat.shards.js @@ -112,9 +112,7 @@ function buildCatShards (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cat.snapshots.js b/api/api/cat.snapshots.js index 60a0e6797..bb4539fe9 100644 --- a/api/api/cat.snapshots.js +++ b/api/api/cat.snapshots.js @@ -109,9 +109,7 @@ function buildCatSnapshots (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cat.tasks.js b/api/api/cat.tasks.js index 170fe567c..69146dc5f 100644 --- a/api/api/cat.tasks.js +++ b/api/api/cat.tasks.js @@ -114,9 +114,7 @@ function buildCatTasks (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cat.templates.js b/api/api/cat.templates.js index 62e542b3c..2fadb773e 100644 --- a/api/api/cat.templates.js +++ b/api/api/cat.templates.js @@ -109,9 +109,7 @@ function buildCatTemplates (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cat.thread_pool.js b/api/api/cat.thread_pool.js index 59d97ee50..18ad2f6ab 100644 --- a/api/api/cat.thread_pool.js +++ b/api/api/cat.thread_pool.js @@ -112,9 +112,7 @@ function buildCatThreadPool (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/clear_scroll.js b/api/api/clear_scroll.js index 331e7bfe5..8b83b745c 100644 --- a/api/api/clear_scroll.js +++ b/api/api/clear_scroll.js @@ -81,9 +81,7 @@ function buildClearScroll (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cluster.allocation_explain.js b/api/api/cluster.allocation_explain.js index d8c934dbe..026757f3a 100644 --- a/api/api/cluster.allocation_explain.js +++ b/api/api/cluster.allocation_explain.js @@ -86,9 +86,7 @@ function buildClusterAllocationExplain (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cluster.get_settings.js b/api/api/cluster.get_settings.js index db046d645..72514b9b9 100644 --- a/api/api/cluster.get_settings.js +++ b/api/api/cluster.get_settings.js @@ -99,9 +99,7 @@ function buildClusterGetSettings (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cluster.health.js b/api/api/cluster.health.js index 5f3526f88..98361352c 100644 --- a/api/api/cluster.health.js +++ b/api/api/cluster.health.js @@ -118,9 +118,7 @@ function buildClusterHealth (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cluster.pending_tasks.js b/api/api/cluster.pending_tasks.js index dfc9df2e6..f8faf7fda 100644 --- a/api/api/cluster.pending_tasks.js +++ b/api/api/cluster.pending_tasks.js @@ -93,9 +93,7 @@ function buildClusterPendingTasks (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cluster.put_settings.js b/api/api/cluster.put_settings.js index 275dcd800..659fddac3 100644 --- a/api/api/cluster.put_settings.js +++ b/api/api/cluster.put_settings.js @@ -97,9 +97,7 @@ function buildClusterPutSettings (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cluster.remote_info.js b/api/api/cluster.remote_info.js index 8445b4e44..9fd4f98d8 100644 --- a/api/api/cluster.remote_info.js +++ b/api/api/cluster.remote_info.js @@ -87,9 +87,7 @@ function buildClusterRemoteInfo (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cluster.reroute.js b/api/api/cluster.reroute.js index fc7fc927d..0f9281a40 100644 --- a/api/api/cluster.reroute.js +++ b/api/api/cluster.reroute.js @@ -98,9 +98,7 @@ function buildClusterReroute (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cluster.state.js b/api/api/cluster.state.js index 98df3eb07..98eba742f 100644 --- a/api/api/cluster.state.js +++ b/api/api/cluster.state.js @@ -115,9 +115,7 @@ function buildClusterState (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/cluster.stats.js b/api/api/cluster.stats.js index f48a3420e..cb1f7f9bd 100644 --- a/api/api/cluster.stats.js +++ b/api/api/cluster.stats.js @@ -96,9 +96,7 @@ function buildClusterStats (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/count.js b/api/api/count.js index bafcd080d..dce62b73b 100644 --- a/api/api/count.js +++ b/api/api/count.js @@ -129,9 +129,7 @@ function buildCount (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/create.js b/api/api/create.js index d44c77bf8..f426ab593 100644 --- a/api/api/create.js +++ b/api/api/create.js @@ -146,9 +146,7 @@ function buildCreate (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/delete.js b/api/api/delete.js index 2a25363df..68ce7ae3c 100644 --- a/api/api/delete.js +++ b/api/api/delete.js @@ -142,9 +142,7 @@ function buildDelete (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/delete_by_query.js b/api/api/delete_by_query.js index 7207af5b7..042b1eced 100644 --- a/api/api/delete_by_query.js +++ b/api/api/delete_by_query.js @@ -200,9 +200,7 @@ function buildDeleteByQuery (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/delete_script.js b/api/api/delete_script.js index 338432402..8ab1f560e 100644 --- a/api/api/delete_script.js +++ b/api/api/delete_script.js @@ -100,9 +100,7 @@ function buildDeleteScript (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/exists.js b/api/api/exists.js index 7be0f4898..1c40895d7 100644 --- a/api/api/exists.js +++ b/api/api/exists.js @@ -154,9 +154,7 @@ function buildExists (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/exists_source.js b/api/api/exists_source.js index 4fc17e5e6..d3c752c2f 100644 --- a/api/api/exists_source.js +++ b/api/api/exists_source.js @@ -151,9 +151,7 @@ function buildExistsSource (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/explain.js b/api/api/explain.js index d270bf0e4..30b08562b 100644 --- a/api/api/explain.js +++ b/api/api/explain.js @@ -155,9 +155,7 @@ function buildExplain (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/field_caps.js b/api/api/field_caps.js index f398dc57b..fdfcd2907 100644 --- a/api/api/field_caps.js +++ b/api/api/field_caps.js @@ -93,9 +93,7 @@ function buildFieldCaps (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/get.js b/api/api/get.js index 9c2d737bf..999a1d992 100644 --- a/api/api/get.js +++ b/api/api/get.js @@ -154,9 +154,7 @@ function buildGet (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/get_script.js b/api/api/get_script.js index 39bd7e54a..f743b84fb 100644 --- a/api/api/get_script.js +++ b/api/api/get_script.js @@ -97,9 +97,7 @@ function buildGetScript (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/get_source.js b/api/api/get_source.js index bac64bb3b..016fd450c 100644 --- a/api/api/get_source.js +++ b/api/api/get_source.js @@ -151,9 +151,7 @@ function buildGetSource (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/index.js b/api/api/index.js index 7d259cfa0..413f5d60b 100644 --- a/api/api/index.js +++ b/api/api/index.js @@ -143,9 +143,7 @@ function buildIndex (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.analyze.js b/api/api/indices.analyze.js index cdd0866b0..b4a48c878 100644 --- a/api/api/indices.analyze.js +++ b/api/api/indices.analyze.js @@ -84,9 +84,7 @@ function buildIndicesAnalyze (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.clear_cache.js b/api/api/indices.clear_cache.js index 705aedb30..3fe9fb597 100644 --- a/api/api/indices.clear_cache.js +++ b/api/api/indices.clear_cache.js @@ -118,9 +118,7 @@ function buildIndicesClearCache (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.close.js b/api/api/indices.close.js index 3f6be4ad4..738786c2d 100644 --- a/api/api/indices.close.js +++ b/api/api/indices.close.js @@ -109,9 +109,7 @@ function buildIndicesClose (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.create.js b/api/api/indices.create.js index 2433d1fbc..f6cdb6780 100644 --- a/api/api/indices.create.js +++ b/api/api/indices.create.js @@ -101,9 +101,7 @@ function buildIndicesCreate (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.delete.js b/api/api/indices.delete.js index fe51f0448..04ef7250b 100644 --- a/api/api/indices.delete.js +++ b/api/api/indices.delete.js @@ -109,9 +109,7 @@ function buildIndicesDelete (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.delete_alias.js b/api/api/indices.delete_alias.js index 0b4679fb4..f3a9e8130 100644 --- a/api/api/indices.delete_alias.js +++ b/api/api/indices.delete_alias.js @@ -117,9 +117,7 @@ function buildIndicesDeleteAlias (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.delete_template.js b/api/api/indices.delete_template.js index f25ec411d..4d3066e14 100644 --- a/api/api/indices.delete_template.js +++ b/api/api/indices.delete_template.js @@ -100,9 +100,7 @@ function buildIndicesDeleteTemplate (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.exists.js b/api/api/indices.exists.js index b6fdf9f89..53df35461 100644 --- a/api/api/indices.exists.js +++ b/api/api/indices.exists.js @@ -112,9 +112,7 @@ function buildIndicesExists (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.exists_alias.js b/api/api/indices.exists_alias.js index 8e90ba851..4f5cdcdf7 100644 --- a/api/api/indices.exists_alias.js +++ b/api/api/indices.exists_alias.js @@ -107,9 +107,7 @@ function buildIndicesExistsAlias (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.exists_template.js b/api/api/indices.exists_template.js index 943b545b8..71cb9b5b7 100644 --- a/api/api/indices.exists_template.js +++ b/api/api/indices.exists_template.js @@ -103,9 +103,7 @@ function buildIndicesExistsTemplate (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.exists_type.js b/api/api/indices.exists_type.js index 2e40c05ac..7a5303247 100644 --- a/api/api/indices.exists_type.js +++ b/api/api/indices.exists_type.js @@ -121,9 +121,7 @@ function buildIndicesExistsType (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.flush.js b/api/api/indices.flush.js index 47a8d2201..3c273b3a0 100644 --- a/api/api/indices.flush.js +++ b/api/api/indices.flush.js @@ -103,9 +103,7 @@ function buildIndicesFlush (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.flush_synced.js b/api/api/indices.flush_synced.js index 7d1f95a09..d73deb4a2 100644 --- a/api/api/indices.flush_synced.js +++ b/api/api/indices.flush_synced.js @@ -97,9 +97,7 @@ function buildIndicesFlushSynced (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.forcemerge.js b/api/api/indices.forcemerge.js index 89f0b9310..2e89e64b7 100644 --- a/api/api/indices.forcemerge.js +++ b/api/api/indices.forcemerge.js @@ -106,9 +106,7 @@ function buildIndicesForcemerge (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.get.js b/api/api/indices.get.js index 3215012be..5b02972ec 100644 --- a/api/api/indices.get.js +++ b/api/api/indices.get.js @@ -115,9 +115,7 @@ function buildIndicesGet (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.get_alias.js b/api/api/indices.get_alias.js index 45f8ff747..5ab7c2c63 100644 --- a/api/api/indices.get_alias.js +++ b/api/api/indices.get_alias.js @@ -101,9 +101,7 @@ function buildIndicesGetAlias (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.get_field_mapping.js b/api/api/indices.get_field_mapping.js index 13fd55563..5812d30a7 100644 --- a/api/api/indices.get_field_mapping.js +++ b/api/api/indices.get_field_mapping.js @@ -111,9 +111,7 @@ function buildIndicesGetFieldMapping (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.get_mapping.js b/api/api/indices.get_mapping.js index c077f9a43..39ea555a9 100644 --- a/api/api/indices.get_mapping.js +++ b/api/api/indices.get_mapping.js @@ -104,9 +104,7 @@ function buildIndicesGetMapping (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.get_settings.js b/api/api/indices.get_settings.js index e29b58a28..31857139c 100644 --- a/api/api/indices.get_settings.js +++ b/api/api/indices.get_settings.js @@ -110,9 +110,7 @@ function buildIndicesGetSettings (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.get_template.js b/api/api/indices.get_template.js index 6824d30d8..d88d5ce2d 100644 --- a/api/api/indices.get_template.js +++ b/api/api/indices.get_template.js @@ -97,9 +97,7 @@ function buildIndicesGetTemplate (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.get_upgrade.js b/api/api/indices.get_upgrade.js index 7c144538c..115e562ce 100644 --- a/api/api/indices.get_upgrade.js +++ b/api/api/indices.get_upgrade.js @@ -97,9 +97,7 @@ function buildIndicesGetUpgrade (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.open.js b/api/api/indices.open.js index 0a2361e15..ca34197d9 100644 --- a/api/api/indices.open.js +++ b/api/api/indices.open.js @@ -112,9 +112,7 @@ function buildIndicesOpen (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.put_alias.js b/api/api/indices.put_alias.js index fc9f30e41..0377acdfc 100644 --- a/api/api/indices.put_alias.js +++ b/api/api/indices.put_alias.js @@ -112,9 +112,7 @@ function buildIndicesPutAlias (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.put_mapping.js b/api/api/indices.put_mapping.js index fd0cb2420..4cb58c7d4 100644 --- a/api/api/indices.put_mapping.js +++ b/api/api/indices.put_mapping.js @@ -114,9 +114,7 @@ function buildIndicesPutMapping (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.put_settings.js b/api/api/indices.put_settings.js index a8d24ce60..4471c0f49 100644 --- a/api/api/indices.put_settings.js +++ b/api/api/indices.put_settings.js @@ -110,9 +110,7 @@ function buildIndicesPutSettings (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.put_template.js b/api/api/indices.put_template.js index 02d12841a..ad7f126de 100644 --- a/api/api/indices.put_template.js +++ b/api/api/indices.put_template.js @@ -110,9 +110,7 @@ function buildIndicesPutTemplate (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.recovery.js b/api/api/indices.recovery.js index 82215416c..eeb9e1b82 100644 --- a/api/api/indices.recovery.js +++ b/api/api/indices.recovery.js @@ -94,9 +94,7 @@ function buildIndicesRecovery (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.refresh.js b/api/api/indices.refresh.js index c9bee4420..946a086f4 100644 --- a/api/api/indices.refresh.js +++ b/api/api/indices.refresh.js @@ -97,9 +97,7 @@ function buildIndicesRefresh (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.rollover.js b/api/api/indices.rollover.js index 71cc44f2c..abd79472c 100644 --- a/api/api/indices.rollover.js +++ b/api/api/indices.rollover.js @@ -110,9 +110,7 @@ function buildIndicesRollover (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.segments.js b/api/api/indices.segments.js index 1942d3253..d636e4280 100644 --- a/api/api/indices.segments.js +++ b/api/api/indices.segments.js @@ -100,9 +100,7 @@ function buildIndicesSegments (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.shard_stores.js b/api/api/indices.shard_stores.js index b3452cff7..835c211f1 100644 --- a/api/api/indices.shard_stores.js +++ b/api/api/indices.shard_stores.js @@ -100,9 +100,7 @@ function buildIndicesShardStores (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.shrink.js b/api/api/indices.shrink.js index 8f7afbebd..72c6f8a2f 100644 --- a/api/api/indices.shrink.js +++ b/api/api/indices.shrink.js @@ -116,9 +116,7 @@ function buildIndicesShrink (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.split.js b/api/api/indices.split.js index b6362db21..0f282669c 100644 --- a/api/api/indices.split.js +++ b/api/api/indices.split.js @@ -116,9 +116,7 @@ function buildIndicesSplit (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.stats.js b/api/api/indices.stats.js index 5ef5f2590..0effc56cb 100644 --- a/api/api/indices.stats.js +++ b/api/api/indices.stats.js @@ -110,9 +110,7 @@ function buildIndicesStats (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.update_aliases.js b/api/api/indices.update_aliases.js index 23c8a3f1c..be335a46d 100644 --- a/api/api/indices.update_aliases.js +++ b/api/api/indices.update_aliases.js @@ -94,9 +94,7 @@ function buildIndicesUpdateAliases (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.upgrade.js b/api/api/indices.upgrade.js index 5dbd9d62a..b0f4433cb 100644 --- a/api/api/indices.upgrade.js +++ b/api/api/indices.upgrade.js @@ -103,9 +103,7 @@ function buildIndicesUpgrade (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/indices.validate_query.js b/api/api/indices.validate_query.js index eac6cc301..8741b272e 100644 --- a/api/api/indices.validate_query.js +++ b/api/api/indices.validate_query.js @@ -126,9 +126,7 @@ function buildIndicesValidateQuery (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/info.js b/api/api/info.js index adf968cd9..8f276a7a4 100644 --- a/api/api/info.js +++ b/api/api/info.js @@ -87,9 +87,7 @@ function buildInfo (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/ingest.delete_pipeline.js b/api/api/ingest.delete_pipeline.js index 5c09102c7..ad583cf00 100644 --- a/api/api/ingest.delete_pipeline.js +++ b/api/api/ingest.delete_pipeline.js @@ -100,9 +100,7 @@ function buildIngestDeletePipeline (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/ingest.get_pipeline.js b/api/api/ingest.get_pipeline.js index c4ed71d6b..db737e802 100644 --- a/api/api/ingest.get_pipeline.js +++ b/api/api/ingest.get_pipeline.js @@ -91,9 +91,7 @@ function buildIngestGetPipeline (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/ingest.processor_grok.js b/api/api/ingest.processor_grok.js index c94f51b76..a21146a18 100644 --- a/api/api/ingest.processor_grok.js +++ b/api/api/ingest.processor_grok.js @@ -87,9 +87,7 @@ function buildIngestProcessorGrok (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/ingest.put_pipeline.js b/api/api/ingest.put_pipeline.js index e87f3b732..dfe3d69d6 100644 --- a/api/api/ingest.put_pipeline.js +++ b/api/api/ingest.put_pipeline.js @@ -101,9 +101,7 @@ function buildIngestPutPipeline (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/ingest.simulate.js b/api/api/ingest.simulate.js index df95e7b8b..c9adf74ba 100644 --- a/api/api/ingest.simulate.js +++ b/api/api/ingest.simulate.js @@ -92,9 +92,7 @@ function buildIngestSimulate (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/mget.js b/api/api/mget.js index cc6dbe375..590af1638 100644 --- a/api/api/mget.js +++ b/api/api/mget.js @@ -122,9 +122,7 @@ function buildMget (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/msearch.js b/api/api/msearch.js index b8312360a..5fe5de3b6 100644 --- a/api/api/msearch.js +++ b/api/api/msearch.js @@ -110,9 +110,7 @@ function buildMsearch (opts) { bulkBody: params.body, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/msearch_template.js b/api/api/msearch_template.js index 4e6e18ef9..f0ae1ea03 100644 --- a/api/api/msearch_template.js +++ b/api/api/msearch_template.js @@ -107,9 +107,7 @@ function buildMsearchTemplate (opts) { bulkBody: params.body, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/mtermvectors.js b/api/api/mtermvectors.js index 5a9d0d902..11e711f62 100644 --- a/api/api/mtermvectors.js +++ b/api/api/mtermvectors.js @@ -129,9 +129,7 @@ function buildMtermvectors (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/nodes.hot_threads.js b/api/api/nodes.hot_threads.js index e2c9ea3fe..977c2a0de 100644 --- a/api/api/nodes.hot_threads.js +++ b/api/api/nodes.hot_threads.js @@ -108,9 +108,7 @@ function buildNodesHotThreads (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/nodes.info.js b/api/api/nodes.info.js index 414d93a99..786ab8bd5 100644 --- a/api/api/nodes.info.js +++ b/api/api/nodes.info.js @@ -95,9 +95,7 @@ function buildNodesInfo (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/nodes.stats.js b/api/api/nodes.stats.js index 3819d2e62..09a84e2f9 100644 --- a/api/api/nodes.stats.js +++ b/api/api/nodes.stats.js @@ -114,9 +114,7 @@ function buildNodesStats (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/nodes.usage.js b/api/api/nodes.usage.js index 17853295f..352f1ee62 100644 --- a/api/api/nodes.usage.js +++ b/api/api/nodes.usage.js @@ -92,9 +92,7 @@ function buildNodesUsage (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/ping.js b/api/api/ping.js index 8351bf512..5679c5976 100644 --- a/api/api/ping.js +++ b/api/api/ping.js @@ -87,9 +87,7 @@ function buildPing (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/put_script.js b/api/api/put_script.js index 87c4c4464..17a0048c8 100644 --- a/api/api/put_script.js +++ b/api/api/put_script.js @@ -113,9 +113,7 @@ function buildPutScript (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/rank_eval.js b/api/api/rank_eval.js index e54102e62..3c1ac5022 100644 --- a/api/api/rank_eval.js +++ b/api/api/rank_eval.js @@ -98,9 +98,7 @@ function buildRankEval (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/reindex.js b/api/api/reindex.js index 453d7eed2..4a618cfd4 100644 --- a/api/api/reindex.js +++ b/api/api/reindex.js @@ -106,9 +106,7 @@ function buildReindex (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/reindex_rethrottle.js b/api/api/reindex_rethrottle.js index 54d8de9e4..8093467b9 100644 --- a/api/api/reindex_rethrottle.js +++ b/api/api/reindex_rethrottle.js @@ -105,9 +105,7 @@ function buildReindexRethrottle (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/render_search_template.js b/api/api/render_search_template.js index 35faf765a..e0bcd4d4f 100644 --- a/api/api/render_search_template.js +++ b/api/api/render_search_template.js @@ -81,9 +81,7 @@ function buildRenderSearchTemplate (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/scripts_painless_execute.js b/api/api/scripts_painless_execute.js index b3f871e75..fcbfc56a1 100644 --- a/api/api/scripts_painless_execute.js +++ b/api/api/scripts_painless_execute.js @@ -80,9 +80,7 @@ function buildScriptsPainlessExecute (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/scroll.js b/api/api/scroll.js index 32e4c7010..b41c47dc3 100644 --- a/api/api/scroll.js +++ b/api/api/scroll.js @@ -87,9 +87,7 @@ function buildScroll (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/search.js b/api/api/search.js index 8f75d2ad5..706f59387 100644 --- a/api/api/search.js +++ b/api/api/search.js @@ -204,9 +204,7 @@ function buildSearch (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/search_shards.js b/api/api/search_shards.js index bf341c32d..8aab7c88b 100644 --- a/api/api/search_shards.js +++ b/api/api/search_shards.js @@ -106,9 +106,7 @@ function buildSearchShards (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/search_template.js b/api/api/search_template.js index e6d2b1e00..103b736ad 100644 --- a/api/api/search_template.js +++ b/api/api/search_template.js @@ -128,9 +128,7 @@ function buildSearchTemplate (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/snapshot.create.js b/api/api/snapshot.create.js index ab12c54cf..5508bec03 100644 --- a/api/api/snapshot.create.js +++ b/api/api/snapshot.create.js @@ -110,9 +110,7 @@ function buildSnapshotCreate (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/snapshot.create_repository.js b/api/api/snapshot.create_repository.js index 52012fb38..b18ad893a 100644 --- a/api/api/snapshot.create_repository.js +++ b/api/api/snapshot.create_repository.js @@ -104,9 +104,7 @@ function buildSnapshotCreateRepository (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/snapshot.delete.js b/api/api/snapshot.delete.js index ca5060144..f9d1064ca 100644 --- a/api/api/snapshot.delete.js +++ b/api/api/snapshot.delete.js @@ -112,9 +112,7 @@ function buildSnapshotDelete (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/snapshot.delete_repository.js b/api/api/snapshot.delete_repository.js index 1291f1767..a1b025aa3 100644 --- a/api/api/snapshot.delete_repository.js +++ b/api/api/snapshot.delete_repository.js @@ -100,9 +100,7 @@ function buildSnapshotDeleteRepository (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/snapshot.get.js b/api/api/snapshot.get.js index 8ffe9ab50..694410fab 100644 --- a/api/api/snapshot.get.js +++ b/api/api/snapshot.get.js @@ -118,9 +118,7 @@ function buildSnapshotGet (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/snapshot.get_repository.js b/api/api/snapshot.get_repository.js index fa83c11f4..12571520a 100644 --- a/api/api/snapshot.get_repository.js +++ b/api/api/snapshot.get_repository.js @@ -94,9 +94,7 @@ function buildSnapshotGetRepository (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/snapshot.restore.js b/api/api/snapshot.restore.js index 92059a1d7..5a947a1b6 100644 --- a/api/api/snapshot.restore.js +++ b/api/api/snapshot.restore.js @@ -110,9 +110,7 @@ function buildSnapshotRestore (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/snapshot.status.js b/api/api/snapshot.status.js index 7d65a5a5c..456e32f5c 100644 --- a/api/api/snapshot.status.js +++ b/api/api/snapshot.status.js @@ -103,9 +103,7 @@ function buildSnapshotStatus (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/snapshot.verify_repository.js b/api/api/snapshot.verify_repository.js index 095eb0bac..52d302c5c 100644 --- a/api/api/snapshot.verify_repository.js +++ b/api/api/snapshot.verify_repository.js @@ -100,9 +100,7 @@ function buildSnapshotVerifyRepository (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/tasks.cancel.js b/api/api/tasks.cancel.js index f403dfdaf..13d4f65d6 100644 --- a/api/api/tasks.cancel.js +++ b/api/api/tasks.cancel.js @@ -97,9 +97,7 @@ function buildTasksCancel (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/tasks.get.js b/api/api/tasks.get.js index 38951667c..1a566b2f4 100644 --- a/api/api/tasks.get.js +++ b/api/api/tasks.get.js @@ -100,9 +100,7 @@ function buildTasksGet (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/tasks.list.js b/api/api/tasks.list.js index 68e38707f..171bd139c 100644 --- a/api/api/tasks.list.js +++ b/api/api/tasks.list.js @@ -108,9 +108,7 @@ function buildTasksList (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/termvectors.js b/api/api/termvectors.js index af07ddd34..378326516 100644 --- a/api/api/termvectors.js +++ b/api/api/termvectors.js @@ -146,9 +146,7 @@ function buildTermvectors (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/update.js b/api/api/update.js index b0140d158..8ff23b6d5 100644 --- a/api/api/update.js +++ b/api/api/update.js @@ -161,9 +161,7 @@ function buildUpdate (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/update_by_query.js b/api/api/update_by_query.js index 56c53fdce..5cd1ae79f 100644 --- a/api/api/update_by_query.js +++ b/api/api/update_by_query.js @@ -200,9 +200,7 @@ function buildUpdateByQuery (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.graph.explore.js b/api/api/xpack.graph.explore.js index b8d593eb9..ec3c90010 100644 --- a/api/api/xpack.graph.explore.js +++ b/api/api/xpack.graph.explore.js @@ -86,9 +86,7 @@ function buildXpackGraphExplore (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.info.js b/api/api/xpack.info.js index a70a56199..aabfd6dbd 100644 --- a/api/api/xpack.info.js +++ b/api/api/xpack.info.js @@ -80,9 +80,7 @@ function buildXpackInfo (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.license.delete.js b/api/api/xpack.license.delete.js index 426fed0da..622fc7d85 100644 --- a/api/api/xpack.license.delete.js +++ b/api/api/xpack.license.delete.js @@ -79,9 +79,7 @@ function buildXpackLicenseDelete (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.license.get.js b/api/api/xpack.license.get.js index d0fd1956e..161ebcc02 100644 --- a/api/api/xpack.license.get.js +++ b/api/api/xpack.license.get.js @@ -80,9 +80,7 @@ function buildXpackLicenseGet (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.license.get_basic_status.js b/api/api/xpack.license.get_basic_status.js index 815d66869..92b117b74 100644 --- a/api/api/xpack.license.get_basic_status.js +++ b/api/api/xpack.license.get_basic_status.js @@ -79,9 +79,7 @@ function buildXpackLicenseGetBasicStatus (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.license.get_trial_status.js b/api/api/xpack.license.get_trial_status.js index 107541302..277bfb74b 100644 --- a/api/api/xpack.license.get_trial_status.js +++ b/api/api/xpack.license.get_trial_status.js @@ -79,9 +79,7 @@ function buildXpackLicenseGetTrialStatus (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.license.post.js b/api/api/xpack.license.post.js index 7515db686..0902f3611 100644 --- a/api/api/xpack.license.post.js +++ b/api/api/xpack.license.post.js @@ -73,9 +73,7 @@ function buildXpackLicensePost (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.license.post_start_basic.js b/api/api/xpack.license.post_start_basic.js index 969690525..3212e99cf 100644 --- a/api/api/xpack.license.post_start_basic.js +++ b/api/api/xpack.license.post_start_basic.js @@ -80,9 +80,7 @@ function buildXpackLicensePostStartBasic (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.license.post_start_trial.js b/api/api/xpack.license.post_start_trial.js index 43ae9b6f3..66f75ec9a 100644 --- a/api/api/xpack.license.post_start_trial.js +++ b/api/api/xpack.license.post_start_trial.js @@ -83,9 +83,7 @@ function buildXpackLicensePostStartTrial (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.migration.deprecations.js b/api/api/xpack.migration.deprecations.js index a507a9bd7..927ef5432 100644 --- a/api/api/xpack.migration.deprecations.js +++ b/api/api/xpack.migration.deprecations.js @@ -80,9 +80,7 @@ function buildXpackMigrationDeprecations (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.migration.get_assistance.js b/api/api/xpack.migration.get_assistance.js index be8fddaac..abe6ed6d5 100644 --- a/api/api/xpack.migration.get_assistance.js +++ b/api/api/xpack.migration.get_assistance.js @@ -79,9 +79,7 @@ function buildXpackMigrationGetAssistance (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.migration.upgrade.js b/api/api/xpack.migration.upgrade.js index 555395a99..57eb6b480 100644 --- a/api/api/xpack.migration.upgrade.js +++ b/api/api/xpack.migration.upgrade.js @@ -81,9 +81,7 @@ function buildXpackMigrationUpgrade (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.close_job.js b/api/api/xpack.ml.close_job.js index ea7393029..54e2a41b6 100644 --- a/api/api/xpack.ml.close_job.js +++ b/api/api/xpack.ml.close_job.js @@ -87,9 +87,7 @@ function buildXpackMlCloseJob (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.delete_calendar.js b/api/api/xpack.ml.delete_calendar.js index 56aad8467..047a4047d 100644 --- a/api/api/xpack.ml.delete_calendar.js +++ b/api/api/xpack.ml.delete_calendar.js @@ -86,9 +86,7 @@ function buildXpackMlDeleteCalendar (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.delete_calendar_event.js b/api/api/xpack.ml.delete_calendar_event.js index 32e06da23..5f519b3f3 100644 --- a/api/api/xpack.ml.delete_calendar_event.js +++ b/api/api/xpack.ml.delete_calendar_event.js @@ -101,9 +101,7 @@ function buildXpackMlDeleteCalendarEvent (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.delete_calendar_job.js b/api/api/xpack.ml.delete_calendar_job.js index 635366ec2..312c4ab3f 100644 --- a/api/api/xpack.ml.delete_calendar_job.js +++ b/api/api/xpack.ml.delete_calendar_job.js @@ -101,9 +101,7 @@ function buildXpackMlDeleteCalendarJob (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.delete_datafeed.js b/api/api/xpack.ml.delete_datafeed.js index 1e9b79b23..0887d5709 100644 --- a/api/api/xpack.ml.delete_datafeed.js +++ b/api/api/xpack.ml.delete_datafeed.js @@ -87,9 +87,7 @@ function buildXpackMlDeleteDatafeed (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.delete_expired_data.js b/api/api/xpack.ml.delete_expired_data.js index 245ab4209..ecb653c55 100644 --- a/api/api/xpack.ml.delete_expired_data.js +++ b/api/api/xpack.ml.delete_expired_data.js @@ -79,9 +79,7 @@ function buildXpackMlDeleteExpiredData (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.delete_filter.js b/api/api/xpack.ml.delete_filter.js index 5bb5c6bfc..c448e6555 100644 --- a/api/api/xpack.ml.delete_filter.js +++ b/api/api/xpack.ml.delete_filter.js @@ -86,9 +86,7 @@ function buildXpackMlDeleteFilter (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.delete_job.js b/api/api/xpack.ml.delete_job.js index 43acbbcf1..09fec33d3 100644 --- a/api/api/xpack.ml.delete_job.js +++ b/api/api/xpack.ml.delete_job.js @@ -87,9 +87,7 @@ function buildXpackMlDeleteJob (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.delete_model_snapshot.js b/api/api/xpack.ml.delete_model_snapshot.js index 668838173..616491dc7 100644 --- a/api/api/xpack.ml.delete_model_snapshot.js +++ b/api/api/xpack.ml.delete_model_snapshot.js @@ -101,9 +101,7 @@ function buildXpackMlDeleteModelSnapshot (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.flush_job.js b/api/api/xpack.ml.flush_job.js index a44363b8b..692e0b696 100644 --- a/api/api/xpack.ml.flush_job.js +++ b/api/api/xpack.ml.flush_job.js @@ -94,9 +94,7 @@ function buildXpackMlFlushJob (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.forecast.js b/api/api/xpack.ml.forecast.js index d30400f26..60b7c4785 100644 --- a/api/api/xpack.ml.forecast.js +++ b/api/api/xpack.ml.forecast.js @@ -90,9 +90,7 @@ function buildXpackMlForecast (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.get_buckets.js b/api/api/xpack.ml.get_buckets.js index f9437281b..49b3c1111 100644 --- a/api/api/xpack.ml.get_buckets.js +++ b/api/api/xpack.ml.get_buckets.js @@ -115,9 +115,7 @@ function buildXpackMlGetBuckets (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.get_calendar_events.js b/api/api/xpack.ml.get_calendar_events.js index 107de9318..f0d15cef7 100644 --- a/api/api/xpack.ml.get_calendar_events.js +++ b/api/api/xpack.ml.get_calendar_events.js @@ -99,9 +99,7 @@ function buildXpackMlGetCalendarEvents (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.get_calendars.js b/api/api/xpack.ml.get_calendars.js index c856066de..30f8c2c9f 100644 --- a/api/api/xpack.ml.get_calendars.js +++ b/api/api/xpack.ml.get_calendars.js @@ -84,9 +84,7 @@ function buildXpackMlGetCalendars (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.get_categories.js b/api/api/xpack.ml.get_categories.js index 1cabd11c0..c0f09458f 100644 --- a/api/api/xpack.ml.get_categories.js +++ b/api/api/xpack.ml.get_categories.js @@ -88,9 +88,7 @@ function buildXpackMlGetCategories (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.get_datafeed_stats.js b/api/api/xpack.ml.get_datafeed_stats.js index 645fcba71..36df79e43 100644 --- a/api/api/xpack.ml.get_datafeed_stats.js +++ b/api/api/xpack.ml.get_datafeed_stats.js @@ -81,9 +81,7 @@ function buildXpackMlGetDatafeedStats (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.get_datafeeds.js b/api/api/xpack.ml.get_datafeeds.js index d491d3191..15b54754c 100644 --- a/api/api/xpack.ml.get_datafeeds.js +++ b/api/api/xpack.ml.get_datafeeds.js @@ -81,9 +81,7 @@ function buildXpackMlGetDatafeeds (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.get_filters.js b/api/api/xpack.ml.get_filters.js index f1ff13d1d..11f3bb0bb 100644 --- a/api/api/xpack.ml.get_filters.js +++ b/api/api/xpack.ml.get_filters.js @@ -84,9 +84,7 @@ function buildXpackMlGetFilters (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.get_influencers.js b/api/api/xpack.ml.get_influencers.js index 4dc4c7b89..c88357dfd 100644 --- a/api/api/xpack.ml.get_influencers.js +++ b/api/api/xpack.ml.get_influencers.js @@ -103,9 +103,7 @@ function buildXpackMlGetInfluencers (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.get_job_stats.js b/api/api/xpack.ml.get_job_stats.js index 7ee5f78c0..93a13d7eb 100644 --- a/api/api/xpack.ml.get_job_stats.js +++ b/api/api/xpack.ml.get_job_stats.js @@ -81,9 +81,7 @@ function buildXpackMlGetJobStats (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.get_jobs.js b/api/api/xpack.ml.get_jobs.js index bf4abf901..eec7b4580 100644 --- a/api/api/xpack.ml.get_jobs.js +++ b/api/api/xpack.ml.get_jobs.js @@ -81,9 +81,7 @@ function buildXpackMlGetJobs (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.get_model_snapshots.js b/api/api/xpack.ml.get_model_snapshots.js index 345daf48f..cd0d55a10 100644 --- a/api/api/xpack.ml.get_model_snapshots.js +++ b/api/api/xpack.ml.get_model_snapshots.js @@ -106,9 +106,7 @@ function buildXpackMlGetModelSnapshots (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.get_overall_buckets.js b/api/api/xpack.ml.get_overall_buckets.js index 20a13e767..5dcb98d45 100644 --- a/api/api/xpack.ml.get_overall_buckets.js +++ b/api/api/xpack.ml.get_overall_buckets.js @@ -100,9 +100,7 @@ function buildXpackMlGetOverallBuckets (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.get_records.js b/api/api/xpack.ml.get_records.js index 4717cbc9c..4128ea678 100644 --- a/api/api/xpack.ml.get_records.js +++ b/api/api/xpack.ml.get_records.js @@ -103,9 +103,7 @@ function buildXpackMlGetRecords (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.info.js b/api/api/xpack.ml.info.js index 6691fbb1f..e25d043d7 100644 --- a/api/api/xpack.ml.info.js +++ b/api/api/xpack.ml.info.js @@ -71,9 +71,7 @@ function buildXpackMlInfo (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.open_job.js b/api/api/xpack.ml.open_job.js index 19a1febcb..f1bfa8404 100644 --- a/api/api/xpack.ml.open_job.js +++ b/api/api/xpack.ml.open_job.js @@ -88,9 +88,7 @@ function buildXpackMlOpenJob (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.post_calendar_events.js b/api/api/xpack.ml.post_calendar_events.js index c9868a8e2..1f5f1b9e4 100644 --- a/api/api/xpack.ml.post_calendar_events.js +++ b/api/api/xpack.ml.post_calendar_events.js @@ -87,9 +87,7 @@ function buildXpackMlPostCalendarEvents (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.post_data.js b/api/api/xpack.ml.post_data.js index f5a0fe3b6..a7cb0f074 100644 --- a/api/api/xpack.ml.post_data.js +++ b/api/api/xpack.ml.post_data.js @@ -91,9 +91,7 @@ function buildXpackMlPostData (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.preview_datafeed.js b/api/api/xpack.ml.preview_datafeed.js index 050790b32..57a9a174b 100644 --- a/api/api/xpack.ml.preview_datafeed.js +++ b/api/api/xpack.ml.preview_datafeed.js @@ -86,9 +86,7 @@ function buildXpackMlPreviewDatafeed (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.put_calendar.js b/api/api/xpack.ml.put_calendar.js index b4299a313..6022adea8 100644 --- a/api/api/xpack.ml.put_calendar.js +++ b/api/api/xpack.ml.put_calendar.js @@ -81,9 +81,7 @@ function buildXpackMlPutCalendar (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.put_calendar_job.js b/api/api/xpack.ml.put_calendar_job.js index 3345d2e02..d224e14c6 100644 --- a/api/api/xpack.ml.put_calendar_job.js +++ b/api/api/xpack.ml.put_calendar_job.js @@ -101,9 +101,7 @@ function buildXpackMlPutCalendarJob (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.put_datafeed.js b/api/api/xpack.ml.put_datafeed.js index 69b66d351..11110736f 100644 --- a/api/api/xpack.ml.put_datafeed.js +++ b/api/api/xpack.ml.put_datafeed.js @@ -87,9 +87,7 @@ function buildXpackMlPutDatafeed (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.put_filter.js b/api/api/xpack.ml.put_filter.js index 20e0788c1..3fb862d56 100644 --- a/api/api/xpack.ml.put_filter.js +++ b/api/api/xpack.ml.put_filter.js @@ -87,9 +87,7 @@ function buildXpackMlPutFilter (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.put_job.js b/api/api/xpack.ml.put_job.js index 80753e7cc..a33ef0785 100644 --- a/api/api/xpack.ml.put_job.js +++ b/api/api/xpack.ml.put_job.js @@ -87,9 +87,7 @@ function buildXpackMlPutJob (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.revert_model_snapshot.js b/api/api/xpack.ml.revert_model_snapshot.js index a4bd7cabc..8cc7a50d6 100644 --- a/api/api/xpack.ml.revert_model_snapshot.js +++ b/api/api/xpack.ml.revert_model_snapshot.js @@ -97,9 +97,7 @@ function buildXpackMlRevertModelSnapshot (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.start_datafeed.js b/api/api/xpack.ml.start_datafeed.js index 10f4d488d..6067f8cdb 100644 --- a/api/api/xpack.ml.start_datafeed.js +++ b/api/api/xpack.ml.start_datafeed.js @@ -88,9 +88,7 @@ function buildXpackMlStartDatafeed (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.stop_datafeed.js b/api/api/xpack.ml.stop_datafeed.js index 4381a8b6a..d97f93c83 100644 --- a/api/api/xpack.ml.stop_datafeed.js +++ b/api/api/xpack.ml.stop_datafeed.js @@ -87,9 +87,7 @@ function buildXpackMlStopDatafeed (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.update_datafeed.js b/api/api/xpack.ml.update_datafeed.js index f3d8d424b..dbbceba53 100644 --- a/api/api/xpack.ml.update_datafeed.js +++ b/api/api/xpack.ml.update_datafeed.js @@ -87,9 +87,7 @@ function buildXpackMlUpdateDatafeed (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.update_filter.js b/api/api/xpack.ml.update_filter.js index 8ae999c72..4555df771 100644 --- a/api/api/xpack.ml.update_filter.js +++ b/api/api/xpack.ml.update_filter.js @@ -87,9 +87,7 @@ function buildXpackMlUpdateFilter (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.update_job.js b/api/api/xpack.ml.update_job.js index 6e765d087..86bb0ef7b 100644 --- a/api/api/xpack.ml.update_job.js +++ b/api/api/xpack.ml.update_job.js @@ -87,9 +87,7 @@ function buildXpackMlUpdateJob (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.update_model_snapshot.js b/api/api/xpack.ml.update_model_snapshot.js index 236c9e661..2bbffe196 100644 --- a/api/api/xpack.ml.update_model_snapshot.js +++ b/api/api/xpack.ml.update_model_snapshot.js @@ -102,9 +102,7 @@ function buildXpackMlUpdateModelSnapshot (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.validate.js b/api/api/xpack.ml.validate.js index edcd81e14..f192dbb67 100644 --- a/api/api/xpack.ml.validate.js +++ b/api/api/xpack.ml.validate.js @@ -80,9 +80,7 @@ function buildXpackMlValidate (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ml.validate_detector.js b/api/api/xpack.ml.validate_detector.js index 312374e95..c0f1e3f74 100644 --- a/api/api/xpack.ml.validate_detector.js +++ b/api/api/xpack.ml.validate_detector.js @@ -80,9 +80,7 @@ function buildXpackMlValidateDetector (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.monitoring.bulk.js b/api/api/xpack.monitoring.bulk.js index 543f9e2bc..874fd3e33 100644 --- a/api/api/xpack.monitoring.bulk.js +++ b/api/api/xpack.monitoring.bulk.js @@ -88,9 +88,7 @@ function buildXpackMonitoringBulk (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.rollup.delete_job.js b/api/api/xpack.rollup.delete_job.js index 0bac5a235..9d69aa0d6 100644 --- a/api/api/xpack.rollup.delete_job.js +++ b/api/api/xpack.rollup.delete_job.js @@ -80,9 +80,7 @@ function buildXpackRollupDeleteJob (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.rollup.get_jobs.js b/api/api/xpack.rollup.get_jobs.js index 80ee35fd7..3eed24003 100644 --- a/api/api/xpack.rollup.get_jobs.js +++ b/api/api/xpack.rollup.get_jobs.js @@ -72,9 +72,7 @@ function buildXpackRollupGetJobs (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.rollup.get_rollup_caps.js b/api/api/xpack.rollup.get_rollup_caps.js index 3aa0130b5..c198f852d 100644 --- a/api/api/xpack.rollup.get_rollup_caps.js +++ b/api/api/xpack.rollup.get_rollup_caps.js @@ -72,9 +72,7 @@ function buildXpackRollupGetRollupCaps (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.rollup.get_rollup_index_caps.js b/api/api/xpack.rollup.get_rollup_index_caps.js index 20dda135c..c1ddd2ad4 100644 --- a/api/api/xpack.rollup.get_rollup_index_caps.js +++ b/api/api/xpack.rollup.get_rollup_index_caps.js @@ -80,9 +80,7 @@ function buildXpackRollupGetRollupIndexCaps (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.rollup.put_job.js b/api/api/xpack.rollup.put_job.js index 2cb46a5bd..80e5d8cb7 100644 --- a/api/api/xpack.rollup.put_job.js +++ b/api/api/xpack.rollup.put_job.js @@ -87,9 +87,7 @@ function buildXpackRollupPutJob (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.rollup.rollup_search.js b/api/api/xpack.rollup.rollup_search.js index 2cb90065f..b5dfbeafb 100644 --- a/api/api/xpack.rollup.rollup_search.js +++ b/api/api/xpack.rollup.rollup_search.js @@ -98,9 +98,7 @@ function buildXpackRollupRollupSearch (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.rollup.start_job.js b/api/api/xpack.rollup.start_job.js index b513b7dce..f9e230d2e 100644 --- a/api/api/xpack.rollup.start_job.js +++ b/api/api/xpack.rollup.start_job.js @@ -80,9 +80,7 @@ function buildXpackRollupStartJob (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.rollup.stop_job.js b/api/api/xpack.rollup.stop_job.js index 0a1e4340a..9a0aa470c 100644 --- a/api/api/xpack.rollup.stop_job.js +++ b/api/api/xpack.rollup.stop_job.js @@ -80,9 +80,7 @@ function buildXpackRollupStopJob (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.security.authenticate.js b/api/api/xpack.security.authenticate.js index 5355caab5..b1564e6b9 100644 --- a/api/api/xpack.security.authenticate.js +++ b/api/api/xpack.security.authenticate.js @@ -79,9 +79,7 @@ function buildXpackSecurityAuthenticate (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.security.change_password.js b/api/api/xpack.security.change_password.js index 69e7fb40e..b0853aa9a 100644 --- a/api/api/xpack.security.change_password.js +++ b/api/api/xpack.security.change_password.js @@ -82,9 +82,7 @@ function buildXpackSecurityChangePassword (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.security.clear_cached_realms.js b/api/api/xpack.security.clear_cached_realms.js index 8b3821303..27b96dad3 100644 --- a/api/api/xpack.security.clear_cached_realms.js +++ b/api/api/xpack.security.clear_cached_realms.js @@ -87,9 +87,7 @@ function buildXpackSecurityClearCachedRealms (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.security.clear_cached_roles.js b/api/api/xpack.security.clear_cached_roles.js index f9058cb6b..e0d2c87eb 100644 --- a/api/api/xpack.security.clear_cached_roles.js +++ b/api/api/xpack.security.clear_cached_roles.js @@ -86,9 +86,7 @@ function buildXpackSecurityClearCachedRoles (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.security.delete_privileges.js b/api/api/xpack.security.delete_privileges.js index c8320fde7..4333e87d2 100644 --- a/api/api/xpack.security.delete_privileges.js +++ b/api/api/xpack.security.delete_privileges.js @@ -102,9 +102,7 @@ function buildXpackSecurityDeletePrivileges (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.security.delete_role.js b/api/api/xpack.security.delete_role.js index c24732e11..8967a3ebc 100644 --- a/api/api/xpack.security.delete_role.js +++ b/api/api/xpack.security.delete_role.js @@ -87,9 +87,7 @@ function buildXpackSecurityDeleteRole (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.security.delete_role_mapping.js b/api/api/xpack.security.delete_role_mapping.js index d59fbdfe8..00a8f0164 100644 --- a/api/api/xpack.security.delete_role_mapping.js +++ b/api/api/xpack.security.delete_role_mapping.js @@ -87,9 +87,7 @@ function buildXpackSecurityDeleteRoleMapping (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.security.delete_user.js b/api/api/xpack.security.delete_user.js index f985efe06..d84670d64 100644 --- a/api/api/xpack.security.delete_user.js +++ b/api/api/xpack.security.delete_user.js @@ -87,9 +87,7 @@ function buildXpackSecurityDeleteUser (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.security.disable_user.js b/api/api/xpack.security.disable_user.js index 6d6a7c0ca..3c382d912 100644 --- a/api/api/xpack.security.disable_user.js +++ b/api/api/xpack.security.disable_user.js @@ -81,9 +81,7 @@ function buildXpackSecurityDisableUser (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.security.enable_user.js b/api/api/xpack.security.enable_user.js index ce96b8ae8..ed4518937 100644 --- a/api/api/xpack.security.enable_user.js +++ b/api/api/xpack.security.enable_user.js @@ -81,9 +81,7 @@ function buildXpackSecurityEnableUser (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.security.get_privileges.js b/api/api/xpack.security.get_privileges.js index 0bb42c912..4ba715bac 100644 --- a/api/api/xpack.security.get_privileges.js +++ b/api/api/xpack.security.get_privileges.js @@ -89,9 +89,7 @@ function buildXpackSecurityGetPrivileges (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.security.get_role.js b/api/api/xpack.security.get_role.js index 52748befd..85a75abc5 100644 --- a/api/api/xpack.security.get_role.js +++ b/api/api/xpack.security.get_role.js @@ -80,9 +80,7 @@ function buildXpackSecurityGetRole (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.security.get_role_mapping.js b/api/api/xpack.security.get_role_mapping.js index cf007ca38..0cceb6b1a 100644 --- a/api/api/xpack.security.get_role_mapping.js +++ b/api/api/xpack.security.get_role_mapping.js @@ -80,9 +80,7 @@ function buildXpackSecurityGetRoleMapping (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.security.get_token.js b/api/api/xpack.security.get_token.js index 26d25904f..2f8877b56 100644 --- a/api/api/xpack.security.get_token.js +++ b/api/api/xpack.security.get_token.js @@ -80,9 +80,7 @@ function buildXpackSecurityGetToken (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.security.get_user.js b/api/api/xpack.security.get_user.js index 938c3502a..645500eeb 100644 --- a/api/api/xpack.security.get_user.js +++ b/api/api/xpack.security.get_user.js @@ -80,9 +80,7 @@ function buildXpackSecurityGetUser (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.security.has_privileges.js b/api/api/xpack.security.has_privileges.js index 7c2b046d5..d888bb1b0 100644 --- a/api/api/xpack.security.has_privileges.js +++ b/api/api/xpack.security.has_privileges.js @@ -81,9 +81,7 @@ function buildXpackSecurityHasPrivileges (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.security.invalidate_token.js b/api/api/xpack.security.invalidate_token.js index a6e7304ea..e5b3f6fe6 100644 --- a/api/api/xpack.security.invalidate_token.js +++ b/api/api/xpack.security.invalidate_token.js @@ -80,9 +80,7 @@ function buildXpackSecurityInvalidateToken (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.security.put_privileges.js b/api/api/xpack.security.put_privileges.js index 210a15f2b..0b1c6637b 100644 --- a/api/api/xpack.security.put_privileges.js +++ b/api/api/xpack.security.put_privileges.js @@ -81,9 +81,7 @@ function buildXpackSecurityPutPrivileges (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.security.put_role.js b/api/api/xpack.security.put_role.js index 045e7dbc4..ddd30ab09 100644 --- a/api/api/xpack.security.put_role.js +++ b/api/api/xpack.security.put_role.js @@ -88,9 +88,7 @@ function buildXpackSecurityPutRole (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.security.put_role_mapping.js b/api/api/xpack.security.put_role_mapping.js index d0a0c42bf..57ec1a6f4 100644 --- a/api/api/xpack.security.put_role_mapping.js +++ b/api/api/xpack.security.put_role_mapping.js @@ -88,9 +88,7 @@ function buildXpackSecurityPutRoleMapping (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.security.put_user.js b/api/api/xpack.security.put_user.js index 466ebd4e7..0ad0a7031 100644 --- a/api/api/xpack.security.put_user.js +++ b/api/api/xpack.security.put_user.js @@ -88,9 +88,7 @@ function buildXpackSecurityPutUser (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.sql.clear_cursor.js b/api/api/xpack.sql.clear_cursor.js index a93a52d99..69ae7dbdb 100644 --- a/api/api/xpack.sql.clear_cursor.js +++ b/api/api/xpack.sql.clear_cursor.js @@ -80,9 +80,7 @@ function buildXpackSqlClearCursor (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.sql.query.js b/api/api/xpack.sql.query.js index 917a341e7..1397aaa28 100644 --- a/api/api/xpack.sql.query.js +++ b/api/api/xpack.sql.query.js @@ -81,9 +81,7 @@ function buildXpackSqlQuery (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.sql.translate.js b/api/api/xpack.sql.translate.js index bc4c8929d..74fc9f25a 100644 --- a/api/api/xpack.sql.translate.js +++ b/api/api/xpack.sql.translate.js @@ -80,9 +80,7 @@ function buildXpackSqlTranslate (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.ssl.certificates.js b/api/api/xpack.ssl.certificates.js index 6f588cc1f..f7a2e25ef 100644 --- a/api/api/xpack.ssl.certificates.js +++ b/api/api/xpack.ssl.certificates.js @@ -79,9 +79,7 @@ function buildXpackSslCertificates (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.usage.js b/api/api/xpack.usage.js index 2b989e752..c7c61d359 100644 --- a/api/api/xpack.usage.js +++ b/api/api/xpack.usage.js @@ -80,9 +80,7 @@ function buildXpackUsage (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.watcher.ack_watch.js b/api/api/xpack.watcher.ack_watch.js index 6bbb92a74..afd799396 100644 --- a/api/api/xpack.watcher.ack_watch.js +++ b/api/api/xpack.watcher.ack_watch.js @@ -96,9 +96,7 @@ function buildXpackWatcherAckWatch (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.watcher.activate_watch.js b/api/api/xpack.watcher.activate_watch.js index 2669b8c39..f972b5c0a 100644 --- a/api/api/xpack.watcher.activate_watch.js +++ b/api/api/xpack.watcher.activate_watch.js @@ -87,9 +87,7 @@ function buildXpackWatcherActivateWatch (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.watcher.deactivate_watch.js b/api/api/xpack.watcher.deactivate_watch.js index 4e48a6ac5..b51feb1c1 100644 --- a/api/api/xpack.watcher.deactivate_watch.js +++ b/api/api/xpack.watcher.deactivate_watch.js @@ -87,9 +87,7 @@ function buildXpackWatcherDeactivateWatch (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.watcher.delete_watch.js b/api/api/xpack.watcher.delete_watch.js index 25a83f816..2215270e2 100644 --- a/api/api/xpack.watcher.delete_watch.js +++ b/api/api/xpack.watcher.delete_watch.js @@ -87,9 +87,7 @@ function buildXpackWatcherDeleteWatch (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.watcher.execute_watch.js b/api/api/xpack.watcher.execute_watch.js index 4fddc77b8..092ae039e 100644 --- a/api/api/xpack.watcher.execute_watch.js +++ b/api/api/xpack.watcher.execute_watch.js @@ -74,9 +74,7 @@ function buildXpackWatcherExecuteWatch (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.watcher.get_watch.js b/api/api/xpack.watcher.get_watch.js index 7afda8433..13a950765 100644 --- a/api/api/xpack.watcher.get_watch.js +++ b/api/api/xpack.watcher.get_watch.js @@ -86,9 +86,7 @@ function buildXpackWatcherGetWatch (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.watcher.put_watch.js b/api/api/xpack.watcher.put_watch.js index 29d33296a..63d0dc939 100644 --- a/api/api/xpack.watcher.put_watch.js +++ b/api/api/xpack.watcher.put_watch.js @@ -88,9 +88,7 @@ function buildXpackWatcherPutWatch (opts) { body: params.body || '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.watcher.restart.js b/api/api/xpack.watcher.restart.js index f89aaf2ea..4b3730710 100644 --- a/api/api/xpack.watcher.restart.js +++ b/api/api/xpack.watcher.restart.js @@ -79,9 +79,7 @@ function buildXpackWatcherRestart (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.watcher.start.js b/api/api/xpack.watcher.start.js index 2169f1149..aa81b5af0 100644 --- a/api/api/xpack.watcher.start.js +++ b/api/api/xpack.watcher.start.js @@ -79,9 +79,7 @@ function buildXpackWatcherStart (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.watcher.stats.js b/api/api/xpack.watcher.stats.js index f5b53ca03..37d4366b3 100644 --- a/api/api/xpack.watcher.stats.js +++ b/api/api/xpack.watcher.stats.js @@ -84,9 +84,7 @@ function buildXpackWatcherStats (opts) { body: null, headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) diff --git a/api/api/xpack.watcher.stop.js b/api/api/xpack.watcher.stop.js index 22f5d582f..a712ad342 100644 --- a/api/api/xpack.watcher.stop.js +++ b/api/api/xpack.watcher.stop.js @@ -79,9 +79,7 @@ function buildXpackWatcherStop (opts) { body: '', headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) From e15546541e509dfd241cbfa0e4b1577c95e6c91e Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 15 Nov 2018 17:48:10 +0100 Subject: [PATCH 042/172] Updated scripts --- scripts/utils/generate.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/utils/generate.js b/scripts/utils/generate.js index a6d09ad3f..e3be22b72 100644 --- a/scripts/utils/generate.js +++ b/scripts/utils/generate.js @@ -134,9 +134,7 @@ function generate (spec, common) { ${genBody(api, methods, spec[api].body)} headers: params.headers || null, ignore, - requestTimeout: params.requestTimeout || null, - agent: null, - url: '' + requestTimeout: params.requestTimeout || null } return makeRequest(request, callback) From 11b0d5075127433d13b8975683bbcebc6b00ccfd Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 15 Nov 2018 17:50:56 +0100 Subject: [PATCH 043/172] WIP: initial prototype - Added asStream option - Better handling of request object --- lib/Connection.js | 14 ++++++++++---- lib/Transport.js | 10 +++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/Connection.js b/lib/Connection.js index bb17190b6..0fe0b0997 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -11,6 +11,7 @@ class Connection { constructor (opts = {}) { this.url = opts.url this.ssl = opts.ssl || null + // TODO: clean user:password from id this.id = opts.id || opts.url.href this.headers = opts.headers || null this.deadCount = 0 @@ -25,7 +26,7 @@ class Connection { keepAliveMsecs: 1000, maxSockets: Infinity, maxFreeSockets: 256 - }, opts.agent || opts.agent) + }, opts.agent) this._agent = this.url.protocol === 'http:' ? new http.Agent(agentOptions) : new https.Agent(Object.assign({}, agentOptions, this.ssl)) @@ -38,7 +39,6 @@ class Connection { request (params, callback) { this._openRequests++ var ended = false - params.agent = this._agent debug('Starting a new request', params) const request = this.makeRequest(this.buildRequestObject(params)) @@ -49,7 +49,12 @@ class Connection { if (ended === false) { ended = true this._openRequests-- - callback(null, decompressResponse(response)) + + if (params.asStream === true) { + callback(null, response) + } else { + callback(null, decompressResponse(response)) + } } }) @@ -131,7 +136,8 @@ class Connection { headers: this.headers, auth: !!url.username === true || !!url.password === true ? `${url.username}:${url.password}` - : undefined + : undefined, + agent: this._agent } const paramsKeys = Object.keys(params) diff --git a/lib/Transport.js b/lib/Transport.js index e957e94dc..c37048ed0 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -80,7 +80,8 @@ class Transport { // handles request timeout params.timeout = toMs(params.requestTimeout || this.requestTimeout) - this.emit('request', params) + // TODO: expose nicely the node metadata (also in response an error) + this.emit('request', params, connection) // perform the actual http request const request = connection.request(params, (err, response) => { @@ -116,10 +117,9 @@ class Transport { result.warnings = headers['warning'].split(/(?!\B"[^"]*),(?![^"]*"\B)/) } - // TODO: expose `asStream` option for returning the - // body already parsed? - if (params.asHttpResponse === true) { - callback(null, response) + if (params.asStream === true) { + result.body = response + callback(null, result) return } From bd5ba19e17942d1ce012436d786b32f8d9739a0e Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 15 Nov 2018 17:53:54 +0100 Subject: [PATCH 044/172] Updated test --- test/unit/client.test.js | 8 ++++---- test/unit/connection.test.js | 31 +++++++++++++++++++++++++++++++ test/unit/transport.test.js | 16 ++++++++-------- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/test/unit/client.test.js b/test/unit/client.test.js index a60476d48..e59d83cab 100644 --- a/test/unit/client.test.js +++ b/test/unit/client.test.js @@ -79,7 +79,7 @@ test('Configure host', t => { }) const pool = client[kConnectionPool] t.match(pool.connections.get('node'), { - url: new URL('http://user@passwordlocalhost:9200'), + url: new URL('http://localhost:9200'), id: 'node', ssl: 'ssl', deadCount: 0, @@ -114,7 +114,7 @@ test('Configure host', t => { }) const pool = client[kConnectionPool] t.match(pool.connections.get('node1'), { - url: new URL('http://user@passwordlocalhost:9200'), + url: new URL('http://localhost:9200'), id: 'node1', ssl: 'ssl', deadCount: 0, @@ -125,7 +125,7 @@ test('Configure host', t => { } }) t.match(pool.connections.get('node2'), { - url: new URL('http://user@passwordlocalhost:9200'), + url: new URL('http://localhost:9200'), id: 'node2', ssl: 'ssl', deadCount: 0, @@ -148,7 +148,7 @@ test('Configure host', t => { }) const pool = client[kConnectionPool] t.match(pool.connections.get('node'), { - url: new URL('http://user@passwordlocalhost:9200'), + url: new URL('http://localhost:9200'), headers: { 'x-foo': 'bar' } }) t.end() diff --git a/test/unit/connection.test.js b/test/unit/connection.test.js index b2b78910e..5a1316b46 100644 --- a/test/unit/connection.test.js +++ b/test/unit/connection.test.js @@ -463,3 +463,34 @@ test('Custom headers for connection', t => { }) }) }) + +// TODO: add a check that the response is not decompressed +test('asStream set to true', t => { + t.plan(2) + + function handler (req, res) { + res.end('ok') + } + + buildServer(handler, ({ port }, server) => { + const connection = new Connection({ + url: new URL(`http://localhost:${port}`) + }) + connection.request({ + path: '/hello', + method: 'GET', + asStream: true + }, (err, res) => { + t.error(err) + + var payload = '' + res.setEncoding('utf8') + res.on('data', chunk => { payload += chunk }) + res.on('error', err => t.fail(err)) + res.on('end', () => { + t.strictEqual(payload, 'ok') + server.stop() + }) + }) + }) +}) diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index 46c0ee614..894a2d4a3 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -1376,7 +1376,7 @@ test('Warning header', t => { t.end() }) -test('asHttpResponse enabled', t => { +test('asStream set to true', t => { t.plan(3) function handler (req, res) { res.setHeader('Content-Type', 'application/json;utf=8') @@ -1400,19 +1400,19 @@ test('asHttpResponse enabled', t => { transport.request({ method: 'GET', path: '/hello', - asHttpResponse: true - }, (err, response) => { + asStream: true + }, (err, { body, headers }) => { t.error(err) - t.match(response.headers, { + t.match(headers, { connection: 'keep-alive', 'content-type': 'application/json;utf=8' }) var payload = '' - response.setEncoding('utf8') - response.on('data', chunk => { payload += chunk }) - response.on('error', err => t.fail(err)) - response.on('end', () => { + body.setEncoding('utf8') + body.on('data', chunk => { payload += chunk }) + body.on('error', err => t.fail(err)) + body.on('end', () => { t.deepEqual(JSON.parse(payload), { hello: 'world' }) server.stop() }) From 8475bc52fa14f670a0ef1d0f6af53d4b7a9ba1d2 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 19 Nov 2018 11:32:20 +0100 Subject: [PATCH 045/172] API generation --- api/api/ccr.delete_auto_follow_pattern.js | 90 +++++++++++++ api/api/ccr.follow.js | 97 +++++++++++++ api/api/ccr.follow_stats.js | 82 +++++++++++ api/api/ccr.get_auto_follow_pattern.js | 82 +++++++++++ api/api/ccr.pause_follow.js | 90 +++++++++++++ api/api/ccr.put_auto_follow_pattern.js | 97 +++++++++++++ api/api/ccr.resume_follow.js | 97 +++++++++++++ api/api/ccr.stats.js | 81 +++++++++++ api/api/ccr.unfollow.js | 90 +++++++++++++ api/api/delete_by_query_rethrottle.js | 113 ++++++++++++++++ api/api/msearch.js | 3 + api/api/nodes.reload_secure_settings.js | 101 ++++++++++++++ api/api/reindex_rethrottle.js | 6 +- api/api/update_by_query_rethrottle.js | 113 ++++++++++++++++ api/api/xpack.ml.delete_forecast.js | 109 +++++++++++++++ api/api/xpack.ml.delete_job.js | 7 +- api/api/xpack.ml.find_file_structure.js | 127 ++++++++++++++++++ api/api/xpack.security.delete_role_mapping.js | 2 +- api/api/xpack.security.delete_user.js | 2 +- api/api/xpack.security.disable_user.js | 2 +- api/api/xpack.security.enable_user.js | 2 +- api/api/xpack.security.get_role_mapping.js | 2 +- api/api/xpack.security.get_token.js | 2 +- api/api/xpack.security.get_user.js | 2 +- api/api/xpack.security.get_user_privileges.js | 89 ++++++++++++ api/api/xpack.security.has_privileges.js | 2 +- api/api/xpack.security.invalidate_token.js | 2 +- api/api/xpack.security.put_role_mapping.js | 2 +- api/api/xpack.security.put_user.js | 2 +- api/index.js | 44 ++++++ 30 files changed, 1523 insertions(+), 17 deletions(-) create mode 100644 api/api/ccr.delete_auto_follow_pattern.js create mode 100644 api/api/ccr.follow.js create mode 100644 api/api/ccr.follow_stats.js create mode 100644 api/api/ccr.get_auto_follow_pattern.js create mode 100644 api/api/ccr.pause_follow.js create mode 100644 api/api/ccr.put_auto_follow_pattern.js create mode 100644 api/api/ccr.resume_follow.js create mode 100644 api/api/ccr.stats.js create mode 100644 api/api/ccr.unfollow.js create mode 100644 api/api/delete_by_query_rethrottle.js create mode 100644 api/api/nodes.reload_secure_settings.js create mode 100644 api/api/update_by_query_rethrottle.js create mode 100644 api/api/xpack.ml.delete_forecast.js create mode 100644 api/api/xpack.ml.find_file_structure.js create mode 100644 api/api/xpack.security.get_user_privileges.js diff --git a/api/api/ccr.delete_auto_follow_pattern.js b/api/api/ccr.delete_auto_follow_pattern.js new file mode 100644 index 000000000..e1fc80d4c --- /dev/null +++ b/api/api/ccr.delete_auto_follow_pattern.js @@ -0,0 +1,90 @@ +'use strict' + +function buildCcrDeleteAutoFollowPattern (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ccr.delete_auto_follow_pattern](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html) request + * + * @param {string} name - The name of the auto follow pattern. + */ + return function ccrDeleteAutoFollowPattern (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ccrDeleteAutoFollowPattern(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['name'] == null) { + return callback( + new ConfigurationError('Missing required parameter: name'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_ccr', 'auto_follow', params['name']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCcrDeleteAutoFollowPattern diff --git a/api/api/ccr.follow.js b/api/api/ccr.follow.js new file mode 100644 index 000000000..2c02acde8 --- /dev/null +++ b/api/api/ccr.follow.js @@ -0,0 +1,97 @@ +'use strict' + +function buildCcrFollow (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ccr.follow](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html) request + * + * @param {string} index - The name of the follower index + * @param {object} body - The name of the leader index and other optional ccr related parameters + */ + return function ccrFollow (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ccrFollow(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + result + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_ccr', 'follow'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCcrFollow diff --git a/api/api/ccr.follow_stats.js b/api/api/ccr.follow_stats.js new file mode 100644 index 000000000..b762fd549 --- /dev/null +++ b/api/api/ccr.follow_stats.js @@ -0,0 +1,82 @@ +'use strict' + +function buildCcrFollowStats (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ccr.follow_stats](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html) request + * + * @param {list} index - A comma-separated list of index patterns; use `_all` to perform the operation on all indices + */ + return function ccrFollowStats (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ccrFollowStats(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_ccr', 'stats'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCcrFollowStats diff --git a/api/api/ccr.get_auto_follow_pattern.js b/api/api/ccr.get_auto_follow_pattern.js new file mode 100644 index 000000000..010e3cf40 --- /dev/null +++ b/api/api/ccr.get_auto_follow_pattern.js @@ -0,0 +1,82 @@ +'use strict' + +function buildCcrGetAutoFollowPattern (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ccr.get_auto_follow_pattern](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html) request + * + * @param {string} name - The name of the auto follow pattern. + */ + return function ccrGetAutoFollowPattern (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ccrGetAutoFollowPattern(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_ccr', 'auto_follow', params['name']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCcrGetAutoFollowPattern diff --git a/api/api/ccr.pause_follow.js b/api/api/ccr.pause_follow.js new file mode 100644 index 000000000..fbf050432 --- /dev/null +++ b/api/api/ccr.pause_follow.js @@ -0,0 +1,90 @@ +'use strict' + +function buildCcrPauseFollow (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ccr.pause_follow](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html) request + * + * @param {string} index - The name of the follower index that should pause following its leader index. + */ + return function ccrPauseFollow (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ccrPauseFollow(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_ccr', 'pause_follow'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCcrPauseFollow diff --git a/api/api/ccr.put_auto_follow_pattern.js b/api/api/ccr.put_auto_follow_pattern.js new file mode 100644 index 000000000..55b12438a --- /dev/null +++ b/api/api/ccr.put_auto_follow_pattern.js @@ -0,0 +1,97 @@ +'use strict' + +function buildCcrPutAutoFollowPattern (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ccr.put_auto_follow_pattern](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html) request + * + * @param {string} name - The name of the auto follow pattern. + * @param {object} body - The specification of the auto follow pattern + */ + return function ccrPutAutoFollowPattern (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ccrPutAutoFollowPattern(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['name'] == null) { + return callback( + new ConfigurationError('Missing required parameter: name'), + result + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_ccr', 'auto_follow', params['name']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCcrPutAutoFollowPattern diff --git a/api/api/ccr.resume_follow.js b/api/api/ccr.resume_follow.js new file mode 100644 index 000000000..942fc5ae9 --- /dev/null +++ b/api/api/ccr.resume_follow.js @@ -0,0 +1,97 @@ +'use strict' + +function buildCcrResumeFollow (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ccr.resume_follow](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-resume-follow.html) request + * + * @param {string} index - The name of the follow index to resume following. + * @param {object} body - The name of the leader index and other optional ccr related parameters + */ + return function ccrResumeFollow (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ccrResumeFollow(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + result + ) + } + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_ccr', 'resume_follow'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCcrResumeFollow diff --git a/api/api/ccr.stats.js b/api/api/ccr.stats.js new file mode 100644 index 000000000..6b20d6dd1 --- /dev/null +++ b/api/api/ccr.stats.js @@ -0,0 +1,81 @@ +'use strict' + +function buildCcrStats (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ccr.stats](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html) request + * + */ + return function ccrStats (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ccrStats(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_ccr', 'stats'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCcrStats diff --git a/api/api/ccr.unfollow.js b/api/api/ccr.unfollow.js new file mode 100644 index 000000000..d12c23946 --- /dev/null +++ b/api/api/ccr.unfollow.js @@ -0,0 +1,90 @@ +'use strict' + +function buildCcrUnfollow (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ccr.unfollow](http://www.elastic.co/guide/en/elasticsearch/reference/current) request + * + * @param {string} index - The name of the follower index that should be turned into a regular index. + */ + return function ccrUnfollow (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ccrUnfollow(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = [params['index'], '_ccr', 'unfollow'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null + } + + return makeRequest(request, callback) + } +} + +module.exports = buildCcrUnfollow diff --git a/api/api/delete_by_query_rethrottle.js b/api/api/delete_by_query_rethrottle.js new file mode 100644 index 000000000..c54f37ede --- /dev/null +++ b/api/api/delete_by_query_rethrottle.js @@ -0,0 +1,113 @@ +'use strict' + +function buildDeleteByQueryRethrottle (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [delete_by_query_rethrottle](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html) request + * + * @param {string} task_id - The task id to rethrottle + * @param {number} requests_per_second - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. + */ + return function deleteByQueryRethrottle (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + deleteByQueryRethrottle(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['task_id'] == null && params['taskId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: task_id or taskId'), + result + ) + } + if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) { + return callback( + new ConfigurationError('Missing required parameter: requests_per_second or requestsPerSecond'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'requests_per_second', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'requestsPerSecond', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_delete_by_query', params['task_id'] || params['taskId'], '_rethrottle'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null + } + + return makeRequest(request, callback) + } +} + +module.exports = buildDeleteByQueryRethrottle diff --git a/api/api/msearch.js b/api/api/msearch.js index 5fe5de3b6..d201b9d3b 100644 --- a/api/api/msearch.js +++ b/api/api/msearch.js @@ -12,6 +12,7 @@ function buildMsearch (opts) { * @param {number} max_concurrent_searches - Controls the maximum number of concurrent searches the multi search api will execute * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response * @param {number} pre_filter_shard_size - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on it's rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. + * @param {number} max_concurrent_shard_requests - The number of concurrent shard requests each sub search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests * @param {object} body - The request definitions (metadata-search request definition pairs), separated by newlines */ return function msearch (params, callback) { @@ -52,6 +53,7 @@ function buildMsearch (opts) { 'max_concurrent_searches', 'typed_keys', 'pre_filter_shard_size', + 'max_concurrent_shard_requests', 'pretty', 'human', 'error_trace', @@ -63,6 +65,7 @@ function buildMsearch (opts) { 'maxConcurrentSearches', 'typedKeys', 'preFilterShardSize', + 'maxConcurrentShardRequests', 'pretty', 'human', 'errorTrace', diff --git a/api/api/nodes.reload_secure_settings.js b/api/api/nodes.reload_secure_settings.js new file mode 100644 index 000000000..37c682b31 --- /dev/null +++ b/api/api/nodes.reload_secure_settings.js @@ -0,0 +1,101 @@ +'use strict' + +function buildNodesReloadSecureSettings (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [nodes.reload_secure_settings](https://www.elastic.co/guide/en/elasticsearch/reference/6.5/secure-settings.html#reloadable-secure-settings) request + * + * @param {list} node_id - A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes. + * @param {time} timeout - Explicit operation timeout + */ + return function nodesReloadSecureSettings (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + nodesReloadSecureSettings(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'timeout', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_nodes', params['node_id'] || params['nodeId'], 'reload_secure_settings'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null + } + + return makeRequest(request, callback) + } +} + +module.exports = buildNodesReloadSecureSettings diff --git a/api/api/reindex_rethrottle.js b/api/api/reindex_rethrottle.js index 8093467b9..ce6bf9b27 100644 --- a/api/api/reindex_rethrottle.js +++ b/api/api/reindex_rethrottle.js @@ -95,12 +95,10 @@ function buildReindexRethrottle (opts) { } // build request object - const parts = ['_delete_by_query', params['task_id'] || params['taskId'], '_rethrottle'] + const parts = ['_reindex', params['task_id'] || params['taskId'], '_rethrottle'] const request = { method, - path: (params['task_id'] || params['taskId']) != null - ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') - : '/_reindex/{task_id}/_rethrottle', + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', headers: params.headers || null, diff --git a/api/api/update_by_query_rethrottle.js b/api/api/update_by_query_rethrottle.js new file mode 100644 index 000000000..b2c5acff2 --- /dev/null +++ b/api/api/update_by_query_rethrottle.js @@ -0,0 +1,113 @@ +'use strict' + +function buildUpdateByQueryRethrottle (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [update_by_query_rethrottle](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html) request + * + * @param {string} task_id - The task id to rethrottle + * @param {number} requests_per_second - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. + */ + return function updateByQueryRethrottle (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + updateByQueryRethrottle(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['task_id'] == null && params['taskId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: task_id or taskId'), + result + ) + } + if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) { + return callback( + new ConfigurationError('Missing required parameter: requests_per_second or requestsPerSecond'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'requests_per_second', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + const acceptedQuerystringCamelCased = [ + 'requestsPerSecond', + 'pretty', + 'human', + 'errorTrace', + 'source', + 'filterPath' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_update_by_query', params['task_id'] || params['taskId'], '_rethrottle'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null + } + + return makeRequest(request, callback) + } +} + +module.exports = buildUpdateByQueryRethrottle diff --git a/api/api/xpack.ml.delete_forecast.js b/api/api/xpack.ml.delete_forecast.js new file mode 100644 index 000000000..7ebba4f81 --- /dev/null +++ b/api/api/xpack.ml.delete_forecast.js @@ -0,0 +1,109 @@ +'use strict' + +function buildXpackMlDeleteForecast (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.delete_forecast](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html) request + * + * @param {string} job_id - The ID of the job from which to delete forecasts + * @param {string} forecast_id - The ID of the forecast to delete, can be comma delimited list. Leaving blank implies `_all` + * @param {boolean} allow_no_forecasts - Whether to ignore if `_all` matches no forecasts + * @param {time} timeout - Controls the time to wait until the forecast(s) are deleted. Default to 30 seconds + */ + return function xpackMlDeleteForecast (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlDeleteForecast(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + return callback( + new ConfigurationError('Missing required parameter: job_id or jobId'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // check required url components + if ((params['forecast_id'] != null || params['forecastId'] != null) && ((params['job_id'] == null || params['jobId']))) { + return callback( + new ConfigurationError('Missing required parameter of the url: job_id'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'allow_no_forecasts', + 'timeout' + ] + const acceptedQuerystringCamelCased = [ + 'allowNoForecasts', + 'timeout' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_forecast', params['forecast_id'] || params['forecastId']] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlDeleteForecast diff --git a/api/api/xpack.ml.delete_job.js b/api/api/xpack.ml.delete_job.js index 09fec33d3..b6bb053d7 100644 --- a/api/api/xpack.ml.delete_job.js +++ b/api/api/xpack.ml.delete_job.js @@ -8,6 +8,7 @@ function buildXpackMlDeleteJob (opts) { * * @param {string} job_id - The ID of the job to delete * @param {boolean} force - True if the job should be forcefully deleted + * @param {boolean} wait_for_completion - Should this request wait until the operation has completed before returning */ return function xpackMlDeleteJob (params, callback) { if (typeof params === 'function' || params == null) { @@ -41,10 +42,12 @@ function buildXpackMlDeleteJob (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ - 'force' + 'force', + 'wait_for_completion' ] const acceptedQuerystringCamelCased = [ - 'force' + 'force', + 'waitForCompletion' ] for (var i = 0, len = keys.length; i < len; i++) { diff --git a/api/api/xpack.ml.find_file_structure.js b/api/api/xpack.ml.find_file_structure.js new file mode 100644 index 000000000..3e3cdb580 --- /dev/null +++ b/api/api/xpack.ml.find_file_structure.js @@ -0,0 +1,127 @@ +'use strict' + +function buildXpackMlFindFileStructure (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.ml.find_file_structure](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-file-structure.html) request + * + * @param {int} lines_to_sample - How many lines of the file should be included in the analysis + * @param {time} timeout - Timeout after which the analysis will be aborted + * @param {string} charset - Optional parameter to specify the character set of the file + * @param {enum} format - Optional parameter to specify the high level file format + * @param {boolean} has_header_row - Optional parameter to specify whether a delimited file includes the column names in its first row + * @param {list} column_names - Optional parameter containing a comma separated list of the column names for a delimited file + * @param {string} delimiter - Optional parameter to specify the delimiter character for a delimited file - must be a single character + * @param {string} quote - Optional parameter to specify the quote character for a delimited file - must be a single character + * @param {boolean} should_trim_fields - Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them + * @param {string} grok_pattern - Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file + * @param {string} timestamp_field - Optional parameter to specify the timestamp field in the file + * @param {string} timestamp_format - Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format + * @param {boolean} explain - Whether to include a commentary on how the structure was derived + * @param {object} body - The contents of the file to be analyzed + */ + return function xpackMlFindFileStructure (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMlFindFileStructure(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'lines_to_sample', + 'timeout', + 'charset', + 'format', + 'has_header_row', + 'column_names', + 'delimiter', + 'quote', + 'should_trim_fields', + 'grok_pattern', + 'timestamp_field', + 'timestamp_format', + 'explain' + ] + const acceptedQuerystringCamelCased = [ + 'linesToSample', + 'timeout', + 'charset', + 'format', + 'hasHeaderRow', + 'columnNames', + 'delimiter', + 'quote', + 'shouldTrimFields', + 'grokPattern', + 'timestampField', + 'timestampFormat', + 'explain' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'ml', 'find_file_structure'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: params.body || '', + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackMlFindFileStructure diff --git a/api/api/xpack.security.delete_role_mapping.js b/api/api/xpack.security.delete_role_mapping.js index 00a8f0164..8747d94ca 100644 --- a/api/api/xpack.security.delete_role_mapping.js +++ b/api/api/xpack.security.delete_role_mapping.js @@ -4,7 +4,7 @@ function buildXpackSecurityDeleteRoleMapping (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.delete_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-role-mapping.html#security-api-delete-role-mapping) request + * Perform a [xpack.security.delete_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role-mapping.html) request * * @param {string} name - Role-mapping name * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. diff --git a/api/api/xpack.security.delete_user.js b/api/api/xpack.security.delete_user.js index d84670d64..3bed165bc 100644 --- a/api/api/xpack.security.delete_user.js +++ b/api/api/xpack.security.delete_user.js @@ -4,7 +4,7 @@ function buildXpackSecurityDeleteUser (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.delete_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-users.html#security-api-delete-user) request + * Perform a [xpack.security.delete_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-user.html) request * * @param {string} username - username * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. diff --git a/api/api/xpack.security.disable_user.js b/api/api/xpack.security.disable_user.js index 3c382d912..30d154981 100644 --- a/api/api/xpack.security.disable_user.js +++ b/api/api/xpack.security.disable_user.js @@ -4,7 +4,7 @@ function buildXpackSecurityDisableUser (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.disable_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-users.html#security-api-disable-user) request + * Perform a [xpack.security.disable_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-disable-user.html) request * * @param {string} username - The username of the user to disable * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. diff --git a/api/api/xpack.security.enable_user.js b/api/api/xpack.security.enable_user.js index ed4518937..4df443a29 100644 --- a/api/api/xpack.security.enable_user.js +++ b/api/api/xpack.security.enable_user.js @@ -4,7 +4,7 @@ function buildXpackSecurityEnableUser (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.enable_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-users.html#security-api-enable-user) request + * Perform a [xpack.security.enable_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-enable-user.html) request * * @param {string} username - The username of the user to enable * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. diff --git a/api/api/xpack.security.get_role_mapping.js b/api/api/xpack.security.get_role_mapping.js index 0cceb6b1a..dea05f037 100644 --- a/api/api/xpack.security.get_role_mapping.js +++ b/api/api/xpack.security.get_role_mapping.js @@ -4,7 +4,7 @@ function buildXpackSecurityGetRoleMapping (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.get_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-role-mapping.html#security-api-get-role-mapping) request + * Perform a [xpack.security.get_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role-mapping.html) request * * @param {string} name - Role-Mapping name */ diff --git a/api/api/xpack.security.get_token.js b/api/api/xpack.security.get_token.js index 2f8877b56..913e8c83b 100644 --- a/api/api/xpack.security.get_token.js +++ b/api/api/xpack.security.get_token.js @@ -4,7 +4,7 @@ function buildXpackSecurityGetToken (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.get_token](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-tokens.html#security-api-get-token) request + * Perform a [xpack.security.get_token](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html) request * * @param {object} body - The token request to get */ diff --git a/api/api/xpack.security.get_user.js b/api/api/xpack.security.get_user.js index 645500eeb..4ee4a2493 100644 --- a/api/api/xpack.security.get_user.js +++ b/api/api/xpack.security.get_user.js @@ -4,7 +4,7 @@ function buildXpackSecurityGetUser (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.get_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-users.html#security-api-get-user) request + * Perform a [xpack.security.get_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user.html) request * * @param {list} username - A comma-separated list of usernames */ diff --git a/api/api/xpack.security.get_user_privileges.js b/api/api/xpack.security.get_user_privileges.js new file mode 100644 index 000000000..a0f8da0b9 --- /dev/null +++ b/api/api/xpack.security.get_user_privileges.js @@ -0,0 +1,89 @@ +'use strict' + +function buildXpackSecurityGetUserPrivileges (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [xpack.security.get_user_privileges](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-privileges.html) request + * + */ + return function xpackSecurityGetUserPrivileges (params, callback) { + if (typeof params === 'function' || params == null) { + callback = params + params = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSecurityGetUserPrivileges(params, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = params.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + // build request object + const parts = ['_xpack', 'security', 'user', '_privileges'] + const request = { + method, + path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + querystring, + body: null, + headers: params.headers || null, + ignore, + requestTimeout: params.requestTimeout || null + } + + return makeRequest(request, callback) + } +} + +module.exports = buildXpackSecurityGetUserPrivileges diff --git a/api/api/xpack.security.has_privileges.js b/api/api/xpack.security.has_privileges.js index d888bb1b0..e772571da 100644 --- a/api/api/xpack.security.has_privileges.js +++ b/api/api/xpack.security.has_privileges.js @@ -4,7 +4,7 @@ function buildXpackSecurityHasPrivileges (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.has_privileges](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-privileges.html) request + * Perform a [xpack.security.has_privileges](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html) request * * @param {string} user - Username * @param {object} body - The privileges to test diff --git a/api/api/xpack.security.invalidate_token.js b/api/api/xpack.security.invalidate_token.js index e5b3f6fe6..52d7cd7dd 100644 --- a/api/api/xpack.security.invalidate_token.js +++ b/api/api/xpack.security.invalidate_token.js @@ -4,7 +4,7 @@ function buildXpackSecurityInvalidateToken (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.invalidate_token](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-tokens.html#security-api-invalidate-token) request + * Perform a [xpack.security.invalidate_token](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html) request * * @param {object} body - The token to invalidate */ diff --git a/api/api/xpack.security.put_role_mapping.js b/api/api/xpack.security.put_role_mapping.js index 57ec1a6f4..3cacc94b7 100644 --- a/api/api/xpack.security.put_role_mapping.js +++ b/api/api/xpack.security.put_role_mapping.js @@ -4,7 +4,7 @@ function buildXpackSecurityPutRoleMapping (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.put_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-role-mapping.html#security-api-put-role-mapping) request + * Perform a [xpack.security.put_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role-mapping.html) request * * @param {string} name - Role-mapping name * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. diff --git a/api/api/xpack.security.put_user.js b/api/api/xpack.security.put_user.js index 0ad0a7031..7c92ddf60 100644 --- a/api/api/xpack.security.put_user.js +++ b/api/api/xpack.security.put_user.js @@ -4,7 +4,7 @@ function buildXpackSecurityPutUser (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.put_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-users.html#security-api-put-user) request + * Perform a [xpack.security.put_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html) request * * @param {string} username - The username of the User * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. diff --git a/api/index.js b/api/index.js index 20603b0a3..7417f3b6c 100644 --- a/api/index.js +++ b/api/index.js @@ -23,6 +23,15 @@ const catSnapshots = require('./api/cat.snapshots.js') const catTasks = require('./api/cat.tasks.js') const catTemplates = require('./api/cat.templates.js') const catThreadPool = require('./api/cat.thread_pool.js') +const ccrDeleteAutoFollowPattern = require('./api/ccr.delete_auto_follow_pattern.js') +const ccrFollow = require('./api/ccr.follow.js') +const ccrFollowStats = require('./api/ccr.follow_stats.js') +const ccrGetAutoFollowPattern = require('./api/ccr.get_auto_follow_pattern.js') +const ccrPauseFollow = require('./api/ccr.pause_follow.js') +const ccrPutAutoFollowPattern = require('./api/ccr.put_auto_follow_pattern.js') +const ccrResumeFollow = require('./api/ccr.resume_follow.js') +const ccrStats = require('./api/ccr.stats.js') +const ccrUnfollow = require('./api/ccr.unfollow.js') const clearScroll = require('./api/clear_scroll.js') const clusterAllocationExplain = require('./api/cluster.allocation_explain.js') const clusterGetSettings = require('./api/cluster.get_settings.js') @@ -37,6 +46,7 @@ const count = require('./api/count.js') const create = require('./api/create.js') const _delete = require('./api/delete.js') const deleteByQuery = require('./api/delete_by_query.js') +const deleteByQueryRethrottle = require('./api/delete_by_query_rethrottle.js') const deleteScript = require('./api/delete_script.js') const exists = require('./api/exists.js') const existsSource = require('./api/exists_source.js') @@ -95,6 +105,7 @@ const msearchTemplate = require('./api/msearch_template.js') const mtermvectors = require('./api/mtermvectors.js') const nodesHotThreads = require('./api/nodes.hot_threads.js') const nodesInfo = require('./api/nodes.info.js') +const nodesReloadSecureSettings = require('./api/nodes.reload_secure_settings.js') const nodesStats = require('./api/nodes.stats.js') const nodesUsage = require('./api/nodes.usage.js') const ping = require('./api/ping.js') @@ -123,6 +134,7 @@ const tasksList = require('./api/tasks.list.js') const termvectors = require('./api/termvectors.js') const update = require('./api/update.js') const updateByQuery = require('./api/update_by_query.js') +const updateByQueryRethrottle = require('./api/update_by_query_rethrottle.js') const xpackGraphExplore = require('./api/xpack.graph.explore.js') const xpackInfo = require('./api/xpack.info.js') const xpackLicenseDelete = require('./api/xpack.license.delete.js') @@ -142,8 +154,10 @@ const xpackMlDeleteCalendarJob = require('./api/xpack.ml.delete_calendar_job.js' const xpackMlDeleteDatafeed = require('./api/xpack.ml.delete_datafeed.js') const xpackMlDeleteExpiredData = require('./api/xpack.ml.delete_expired_data.js') const xpackMlDeleteFilter = require('./api/xpack.ml.delete_filter.js') +const xpackMlDeleteForecast = require('./api/xpack.ml.delete_forecast.js') const xpackMlDeleteJob = require('./api/xpack.ml.delete_job.js') const xpackMlDeleteModelSnapshot = require('./api/xpack.ml.delete_model_snapshot.js') +const xpackMlFindFileStructure = require('./api/xpack.ml.find_file_structure.js') const xpackMlFlushJob = require('./api/xpack.ml.flush_job.js') const xpackMlForecast = require('./api/xpack.ml.forecast.js') const xpackMlGetBuckets = require('./api/xpack.ml.get_buckets.js') @@ -202,6 +216,7 @@ const xpackSecurityGetRole = require('./api/xpack.security.get_role.js') const xpackSecurityGetRoleMapping = require('./api/xpack.security.get_role_mapping.js') const xpackSecurityGetToken = require('./api/xpack.security.get_token.js') const xpackSecurityGetUser = require('./api/xpack.security.get_user.js') +const xpackSecurityGetUserPrivileges = require('./api/xpack.security.get_user_privileges.js') const xpackSecurityHasPrivileges = require('./api/xpack.security.has_privileges.js') const xpackSecurityInvalidateToken = require('./api/xpack.security.invalidate_token.js') const xpackSecurityPutPrivileges = require('./api/xpack.security.put_privileges.js') @@ -256,6 +271,23 @@ function ESAPI (opts) { thread_pool: catThreadPool(opts), threadPool: catThreadPool(opts) }, + ccr: { + delete_auto_follow_pattern: ccrDeleteAutoFollowPattern(opts), + deleteAutoFollowPattern: ccrDeleteAutoFollowPattern(opts), + follow: ccrFollow(opts), + follow_stats: ccrFollowStats(opts), + followStats: ccrFollowStats(opts), + get_auto_follow_pattern: ccrGetAutoFollowPattern(opts), + getAutoFollowPattern: ccrGetAutoFollowPattern(opts), + pause_follow: ccrPauseFollow(opts), + pauseFollow: ccrPauseFollow(opts), + put_auto_follow_pattern: ccrPutAutoFollowPattern(opts), + putAutoFollowPattern: ccrPutAutoFollowPattern(opts), + resume_follow: ccrResumeFollow(opts), + resumeFollow: ccrResumeFollow(opts), + stats: ccrStats(opts), + unfollow: ccrUnfollow(opts) + }, clear_scroll: clearScroll(opts), clearScroll: clearScroll(opts), cluster: { @@ -279,6 +311,8 @@ function ESAPI (opts) { delete: _delete(opts), delete_by_query: deleteByQuery(opts), deleteByQuery: deleteByQuery(opts), + delete_by_query_rethrottle: deleteByQueryRethrottle(opts), + deleteByQueryRethrottle: deleteByQueryRethrottle(opts), delete_script: deleteScript(opts), deleteScript: deleteScript(opts), exists: exists(opts), @@ -373,6 +407,8 @@ function ESAPI (opts) { hot_threads: nodesHotThreads(opts), hotThreads: nodesHotThreads(opts), info: nodesInfo(opts), + reload_secure_settings: nodesReloadSecureSettings(opts), + reloadSecureSettings: nodesReloadSecureSettings(opts), stats: nodesStats(opts), usage: nodesUsage(opts) }, @@ -418,6 +454,8 @@ function ESAPI (opts) { update: update(opts), update_by_query: updateByQuery(opts), updateByQuery: updateByQuery(opts), + update_by_query_rethrottle: updateByQueryRethrottle(opts), + updateByQueryRethrottle: updateByQueryRethrottle(opts), xpack: { graph: { explore: xpackGraphExplore(opts) @@ -457,10 +495,14 @@ function ESAPI (opts) { deleteExpiredData: xpackMlDeleteExpiredData(opts), delete_filter: xpackMlDeleteFilter(opts), deleteFilter: xpackMlDeleteFilter(opts), + delete_forecast: xpackMlDeleteForecast(opts), + deleteForecast: xpackMlDeleteForecast(opts), delete_job: xpackMlDeleteJob(opts), deleteJob: xpackMlDeleteJob(opts), delete_model_snapshot: xpackMlDeleteModelSnapshot(opts), deleteModelSnapshot: xpackMlDeleteModelSnapshot(opts), + find_file_structure: xpackMlFindFileStructure(opts), + findFileStructure: xpackMlFindFileStructure(opts), flush_job: xpackMlFlushJob(opts), flushJob: xpackMlFlushJob(opts), forecast: xpackMlForecast(opts), @@ -578,6 +620,8 @@ function ESAPI (opts) { getToken: xpackSecurityGetToken(opts), get_user: xpackSecurityGetUser(opts), getUser: xpackSecurityGetUser(opts), + get_user_privileges: xpackSecurityGetUserPrivileges(opts), + getUserPrivileges: xpackSecurityGetUserPrivileges(opts), has_privileges: xpackSecurityHasPrivileges(opts), hasPrivileges: xpackSecurityHasPrivileges(opts), invalidate_token: xpackSecurityInvalidateToken(opts), From d259b82763e9de1b9f4a267a6a95d95ab40dd6d6 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 19 Nov 2018 11:33:20 +0100 Subject: [PATCH 046/172] Use Elasticsearch 6.5.0 --- .ci/docker-compose.yml | 2 +- .ci/test-matrix.yml | 2 +- .travis.yml | 2 +- scripts/es-docker.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.ci/docker-compose.yml b/.ci/docker-compose.yml index 541bb4898..5176c6440 100644 --- a/.ci/docker-compose.yml +++ b/.ci/docker-compose.yml @@ -20,7 +20,7 @@ services: depends_on: - elasticsearch elasticsearch: - image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-6.4.0} + image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-6.5.0} volumes: - esvol:/tmp networks: diff --git a/.ci/test-matrix.yml b/.ci/test-matrix.yml index 9848e5c31..6625ffaac 100644 --- a/.ci/test-matrix.yml +++ b/.ci/test-matrix.yml @@ -1,6 +1,6 @@ --- ELASTICSEARCH_VERSION: -- 6.4.0 +- 6.5.0 NODE_JS_VERSION: - 10 diff --git a/.travis.yml b/.travis.yml index 9ba174b40..b4de52bce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ node_js: env: global: - - ELASTICSEARCH_VERSION=6.4.0 + - ELASTICSEARCH_VERSION=6.5.0 - QUIET=true before_install: diff --git a/scripts/es-docker.sh b/scripts/es-docker.sh index 655b09cce..74082aa06 100755 --- a/scripts/es-docker.sh +++ b/scripts/es-docker.sh @@ -6,7 +6,7 @@ exec docker run \ -e "path.repo=/tmp" \ -e "repositories.url.allowed_urls=http://snapshot.*" \ -p 9200:9200 \ - docker.elastic.co/elasticsearch/elasticsearch:6.4.0 + docker.elastic.co/elasticsearch/elasticsearch:6.5.0 # -e "xpack.security.enabled=true" \ # -e "ELASTIC_PASSWORD=passw0rd" \ From 020165168c5904afcab10fcbc7bd9a0bc0894aee Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 19 Nov 2018 11:33:40 +0100 Subject: [PATCH 047/172] WIP: initial prototype - Expose connection info inside events - Fixed minor bugs --- index.js | 21 ++++++++++++--------- lib/Connection.js | 1 + lib/ConnectionPool.js | 3 ++- lib/Transport.js | 22 ++++++++++++---------- 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/index.js b/index.js index 644f32ece..cc5055da6 100644 --- a/index.js +++ b/index.js @@ -59,14 +59,15 @@ class Client extends EventEmitter { this[kSerializer] = new options.Serializer() this[kConnectionPool] = new options.ConnectionPool({ - pingTimeout: opts.pingTimeout, - resurrectStrategy: opts.resurrectStrategy, - randomizeHost: opts.randomizeHost, + pingTimeout: options.pingTimeout, + resurrectStrategy: options.resurrectStrategy, + randomizeHost: options.randomizeHost, ssl: options.ssl, - agent: null, - nodeFilter: opts.nodeFilter, - nodeWeighter: opts.nodeWeighter, - nodeSelector: opts.nodeSelector + agent: options.agent, + nodeFilter: options.nodeFilter, + nodeWeighter: options.nodeWeighter, + nodeSelector: options.nodeSelector, + Connection: options.Connection }) // Add the connections before initialize the Transport @@ -99,7 +100,7 @@ class Client extends EventEmitter { } } -Client.events = { +const events = { RESPONSE: 'response', REQUEST: 'request', ERROR: 'error' @@ -109,6 +110,8 @@ module.exports = { Client, Transport, ConnectionPool, + Connection, Serializer, - symbols + symbols, + events } diff --git a/lib/Connection.js b/lib/Connection.js index 0fe0b0997..028cfdf51 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -86,6 +86,7 @@ class Connection { return request } + // TODO: write a better closing logic close () { debug('Closing connection', this.id) if (this._openRequests > 0) { diff --git a/lib/ConnectionPool.js b/lib/ConnectionPool.js index a42832ca0..47e461751 100644 --- a/lib/ConnectionPool.js +++ b/lib/ConnectionPool.js @@ -25,6 +25,7 @@ class ConnectionPool { this.pingTimeout = opts.pingTimeout this.randomizeHost = opts.randomizeHost === true this.nodeFilter = opts.nodeFilter || defaultNodeFilter + this.Connection = opts.Connection if (typeof opts.nodeSelector === 'function') { this.nodeSelector = opts.nodeSelector @@ -195,7 +196,7 @@ class ConnectionPool { if (opts.ssl == null) opts.ssl = this._ssl if (opts.agent == null) opts.agent = this._agent - const connection = new Connection(opts) + const connection = new this.Connection(opts) debug('Adding a new connection', connection) if (this.connections.has(connection.id)) { throw new Error(`Connection with id '${connection.id}' is already present`) diff --git a/lib/Transport.js b/lib/Transport.js index c37048ed0..83e4445c3 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -80,8 +80,7 @@ class Transport { // handles request timeout params.timeout = toMs(params.requestTimeout || this.requestTimeout) - // TODO: expose nicely the node metadata (also in response an error) - this.emit('request', params, connection) + this.emit('request', connection, params) // perform the actual http request const request = connection.request(params, (err, response) => { @@ -105,7 +104,7 @@ class Transport { ? err : new ConnectionError(err.message, params) - this.emit('error', error, params) + this.emit('error', error, connection, params) return callback(error, result) } @@ -119,6 +118,7 @@ class Transport { if (params.asStream === true) { result.body = response + this.emit('response', connection, params, result) callback(null, result) return } @@ -142,7 +142,7 @@ class Transport { try { result.body = this.serializer.deserialize(payload) } catch (err) { - this.emit('error', err, params) + this.emit('error', err, connection, params) return callback(err, result) } } else { @@ -171,7 +171,7 @@ class Transport { this.connectionPool.markAlive(connection) } - this.emit('response', params, result) + this.emit('response', connection, params, result) if (ignoreStatusCode === false && statusCode >= 400) { callback(new ResponseError(result), result) } else { @@ -206,23 +206,25 @@ class Transport { this._isSniffing = true debug('Started sniffing request') - this.request({ + const request = { method: 'GET', path: this.sniffEndpoint - }, (err, body) => { + } + + this.request(request, (err, result) => { this._isSniffing = false if (this._sniffEnabled === true) { this._nextSniff = Date.now() + this.sniffInterval } if (err != null) { - this.emit('error', err) + this.emit('error', err, null, request) debug('Sniffing errored', err) return callback(err) } - debug('Sniffing ended successfully', body) - const hosts = this.connectionPool.nodesToHost(body.nodes) + debug('Sniffing ended successfully', result.body) + const hosts = this.connectionPool.nodesToHost(result.body.nodes) this.connectionPool.update(hosts) callback(null, hosts) From da710e26e17f4a71a3ee1c090ec2565e401e0a7b Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 19 Nov 2018 11:35:02 +0100 Subject: [PATCH 048/172] Updated test --- test/integration/index.js | 8 +- test/unit/connection-pool.test.js | 118 +++--- test/unit/events.test.js | 106 +++++ test/unit/transport.test.js | 625 +++++++++++++----------------- test/utils/MockConnection.js | 65 ++++ test/utils/index.js | 4 +- 6 files changed, 502 insertions(+), 424 deletions(-) create mode 100644 test/unit/events.test.js create mode 100644 test/utils/MockConnection.js diff --git a/test/integration/index.js b/test/integration/index.js index afc72421f..9b5a353c0 100644 --- a/test/integration/index.js +++ b/test/integration/index.js @@ -8,7 +8,7 @@ const Git = require('simple-git') const ora = require('ora') const minimist = require('minimist') const tap = require('tap') -const elasticsearch = require('../../index') +const { Client } = require('../../index') const TestRunner = require('./test-runner') const esRepo = 'https://github.com/elastic/elasticsearch.git' @@ -24,9 +24,7 @@ function Runner (opts) { assert(opts.node, 'Missing base node') this.bailout = opts.bailout - this.client = new elasticsearch.Client({ - node: opts.node - }) + this.client = new Client({ node: opts.node }) this.log = ora('Loading yaml suite').start() } @@ -239,7 +237,7 @@ if (require.main === module) { default: { // node: 'http://elastic:passw0rd@localhost:9200', node: process.env.TEST_ES_SERVER || 'http://localhost:9200', - version: '6.4', + version: '6.5', bailout: false } }) diff --git a/test/unit/connection-pool.test.js b/test/unit/connection-pool.test.js index 460573630..69cd3da00 100644 --- a/test/unit/connection-pool.test.js +++ b/test/unit/connection-pool.test.js @@ -4,11 +4,11 @@ const { test } = require('tap') const { URL } = require('url') const ConnectionPool = require('../../lib/ConnectionPool') const Connection = require('../../lib/Connection') -const { buildServer } = require('../utils') +const { connection: { MockConnection, MockConnectionTimeout } } = require('../utils') test('API', t => { t.test('addConnection', t => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) const href = 'http://localhost:9200/' pool.addConnection(href) t.ok(pool.connections.get(href) instanceof Connection) @@ -18,7 +18,7 @@ test('API', t => { }) t.test('addConnection should throw with two connections with the same id', t => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) const href = 'http://localhost:9200/' pool.addConnection(href) try { @@ -31,7 +31,7 @@ test('API', t => { }) t.test('markDead', t => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) const href = 'http://localhost:9200/' var connection = pool.addConnection(href) pool.markDead(connection) @@ -43,7 +43,7 @@ test('API', t => { }) t.test('markDead should sort the dead queue by deadTimeout', t => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) const href1 = 'http://localhost:9200/1' const href2 = 'http://localhost:9200/2' const conn1 = pool.addConnection(href1) @@ -57,7 +57,7 @@ test('API', t => { }) t.test('markAlive', t => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) const href = 'http://localhost:9200/' var connection = pool.addConnection(href) pool.markDead(connection) @@ -73,51 +73,42 @@ test('API', t => { t.test('resurrect', t => { t.test('ping strategy', t => { t.test('alive', t => { - function handler (req, res) { - res.end() - } - - buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ - resurrectStrategy: 'ping', - pingTimeout: 3000 - }) - const href = `http://localhost:${port}/` - var connection = pool.addConnection(href) - pool.markDead(connection) - pool.resurrect(Date.now() + 1000 * 60 * 3, (isAlive, connection) => { - t.true(isAlive) - connection = pool.connections.get(connection.id) - t.strictEqual(connection.deadCount, 0) - t.strictEqual(connection.resurrectTimeout, 0) - t.strictEqual(connection.status, Connection.statuses.ALIVE) - t.deepEqual(pool.dead, []) - server.stop() - t.end() - }) + const pool = new ConnectionPool({ + resurrectStrategy: 'ping', + pingTimeout: 3000, + Connection: MockConnection + }) + const href = 'http://localhost:9200/' + var connection = pool.addConnection(href) + pool.markDead(connection) + pool.resurrect(Date.now() + 1000 * 60 * 3, (isAlive, connection) => { + t.true(isAlive) + connection = pool.connections.get(connection.id) + t.strictEqual(connection.deadCount, 0) + t.strictEqual(connection.resurrectTimeout, 0) + t.strictEqual(connection.status, Connection.statuses.ALIVE) + t.deepEqual(pool.dead, []) + t.end() }) }) t.test('dead', t => { - buildServer(() => {}, ({ port }, server) => { - server.close() - const pool = new ConnectionPool({ - resurrectStrategy: 'ping', - pingTimeout: 3000 - }) - const href = `http://localhost:${port}/` - var connection = pool.addConnection(href) - pool.markDead(connection) - pool.resurrect(Date.now() + 1000 * 60 * 3, (isAlive, connection) => { - t.false(isAlive) - connection = pool.connections.get(connection.id) - t.strictEqual(connection.deadCount, 2) - t.true(connection.resurrectTimeout > 0) - t.strictEqual(connection.status, Connection.statuses.DEAD) - t.deepEqual(pool.dead, [href]) - server.stop() - t.end() - }) + const pool = new ConnectionPool({ + resurrectStrategy: 'ping', + pingTimeout: 3000, + Connection: MockConnectionTimeout + }) + const href = 'http://localhost:9200/' + var connection = pool.addConnection(href) + pool.markDead(connection) + pool.resurrect(Date.now() + 1000 * 60 * 3, (isAlive, connection) => { + t.false(isAlive) + connection = pool.connections.get(connection.id) + t.strictEqual(connection.deadCount, 2) + t.true(connection.resurrectTimeout > 0) + t.strictEqual(connection.status, Connection.statuses.DEAD) + t.deepEqual(pool.dead, [href]) + t.end() }) }) @@ -126,7 +117,8 @@ test('API', t => { t.test('optimistic strategy', t => { const pool = new ConnectionPool({ - resurrectStrategy: 'optimistic' + resurrectStrategy: 'optimistic', + Connection }) const href = 'http://localhost:9200/' var connection = pool.addConnection(href) @@ -144,7 +136,8 @@ test('API', t => { t.test('none strategy', t => { const pool = new ConnectionPool({ - resurrectStrategy: 'none' + resurrectStrategy: 'none', + Connection }) const href = 'http://localhost:9200/' var connection = pool.addConnection(href) @@ -166,7 +159,7 @@ test('API', t => { t.test('getConnection', t => { t.test('Should return a connection', t => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) const href = 'http://localhost:9200/' pool.addConnection(href) t.ok(pool.getConnection() instanceof Connection) @@ -174,7 +167,7 @@ test('API', t => { }) t.test('filter option', t => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) const href1 = 'http://localhost:9200/' const href2 = 'http://localhost:9200/other' pool.addConnection([href1, href2]) @@ -184,9 +177,9 @@ test('API', t => { t.end() }) - t.test('filter and weighter should get Connection objects', t => { + t.test('filter should get Connection objects', t => { t.plan(2) - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) const href1 = 'http://localhost:9200/' const href2 = 'http://localhost:9200/other' pool.addConnection([href1, href2]) @@ -200,7 +193,7 @@ test('API', t => { t.test('filter should get alive connections', t => { t.plan(2) - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) const href1 = 'http://localhost:9200/' const href2 = 'http://localhost:9200/other' const conn = pool.addConnection(href1) @@ -220,6 +213,7 @@ test('API', t => { const href1 = 'http://localhost:9200/' const href2 = 'http://localhost:9200/other' const pool = new ConnectionPool({ + Connection, nodeFilter: node => { t.ok('called') return true @@ -233,7 +227,7 @@ test('API', t => { }) t.test('removeConnection', t => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) const href = 'http://localhost:9200/' var connection = pool.addConnection(href) t.ok(pool.getConnection() instanceof Connection) @@ -243,7 +237,7 @@ test('API', t => { }) t.test('empty', t => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection('http://localhost:9200/') pool.addConnection('http://localhost:9201/') pool.empty() @@ -253,7 +247,7 @@ test('API', t => { }) t.test('urlToHost', t => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) const url = 'http://localhost:9200' t.deepEqual( pool.urlToHost(url), @@ -263,7 +257,7 @@ test('API', t => { }) t.test('nodesToHost', t => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) const nodes = { a1: { http: { @@ -307,7 +301,7 @@ test('API', t => { t.fail('Should not be called') } } - const pool = new CustomConnectionPool() + const pool = new CustomConnectionPool({ Connection }) pool.addConnection([{ url: new URL('http://127.0.0.1:9200'), id: 'a1', @@ -348,7 +342,7 @@ test('API', t => { super.markAlive(connection) } } - const pool = new CustomConnectionPool() + const pool = new CustomConnectionPool({ Connection }) const conn1 = pool.addConnection({ url: new URL('http://127.0.0.1:9200'), id: 'a1', @@ -388,7 +382,7 @@ test('API', t => { t.test('Add a new connection', t => { t.plan(2) - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection({ url: new URL('http://127.0.0.1:9200'), id: 'a1', @@ -415,7 +409,7 @@ test('API', t => { t.test('Remove old connections', t => { t.plan(3) - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection({ url: new URL('http://127.0.0.1:9200'), id: 'a1', diff --git a/test/unit/events.test.js b/test/unit/events.test.js new file mode 100644 index 000000000..2c8d8f17a --- /dev/null +++ b/test/unit/events.test.js @@ -0,0 +1,106 @@ +'use strict' + +const { test } = require('tap') +const { Client, events } = require('../../index') +const { TimeoutError } = require('../../lib/errors') +const { connection: { MockConnection, MockConnectionTimeout } } = require('../utils') + +test('Should emit a request event when a request is performed', t => { + t.plan(3) + + const client = new Client({ + node: 'http://localhost:9200', + Connection: MockConnection + }) + + client.on(events.REQUEST, (connection, request) => { + t.match(connection, { + id: 'http://localhost:9200' + }) + t.match(request, { + method: 'GET', + path: '/test/doc/_search', + querystring: 'q=foo%3Abar' + }) + }) + + client.search({ + index: 'test', + type: 'doc', + q: 'foo:bar' + }, (err, result) => { + t.error(err) + }) +}) + +test('Should emit a response event in case of a successful response', t => { + t.plan(4) + + const client = new Client({ + node: 'http://localhost:9200', + Connection: MockConnection + }) + + client.on(events.RESPONSE, (connection, request, response) => { + t.match(connection, { + id: 'http://localhost:9200' + }) + t.match(request, { + method: 'GET', + path: '/test/doc/_search', + querystring: 'q=foo%3Abar' + }) + t.match(response, { + body: { hello: 'world' }, + statusCode: 200, + headers: { + 'content-type': 'application/json;utf=8', + 'connection': 'keep-alive' + }, + warnings: null + }) + }) + + client.search({ + index: 'test', + type: 'doc', + q: 'foo:bar' + }, (err, result) => { + t.error(err) + }) +}) + +test('Should emit an error event in case of a failing response', t => { + t.plan(4) + + const client = new Client({ + node: 'http://localhost:9200', + Connection: MockConnectionTimeout, + maxRetries: 0 + }) + + client.on(events.RESPONSE, (connection, request, response) => { + t.fail('This should not be called') + }) + + client.on(events.ERROR, (error, connection, request) => { + t.ok(error instanceof TimeoutError) + t.match(connection, { + id: 'http://localhost:9200' + }) + t.match(request, { + method: 'GET', + path: '/test/doc/_search', + querystring: 'q=foo%3Abar' + }) + }) + + client.search({ + index: 'test', + type: 'doc', + q: 'foo:bar', + requestTimeout: 500 + }, (err, result) => { + t.ok(err instanceof TimeoutError) + }) +}) diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index 894a2d4a3..e47c97c02 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -2,7 +2,10 @@ const { test } = require('tap') const { URL } = require('url') -const { buildServer } = require('../utils') +const { + buildServer, + connection: { MockConnection, MockConnectionTimeout, MockConnectionError } +} = require('../utils') const { NoLivingConnectionsError, SerializationError, @@ -13,6 +16,7 @@ const { } = require('../../lib/errors') const ConnectionPool = require('../../lib/ConnectionPool') +const Connection = require('../../lib/Connection') const Serializer = require('../../lib/Serializer') const Transport = require('../../lib/Transport') @@ -24,7 +28,7 @@ test('Basic', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -67,7 +71,7 @@ test('Send POST', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -123,7 +127,7 @@ test('Send POST (ndjson)', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -156,7 +160,7 @@ test('Not JSON payload from server', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -182,7 +186,7 @@ test('Not JSON payload from server', t => { test('NoLivingConnectionsError', t => { t.plan(1) - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) const transport = new Transport({ emit: () => {}, @@ -204,7 +208,7 @@ test('NoLivingConnectionsError', t => { test('SerializationError', t => { t.plan(1) - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection('http://localhost:9200') const transport = new Transport({ @@ -236,7 +240,7 @@ test('DeserializationError', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -269,37 +273,27 @@ test('TimeoutError (should call markDead on the failing connection)', t => { } } - function handler (req, res) { - setTimeout(() => { - res.setHeader('Content-Type', 'application/json;utf=8') - res.end(JSON.stringify({ hello: 'world' })) - }, 1000) - } + const pool = new CustomConnectionPool({ Connection: MockConnectionTimeout }) + pool.addConnection({ + url: new URL('http://localhost:9200'), + id: 'node1' + }) - buildServer(handler, ({ port }, server) => { - const pool = new CustomConnectionPool() - pool.addConnection({ - url: new URL(`http://localhost:${port}`), - id: 'node1' - }) + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 0, + requestTimeout: 500, + sniffInterval: false, + sniffOnStart: false + }) - const transport = new Transport({ - emit: () => {}, - connectionPool: pool, - serializer: new Serializer(), - maxRetries: 0, - requestTimeout: 500, - sniffInterval: false, - sniffOnStart: false - }) - - transport.request({ - method: 'GET', - path: '/hello' - }, (err, { body }) => { - t.ok(err instanceof TimeoutError) - server.stop() - }) + transport.request({ + method: 'GET', + path: '/hello' + }, (err, { body }) => { + t.ok(err instanceof TimeoutError) }) }) @@ -313,31 +307,27 @@ test('ConnectionError (should call markDead on the failing connection)', t => { } } - buildServer(() => {}, ({ port }, server) => { - server.close() - const pool = new CustomConnectionPool() - pool.addConnection({ - url: new URL(`http://localhost:${port}`), - id: 'node1' - }) + const pool = new CustomConnectionPool({ Connection: MockConnectionError }) + pool.addConnection({ + url: new URL('http://localhost:9200'), + id: 'node1' + }) - const transport = new Transport({ - emit: () => {}, - connectionPool: pool, - serializer: new Serializer(), - maxRetries: 0, - requestTimeout: 30000, - sniffInterval: false, - sniffOnStart: false - }) + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 0, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) - transport.request({ - method: 'GET', - path: '/hello' - }, (err, { body }) => { - t.ok(err instanceof ConnectionError) - server.stop() - }) + transport.request({ + method: 'GET', + path: '/hello' + }, (err, { body }) => { + t.ok(err instanceof ConnectionError) }) }) @@ -358,7 +348,7 @@ test('Retry mechanism', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection([{ url: new URL(`http://localhost:${port}`), id: 'node1' @@ -401,36 +391,28 @@ test('Should call markAlive with a successful response', t => { } } - function handler (req, res) { - res.setHeader('Content-Type', 'application/json;utf=8') - res.end(JSON.stringify({ hello: 'world' })) - } + const pool = new CustomConnectionPool({ Connection: MockConnection }) + pool.addConnection({ + url: new URL('http://localhost:9200'), + id: 'node1' + }) - buildServer(handler, ({ port }, server) => { - const pool = new CustomConnectionPool() - pool.addConnection({ - url: new URL(`http://localhost:${port}`), - id: 'node1' - }) + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) - const transport = new Transport({ - emit: () => {}, - connectionPool: pool, - serializer: new Serializer(), - maxRetries: 3, - requestTimeout: 30000, - sniffInterval: false, - sniffOnStart: false - }) - - transport.request({ - method: 'GET', - path: '/hello' - }, (err, { body }) => { - t.error(err) - t.deepEqual(body, { hello: 'world' }) - server.stop() - }) + transport.request({ + method: 'GET', + path: '/hello' + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) }) }) @@ -443,77 +425,59 @@ test('Should call resurrect on every request', t => { } } - function handler (req, res) { - res.setHeader('Content-Type', 'application/json;utf=8') - res.end(JSON.stringify({ hello: 'world' })) - } + const pool = new CustomConnectionPool({ Connection: MockConnection }) + pool.addConnection({ + url: new URL('http://localhost:9200'), + id: 'node1' + }) - buildServer(handler, ({ port }, server) => { - const pool = new CustomConnectionPool() - pool.addConnection({ - url: new URL(`http://localhost:${port}`), - id: 'node1' - }) + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) - const transport = new Transport({ - emit: () => {}, - connectionPool: pool, - serializer: new Serializer(), - maxRetries: 3, - requestTimeout: 30000, - sniffInterval: false, - sniffOnStart: false - }) - - transport.request({ - method: 'GET', - path: '/hello' - }, (err, { body }) => { - t.error(err) - t.deepEqual(body, { hello: 'world' }) - server.stop() - }) + transport.request({ + method: 'GET', + path: '/hello' + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) }) }) test('Should return a request aborter utility', t => { t.plan(1) - function handler (req, res) { - setTimeout(() => { - res.setHeader('Content-Type', 'application/json;utf=8') - res.end(JSON.stringify({ hello: 'world' })) - }, 1000) - } - - buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() - pool.addConnection({ - url: new URL(`http://localhost:${port}`), - id: 'node1' - }) - - const transport = new Transport({ - emit: () => {}, - connectionPool: pool, - serializer: new Serializer(), - maxRetries: 3, - requestTimeout: 30000, - sniffInterval: false, - sniffOnStart: false - }) - - const request = transport.request({ - method: 'GET', - path: '/hello' - }, (_err, body) => { - t.fail('Should not be called') - }) - - request.abort() - server.stop() - t.pass('ok') + const pool = new ConnectionPool({ Connection, MockConnection }) + pool.addConnection({ + url: new URL('http://localhost:9200'), + id: 'node1' }) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + const request = transport.request({ + method: 'GET', + path: '/hello' + }, (_err, body) => { + t.fail('Should not be called') + }) + + request.abort() + t.pass('ok') }) test('ResponseError', t => { @@ -526,7 +490,7 @@ test('ResponseError', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -561,7 +525,7 @@ test('Override requestTimeout', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -609,7 +573,7 @@ test('sniff', t => { } buildServer(handler, ({ port }, server) => { - const pool = new CustomConnectionPool() + const pool = new CustomConnectionPool({ Connection }) pool.addConnection(`http://localhost:${port}`) // eslint-disable-next-line @@ -653,7 +617,7 @@ test('sniff', t => { } buildServer(handler, ({ port }, server) => { - const pool = new CustomConnectionPool() + const pool = new CustomConnectionPool({ Connection }) pool.addConnection(`http://localhost:${port}`) pool.addConnection(`http://localhost:${port}/other`) @@ -700,7 +664,7 @@ test('sniff', t => { } buildServer(handler, ({ port }, server) => { - const pool = new CustomConnectionPool() + const pool = new CustomConnectionPool({ Connection }) pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -741,25 +705,21 @@ test('sniff', t => { } } - buildServer(() => {}, ({ port }, server) => { - server.close() - const pool = new CustomConnectionPool() - pool.addConnection(`http://localhost:${port}`) + const pool = new CustomConnectionPool({ Connection: MockConnectionError }) + pool.addConnection('http://localhost:9200') - const transport = new Transport({ - emit: () => {}, - connectionPool: pool, - serializer: new Serializer(), - maxRetries: 0, - requestTimeout: 30000, - sniffInterval: false, - sniffEndpoint: '/sniff' - }) + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 0, + requestTimeout: 30000, + sniffInterval: false, + sniffEndpoint: '/sniff' + }) - transport.sniff((err, hosts) => { - t.ok(err instanceof ConnectionError) - server.stop() - }) + transport.sniff((err, hosts) => { + t.ok(err instanceof ConnectionError) }) }) @@ -773,11 +733,6 @@ test(`Should mark as dead connections where the statusCode is 502/3/4 function runTest (statusCode) { t.test(statusCode, t => { t.plan(3) - function handler (req, res) { - res.statusCode = statusCode - res.setHeader('Content-Type', 'application/json;utf=8') - res.end(JSON.stringify({ hello: 'world' })) - } class CustomConnectionPool extends ConnectionPool { markDead (connection) { @@ -786,31 +741,28 @@ test(`Should mark as dead connections where the statusCode is 502/3/4 } } - buildServer(handler, ({ port }, server) => { - const pool = new CustomConnectionPool() - pool.addConnection(`http://localhost:${port}`) + const pool = new CustomConnectionPool({ Connection: MockConnection }) + pool.addConnection('http://localhost:9200') - const transport = new Transport({ - emit: () => {}, - connectionPool: pool, - serializer: new Serializer(), - maxRetries: 0, - requestTimeout: 30000, - sniffInterval: false, - sniffOnStart: false - }) + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 0, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) - transport.request({ - method: 'GET', - path: '/hello' - }, (err, { body }) => { - t.ok(err instanceof ResponseError) - t.match(err, { - body: { hello: 'world' }, - headers: { 'content-type': 'application/json;utf=8' }, - statusCode: statusCode - }) - server.stop() + transport.request({ + method: 'GET', + path: `/${statusCode}` + }, (err, { body }) => { + t.ok(err instanceof ResponseError) + t.match(err, { + body: { hello: 'world' }, + headers: { 'content-type': 'application/json;utf=8' }, + statusCode: statusCode }) }) }) @@ -843,7 +795,7 @@ test('Should retry the request if the statusCode is 502/3/4', t => { } buildServer(handler, ({ port }, server) => { - const pool = new CustomConnectionPool() + const pool = new CustomConnectionPool({ Connection }) pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -873,51 +825,42 @@ test('Should retry the request if the statusCode is 502/3/4', t => { test('Ignore status code', t => { t.plan(4) - function handler (req, res) { - res.statusCode = 404 - res.setHeader('Content-Type', 'application/json;utf=8') - res.end(JSON.stringify({ hello: 'world' })) - } - buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() - pool.addConnection(`http://localhost:${port}`) + const pool = new ConnectionPool({ Connection: MockConnection }) + pool.addConnection('http://localhost:9200') - const transport = new Transport({ - emit: () => {}, - connectionPool: pool, - serializer: new Serializer(), - maxRetries: 3, - requestTimeout: 30000, - sniffInterval: false, - sniffOnStart: false - }) + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) - transport.request({ - method: 'GET', - path: '/hello', - ignore: [404] - }, (err, { body }) => { - t.error(err) - t.deepEqual(body, { hello: 'world' }) - }) + transport.request({ + method: 'GET', + path: '/404', + ignore: [404] + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + }) - transport.request({ - method: 'GET', - path: '/hello' - }, (err, { body }) => { - t.ok(err instanceof ResponseError) - }) + transport.request({ + method: 'GET', + path: '/404' + }, (err, { body }) => { + t.ok(err instanceof ResponseError) + }) - transport.request({ - method: 'GET', - path: '/hello', - ignore: [403, 405] - }, (err, { body }) => { - t.ok(err instanceof ResponseError) - }) - - setTimeout(() => server.stop(), 100) + transport.request({ + method: 'GET', + path: '/404', + ignore: [403, 405] + }, (err, { body }) => { + t.ok(err instanceof ResponseError) }) }) @@ -930,7 +873,7 @@ test('Should serialize the querystring', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -970,7 +913,7 @@ test('timeout option', t => { t.plan(1) buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection({ url: new URL(`http://localhost:${port}`), id: 'node1' @@ -1000,7 +943,7 @@ test('timeout option', t => { t.plan(1) buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection({ url: new URL(`http://localhost:${port}`), id: 'node1' @@ -1035,7 +978,7 @@ test('timeout option', t => { t.plan(1) buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection({ url: new URL(`http://localhost:${port}`), id: 'node1' @@ -1065,7 +1008,7 @@ test('timeout option', t => { t.plan(1) buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection({ url: new URL(`http://localhost:${port}`), id: 'node1' @@ -1100,131 +1043,101 @@ test('timeout option', t => { test('Should cast to boolean HEAD request', t => { t.test('2xx response', t => { - t.plan(2) - function handler (req, res) { - res.setHeader('Content-Type', 'application/json;utf=8') - res.end('') - } + t.plan(3) + const pool = new ConnectionPool({ Connection: MockConnection }) + pool.addConnection('http://localhost:9200') - buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() - pool.addConnection(`http://localhost:${port}`) + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) - const transport = new Transport({ - emit: () => {}, - connectionPool: pool, - serializer: new Serializer(), - maxRetries: 3, - requestTimeout: 30000, - sniffInterval: false, - sniffOnStart: false - }) - - transport.request({ - method: 'HEAD', - path: '/hello' - }, (err, { body }) => { - t.error(err) - t.strictEqual(body, true) - server.stop() - }) + transport.request({ + method: 'HEAD', + path: '/200' + }, (err, { body, statusCode }) => { + t.error(err) + t.strictEqual(statusCode, 200) + t.strictEqual(body, true) }) }) t.test('404 response', t => { - t.plan(2) - function handler (req, res) { - res.statusCode = 404 - res.setHeader('Content-Type', 'application/json;utf=8') - res.end('') - } + t.plan(3) + const pool = new ConnectionPool({ Connection: MockConnection }) + pool.addConnection('http://localhost:9200') - buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() - pool.addConnection(`http://localhost:${port}`) + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) - const transport = new Transport({ - emit: () => {}, - connectionPool: pool, - serializer: new Serializer(), - maxRetries: 3, - requestTimeout: 30000, - sniffInterval: false, - sniffOnStart: false - }) - - transport.request({ - method: 'HEAD', - path: '/hello' - }, (err, { body }) => { - t.error(err) - t.strictEqual(body, false) - server.stop() - }) + transport.request({ + method: 'HEAD', + path: '/404' + }, (err, { body, statusCode }) => { + t.error(err) + t.strictEqual(statusCode, 404) + t.strictEqual(body, false) }) }) t.test('4xx response', t => { - t.plan(1) - function handler (req, res) { - res.statusCode = 400 - res.setHeader('Content-Type', 'application/json;utf=8') - res.end(JSON.stringify({ hello: 'world' })) - } + t.plan(2) - buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() - pool.addConnection(`http://localhost:${port}`) + const pool = new ConnectionPool({ Connection: MockConnection }) + pool.addConnection('http://localhost:9200') - const transport = new Transport({ - emit: () => {}, - connectionPool: pool, - serializer: new Serializer(), - maxRetries: 3, - requestTimeout: 30000, - sniffInterval: false, - sniffOnStart: false - }) + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) - transport.request({ - method: 'HEAD', - path: '/hello' - }, (err, { body }) => { - t.ok(err instanceof ResponseError) - server.stop() - }) + transport.request({ + method: 'HEAD', + path: '/400' + }, (err, { body, statusCode }) => { + t.ok(err instanceof ResponseError) + t.strictEqual(statusCode, 400) }) }) t.test('5xx response', t => { - t.plan(1) - function handler (req, res) { - res.statusCode = 500 - res.setHeader('Content-Type', 'application/json;utf=8') - res.end(JSON.stringify({ hello: 'world' })) - } + t.plan(2) + const pool = new ConnectionPool({ Connection: MockConnection }) + pool.addConnection('http://localhost:9200') - buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() - pool.addConnection(`http://localhost:${port}`) + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) - const transport = new Transport({ - emit: () => {}, - connectionPool: pool, - serializer: new Serializer(), - maxRetries: 3, - requestTimeout: 30000, - sniffInterval: false, - sniffOnStart: false - }) - - transport.request({ - method: 'HEAD', - path: '/hello' - }, (err, { body }) => { - t.ok(err instanceof ResponseError) - server.stop() - }) + transport.request({ + method: 'HEAD', + path: '/500' + }, (err, { body, statusCode }) => { + t.ok(err instanceof ResponseError) + t.strictEqual(statusCode, 500) }) }) @@ -1242,7 +1155,7 @@ test('Suggest compression', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -1278,7 +1191,7 @@ test('Warning header', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -1315,7 +1228,7 @@ test('Warning header', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -1349,7 +1262,7 @@ test('Warning header', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ @@ -1384,7 +1297,7 @@ test('asStream set to true', t => { } buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool() + const pool = new ConnectionPool({ Connection }) pool.addConnection(`http://localhost:${port}`) const transport = new Transport({ diff --git a/test/utils/MockConnection.js b/test/utils/MockConnection.js new file mode 100644 index 000000000..6e751b897 --- /dev/null +++ b/test/utils/MockConnection.js @@ -0,0 +1,65 @@ +'use strict' + +const { Connection } = require('../../index') +const { TimeoutError } = require('../../lib/errors') +const intoStream = require('into-stream') + +class MockConnection extends Connection { + request (params, callback) { + var aborted = false + const stream = intoStream(JSON.stringify({ hello: 'world' })) + stream.statusCode = setStatusCode(params.path) + stream.headers = { + 'content-type': 'application/json;utf=8', + 'date': new Date().toISOString(), + 'connection': 'keep-alive', + 'content-length': '17' + } + process.nextTick(() => { + if (!aborted) { + callback(null, stream) + } + }) + return { + abort: () => { aborted = true } + } + } +} + +class MockConnectionTimeout extends Connection { + request (params, callback) { + var aborted = false + process.nextTick(() => { + if (!aborted) { + callback(new TimeoutError('Request timed out', params), null) + } + }) + return { + abort: () => { aborted = true } + } + } +} + +class MockConnectionError extends Connection { + request (params, callback) { + var aborted = false + process.nextTick(() => { + if (!aborted) { + callback(new Error('Kaboom'), null) + } + }) + return { + abort: () => { aborted = true } + } + } +} + +function setStatusCode (path) { + const statusCode = Number(path.slice(1)) + if (Number.isInteger(statusCode)) { + return statusCode + } + return 200 +} + +module.exports = { MockConnection, MockConnectionTimeout, MockConnectionError } diff --git a/test/utils/index.js b/test/utils/index.js index af44045c1..c35e6c5c4 100644 --- a/test/utils/index.js +++ b/test/utils/index.js @@ -1,7 +1,9 @@ 'use strict' const buildServer = require('./buildServer') +const connection = require('./MockConnection') module.exports = { - buildServer + buildServer, + connection } From 77f99e7761558e381b92ffd32ae8ef85625209b7 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 19 Nov 2018 11:35:11 +0100 Subject: [PATCH 049/172] Updated scripts --- scripts/utils/clone-es.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/utils/clone-es.js b/scripts/utils/clone-es.js index 4d424c00a..ad4ec69e6 100644 --- a/scripts/utils/clone-es.js +++ b/scripts/utils/clone-es.js @@ -47,7 +47,7 @@ function cloneAndCheckout (opts, callback) { git.checkout(tag, err => { if (err) { if (retry++ > 0) { - callback(new Error(`Cannot checkout tag '${tag}'`)) + callback(new Error(`Cannot checkout tag '${tag}'`), { apiFolder, xPackFolder }) return } return pull(checkout) @@ -60,7 +60,7 @@ function cloneAndCheckout (opts, callback) { log.text = 'Pulling elasticsearch repository...' git.pull(err => { if (err) { - callback(err) + callback(err, { apiFolder, xPackFolder }) return } cb() @@ -71,7 +71,7 @@ function cloneAndCheckout (opts, callback) { log.text = 'Cloning elasticsearch repository...' git.clone(esRepo, esFolder, err => { if (err) { - callback(err) + callback(err, { apiFolder, xPackFolder }) return } cb() From 4ad6c255d66e5c2f221dfcc53acfb109944ef0cf Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 19 Nov 2018 12:39:54 +0100 Subject: [PATCH 050/172] Bumped v0.1.0-alpha.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 88cebd6f0..4f8ce0d91 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "The official Elasticsearch client for Node.js", "main": "index.js", "homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html", - "version": "0.1.0-alpha.0", + "version": "0.1.0-alpha.1", "keywords": [ "elasticsearch", "elastic", From 79b4187f306e6285b10ca487c10e02370a64b6f4 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 20 Nov 2018 18:51:23 +0100 Subject: [PATCH 051/172] WIP: initial prototype - Hide auth data from Node ID - Added support for sending streams --- lib/Connection.js | 25 ++++++++++++++++++++++--- lib/Transport.js | 23 ++++++++++++++++++----- package.json | 3 ++- 3 files changed, 42 insertions(+), 9 deletions(-) diff --git a/lib/Connection.js b/lib/Connection.js index 028cfdf51..074132ef2 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -5,14 +5,14 @@ const http = require('http') const https = require('https') const debug = require('debug')('elasticsearch') const decompressResponse = require('decompress-response') +const pump = require('pump') const { TimeoutError } = require('./errors') class Connection { constructor (opts = {}) { this.url = opts.url this.ssl = opts.ssl || null - // TODO: clean user:password from id - this.id = opts.id || opts.url.href + this.id = opts.id || stripAuth(opts.url.href) this.headers = opts.headers || null this.deadCount = 0 this.resurrectTimeout = 0 @@ -81,7 +81,17 @@ class Connection { request.setNoDelay(true) // starts the request - request.end(params.body) + if (isStream(params.body) === true) { + pump(params.body, request, err => { + if (err != null && ended === false) { + ended = true + this._openRequests-- + callback(err) + } + }) + } else { + request.end(params.body) + } return request } @@ -191,6 +201,15 @@ const validStatuses = Object.keys(Connection.statuses) const validRoles = Object.keys(Connection.roles) .map(k => Connection.roles[k]) +function stripAuth (url) { + if (url.indexOf('@') === -1) return url + return url.slice(0, url.indexOf('//') + 2) + url.slice(url.indexOf('@') + 1) +} + +function isStream (obj) { + return obj != null && typeof obj.pipe === 'function' +} + function resolve (host, path) { const hostEndWithSlash = host[host.length - 1] === '/' const pathStartsWithSlash = path[0] === '/' diff --git a/lib/Transport.js b/lib/Transport.js index 83e4445c3..2bd74f8c5 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -34,7 +34,6 @@ class Transport { } } - // TODO: should be able to send a stream of json data request (params, callback) { callback = once(callback) const result = { body: null, statusCode: null, headers: null, warnings: null } @@ -47,7 +46,7 @@ class Transport { params.headers = params.headers || {} // handle json body if (params.body != null) { - if (typeof params.body !== 'string') { + if (shouldSerialize(params.body) === true) { try { params.body = this.serializer.serialize(params.body) } catch (err) { @@ -55,10 +54,12 @@ class Transport { } } params.headers['Content-Type'] = 'application/json' - params.headers['Content-Length'] = '' + Buffer.byteLength(params.body) + if (isStream(params.body) === false) { + params.headers['Content-Length'] = '' + Buffer.byteLength(params.body) + } // handle ndjson body } else if (params.bulkBody != null) { - if (typeof params.bulkBody !== 'string') { + if (shouldSerialize(params.bulkBody) === true) { try { params.body = this.serializer.ndserialize(params.bulkBody) } catch (err) { @@ -68,7 +69,9 @@ class Transport { params.body = params.bulkBody } params.headers['Content-Type'] = 'application/x-ndjson' - params.headers['Content-Length'] = '' + Buffer.byteLength(params.body) + if (isStream(params.body) === false) { + params.headers['Content-Length'] = '' + Buffer.byteLength(params.body) + } } if (this.suggestCompression === true) { @@ -239,4 +242,14 @@ function toMs (time) { return time } +function shouldSerialize (obj) { + return typeof obj !== 'string' && + typeof obj.pipe !== 'function' && + Buffer.isBuffer(obj) === false +} + +function isStream (obj) { + return typeof obj.pipe === 'function' +} + module.exports = Transport diff --git a/package.json b/package.json index 4f8ce0d91..9776ac6cb 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,8 @@ "debug": "^4.1.0", "decompress-response": "^3.3.0", "ms": "^2.1.1", - "once": "^1.4.0" + "once": "^1.4.0", + "pump": "^3.0.0" }, "license": "Apache-2.0", "repository": { From 53329e48bcf394cba70ef63b41b05eb7b02e9946 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 20 Nov 2018 18:52:22 +0100 Subject: [PATCH 052/172] Updated test --- test/unit/connection.test.js | 66 +++++++++++++++++++++++++++ test/unit/transport.test.js | 87 ++++++++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+) diff --git a/test/unit/connection.test.js b/test/unit/connection.test.js index 5a1316b46..07eccf053 100644 --- a/test/unit/connection.test.js +++ b/test/unit/connection.test.js @@ -266,6 +266,64 @@ test('Body request', t => { }) }) +test('Send body as buffer', t => { + t.plan(2) + + function handler (req, res) { + var payload = '' + req.setEncoding('utf8') + req.on('data', chunk => { payload += chunk }) + req.on('error', err => t.fail(err)) + req.on('end', () => { + t.strictEqual(payload, 'hello') + res.end('ok') + }) + } + + buildServer(handler, ({ port }, server) => { + const connection = new Connection({ + url: new URL(`http://localhost:${port}`) + }) + connection.request({ + path: '/hello', + method: 'POST', + body: Buffer.from('hello') + }, (err, res) => { + t.error(err) + server.stop() + }) + }) +}) + +test('Send body as stream', t => { + t.plan(2) + + function handler (req, res) { + var payload = '' + req.setEncoding('utf8') + req.on('data', chunk => { payload += chunk }) + req.on('error', err => t.fail(err)) + req.on('end', () => { + t.strictEqual(payload, 'hello') + res.end('ok') + }) + } + + buildServer(handler, ({ port }, server) => { + const connection = new Connection({ + url: new URL(`http://localhost:${port}`) + }) + connection.request({ + path: '/hello', + method: 'POST', + body: intoStream('hello') + }, (err, res) => { + t.error(err) + server.stop() + }) + }) +}) + test('Should handle compression', t => { t.test('gzip', t => { t.plan(3) @@ -494,3 +552,11 @@ test('asStream set to true', t => { }) }) }) + +test('Connection id should not contain credentials', t => { + const connection = new Connection({ + url: new URL('http://user:password@localhost:9200') + }) + t.strictEqual(connection.id, 'http://localhost:9200/') + t.end() +}) diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index e47c97c02..33c9427ec 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -2,6 +2,7 @@ const { test } = require('tap') const { URL } = require('url') +const intoStream = require('into-stream') const { buildServer, connection: { MockConnection, MockConnectionTimeout, MockConnectionError } @@ -152,6 +153,92 @@ test('Send POST (ndjson)', t => { }) }) +test('Send stream', t => { + t.plan(4) + function handler (req, res) { + t.match(req.headers, { + 'content-type': 'application/json' + }) + var json = '' + req.setEncoding('utf8') + req.on('data', chunk => { json += chunk }) + req.on('error', err => t.fail(err)) + req.on('end', () => { + t.deepEqual(JSON.parse(json), { hello: 'world' }) + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + }) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ Connection }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'POST', + path: '/hello', + body: intoStream(JSON.stringify({ hello: 'world' })) + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + server.stop() + }) + }) +}) + +test('Send stream (bulkBody)', t => { + t.plan(4) + function handler (req, res) { + t.match(req.headers, { + 'content-type': 'application/x-ndjson' + }) + var json = '' + req.setEncoding('utf8') + req.on('data', chunk => { json += chunk }) + req.on('error', err => t.fail(err)) + req.on('end', () => { + t.deepEqual(JSON.parse(json), { hello: 'world' }) + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + }) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ Connection }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'POST', + path: '/hello', + bulkBody: intoStream(JSON.stringify({ hello: 'world' })) + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + server.stop() + }) + }) +}) + test('Not JSON payload from server', t => { t.plan(2) function handler (req, res) { From e20961fb3ae81f5fa5173cb294af073ce8d751e9 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 21 Nov 2018 11:15:06 +0100 Subject: [PATCH 053/172] API generation --- api/index.js | 1019 ++++++++++++++++++++------------------------------ 1 file changed, 399 insertions(+), 620 deletions(-) diff --git a/api/index.js b/api/index.js index 7417f3b6c..878b8e497 100644 --- a/api/index.js +++ b/api/index.js @@ -2,668 +2,430 @@ const assert = require('assert') -const bulk = require('./api/bulk.js') -const catAliases = require('./api/cat.aliases.js') -const catAllocation = require('./api/cat.allocation.js') -const catCount = require('./api/cat.count.js') -const catFielddata = require('./api/cat.fielddata.js') -const catHealth = require('./api/cat.health.js') -const catHelp = require('./api/cat.help.js') -const catIndices = require('./api/cat.indices.js') -const catMaster = require('./api/cat.master.js') -const catNodeattrs = require('./api/cat.nodeattrs.js') -const catNodes = require('./api/cat.nodes.js') -const catPendingTasks = require('./api/cat.pending_tasks.js') -const catPlugins = require('./api/cat.plugins.js') -const catRecovery = require('./api/cat.recovery.js') -const catRepositories = require('./api/cat.repositories.js') -const catSegments = require('./api/cat.segments.js') -const catShards = require('./api/cat.shards.js') -const catSnapshots = require('./api/cat.snapshots.js') -const catTasks = require('./api/cat.tasks.js') -const catTemplates = require('./api/cat.templates.js') -const catThreadPool = require('./api/cat.thread_pool.js') -const ccrDeleteAutoFollowPattern = require('./api/ccr.delete_auto_follow_pattern.js') -const ccrFollow = require('./api/ccr.follow.js') -const ccrFollowStats = require('./api/ccr.follow_stats.js') -const ccrGetAutoFollowPattern = require('./api/ccr.get_auto_follow_pattern.js') -const ccrPauseFollow = require('./api/ccr.pause_follow.js') -const ccrPutAutoFollowPattern = require('./api/ccr.put_auto_follow_pattern.js') -const ccrResumeFollow = require('./api/ccr.resume_follow.js') -const ccrStats = require('./api/ccr.stats.js') -const ccrUnfollow = require('./api/ccr.unfollow.js') -const clearScroll = require('./api/clear_scroll.js') -const clusterAllocationExplain = require('./api/cluster.allocation_explain.js') -const clusterGetSettings = require('./api/cluster.get_settings.js') -const clusterHealth = require('./api/cluster.health.js') -const clusterPendingTasks = require('./api/cluster.pending_tasks.js') -const clusterPutSettings = require('./api/cluster.put_settings.js') -const clusterRemoteInfo = require('./api/cluster.remote_info.js') -const clusterReroute = require('./api/cluster.reroute.js') -const clusterState = require('./api/cluster.state.js') -const clusterStats = require('./api/cluster.stats.js') -const count = require('./api/count.js') -const create = require('./api/create.js') -const _delete = require('./api/delete.js') -const deleteByQuery = require('./api/delete_by_query.js') -const deleteByQueryRethrottle = require('./api/delete_by_query_rethrottle.js') -const deleteScript = require('./api/delete_script.js') -const exists = require('./api/exists.js') -const existsSource = require('./api/exists_source.js') -const explain = require('./api/explain.js') -const fieldCaps = require('./api/field_caps.js') -const get = require('./api/get.js') -const getScript = require('./api/get_script.js') -const getSource = require('./api/get_source.js') -const index = require('./api/index.js') -const indicesAnalyze = require('./api/indices.analyze.js') -const indicesClearCache = require('./api/indices.clear_cache.js') -const indicesClose = require('./api/indices.close.js') -const indicesCreate = require('./api/indices.create.js') -const indicesDelete = require('./api/indices.delete.js') -const indicesDeleteAlias = require('./api/indices.delete_alias.js') -const indicesDeleteTemplate = require('./api/indices.delete_template.js') -const indicesExists = require('./api/indices.exists.js') -const indicesExistsAlias = require('./api/indices.exists_alias.js') -const indicesExistsTemplate = require('./api/indices.exists_template.js') -const indicesExistsType = require('./api/indices.exists_type.js') -const indicesFlush = require('./api/indices.flush.js') -const indicesFlushSynced = require('./api/indices.flush_synced.js') -const indicesForcemerge = require('./api/indices.forcemerge.js') -const indicesGet = require('./api/indices.get.js') -const indicesGetAlias = require('./api/indices.get_alias.js') -const indicesGetFieldMapping = require('./api/indices.get_field_mapping.js') -const indicesGetMapping = require('./api/indices.get_mapping.js') -const indicesGetSettings = require('./api/indices.get_settings.js') -const indicesGetTemplate = require('./api/indices.get_template.js') -const indicesGetUpgrade = require('./api/indices.get_upgrade.js') -const indicesOpen = require('./api/indices.open.js') -const indicesPutAlias = require('./api/indices.put_alias.js') -const indicesPutMapping = require('./api/indices.put_mapping.js') -const indicesPutSettings = require('./api/indices.put_settings.js') -const indicesPutTemplate = require('./api/indices.put_template.js') -const indicesRecovery = require('./api/indices.recovery.js') -const indicesRefresh = require('./api/indices.refresh.js') -const indicesRollover = require('./api/indices.rollover.js') -const indicesSegments = require('./api/indices.segments.js') -const indicesShardStores = require('./api/indices.shard_stores.js') -const indicesShrink = require('./api/indices.shrink.js') -const indicesSplit = require('./api/indices.split.js') -const indicesStats = require('./api/indices.stats.js') -const indicesUpdateAliases = require('./api/indices.update_aliases.js') -const indicesUpgrade = require('./api/indices.upgrade.js') -const indicesValidateQuery = require('./api/indices.validate_query.js') -const info = require('./api/info.js') -const ingestDeletePipeline = require('./api/ingest.delete_pipeline.js') -const ingestGetPipeline = require('./api/ingest.get_pipeline.js') -const ingestProcessorGrok = require('./api/ingest.processor_grok.js') -const ingestPutPipeline = require('./api/ingest.put_pipeline.js') -const ingestSimulate = require('./api/ingest.simulate.js') -const mget = require('./api/mget.js') -const msearch = require('./api/msearch.js') -const msearchTemplate = require('./api/msearch_template.js') -const mtermvectors = require('./api/mtermvectors.js') -const nodesHotThreads = require('./api/nodes.hot_threads.js') -const nodesInfo = require('./api/nodes.info.js') -const nodesReloadSecureSettings = require('./api/nodes.reload_secure_settings.js') -const nodesStats = require('./api/nodes.stats.js') -const nodesUsage = require('./api/nodes.usage.js') -const ping = require('./api/ping.js') -const putScript = require('./api/put_script.js') -const rankEval = require('./api/rank_eval.js') -const reindex = require('./api/reindex.js') -const reindexRethrottle = require('./api/reindex_rethrottle.js') -const renderSearchTemplate = require('./api/render_search_template.js') -const scriptsPainlessExecute = require('./api/scripts_painless_execute.js') -const scroll = require('./api/scroll.js') -const search = require('./api/search.js') -const searchShards = require('./api/search_shards.js') -const searchTemplate = require('./api/search_template.js') -const snapshotCreate = require('./api/snapshot.create.js') -const snapshotCreateRepository = require('./api/snapshot.create_repository.js') -const snapshotDelete = require('./api/snapshot.delete.js') -const snapshotDeleteRepository = require('./api/snapshot.delete_repository.js') -const snapshotGet = require('./api/snapshot.get.js') -const snapshotGetRepository = require('./api/snapshot.get_repository.js') -const snapshotRestore = require('./api/snapshot.restore.js') -const snapshotStatus = require('./api/snapshot.status.js') -const snapshotVerifyRepository = require('./api/snapshot.verify_repository.js') -const tasksCancel = require('./api/tasks.cancel.js') -const tasksGet = require('./api/tasks.get.js') -const tasksList = require('./api/tasks.list.js') -const termvectors = require('./api/termvectors.js') -const update = require('./api/update.js') -const updateByQuery = require('./api/update_by_query.js') -const updateByQueryRethrottle = require('./api/update_by_query_rethrottle.js') -const xpackGraphExplore = require('./api/xpack.graph.explore.js') -const xpackInfo = require('./api/xpack.info.js') -const xpackLicenseDelete = require('./api/xpack.license.delete.js') -const xpackLicenseGet = require('./api/xpack.license.get.js') -const xpackLicenseGetBasicStatus = require('./api/xpack.license.get_basic_status.js') -const xpackLicenseGetTrialStatus = require('./api/xpack.license.get_trial_status.js') -const xpackLicensePost = require('./api/xpack.license.post.js') -const xpackLicensePostStartBasic = require('./api/xpack.license.post_start_basic.js') -const xpackLicensePostStartTrial = require('./api/xpack.license.post_start_trial.js') -const xpackMigrationDeprecations = require('./api/xpack.migration.deprecations.js') -const xpackMigrationGetAssistance = require('./api/xpack.migration.get_assistance.js') -const xpackMigrationUpgrade = require('./api/xpack.migration.upgrade.js') -const xpackMlCloseJob = require('./api/xpack.ml.close_job.js') -const xpackMlDeleteCalendar = require('./api/xpack.ml.delete_calendar.js') -const xpackMlDeleteCalendarEvent = require('./api/xpack.ml.delete_calendar_event.js') -const xpackMlDeleteCalendarJob = require('./api/xpack.ml.delete_calendar_job.js') -const xpackMlDeleteDatafeed = require('./api/xpack.ml.delete_datafeed.js') -const xpackMlDeleteExpiredData = require('./api/xpack.ml.delete_expired_data.js') -const xpackMlDeleteFilter = require('./api/xpack.ml.delete_filter.js') -const xpackMlDeleteForecast = require('./api/xpack.ml.delete_forecast.js') -const xpackMlDeleteJob = require('./api/xpack.ml.delete_job.js') -const xpackMlDeleteModelSnapshot = require('./api/xpack.ml.delete_model_snapshot.js') -const xpackMlFindFileStructure = require('./api/xpack.ml.find_file_structure.js') -const xpackMlFlushJob = require('./api/xpack.ml.flush_job.js') -const xpackMlForecast = require('./api/xpack.ml.forecast.js') -const xpackMlGetBuckets = require('./api/xpack.ml.get_buckets.js') -const xpackMlGetCalendarEvents = require('./api/xpack.ml.get_calendar_events.js') -const xpackMlGetCalendars = require('./api/xpack.ml.get_calendars.js') -const xpackMlGetCategories = require('./api/xpack.ml.get_categories.js') -const xpackMlGetDatafeedStats = require('./api/xpack.ml.get_datafeed_stats.js') -const xpackMlGetDatafeeds = require('./api/xpack.ml.get_datafeeds.js') -const xpackMlGetFilters = require('./api/xpack.ml.get_filters.js') -const xpackMlGetInfluencers = require('./api/xpack.ml.get_influencers.js') -const xpackMlGetJobStats = require('./api/xpack.ml.get_job_stats.js') -const xpackMlGetJobs = require('./api/xpack.ml.get_jobs.js') -const xpackMlGetModelSnapshots = require('./api/xpack.ml.get_model_snapshots.js') -const xpackMlGetOverallBuckets = require('./api/xpack.ml.get_overall_buckets.js') -const xpackMlGetRecords = require('./api/xpack.ml.get_records.js') -const xpackMlInfo = require('./api/xpack.ml.info.js') -const xpackMlOpenJob = require('./api/xpack.ml.open_job.js') -const xpackMlPostCalendarEvents = require('./api/xpack.ml.post_calendar_events.js') -const xpackMlPostData = require('./api/xpack.ml.post_data.js') -const xpackMlPreviewDatafeed = require('./api/xpack.ml.preview_datafeed.js') -const xpackMlPutCalendar = require('./api/xpack.ml.put_calendar.js') -const xpackMlPutCalendarJob = require('./api/xpack.ml.put_calendar_job.js') -const xpackMlPutDatafeed = require('./api/xpack.ml.put_datafeed.js') -const xpackMlPutFilter = require('./api/xpack.ml.put_filter.js') -const xpackMlPutJob = require('./api/xpack.ml.put_job.js') -const xpackMlRevertModelSnapshot = require('./api/xpack.ml.revert_model_snapshot.js') -const xpackMlStartDatafeed = require('./api/xpack.ml.start_datafeed.js') -const xpackMlStopDatafeed = require('./api/xpack.ml.stop_datafeed.js') -const xpackMlUpdateDatafeed = require('./api/xpack.ml.update_datafeed.js') -const xpackMlUpdateFilter = require('./api/xpack.ml.update_filter.js') -const xpackMlUpdateJob = require('./api/xpack.ml.update_job.js') -const xpackMlUpdateModelSnapshot = require('./api/xpack.ml.update_model_snapshot.js') -const xpackMlValidate = require('./api/xpack.ml.validate.js') -const xpackMlValidateDetector = require('./api/xpack.ml.validate_detector.js') -const xpackMonitoringBulk = require('./api/xpack.monitoring.bulk.js') -const xpackRollupDeleteJob = require('./api/xpack.rollup.delete_job.js') -const xpackRollupGetJobs = require('./api/xpack.rollup.get_jobs.js') -const xpackRollupGetRollupCaps = require('./api/xpack.rollup.get_rollup_caps.js') -const xpackRollupGetRollupIndexCaps = require('./api/xpack.rollup.get_rollup_index_caps.js') -const xpackRollupPutJob = require('./api/xpack.rollup.put_job.js') -const xpackRollupRollupSearch = require('./api/xpack.rollup.rollup_search.js') -const xpackRollupStartJob = require('./api/xpack.rollup.start_job.js') -const xpackRollupStopJob = require('./api/xpack.rollup.stop_job.js') -const xpackSecurityAuthenticate = require('./api/xpack.security.authenticate.js') -const xpackSecurityChangePassword = require('./api/xpack.security.change_password.js') -const xpackSecurityClearCachedRealms = require('./api/xpack.security.clear_cached_realms.js') -const xpackSecurityClearCachedRoles = require('./api/xpack.security.clear_cached_roles.js') -const xpackSecurityDeletePrivileges = require('./api/xpack.security.delete_privileges.js') -const xpackSecurityDeleteRole = require('./api/xpack.security.delete_role.js') -const xpackSecurityDeleteRoleMapping = require('./api/xpack.security.delete_role_mapping.js') -const xpackSecurityDeleteUser = require('./api/xpack.security.delete_user.js') -const xpackSecurityDisableUser = require('./api/xpack.security.disable_user.js') -const xpackSecurityEnableUser = require('./api/xpack.security.enable_user.js') -const xpackSecurityGetPrivileges = require('./api/xpack.security.get_privileges.js') -const xpackSecurityGetRole = require('./api/xpack.security.get_role.js') -const xpackSecurityGetRoleMapping = require('./api/xpack.security.get_role_mapping.js') -const xpackSecurityGetToken = require('./api/xpack.security.get_token.js') -const xpackSecurityGetUser = require('./api/xpack.security.get_user.js') -const xpackSecurityGetUserPrivileges = require('./api/xpack.security.get_user_privileges.js') -const xpackSecurityHasPrivileges = require('./api/xpack.security.has_privileges.js') -const xpackSecurityInvalidateToken = require('./api/xpack.security.invalidate_token.js') -const xpackSecurityPutPrivileges = require('./api/xpack.security.put_privileges.js') -const xpackSecurityPutRole = require('./api/xpack.security.put_role.js') -const xpackSecurityPutRoleMapping = require('./api/xpack.security.put_role_mapping.js') -const xpackSecurityPutUser = require('./api/xpack.security.put_user.js') -const xpackSqlClearCursor = require('./api/xpack.sql.clear_cursor.js') -const xpackSqlQuery = require('./api/xpack.sql.query.js') -const xpackSqlTranslate = require('./api/xpack.sql.translate.js') -const xpackSslCertificates = require('./api/xpack.ssl.certificates.js') -const xpackUsage = require('./api/xpack.usage.js') -const xpackWatcherAckWatch = require('./api/xpack.watcher.ack_watch.js') -const xpackWatcherActivateWatch = require('./api/xpack.watcher.activate_watch.js') -const xpackWatcherDeactivateWatch = require('./api/xpack.watcher.deactivate_watch.js') -const xpackWatcherDeleteWatch = require('./api/xpack.watcher.delete_watch.js') -const xpackWatcherExecuteWatch = require('./api/xpack.watcher.execute_watch.js') -const xpackWatcherGetWatch = require('./api/xpack.watcher.get_watch.js') -const xpackWatcherPutWatch = require('./api/xpack.watcher.put_watch.js') -const xpackWatcherRestart = require('./api/xpack.watcher.restart.js') -const xpackWatcherStart = require('./api/xpack.watcher.start.js') -const xpackWatcherStats = require('./api/xpack.watcher.stats.js') -const xpackWatcherStop = require('./api/xpack.watcher.stop.js') - function ESAPI (opts) { assert(opts.makeRequest, 'Missing makeRequest function') assert(opts.ConfigurationError, 'Missing ConfigurationError class') assert(opts.result, 'Missing default result object') const apis = { - bulk: bulk(opts), + bulk: lazyLoad('./api/bulk.js', opts), cat: { - aliases: catAliases(opts), - allocation: catAllocation(opts), - count: catCount(opts), - fielddata: catFielddata(opts), - health: catHealth(opts), - help: catHelp(opts), - indices: catIndices(opts), - master: catMaster(opts), - nodeattrs: catNodeattrs(opts), - nodes: catNodes(opts), - pending_tasks: catPendingTasks(opts), - pendingTasks: catPendingTasks(opts), - plugins: catPlugins(opts), - recovery: catRecovery(opts), - repositories: catRepositories(opts), - segments: catSegments(opts), - shards: catShards(opts), - snapshots: catSnapshots(opts), - tasks: catTasks(opts), - templates: catTemplates(opts), - thread_pool: catThreadPool(opts), - threadPool: catThreadPool(opts) + aliases: lazyLoad('./api/cat.aliases.js', opts), + allocation: lazyLoad('./api/cat.allocation.js', opts), + count: lazyLoad('./api/cat.count.js', opts), + fielddata: lazyLoad('./api/cat.fielddata.js', opts), + health: lazyLoad('./api/cat.health.js', opts), + help: lazyLoad('./api/cat.help.js', opts), + indices: lazyLoad('./api/cat.indices.js', opts), + master: lazyLoad('./api/cat.master.js', opts), + nodeattrs: lazyLoad('./api/cat.nodeattrs.js', opts), + nodes: lazyLoad('./api/cat.nodes.js', opts), + pending_tasks: lazyLoad('./api/cat.pending_tasks.js', opts), + pendingTasks: lazyLoad('./api/cat.pending_tasks.js', opts), + plugins: lazyLoad('./api/cat.plugins.js', opts), + recovery: lazyLoad('./api/cat.recovery.js', opts), + repositories: lazyLoad('./api/cat.repositories.js', opts), + segments: lazyLoad('./api/cat.segments.js', opts), + shards: lazyLoad('./api/cat.shards.js', opts), + snapshots: lazyLoad('./api/cat.snapshots.js', opts), + tasks: lazyLoad('./api/cat.tasks.js', opts), + templates: lazyLoad('./api/cat.templates.js', opts), + thread_pool: lazyLoad('./api/cat.thread_pool.js', opts), + threadPool: lazyLoad('./api/cat.thread_pool.js', opts) }, ccr: { - delete_auto_follow_pattern: ccrDeleteAutoFollowPattern(opts), - deleteAutoFollowPattern: ccrDeleteAutoFollowPattern(opts), - follow: ccrFollow(opts), - follow_stats: ccrFollowStats(opts), - followStats: ccrFollowStats(opts), - get_auto_follow_pattern: ccrGetAutoFollowPattern(opts), - getAutoFollowPattern: ccrGetAutoFollowPattern(opts), - pause_follow: ccrPauseFollow(opts), - pauseFollow: ccrPauseFollow(opts), - put_auto_follow_pattern: ccrPutAutoFollowPattern(opts), - putAutoFollowPattern: ccrPutAutoFollowPattern(opts), - resume_follow: ccrResumeFollow(opts), - resumeFollow: ccrResumeFollow(opts), - stats: ccrStats(opts), - unfollow: ccrUnfollow(opts) + delete_auto_follow_pattern: lazyLoad('./api/ccr.delete_auto_follow_pattern.js', opts), + deleteAutoFollowPattern: lazyLoad('./api/ccr.delete_auto_follow_pattern.js', opts), + follow: lazyLoad('./api/ccr.follow.js', opts), + follow_stats: lazyLoad('./api/ccr.follow_stats.js', opts), + followStats: lazyLoad('./api/ccr.follow_stats.js', opts), + get_auto_follow_pattern: lazyLoad('./api/ccr.get_auto_follow_pattern.js', opts), + getAutoFollowPattern: lazyLoad('./api/ccr.get_auto_follow_pattern.js', opts), + pause_follow: lazyLoad('./api/ccr.pause_follow.js', opts), + pauseFollow: lazyLoad('./api/ccr.pause_follow.js', opts), + put_auto_follow_pattern: lazyLoad('./api/ccr.put_auto_follow_pattern.js', opts), + putAutoFollowPattern: lazyLoad('./api/ccr.put_auto_follow_pattern.js', opts), + resume_follow: lazyLoad('./api/ccr.resume_follow.js', opts), + resumeFollow: lazyLoad('./api/ccr.resume_follow.js', opts), + stats: lazyLoad('./api/ccr.stats.js', opts), + unfollow: lazyLoad('./api/ccr.unfollow.js', opts) }, - clear_scroll: clearScroll(opts), - clearScroll: clearScroll(opts), + clear_scroll: lazyLoad('./api/clear_scroll.js', opts), + clearScroll: lazyLoad('./api/clear_scroll.js', opts), cluster: { - allocation_explain: clusterAllocationExplain(opts), - allocationExplain: clusterAllocationExplain(opts), - get_settings: clusterGetSettings(opts), - getSettings: clusterGetSettings(opts), - health: clusterHealth(opts), - pending_tasks: clusterPendingTasks(opts), - pendingTasks: clusterPendingTasks(opts), - put_settings: clusterPutSettings(opts), - putSettings: clusterPutSettings(opts), - remote_info: clusterRemoteInfo(opts), - remoteInfo: clusterRemoteInfo(opts), - reroute: clusterReroute(opts), - state: clusterState(opts), - stats: clusterStats(opts) + allocation_explain: lazyLoad('./api/cluster.allocation_explain.js', opts), + allocationExplain: lazyLoad('./api/cluster.allocation_explain.js', opts), + get_settings: lazyLoad('./api/cluster.get_settings.js', opts), + getSettings: lazyLoad('./api/cluster.get_settings.js', opts), + health: lazyLoad('./api/cluster.health.js', opts), + pending_tasks: lazyLoad('./api/cluster.pending_tasks.js', opts), + pendingTasks: lazyLoad('./api/cluster.pending_tasks.js', opts), + put_settings: lazyLoad('./api/cluster.put_settings.js', opts), + putSettings: lazyLoad('./api/cluster.put_settings.js', opts), + remote_info: lazyLoad('./api/cluster.remote_info.js', opts), + remoteInfo: lazyLoad('./api/cluster.remote_info.js', opts), + reroute: lazyLoad('./api/cluster.reroute.js', opts), + state: lazyLoad('./api/cluster.state.js', opts), + stats: lazyLoad('./api/cluster.stats.js', opts) }, - count: count(opts), - create: create(opts), - delete: _delete(opts), - delete_by_query: deleteByQuery(opts), - deleteByQuery: deleteByQuery(opts), - delete_by_query_rethrottle: deleteByQueryRethrottle(opts), - deleteByQueryRethrottle: deleteByQueryRethrottle(opts), - delete_script: deleteScript(opts), - deleteScript: deleteScript(opts), - exists: exists(opts), - exists_source: existsSource(opts), - existsSource: existsSource(opts), - explain: explain(opts), - field_caps: fieldCaps(opts), - fieldCaps: fieldCaps(opts), - get: get(opts), - get_script: getScript(opts), - getScript: getScript(opts), - get_source: getSource(opts), - getSource: getSource(opts), - index: index(opts), + count: lazyLoad('./api/count.js', opts), + create: lazyLoad('./api/create.js', opts), + delete: lazyLoad('./api/delete.js', opts), + delete_by_query: lazyLoad('./api/delete_by_query.js', opts), + deleteByQuery: lazyLoad('./api/delete_by_query.js', opts), + delete_by_query_rethrottle: lazyLoad('./api/delete_by_query_rethrottle.js', opts), + deleteByQueryRethrottle: lazyLoad('./api/delete_by_query_rethrottle.js', opts), + delete_script: lazyLoad('./api/delete_script.js', opts), + deleteScript: lazyLoad('./api/delete_script.js', opts), + exists: lazyLoad('./api/exists.js', opts), + exists_source: lazyLoad('./api/exists_source.js', opts), + existsSource: lazyLoad('./api/exists_source.js', opts), + explain: lazyLoad('./api/explain.js', opts), + field_caps: lazyLoad('./api/field_caps.js', opts), + fieldCaps: lazyLoad('./api/field_caps.js', opts), + get: lazyLoad('./api/get.js', opts), + get_script: lazyLoad('./api/get_script.js', opts), + getScript: lazyLoad('./api/get_script.js', opts), + get_source: lazyLoad('./api/get_source.js', opts), + getSource: lazyLoad('./api/get_source.js', opts), + index: lazyLoad('./api/index.js', opts), indices: { - analyze: indicesAnalyze(opts), - clear_cache: indicesClearCache(opts), - clearCache: indicesClearCache(opts), - close: indicesClose(opts), - create: indicesCreate(opts), - delete: indicesDelete(opts), - delete_alias: indicesDeleteAlias(opts), - deleteAlias: indicesDeleteAlias(opts), - delete_template: indicesDeleteTemplate(opts), - deleteTemplate: indicesDeleteTemplate(opts), - exists: indicesExists(opts), - exists_alias: indicesExistsAlias(opts), - existsAlias: indicesExistsAlias(opts), - exists_template: indicesExistsTemplate(opts), - existsTemplate: indicesExistsTemplate(opts), - exists_type: indicesExistsType(opts), - existsType: indicesExistsType(opts), - flush: indicesFlush(opts), - flush_synced: indicesFlushSynced(opts), - flushSynced: indicesFlushSynced(opts), - forcemerge: indicesForcemerge(opts), - get: indicesGet(opts), - get_alias: indicesGetAlias(opts), - getAlias: indicesGetAlias(opts), - get_field_mapping: indicesGetFieldMapping(opts), - getFieldMapping: indicesGetFieldMapping(opts), - get_mapping: indicesGetMapping(opts), - getMapping: indicesGetMapping(opts), - get_settings: indicesGetSettings(opts), - getSettings: indicesGetSettings(opts), - get_template: indicesGetTemplate(opts), - getTemplate: indicesGetTemplate(opts), - get_upgrade: indicesGetUpgrade(opts), - getUpgrade: indicesGetUpgrade(opts), - open: indicesOpen(opts), - put_alias: indicesPutAlias(opts), - putAlias: indicesPutAlias(opts), - put_mapping: indicesPutMapping(opts), - putMapping: indicesPutMapping(opts), - put_settings: indicesPutSettings(opts), - putSettings: indicesPutSettings(opts), - put_template: indicesPutTemplate(opts), - putTemplate: indicesPutTemplate(opts), - recovery: indicesRecovery(opts), - refresh: indicesRefresh(opts), - rollover: indicesRollover(opts), - segments: indicesSegments(opts), - shard_stores: indicesShardStores(opts), - shardStores: indicesShardStores(opts), - shrink: indicesShrink(opts), - split: indicesSplit(opts), - stats: indicesStats(opts), - update_aliases: indicesUpdateAliases(opts), - updateAliases: indicesUpdateAliases(opts), - upgrade: indicesUpgrade(opts), - validate_query: indicesValidateQuery(opts), - validateQuery: indicesValidateQuery(opts) + analyze: lazyLoad('./api/indices.analyze.js', opts), + clear_cache: lazyLoad('./api/indices.clear_cache.js', opts), + clearCache: lazyLoad('./api/indices.clear_cache.js', opts), + close: lazyLoad('./api/indices.close.js', opts), + create: lazyLoad('./api/indices.create.js', opts), + delete: lazyLoad('./api/indices.delete.js', opts), + delete_alias: lazyLoad('./api/indices.delete_alias.js', opts), + deleteAlias: lazyLoad('./api/indices.delete_alias.js', opts), + delete_template: lazyLoad('./api/indices.delete_template.js', opts), + deleteTemplate: lazyLoad('./api/indices.delete_template.js', opts), + exists: lazyLoad('./api/indices.exists.js', opts), + exists_alias: lazyLoad('./api/indices.exists_alias.js', opts), + existsAlias: lazyLoad('./api/indices.exists_alias.js', opts), + exists_template: lazyLoad('./api/indices.exists_template.js', opts), + existsTemplate: lazyLoad('./api/indices.exists_template.js', opts), + exists_type: lazyLoad('./api/indices.exists_type.js', opts), + existsType: lazyLoad('./api/indices.exists_type.js', opts), + flush: lazyLoad('./api/indices.flush.js', opts), + flush_synced: lazyLoad('./api/indices.flush_synced.js', opts), + flushSynced: lazyLoad('./api/indices.flush_synced.js', opts), + forcemerge: lazyLoad('./api/indices.forcemerge.js', opts), + get: lazyLoad('./api/indices.get.js', opts), + get_alias: lazyLoad('./api/indices.get_alias.js', opts), + getAlias: lazyLoad('./api/indices.get_alias.js', opts), + get_field_mapping: lazyLoad('./api/indices.get_field_mapping.js', opts), + getFieldMapping: lazyLoad('./api/indices.get_field_mapping.js', opts), + get_mapping: lazyLoad('./api/indices.get_mapping.js', opts), + getMapping: lazyLoad('./api/indices.get_mapping.js', opts), + get_settings: lazyLoad('./api/indices.get_settings.js', opts), + getSettings: lazyLoad('./api/indices.get_settings.js', opts), + get_template: lazyLoad('./api/indices.get_template.js', opts), + getTemplate: lazyLoad('./api/indices.get_template.js', opts), + get_upgrade: lazyLoad('./api/indices.get_upgrade.js', opts), + getUpgrade: lazyLoad('./api/indices.get_upgrade.js', opts), + open: lazyLoad('./api/indices.open.js', opts), + put_alias: lazyLoad('./api/indices.put_alias.js', opts), + putAlias: lazyLoad('./api/indices.put_alias.js', opts), + put_mapping: lazyLoad('./api/indices.put_mapping.js', opts), + putMapping: lazyLoad('./api/indices.put_mapping.js', opts), + put_settings: lazyLoad('./api/indices.put_settings.js', opts), + putSettings: lazyLoad('./api/indices.put_settings.js', opts), + put_template: lazyLoad('./api/indices.put_template.js', opts), + putTemplate: lazyLoad('./api/indices.put_template.js', opts), + recovery: lazyLoad('./api/indices.recovery.js', opts), + refresh: lazyLoad('./api/indices.refresh.js', opts), + rollover: lazyLoad('./api/indices.rollover.js', opts), + segments: lazyLoad('./api/indices.segments.js', opts), + shard_stores: lazyLoad('./api/indices.shard_stores.js', opts), + shardStores: lazyLoad('./api/indices.shard_stores.js', opts), + shrink: lazyLoad('./api/indices.shrink.js', opts), + split: lazyLoad('./api/indices.split.js', opts), + stats: lazyLoad('./api/indices.stats.js', opts), + update_aliases: lazyLoad('./api/indices.update_aliases.js', opts), + updateAliases: lazyLoad('./api/indices.update_aliases.js', opts), + upgrade: lazyLoad('./api/indices.upgrade.js', opts), + validate_query: lazyLoad('./api/indices.validate_query.js', opts), + validateQuery: lazyLoad('./api/indices.validate_query.js', opts) }, - info: info(opts), + info: lazyLoad('./api/info.js', opts), ingest: { - delete_pipeline: ingestDeletePipeline(opts), - deletePipeline: ingestDeletePipeline(opts), - get_pipeline: ingestGetPipeline(opts), - getPipeline: ingestGetPipeline(opts), - processor_grok: ingestProcessorGrok(opts), - processorGrok: ingestProcessorGrok(opts), - put_pipeline: ingestPutPipeline(opts), - putPipeline: ingestPutPipeline(opts), - simulate: ingestSimulate(opts) + delete_pipeline: lazyLoad('./api/ingest.delete_pipeline.js', opts), + deletePipeline: lazyLoad('./api/ingest.delete_pipeline.js', opts), + get_pipeline: lazyLoad('./api/ingest.get_pipeline.js', opts), + getPipeline: lazyLoad('./api/ingest.get_pipeline.js', opts), + processor_grok: lazyLoad('./api/ingest.processor_grok.js', opts), + processorGrok: lazyLoad('./api/ingest.processor_grok.js', opts), + put_pipeline: lazyLoad('./api/ingest.put_pipeline.js', opts), + putPipeline: lazyLoad('./api/ingest.put_pipeline.js', opts), + simulate: lazyLoad('./api/ingest.simulate.js', opts) }, - mget: mget(opts), - msearch: msearch(opts), - msearch_template: msearchTemplate(opts), - msearchTemplate: msearchTemplate(opts), - mtermvectors: mtermvectors(opts), + mget: lazyLoad('./api/mget.js', opts), + msearch: lazyLoad('./api/msearch.js', opts), + msearch_template: lazyLoad('./api/msearch_template.js', opts), + msearchTemplate: lazyLoad('./api/msearch_template.js', opts), + mtermvectors: lazyLoad('./api/mtermvectors.js', opts), nodes: { - hot_threads: nodesHotThreads(opts), - hotThreads: nodesHotThreads(opts), - info: nodesInfo(opts), - reload_secure_settings: nodesReloadSecureSettings(opts), - reloadSecureSettings: nodesReloadSecureSettings(opts), - stats: nodesStats(opts), - usage: nodesUsage(opts) + hot_threads: lazyLoad('./api/nodes.hot_threads.js', opts), + hotThreads: lazyLoad('./api/nodes.hot_threads.js', opts), + info: lazyLoad('./api/nodes.info.js', opts), + reload_secure_settings: lazyLoad('./api/nodes.reload_secure_settings.js', opts), + reloadSecureSettings: lazyLoad('./api/nodes.reload_secure_settings.js', opts), + stats: lazyLoad('./api/nodes.stats.js', opts), + usage: lazyLoad('./api/nodes.usage.js', opts) }, - ping: ping(opts), - put_script: putScript(opts), - putScript: putScript(opts), - rank_eval: rankEval(opts), - rankEval: rankEval(opts), - reindex: reindex(opts), - reindex_rethrottle: reindexRethrottle(opts), - reindexRethrottle: reindexRethrottle(opts), - render_search_template: renderSearchTemplate(opts), - renderSearchTemplate: renderSearchTemplate(opts), - scripts_painless_execute: scriptsPainlessExecute(opts), - scriptsPainlessExecute: scriptsPainlessExecute(opts), - scroll: scroll(opts), - search: search(opts), - search_shards: searchShards(opts), - searchShards: searchShards(opts), - search_template: searchTemplate(opts), - searchTemplate: searchTemplate(opts), + ping: lazyLoad('./api/ping.js', opts), + put_script: lazyLoad('./api/put_script.js', opts), + putScript: lazyLoad('./api/put_script.js', opts), + rank_eval: lazyLoad('./api/rank_eval.js', opts), + rankEval: lazyLoad('./api/rank_eval.js', opts), + reindex: lazyLoad('./api/reindex.js', opts), + reindex_rethrottle: lazyLoad('./api/reindex_rethrottle.js', opts), + reindexRethrottle: lazyLoad('./api/reindex_rethrottle.js', opts), + render_search_template: lazyLoad('./api/render_search_template.js', opts), + renderSearchTemplate: lazyLoad('./api/render_search_template.js', opts), + scripts_painless_execute: lazyLoad('./api/scripts_painless_execute.js', opts), + scriptsPainlessExecute: lazyLoad('./api/scripts_painless_execute.js', opts), + scroll: lazyLoad('./api/scroll.js', opts), + search: lazyLoad('./api/search.js', opts), + search_shards: lazyLoad('./api/search_shards.js', opts), + searchShards: lazyLoad('./api/search_shards.js', opts), + search_template: lazyLoad('./api/search_template.js', opts), + searchTemplate: lazyLoad('./api/search_template.js', opts), snapshot: { - create: snapshotCreate(opts), - create_repository: snapshotCreateRepository(opts), - createRepository: snapshotCreateRepository(opts), - delete: snapshotDelete(opts), - delete_repository: snapshotDeleteRepository(opts), - deleteRepository: snapshotDeleteRepository(opts), - get: snapshotGet(opts), - get_repository: snapshotGetRepository(opts), - getRepository: snapshotGetRepository(opts), - restore: snapshotRestore(opts), - status: snapshotStatus(opts), - verify_repository: snapshotVerifyRepository(opts), - verifyRepository: snapshotVerifyRepository(opts) + create: lazyLoad('./api/snapshot.create.js', opts), + create_repository: lazyLoad('./api/snapshot.create_repository.js', opts), + createRepository: lazyLoad('./api/snapshot.create_repository.js', opts), + delete: lazyLoad('./api/snapshot.delete.js', opts), + delete_repository: lazyLoad('./api/snapshot.delete_repository.js', opts), + deleteRepository: lazyLoad('./api/snapshot.delete_repository.js', opts), + get: lazyLoad('./api/snapshot.get.js', opts), + get_repository: lazyLoad('./api/snapshot.get_repository.js', opts), + getRepository: lazyLoad('./api/snapshot.get_repository.js', opts), + restore: lazyLoad('./api/snapshot.restore.js', opts), + status: lazyLoad('./api/snapshot.status.js', opts), + verify_repository: lazyLoad('./api/snapshot.verify_repository.js', opts), + verifyRepository: lazyLoad('./api/snapshot.verify_repository.js', opts) }, tasks: { - cancel: tasksCancel(opts), - get: tasksGet(opts), - list: tasksList(opts) + cancel: lazyLoad('./api/tasks.cancel.js', opts), + get: lazyLoad('./api/tasks.get.js', opts), + list: lazyLoad('./api/tasks.list.js', opts) }, - termvectors: termvectors(opts), - update: update(opts), - update_by_query: updateByQuery(opts), - updateByQuery: updateByQuery(opts), - update_by_query_rethrottle: updateByQueryRethrottle(opts), - updateByQueryRethrottle: updateByQueryRethrottle(opts), + termvectors: lazyLoad('./api/termvectors.js', opts), + update: lazyLoad('./api/update.js', opts), + update_by_query: lazyLoad('./api/update_by_query.js', opts), + updateByQuery: lazyLoad('./api/update_by_query.js', opts), + update_by_query_rethrottle: lazyLoad('./api/update_by_query_rethrottle.js', opts), + updateByQueryRethrottle: lazyLoad('./api/update_by_query_rethrottle.js', opts), xpack: { graph: { - explore: xpackGraphExplore(opts) + explore: lazyLoad('./api/xpack.graph.explore.js', opts) }, - info: xpackInfo(opts), + info: lazyLoad('./api/xpack.info.js', opts), license: { - delete: xpackLicenseDelete(opts), - get: xpackLicenseGet(opts), - get_basic_status: xpackLicenseGetBasicStatus(opts), - getBasicStatus: xpackLicenseGetBasicStatus(opts), - get_trial_status: xpackLicenseGetTrialStatus(opts), - getTrialStatus: xpackLicenseGetTrialStatus(opts), - post: xpackLicensePost(opts), - post_start_basic: xpackLicensePostStartBasic(opts), - postStartBasic: xpackLicensePostStartBasic(opts), - post_start_trial: xpackLicensePostStartTrial(opts), - postStartTrial: xpackLicensePostStartTrial(opts) + delete: lazyLoad('./api/xpack.license.delete.js', opts), + get: lazyLoad('./api/xpack.license.get.js', opts), + get_basic_status: lazyLoad('./api/xpack.license.get_basic_status.js', opts), + getBasicStatus: lazyLoad('./api/xpack.license.get_basic_status.js', opts), + get_trial_status: lazyLoad('./api/xpack.license.get_trial_status.js', opts), + getTrialStatus: lazyLoad('./api/xpack.license.get_trial_status.js', opts), + post: lazyLoad('./api/xpack.license.post.js', opts), + post_start_basic: lazyLoad('./api/xpack.license.post_start_basic.js', opts), + postStartBasic: lazyLoad('./api/xpack.license.post_start_basic.js', opts), + post_start_trial: lazyLoad('./api/xpack.license.post_start_trial.js', opts), + postStartTrial: lazyLoad('./api/xpack.license.post_start_trial.js', opts) }, migration: { - deprecations: xpackMigrationDeprecations(opts), - get_assistance: xpackMigrationGetAssistance(opts), - getAssistance: xpackMigrationGetAssistance(opts), - upgrade: xpackMigrationUpgrade(opts) + deprecations: lazyLoad('./api/xpack.migration.deprecations.js', opts), + get_assistance: lazyLoad('./api/xpack.migration.get_assistance.js', opts), + getAssistance: lazyLoad('./api/xpack.migration.get_assistance.js', opts), + upgrade: lazyLoad('./api/xpack.migration.upgrade.js', opts) }, ml: { - close_job: xpackMlCloseJob(opts), - closeJob: xpackMlCloseJob(opts), - delete_calendar: xpackMlDeleteCalendar(opts), - deleteCalendar: xpackMlDeleteCalendar(opts), - delete_calendar_event: xpackMlDeleteCalendarEvent(opts), - deleteCalendarEvent: xpackMlDeleteCalendarEvent(opts), - delete_calendar_job: xpackMlDeleteCalendarJob(opts), - deleteCalendarJob: xpackMlDeleteCalendarJob(opts), - delete_datafeed: xpackMlDeleteDatafeed(opts), - deleteDatafeed: xpackMlDeleteDatafeed(opts), - delete_expired_data: xpackMlDeleteExpiredData(opts), - deleteExpiredData: xpackMlDeleteExpiredData(opts), - delete_filter: xpackMlDeleteFilter(opts), - deleteFilter: xpackMlDeleteFilter(opts), - delete_forecast: xpackMlDeleteForecast(opts), - deleteForecast: xpackMlDeleteForecast(opts), - delete_job: xpackMlDeleteJob(opts), - deleteJob: xpackMlDeleteJob(opts), - delete_model_snapshot: xpackMlDeleteModelSnapshot(opts), - deleteModelSnapshot: xpackMlDeleteModelSnapshot(opts), - find_file_structure: xpackMlFindFileStructure(opts), - findFileStructure: xpackMlFindFileStructure(opts), - flush_job: xpackMlFlushJob(opts), - flushJob: xpackMlFlushJob(opts), - forecast: xpackMlForecast(opts), - get_buckets: xpackMlGetBuckets(opts), - getBuckets: xpackMlGetBuckets(opts), - get_calendar_events: xpackMlGetCalendarEvents(opts), - getCalendarEvents: xpackMlGetCalendarEvents(opts), - get_calendars: xpackMlGetCalendars(opts), - getCalendars: xpackMlGetCalendars(opts), - get_categories: xpackMlGetCategories(opts), - getCategories: xpackMlGetCategories(opts), - get_datafeed_stats: xpackMlGetDatafeedStats(opts), - getDatafeedStats: xpackMlGetDatafeedStats(opts), - get_datafeeds: xpackMlGetDatafeeds(opts), - getDatafeeds: xpackMlGetDatafeeds(opts), - get_filters: xpackMlGetFilters(opts), - getFilters: xpackMlGetFilters(opts), - get_influencers: xpackMlGetInfluencers(opts), - getInfluencers: xpackMlGetInfluencers(opts), - get_job_stats: xpackMlGetJobStats(opts), - getJobStats: xpackMlGetJobStats(opts), - get_jobs: xpackMlGetJobs(opts), - getJobs: xpackMlGetJobs(opts), - get_model_snapshots: xpackMlGetModelSnapshots(opts), - getModelSnapshots: xpackMlGetModelSnapshots(opts), - get_overall_buckets: xpackMlGetOverallBuckets(opts), - getOverallBuckets: xpackMlGetOverallBuckets(opts), - get_records: xpackMlGetRecords(opts), - getRecords: xpackMlGetRecords(opts), - info: xpackMlInfo(opts), - open_job: xpackMlOpenJob(opts), - openJob: xpackMlOpenJob(opts), - post_calendar_events: xpackMlPostCalendarEvents(opts), - postCalendarEvents: xpackMlPostCalendarEvents(opts), - post_data: xpackMlPostData(opts), - postData: xpackMlPostData(opts), - preview_datafeed: xpackMlPreviewDatafeed(opts), - previewDatafeed: xpackMlPreviewDatafeed(opts), - put_calendar: xpackMlPutCalendar(opts), - putCalendar: xpackMlPutCalendar(opts), - put_calendar_job: xpackMlPutCalendarJob(opts), - putCalendarJob: xpackMlPutCalendarJob(opts), - put_datafeed: xpackMlPutDatafeed(opts), - putDatafeed: xpackMlPutDatafeed(opts), - put_filter: xpackMlPutFilter(opts), - putFilter: xpackMlPutFilter(opts), - put_job: xpackMlPutJob(opts), - putJob: xpackMlPutJob(opts), - revert_model_snapshot: xpackMlRevertModelSnapshot(opts), - revertModelSnapshot: xpackMlRevertModelSnapshot(opts), - start_datafeed: xpackMlStartDatafeed(opts), - startDatafeed: xpackMlStartDatafeed(opts), - stop_datafeed: xpackMlStopDatafeed(opts), - stopDatafeed: xpackMlStopDatafeed(opts), - update_datafeed: xpackMlUpdateDatafeed(opts), - updateDatafeed: xpackMlUpdateDatafeed(opts), - update_filter: xpackMlUpdateFilter(opts), - updateFilter: xpackMlUpdateFilter(opts), - update_job: xpackMlUpdateJob(opts), - updateJob: xpackMlUpdateJob(opts), - update_model_snapshot: xpackMlUpdateModelSnapshot(opts), - updateModelSnapshot: xpackMlUpdateModelSnapshot(opts), - validate: xpackMlValidate(opts), - validate_detector: xpackMlValidateDetector(opts), - validateDetector: xpackMlValidateDetector(opts) + close_job: lazyLoad('./api/xpack.ml.close_job.js', opts), + closeJob: lazyLoad('./api/xpack.ml.close_job.js', opts), + delete_calendar: lazyLoad('./api/xpack.ml.delete_calendar.js', opts), + deleteCalendar: lazyLoad('./api/xpack.ml.delete_calendar.js', opts), + delete_calendar_event: lazyLoad('./api/xpack.ml.delete_calendar_event.js', opts), + deleteCalendarEvent: lazyLoad('./api/xpack.ml.delete_calendar_event.js', opts), + delete_calendar_job: lazyLoad('./api/xpack.ml.delete_calendar_job.js', opts), + deleteCalendarJob: lazyLoad('./api/xpack.ml.delete_calendar_job.js', opts), + delete_datafeed: lazyLoad('./api/xpack.ml.delete_datafeed.js', opts), + deleteDatafeed: lazyLoad('./api/xpack.ml.delete_datafeed.js', opts), + delete_expired_data: lazyLoad('./api/xpack.ml.delete_expired_data.js', opts), + deleteExpiredData: lazyLoad('./api/xpack.ml.delete_expired_data.js', opts), + delete_filter: lazyLoad('./api/xpack.ml.delete_filter.js', opts), + deleteFilter: lazyLoad('./api/xpack.ml.delete_filter.js', opts), + delete_forecast: lazyLoad('./api/xpack.ml.delete_forecast.js', opts), + deleteForecast: lazyLoad('./api/xpack.ml.delete_forecast.js', opts), + delete_job: lazyLoad('./api/xpack.ml.delete_job.js', opts), + deleteJob: lazyLoad('./api/xpack.ml.delete_job.js', opts), + delete_model_snapshot: lazyLoad('./api/xpack.ml.delete_model_snapshot.js', opts), + deleteModelSnapshot: lazyLoad('./api/xpack.ml.delete_model_snapshot.js', opts), + find_file_structure: lazyLoad('./api/xpack.ml.find_file_structure.js', opts), + findFileStructure: lazyLoad('./api/xpack.ml.find_file_structure.js', opts), + flush_job: lazyLoad('./api/xpack.ml.flush_job.js', opts), + flushJob: lazyLoad('./api/xpack.ml.flush_job.js', opts), + forecast: lazyLoad('./api/xpack.ml.forecast.js', opts), + get_buckets: lazyLoad('./api/xpack.ml.get_buckets.js', opts), + getBuckets: lazyLoad('./api/xpack.ml.get_buckets.js', opts), + get_calendar_events: lazyLoad('./api/xpack.ml.get_calendar_events.js', opts), + getCalendarEvents: lazyLoad('./api/xpack.ml.get_calendar_events.js', opts), + get_calendars: lazyLoad('./api/xpack.ml.get_calendars.js', opts), + getCalendars: lazyLoad('./api/xpack.ml.get_calendars.js', opts), + get_categories: lazyLoad('./api/xpack.ml.get_categories.js', opts), + getCategories: lazyLoad('./api/xpack.ml.get_categories.js', opts), + get_datafeed_stats: lazyLoad('./api/xpack.ml.get_datafeed_stats.js', opts), + getDatafeedStats: lazyLoad('./api/xpack.ml.get_datafeed_stats.js', opts), + get_datafeeds: lazyLoad('./api/xpack.ml.get_datafeeds.js', opts), + getDatafeeds: lazyLoad('./api/xpack.ml.get_datafeeds.js', opts), + get_filters: lazyLoad('./api/xpack.ml.get_filters.js', opts), + getFilters: lazyLoad('./api/xpack.ml.get_filters.js', opts), + get_influencers: lazyLoad('./api/xpack.ml.get_influencers.js', opts), + getInfluencers: lazyLoad('./api/xpack.ml.get_influencers.js', opts), + get_job_stats: lazyLoad('./api/xpack.ml.get_job_stats.js', opts), + getJobStats: lazyLoad('./api/xpack.ml.get_job_stats.js', opts), + get_jobs: lazyLoad('./api/xpack.ml.get_jobs.js', opts), + getJobs: lazyLoad('./api/xpack.ml.get_jobs.js', opts), + get_model_snapshots: lazyLoad('./api/xpack.ml.get_model_snapshots.js', opts), + getModelSnapshots: lazyLoad('./api/xpack.ml.get_model_snapshots.js', opts), + get_overall_buckets: lazyLoad('./api/xpack.ml.get_overall_buckets.js', opts), + getOverallBuckets: lazyLoad('./api/xpack.ml.get_overall_buckets.js', opts), + get_records: lazyLoad('./api/xpack.ml.get_records.js', opts), + getRecords: lazyLoad('./api/xpack.ml.get_records.js', opts), + info: lazyLoad('./api/xpack.ml.info.js', opts), + open_job: lazyLoad('./api/xpack.ml.open_job.js', opts), + openJob: lazyLoad('./api/xpack.ml.open_job.js', opts), + post_calendar_events: lazyLoad('./api/xpack.ml.post_calendar_events.js', opts), + postCalendarEvents: lazyLoad('./api/xpack.ml.post_calendar_events.js', opts), + post_data: lazyLoad('./api/xpack.ml.post_data.js', opts), + postData: lazyLoad('./api/xpack.ml.post_data.js', opts), + preview_datafeed: lazyLoad('./api/xpack.ml.preview_datafeed.js', opts), + previewDatafeed: lazyLoad('./api/xpack.ml.preview_datafeed.js', opts), + put_calendar: lazyLoad('./api/xpack.ml.put_calendar.js', opts), + putCalendar: lazyLoad('./api/xpack.ml.put_calendar.js', opts), + put_calendar_job: lazyLoad('./api/xpack.ml.put_calendar_job.js', opts), + putCalendarJob: lazyLoad('./api/xpack.ml.put_calendar_job.js', opts), + put_datafeed: lazyLoad('./api/xpack.ml.put_datafeed.js', opts), + putDatafeed: lazyLoad('./api/xpack.ml.put_datafeed.js', opts), + put_filter: lazyLoad('./api/xpack.ml.put_filter.js', opts), + putFilter: lazyLoad('./api/xpack.ml.put_filter.js', opts), + put_job: lazyLoad('./api/xpack.ml.put_job.js', opts), + putJob: lazyLoad('./api/xpack.ml.put_job.js', opts), + revert_model_snapshot: lazyLoad('./api/xpack.ml.revert_model_snapshot.js', opts), + revertModelSnapshot: lazyLoad('./api/xpack.ml.revert_model_snapshot.js', opts), + start_datafeed: lazyLoad('./api/xpack.ml.start_datafeed.js', opts), + startDatafeed: lazyLoad('./api/xpack.ml.start_datafeed.js', opts), + stop_datafeed: lazyLoad('./api/xpack.ml.stop_datafeed.js', opts), + stopDatafeed: lazyLoad('./api/xpack.ml.stop_datafeed.js', opts), + update_datafeed: lazyLoad('./api/xpack.ml.update_datafeed.js', opts), + updateDatafeed: lazyLoad('./api/xpack.ml.update_datafeed.js', opts), + update_filter: lazyLoad('./api/xpack.ml.update_filter.js', opts), + updateFilter: lazyLoad('./api/xpack.ml.update_filter.js', opts), + update_job: lazyLoad('./api/xpack.ml.update_job.js', opts), + updateJob: lazyLoad('./api/xpack.ml.update_job.js', opts), + update_model_snapshot: lazyLoad('./api/xpack.ml.update_model_snapshot.js', opts), + updateModelSnapshot: lazyLoad('./api/xpack.ml.update_model_snapshot.js', opts), + validate: lazyLoad('./api/xpack.ml.validate.js', opts), + validate_detector: lazyLoad('./api/xpack.ml.validate_detector.js', opts), + validateDetector: lazyLoad('./api/xpack.ml.validate_detector.js', opts) }, monitoring: { - bulk: xpackMonitoringBulk(opts) + bulk: lazyLoad('./api/xpack.monitoring.bulk.js', opts) }, rollup: { - delete_job: xpackRollupDeleteJob(opts), - deleteJob: xpackRollupDeleteJob(opts), - get_jobs: xpackRollupGetJobs(opts), - getJobs: xpackRollupGetJobs(opts), - get_rollup_caps: xpackRollupGetRollupCaps(opts), - getRollupCaps: xpackRollupGetRollupCaps(opts), - get_rollup_index_caps: xpackRollupGetRollupIndexCaps(opts), - getRollupIndexCaps: xpackRollupGetRollupIndexCaps(opts), - put_job: xpackRollupPutJob(opts), - putJob: xpackRollupPutJob(opts), - rollup_search: xpackRollupRollupSearch(opts), - rollupSearch: xpackRollupRollupSearch(opts), - start_job: xpackRollupStartJob(opts), - startJob: xpackRollupStartJob(opts), - stop_job: xpackRollupStopJob(opts), - stopJob: xpackRollupStopJob(opts) + delete_job: lazyLoad('./api/xpack.rollup.delete_job.js', opts), + deleteJob: lazyLoad('./api/xpack.rollup.delete_job.js', opts), + get_jobs: lazyLoad('./api/xpack.rollup.get_jobs.js', opts), + getJobs: lazyLoad('./api/xpack.rollup.get_jobs.js', opts), + get_rollup_caps: lazyLoad('./api/xpack.rollup.get_rollup_caps.js', opts), + getRollupCaps: lazyLoad('./api/xpack.rollup.get_rollup_caps.js', opts), + get_rollup_index_caps: lazyLoad('./api/xpack.rollup.get_rollup_index_caps.js', opts), + getRollupIndexCaps: lazyLoad('./api/xpack.rollup.get_rollup_index_caps.js', opts), + put_job: lazyLoad('./api/xpack.rollup.put_job.js', opts), + putJob: lazyLoad('./api/xpack.rollup.put_job.js', opts), + rollup_search: lazyLoad('./api/xpack.rollup.rollup_search.js', opts), + rollupSearch: lazyLoad('./api/xpack.rollup.rollup_search.js', opts), + start_job: lazyLoad('./api/xpack.rollup.start_job.js', opts), + startJob: lazyLoad('./api/xpack.rollup.start_job.js', opts), + stop_job: lazyLoad('./api/xpack.rollup.stop_job.js', opts), + stopJob: lazyLoad('./api/xpack.rollup.stop_job.js', opts) }, security: { - authenticate: xpackSecurityAuthenticate(opts), - change_password: xpackSecurityChangePassword(opts), - changePassword: xpackSecurityChangePassword(opts), - clear_cached_realms: xpackSecurityClearCachedRealms(opts), - clearCachedRealms: xpackSecurityClearCachedRealms(opts), - clear_cached_roles: xpackSecurityClearCachedRoles(opts), - clearCachedRoles: xpackSecurityClearCachedRoles(opts), - delete_privileges: xpackSecurityDeletePrivileges(opts), - deletePrivileges: xpackSecurityDeletePrivileges(opts), - delete_role: xpackSecurityDeleteRole(opts), - deleteRole: xpackSecurityDeleteRole(opts), - delete_role_mapping: xpackSecurityDeleteRoleMapping(opts), - deleteRoleMapping: xpackSecurityDeleteRoleMapping(opts), - delete_user: xpackSecurityDeleteUser(opts), - deleteUser: xpackSecurityDeleteUser(opts), - disable_user: xpackSecurityDisableUser(opts), - disableUser: xpackSecurityDisableUser(opts), - enable_user: xpackSecurityEnableUser(opts), - enableUser: xpackSecurityEnableUser(opts), - get_privileges: xpackSecurityGetPrivileges(opts), - getPrivileges: xpackSecurityGetPrivileges(opts), - get_role: xpackSecurityGetRole(opts), - getRole: xpackSecurityGetRole(opts), - get_role_mapping: xpackSecurityGetRoleMapping(opts), - getRoleMapping: xpackSecurityGetRoleMapping(opts), - get_token: xpackSecurityGetToken(opts), - getToken: xpackSecurityGetToken(opts), - get_user: xpackSecurityGetUser(opts), - getUser: xpackSecurityGetUser(opts), - get_user_privileges: xpackSecurityGetUserPrivileges(opts), - getUserPrivileges: xpackSecurityGetUserPrivileges(opts), - has_privileges: xpackSecurityHasPrivileges(opts), - hasPrivileges: xpackSecurityHasPrivileges(opts), - invalidate_token: xpackSecurityInvalidateToken(opts), - invalidateToken: xpackSecurityInvalidateToken(opts), - put_privileges: xpackSecurityPutPrivileges(opts), - putPrivileges: xpackSecurityPutPrivileges(opts), - put_role: xpackSecurityPutRole(opts), - putRole: xpackSecurityPutRole(opts), - put_role_mapping: xpackSecurityPutRoleMapping(opts), - putRoleMapping: xpackSecurityPutRoleMapping(opts), - put_user: xpackSecurityPutUser(opts), - putUser: xpackSecurityPutUser(opts) + authenticate: lazyLoad('./api/xpack.security.authenticate.js', opts), + change_password: lazyLoad('./api/xpack.security.change_password.js', opts), + changePassword: lazyLoad('./api/xpack.security.change_password.js', opts), + clear_cached_realms: lazyLoad('./api/xpack.security.clear_cached_realms.js', opts), + clearCachedRealms: lazyLoad('./api/xpack.security.clear_cached_realms.js', opts), + clear_cached_roles: lazyLoad('./api/xpack.security.clear_cached_roles.js', opts), + clearCachedRoles: lazyLoad('./api/xpack.security.clear_cached_roles.js', opts), + delete_privileges: lazyLoad('./api/xpack.security.delete_privileges.js', opts), + deletePrivileges: lazyLoad('./api/xpack.security.delete_privileges.js', opts), + delete_role: lazyLoad('./api/xpack.security.delete_role.js', opts), + deleteRole: lazyLoad('./api/xpack.security.delete_role.js', opts), + delete_role_mapping: lazyLoad('./api/xpack.security.delete_role_mapping.js', opts), + deleteRoleMapping: lazyLoad('./api/xpack.security.delete_role_mapping.js', opts), + delete_user: lazyLoad('./api/xpack.security.delete_user.js', opts), + deleteUser: lazyLoad('./api/xpack.security.delete_user.js', opts), + disable_user: lazyLoad('./api/xpack.security.disable_user.js', opts), + disableUser: lazyLoad('./api/xpack.security.disable_user.js', opts), + enable_user: lazyLoad('./api/xpack.security.enable_user.js', opts), + enableUser: lazyLoad('./api/xpack.security.enable_user.js', opts), + get_privileges: lazyLoad('./api/xpack.security.get_privileges.js', opts), + getPrivileges: lazyLoad('./api/xpack.security.get_privileges.js', opts), + get_role: lazyLoad('./api/xpack.security.get_role.js', opts), + getRole: lazyLoad('./api/xpack.security.get_role.js', opts), + get_role_mapping: lazyLoad('./api/xpack.security.get_role_mapping.js', opts), + getRoleMapping: lazyLoad('./api/xpack.security.get_role_mapping.js', opts), + get_token: lazyLoad('./api/xpack.security.get_token.js', opts), + getToken: lazyLoad('./api/xpack.security.get_token.js', opts), + get_user: lazyLoad('./api/xpack.security.get_user.js', opts), + getUser: lazyLoad('./api/xpack.security.get_user.js', opts), + get_user_privileges: lazyLoad('./api/xpack.security.get_user_privileges.js', opts), + getUserPrivileges: lazyLoad('./api/xpack.security.get_user_privileges.js', opts), + has_privileges: lazyLoad('./api/xpack.security.has_privileges.js', opts), + hasPrivileges: lazyLoad('./api/xpack.security.has_privileges.js', opts), + invalidate_token: lazyLoad('./api/xpack.security.invalidate_token.js', opts), + invalidateToken: lazyLoad('./api/xpack.security.invalidate_token.js', opts), + put_privileges: lazyLoad('./api/xpack.security.put_privileges.js', opts), + putPrivileges: lazyLoad('./api/xpack.security.put_privileges.js', opts), + put_role: lazyLoad('./api/xpack.security.put_role.js', opts), + putRole: lazyLoad('./api/xpack.security.put_role.js', opts), + put_role_mapping: lazyLoad('./api/xpack.security.put_role_mapping.js', opts), + putRoleMapping: lazyLoad('./api/xpack.security.put_role_mapping.js', opts), + put_user: lazyLoad('./api/xpack.security.put_user.js', opts), + putUser: lazyLoad('./api/xpack.security.put_user.js', opts) }, sql: { - clear_cursor: xpackSqlClearCursor(opts), - clearCursor: xpackSqlClearCursor(opts), - query: xpackSqlQuery(opts), - translate: xpackSqlTranslate(opts) + clear_cursor: lazyLoad('./api/xpack.sql.clear_cursor.js', opts), + clearCursor: lazyLoad('./api/xpack.sql.clear_cursor.js', opts), + query: lazyLoad('./api/xpack.sql.query.js', opts), + translate: lazyLoad('./api/xpack.sql.translate.js', opts) }, ssl: { - certificates: xpackSslCertificates(opts) + certificates: lazyLoad('./api/xpack.ssl.certificates.js', opts) }, - usage: xpackUsage(opts), + usage: lazyLoad('./api/xpack.usage.js', opts), watcher: { - ack_watch: xpackWatcherAckWatch(opts), - ackWatch: xpackWatcherAckWatch(opts), - activate_watch: xpackWatcherActivateWatch(opts), - activateWatch: xpackWatcherActivateWatch(opts), - deactivate_watch: xpackWatcherDeactivateWatch(opts), - deactivateWatch: xpackWatcherDeactivateWatch(opts), - delete_watch: xpackWatcherDeleteWatch(opts), - deleteWatch: xpackWatcherDeleteWatch(opts), - execute_watch: xpackWatcherExecuteWatch(opts), - executeWatch: xpackWatcherExecuteWatch(opts), - get_watch: xpackWatcherGetWatch(opts), - getWatch: xpackWatcherGetWatch(opts), - put_watch: xpackWatcherPutWatch(opts), - putWatch: xpackWatcherPutWatch(opts), - restart: xpackWatcherRestart(opts), - start: xpackWatcherStart(opts), - stats: xpackWatcherStats(opts), - stop: xpackWatcherStop(opts) + ack_watch: lazyLoad('./api/xpack.watcher.ack_watch.js', opts), + ackWatch: lazyLoad('./api/xpack.watcher.ack_watch.js', opts), + activate_watch: lazyLoad('./api/xpack.watcher.activate_watch.js', opts), + activateWatch: lazyLoad('./api/xpack.watcher.activate_watch.js', opts), + deactivate_watch: lazyLoad('./api/xpack.watcher.deactivate_watch.js', opts), + deactivateWatch: lazyLoad('./api/xpack.watcher.deactivate_watch.js', opts), + delete_watch: lazyLoad('./api/xpack.watcher.delete_watch.js', opts), + deleteWatch: lazyLoad('./api/xpack.watcher.delete_watch.js', opts), + execute_watch: lazyLoad('./api/xpack.watcher.execute_watch.js', opts), + executeWatch: lazyLoad('./api/xpack.watcher.execute_watch.js', opts), + get_watch: lazyLoad('./api/xpack.watcher.get_watch.js', opts), + getWatch: lazyLoad('./api/xpack.watcher.get_watch.js', opts), + put_watch: lazyLoad('./api/xpack.watcher.put_watch.js', opts), + putWatch: lazyLoad('./api/xpack.watcher.put_watch.js', opts), + restart: lazyLoad('./api/xpack.watcher.restart.js', opts), + start: lazyLoad('./api/xpack.watcher.start.js', opts), + stats: lazyLoad('./api/xpack.watcher.stats.js', opts), + stop: lazyLoad('./api/xpack.watcher.stop.js', opts) } } } @@ -671,4 +433,21 @@ function ESAPI (opts) { return apis } +// It's unlikely that a user needs all of our APIs, +// and since require is a sync operation that takes time +// (given the amount of APIs we have), let's lazy load them, +// so a given API file will be required only +// if the user actually needs that API. +// The following implementation takes advantage +// of js closures to have a simple cache with the least overhead. +function lazyLoad (file, opts) { + var fn = null + return function _lazyLoad (params, callback) { + if (fn === null) { + fn = require(file)(opts) + } + return fn(params, callback) + } +} + module.exports = ESAPI From 4ea137db1f79eefc9b0b7a8e4cea167131db5b62 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 21 Nov 2018 11:15:09 +0100 Subject: [PATCH 054/172] Updated scripts --- scripts/utils/genMain.js | 50 ++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/scripts/utils/genMain.js b/scripts/utils/genMain.js index 350a5904f..79d98fa66 100644 --- a/scripts/utils/genMain.js +++ b/scripts/utils/genMain.js @@ -9,7 +9,7 @@ function genFactory (folder) { const apiFiles = readdirSync(folder) const apis = apiFiles .map(file => { - const name = format(file.slice(0, -3)) + // const name = format(file.slice(0, -3)) return file .slice(0, -3) // remove `.js` extension .split('.') @@ -17,12 +17,12 @@ function genFactory (folder) { .reduce((acc, val) => { const obj = { [val]: acc === null - ? `${name}(opts)` + ? `lazyLoad('./api/${file}', opts)` // `${name}(opts)` : acc } if (isSnakeCased(val)) { obj[camelify(val)] = acc === null - ? `${name}(opts)` + ? `lazyLoad('./api/${file}', opts)` // `${name}(opts)` : acc } return obj @@ -43,8 +43,6 @@ function genFactory (folder) { const assert = require('assert') - ${generateApiRequire(apiFiles)} - function ESAPI (opts) { assert(opts.makeRequest, 'Missing makeRequest function') assert(opts.ConfigurationError, 'Missing ConfigurationError class') @@ -56,6 +54,23 @@ function genFactory (folder) { return apis } + // It's unlikely that a user needs all of our APIs, + // and since require is a sync operation that takes time + // (given the amount of APIs we have), let's lazy load them, + // so a given API file will be required only + // if the user actually needs that API. + // The following implementation takes advantage + // of js closures to have a simple cache with the least overhead. + function lazyLoad (file, opts) { + var fn = null + return function _lazyLoad (params, callback) { + if (fn === null) { + fn = require(file)(opts) + } + return fn(params, callback) + } + } + module.exports = ESAPI ` @@ -63,36 +78,11 @@ function genFactory (folder) { return fn + '\n' } -function generateApiRequire (apiFiles) { - return apiFiles - .map(file => { - const name = format(file.slice(0, -3)) - return `const ${name} = require('./api/${file}')` - }) - .join('\n') -} - // from snake_case to camelCase function camelify (str) { return str.replace(/_([a-z])/g, k => k[1].toUpperCase()) } -// from 'hello.world to helloWorld -function undot (str) { - return str.replace(/\.([a-z])/g, k => k[1].toUpperCase()) -} - -function safeWords (str) { - if (str === 'delete') { - return '_delete' - } - return str -} - -function format (str) { - return safeWords(undot(camelify(str))) -} - function isSnakeCased (str) { return !!~str.indexOf('_') } From db73802af9b09157139c50d481c0411a4431ff89 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 21 Nov 2018 11:53:41 +0100 Subject: [PATCH 055/172] Bumped v0.1.0-alpha.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9776ac6cb..f6ed4979b 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "The official Elasticsearch client for Node.js", "main": "index.js", "homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html", - "version": "0.1.0-alpha.1", + "version": "0.1.0-alpha.2", "keywords": [ "elasticsearch", "elastic", From ab1d7ba992cb815417d61e546434ca504cd6ea46 Mon Sep 17 00:00:00 2001 From: Tomas Della Vedova Date: Fri, 30 Nov 2018 17:01:55 +0100 Subject: [PATCH 056/172] Typings support (#737) * Updated scripts * Updated .gitignore * Removed symbols * Fixed typo * Added typings * Updated test * Added typings test --- .gitignore | 2 + index.d.ts | 473 +++++++++++++++++++++++++++++++++++++++ index.js | 24 +- lib/Connection.d.ts | 56 +++++ lib/ConnectionPool.d.ts | 137 ++++++++++++ lib/ConnectionPool.js | 6 +- lib/Serializer.d.ts | 6 + lib/Transport.d.ts | 47 ++++ lib/errors.d.ts | 48 ++++ lib/symbols.js | 15 -- package.json | 5 +- scripts/run.js | 10 +- scripts/utils/genMain.js | 32 ++- test/types/index.ts | 29 +++ test/types/tsconfig.json | 11 + test/unit/client.test.js | 13 +- 16 files changed, 869 insertions(+), 45 deletions(-) create mode 100644 index.d.ts create mode 100644 lib/Connection.d.ts create mode 100644 lib/ConnectionPool.d.ts create mode 100644 lib/Serializer.d.ts create mode 100644 lib/Transport.d.ts create mode 100644 lib/errors.d.ts delete mode 100644 lib/symbols.js create mode 100644 test/types/index.ts create mode 100644 test/types/tsconfig.json diff --git a/.gitignore b/.gitignore index 143024273..f8274fc48 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,5 @@ package-lock.json # elasticsearch repo or binary files elasticsearch* + +api/generated.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 000000000..8cdb34cd8 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,473 @@ +/// + +import { EventEmitter } from 'events'; +import { SecureContextOptions } from 'tls'; +import Transport from './lib/Transport'; +import Connection, { AgentOptions } from './lib/Connection'; +import ConnectionPool, { nodeSelectorFn, nodeFilterFn } from './lib/ConnectionPool'; +import Serializer from './lib/Serializer'; +import { ApiResponse } from './lib/Transport'; + +declare type anyObject = { + [key: string]: any; +}; +declare type callbackFn = (err: Error | null, result: ApiResponse) => void; +declare type apiMethod = (params?: anyObject | callbackFn, callback?: callbackFn) => any; + +interface ClientOptions { + node?: string | string[]; + nodes?: string | string[]; + Connection?: typeof Connection; + ConnectionPool?: typeof ConnectionPool; + Transport?: typeof Transport; + Serializer?: typeof Serializer; + maxRetries?: number; + requestTimeout?: number; + pingTimeout?: number; + sniffInterval?: number; + sniffOnStart?: boolean; + sniffEndpoint?: string; + sniffOnConnectionFault?: boolean; + resurrectStrategy?: string; + randomizeHost?: boolean; + suggestCompression?: boolean; + ssl?: SecureContextOptions; + agent?: AgentOptions; + nodeFilter?: nodeFilterFn; + nodeSelector?: nodeSelectorFn | string; +} + +declare class Client extends EventEmitter { + connectionPool: ConnectionPool; + transport: Transport; + serializer: Serializer + bulk: apiMethod + cat: { + aliases: apiMethod + allocation: apiMethod + count: apiMethod + fielddata: apiMethod + health: apiMethod + help: apiMethod + indices: apiMethod + master: apiMethod + nodeattrs: apiMethod + nodes: apiMethod + pending_tasks: apiMethod + pendingTasks: apiMethod + plugins: apiMethod + recovery: apiMethod + repositories: apiMethod + segments: apiMethod + shards: apiMethod + snapshots: apiMethod + tasks: apiMethod + templates: apiMethod + thread_pool: apiMethod + threadPool: apiMethod + } + ccr: { + delete_auto_follow_pattern: apiMethod + deleteAutoFollowPattern: apiMethod + follow: apiMethod + follow_stats: apiMethod + followStats: apiMethod + get_auto_follow_pattern: apiMethod + getAutoFollowPattern: apiMethod + pause_follow: apiMethod + pauseFollow: apiMethod + put_auto_follow_pattern: apiMethod + putAutoFollowPattern: apiMethod + resume_follow: apiMethod + resumeFollow: apiMethod + stats: apiMethod + unfollow: apiMethod + } + clear_scroll: apiMethod + clearScroll: apiMethod + cluster: { + allocation_explain: apiMethod + allocationExplain: apiMethod + get_settings: apiMethod + getSettings: apiMethod + health: apiMethod + pending_tasks: apiMethod + pendingTasks: apiMethod + put_settings: apiMethod + putSettings: apiMethod + remote_info: apiMethod + remoteInfo: apiMethod + reroute: apiMethod + state: apiMethod + stats: apiMethod + } + count: apiMethod + create: apiMethod + delete: apiMethod + delete_by_query: apiMethod + deleteByQuery: apiMethod + delete_by_query_rethrottle: apiMethod + deleteByQueryRethrottle: apiMethod + delete_script: apiMethod + deleteScript: apiMethod + exists: apiMethod + exists_source: apiMethod + existsSource: apiMethod + explain: apiMethod + field_caps: apiMethod + fieldCaps: apiMethod + get: apiMethod + get_script: apiMethod + getScript: apiMethod + get_source: apiMethod + getSource: apiMethod + index: apiMethod + indices: { + analyze: apiMethod + clear_cache: apiMethod + clearCache: apiMethod + close: apiMethod + create: apiMethod + delete: apiMethod + delete_alias: apiMethod + deleteAlias: apiMethod + delete_template: apiMethod + deleteTemplate: apiMethod + exists: apiMethod + exists_alias: apiMethod + existsAlias: apiMethod + exists_template: apiMethod + existsTemplate: apiMethod + exists_type: apiMethod + existsType: apiMethod + flush: apiMethod + flush_synced: apiMethod + flushSynced: apiMethod + forcemerge: apiMethod + get: apiMethod + get_alias: apiMethod + getAlias: apiMethod + get_field_mapping: apiMethod + getFieldMapping: apiMethod + get_mapping: apiMethod + getMapping: apiMethod + get_settings: apiMethod + getSettings: apiMethod + get_template: apiMethod + getTemplate: apiMethod + get_upgrade: apiMethod + getUpgrade: apiMethod + open: apiMethod + put_alias: apiMethod + putAlias: apiMethod + put_mapping: apiMethod + putMapping: apiMethod + put_settings: apiMethod + putSettings: apiMethod + put_template: apiMethod + putTemplate: apiMethod + recovery: apiMethod + refresh: apiMethod + rollover: apiMethod + segments: apiMethod + shard_stores: apiMethod + shardStores: apiMethod + shrink: apiMethod + split: apiMethod + stats: apiMethod + update_aliases: apiMethod + updateAliases: apiMethod + upgrade: apiMethod + validate_query: apiMethod + validateQuery: apiMethod + } + info: apiMethod + ingest: { + delete_pipeline: apiMethod + deletePipeline: apiMethod + get_pipeline: apiMethod + getPipeline: apiMethod + processor_grok: apiMethod + processorGrok: apiMethod + put_pipeline: apiMethod + putPipeline: apiMethod + simulate: apiMethod + } + mget: apiMethod + msearch: apiMethod + msearch_template: apiMethod + msearchTemplate: apiMethod + mtermvectors: apiMethod + nodes: { + hot_threads: apiMethod + hotThreads: apiMethod + info: apiMethod + reload_secure_settings: apiMethod + reloadSecureSettings: apiMethod + stats: apiMethod + usage: apiMethod + } + ping: apiMethod + put_script: apiMethod + putScript: apiMethod + rank_eval: apiMethod + rankEval: apiMethod + reindex: apiMethod + reindex_rethrottle: apiMethod + reindexRethrottle: apiMethod + render_search_template: apiMethod + renderSearchTemplate: apiMethod + scripts_painless_execute: apiMethod + scriptsPainlessExecute: apiMethod + scroll: apiMethod + search: apiMethod + search_shards: apiMethod + searchShards: apiMethod + search_template: apiMethod + searchTemplate: apiMethod + snapshot: { + create: apiMethod + create_repository: apiMethod + createRepository: apiMethod + delete: apiMethod + delete_repository: apiMethod + deleteRepository: apiMethod + get: apiMethod + get_repository: apiMethod + getRepository: apiMethod + restore: apiMethod + status: apiMethod + verify_repository: apiMethod + verifyRepository: apiMethod + } + tasks: { + cancel: apiMethod + get: apiMethod + list: apiMethod + } + termvectors: apiMethod + update: apiMethod + update_by_query: apiMethod + updateByQuery: apiMethod + update_by_query_rethrottle: apiMethod + updateByQueryRethrottle: apiMethod + xpack: { + graph: { + explore: apiMethod + } + info: apiMethod + license: { + delete: apiMethod + get: apiMethod + get_basic_status: apiMethod + getBasicStatus: apiMethod + get_trial_status: apiMethod + getTrialStatus: apiMethod + post: apiMethod + post_start_basic: apiMethod + postStartBasic: apiMethod + post_start_trial: apiMethod + postStartTrial: apiMethod + } + migration: { + deprecations: apiMethod + get_assistance: apiMethod + getAssistance: apiMethod + upgrade: apiMethod + } + ml: { + close_job: apiMethod + closeJob: apiMethod + delete_calendar: apiMethod + deleteCalendar: apiMethod + delete_calendar_event: apiMethod + deleteCalendarEvent: apiMethod + delete_calendar_job: apiMethod + deleteCalendarJob: apiMethod + delete_datafeed: apiMethod + deleteDatafeed: apiMethod + delete_expired_data: apiMethod + deleteExpiredData: apiMethod + delete_filter: apiMethod + deleteFilter: apiMethod + delete_forecast: apiMethod + deleteForecast: apiMethod + delete_job: apiMethod + deleteJob: apiMethod + delete_model_snapshot: apiMethod + deleteModelSnapshot: apiMethod + find_file_structure: apiMethod + findFileStructure: apiMethod + flush_job: apiMethod + flushJob: apiMethod + forecast: apiMethod + get_buckets: apiMethod + getBuckets: apiMethod + get_calendar_events: apiMethod + getCalendarEvents: apiMethod + get_calendars: apiMethod + getCalendars: apiMethod + get_categories: apiMethod + getCategories: apiMethod + get_datafeed_stats: apiMethod + getDatafeedStats: apiMethod + get_datafeeds: apiMethod + getDatafeeds: apiMethod + get_filters: apiMethod + getFilters: apiMethod + get_influencers: apiMethod + getInfluencers: apiMethod + get_job_stats: apiMethod + getJobStats: apiMethod + get_jobs: apiMethod + getJobs: apiMethod + get_model_snapshots: apiMethod + getModelSnapshots: apiMethod + get_overall_buckets: apiMethod + getOverallBuckets: apiMethod + get_records: apiMethod + getRecords: apiMethod + info: apiMethod + open_job: apiMethod + openJob: apiMethod + post_calendar_events: apiMethod + postCalendarEvents: apiMethod + post_data: apiMethod + postData: apiMethod + preview_datafeed: apiMethod + previewDatafeed: apiMethod + put_calendar: apiMethod + putCalendar: apiMethod + put_calendar_job: apiMethod + putCalendarJob: apiMethod + put_datafeed: apiMethod + putDatafeed: apiMethod + put_filter: apiMethod + putFilter: apiMethod + put_job: apiMethod + putJob: apiMethod + revert_model_snapshot: apiMethod + revertModelSnapshot: apiMethod + start_datafeed: apiMethod + startDatafeed: apiMethod + stop_datafeed: apiMethod + stopDatafeed: apiMethod + update_datafeed: apiMethod + updateDatafeed: apiMethod + update_filter: apiMethod + updateFilter: apiMethod + update_job: apiMethod + updateJob: apiMethod + update_model_snapshot: apiMethod + updateModelSnapshot: apiMethod + validate: apiMethod + validate_detector: apiMethod + validateDetector: apiMethod + } + monitoring: { + bulk: apiMethod + } + rollup: { + delete_job: apiMethod + deleteJob: apiMethod + get_jobs: apiMethod + getJobs: apiMethod + get_rollup_caps: apiMethod + getRollupCaps: apiMethod + get_rollup_index_caps: apiMethod + getRollupIndexCaps: apiMethod + put_job: apiMethod + putJob: apiMethod + rollup_search: apiMethod + rollupSearch: apiMethod + start_job: apiMethod + startJob: apiMethod + stop_job: apiMethod + stopJob: apiMethod + } + security: { + authenticate: apiMethod + change_password: apiMethod + changePassword: apiMethod + clear_cached_realms: apiMethod + clearCachedRealms: apiMethod + clear_cached_roles: apiMethod + clearCachedRoles: apiMethod + delete_privileges: apiMethod + deletePrivileges: apiMethod + delete_role: apiMethod + deleteRole: apiMethod + delete_role_mapping: apiMethod + deleteRoleMapping: apiMethod + delete_user: apiMethod + deleteUser: apiMethod + disable_user: apiMethod + disableUser: apiMethod + enable_user: apiMethod + enableUser: apiMethod + get_privileges: apiMethod + getPrivileges: apiMethod + get_role: apiMethod + getRole: apiMethod + get_role_mapping: apiMethod + getRoleMapping: apiMethod + get_token: apiMethod + getToken: apiMethod + get_user: apiMethod + getUser: apiMethod + get_user_privileges: apiMethod + getUserPrivileges: apiMethod + has_privileges: apiMethod + hasPrivileges: apiMethod + invalidate_token: apiMethod + invalidateToken: apiMethod + put_privileges: apiMethod + putPrivileges: apiMethod + put_role: apiMethod + putRole: apiMethod + put_role_mapping: apiMethod + putRoleMapping: apiMethod + put_user: apiMethod + putUser: apiMethod + } + sql: { + clear_cursor: apiMethod + clearCursor: apiMethod + query: apiMethod + translate: apiMethod + } + ssl: { + certificates: apiMethod + } + usage: apiMethod + watcher: { + ack_watch: apiMethod + ackWatch: apiMethod + activate_watch: apiMethod + activateWatch: apiMethod + deactivate_watch: apiMethod + deactivateWatch: apiMethod + delete_watch: apiMethod + deleteWatch: apiMethod + execute_watch: apiMethod + executeWatch: apiMethod + get_watch: apiMethod + getWatch: apiMethod + put_watch: apiMethod + putWatch: apiMethod + restart: apiMethod + start: apiMethod + stats: apiMethod + stop: apiMethod + } + } + constructor(opts?: ClientOptions); +} + +declare const events: { + RESPONSE: string; + REQUEST: string; + ERROR: string; +}; + +export { Client, Transport, ConnectionPool, Connection, Serializer, events, ApiResponse }; diff --git a/index.js b/index.js index cc5055da6..7765ae8fb 100644 --- a/index.js +++ b/index.js @@ -5,17 +5,10 @@ const Transport = require('./lib/Transport') const Connection = require('./lib/Connection') const ConnectionPool = require('./lib/ConnectionPool') const Serializer = require('./lib/Serializer') -const symbols = require('./lib/symbols') const { ConfigurationError } = require('./lib/errors') const buildApi = require('./api') -const { - kTransport, - kConnectionPool, - kSerializer -} = symbols - class Client extends EventEmitter { constructor (opts = {}) { super() @@ -57,8 +50,8 @@ class Client extends EventEmitter { nodeSelector: 'round-robin' }, opts) - this[kSerializer] = new options.Serializer() - this[kConnectionPool] = new options.ConnectionPool({ + this.serializer = new options.Serializer() + this.connectionPool = new options.ConnectionPool({ pingTimeout: options.pingTimeout, resurrectStrategy: options.resurrectStrategy, randomizeHost: options.randomizeHost, @@ -71,12 +64,12 @@ class Client extends EventEmitter { }) // Add the connections before initialize the Transport - this[kConnectionPool].addConnection(options.node || options.nodes) + this.connectionPool.addConnection(options.node || options.nodes) - this[kTransport] = new options.Transport({ + this.transport = new options.Transport({ emit: this.emit.bind(this), - connectionPool: this[kConnectionPool], - serializer: this[kSerializer], + connectionPool: this.connectionPool, + serializer: this.serializer, maxRetries: options.maxRetries, requestTimeout: options.requestTimeout, sniffInterval: options.sniffInterval, @@ -86,10 +79,8 @@ class Client extends EventEmitter { suggestCompression: options.suggestCompression }) - this.request = this[kTransport].request.bind(this[kTransport]) - const apis = buildApi({ - makeRequest: this[kTransport].request.bind(this[kTransport]), + makeRequest: this.transport.request.bind(this.transport), result: { body: null, statusCode: null, headers: null, warnings: null }, ConfigurationError }) @@ -112,6 +103,5 @@ module.exports = { ConnectionPool, Connection, Serializer, - symbols, events } diff --git a/lib/Connection.d.ts b/lib/Connection.d.ts new file mode 100644 index 000000000..f746940de --- /dev/null +++ b/lib/Connection.d.ts @@ -0,0 +1,56 @@ +/// + +import { URL } from 'url'; +import * as http from 'http'; +import { SecureContextOptions } from 'tls'; + +interface ConnectionOptions { + url: URL; + ssl?: SecureContextOptions; + id?: string; + headers?: any; + agent?: AgentOptions; + status?: string; + roles?: any; +} + +export interface AgentOptions { + keepAlive: boolean; + keepAliveMsecs: number; + maxSockets: number; + maxFreeSockets: number; +} + +export default class Connection { + static statuses: { + ALIVE: string; + DEAD: string; + }; + static roles: { + MASTER: string; + DATA: string; + INGEST: string; + COORDINATING: string; + MACHINE_LEARNING: string; + }; + url: URL; + ssl: SecureContextOptions | null; + id: string; + headers: any; + deadCount: number; + resurrectTimeout: number; + statuses: any; + roles: any; + makeRequest: any; + _openRequests: number; + _status: string; + _agent: http.Agent; + constructor(opts?: ConnectionOptions); + request(params: any, callback: (err: Error | null, response: http.IncomingMessage | null) => void): http.ClientRequest; + close(): Connection; + setRole(role: string, enabled: boolean): Connection; + status: string; + buildRequestObject(params: any): http.ClientRequestArgs; +} + +export {}; diff --git a/lib/ConnectionPool.d.ts b/lib/ConnectionPool.d.ts new file mode 100644 index 000000000..e4ad414c6 --- /dev/null +++ b/lib/ConnectionPool.d.ts @@ -0,0 +1,137 @@ +/// + +import { SecureContextOptions } from 'tls'; +import Connection, { AgentOptions } from './Connection'; + +export interface nodeSelectorFn { + (connections: Connection[]): Connection; +} + +export interface nodeFilterFn { + (connection: Connection): boolean; +} + +interface ConnectionPoolOptions { + ssl?: SecureContextOptions; + agent?: AgentOptions; + pingTimeout?: number; + randomizeHost?: boolean; + Connection: typeof Connection; + resurrectStrategy?: string; + nodeFilter?: nodeFilterFn; + nodeSelector?: string | nodeSelectorFn; +} + +export interface getConnectionOptions { + filter?: nodeFilterFn; + selector?: nodeSelectorFn; +} + +export default class ConnectionPool { + static resurrectStrategies: { + none: number; + ping: number; + optimistic: number; + }; + connections: any; + dead: string[]; + _ssl: SecureContextOptions | null; + _agent: AgentOptions | null; + resurrectTimeout: number; + resurrectTimeoutCutoff: number; + pingTimeout: number; + randomizeHost: boolean; + nodeFilter: nodeFilterFn; + nodeSelector: nodeSelectorFn; + Connection: typeof Connection; + resurrectStrategy: number; + constructor(opts?: ConnectionPoolOptions); + /** + * Marks a connection as 'alive'. + * If needed removes the connection from the dead list + * and then resets the `deadCount`. + * + * @param {object} connection + */ + markAlive(connection: Connection): void; + /** + * Marks a connection as 'dead'. + * If needed adds the connection to the dead list + * and then increments the `deadCount`. + * + * @param {object} connection + */ + markDead(connection: Connection): void; + /** + * If enabled, tries to resurrect a connection with the given + * resurrect strategy ('ping', 'optimistic', 'none'). + * + * @param {number} epoch + * @param {function} callback (isAlive, connection) + */ + resurrect(now?: number, callback?: (isAlive: boolean | null, connection: Connection | null) => void): void; + /** + * Returns an alive connection if present, + * otherwise returns null. + * By default it filters the `master` only nodes. + * It uses the selector to choose which + * connection return. + * + * @param {object} options (filter and selector) + * @returns {object|null} connection + */ + getConnection(opts?: getConnectionOptions): Connection | null; + /** + * Adds a new connection to the pool. + * + * @param {object|string} host + * @returns {ConnectionPool} + */ + addConnection(opts: any): Connection | void; + /** + * Removes a new connection to the pool. + * + * @param {object} connection + * @returns {ConnectionPool} + */ + removeConnection(connection: Connection): ConnectionPool; + /** + * Empties the connection pool. + * + * @returns {ConnectionPool} + */ + empty(): ConnectionPool; + /** + * Update the ConnectionPool with new connections. + * + * @param {array} array of connections + * @returns {ConnectionPool} + */ + update(connections: Connection[]): ConnectionPool; + /** + * Transforms the nodes objects to a host object. + * + * @param {object} nodes + * @returns {array} hosts + */ + nodesToHost(nodes: any): any[]; + /** + * Transforms an url string to a host object + * + * @param {string} url + * @returns {object} host + */ + urlToHost(url: string): any; +} + +declare function defaultNodeFilter(node: Connection): boolean; +declare function roundRobinSelector(): (connections: Connection[]) => Connection; +declare function randomSelector(connections: Connection[]): Connection; + +export declare const internals: { + defaultNodeFilter: typeof defaultNodeFilter; + roundRobinSelector: typeof roundRobinSelector; + randomSelector: typeof randomSelector; +}; + +export {}; diff --git a/lib/ConnectionPool.js b/lib/ConnectionPool.js index 47e461751..32dacfcca 100644 --- a/lib/ConnectionPool.js +++ b/lib/ConnectionPool.js @@ -330,9 +330,9 @@ ConnectionPool.resurrectStrategies = { function defaultNodeFilter (node) { // avoid master only nodes - if (!!node.master === true && - !!node.data === false && - !!node.ingest === false) { + if (!!node.roles.master === true && + !!node.roles.data === false && + !!node.roles.ingest === false) { return false } return true diff --git a/lib/Serializer.d.ts b/lib/Serializer.d.ts new file mode 100644 index 000000000..0a05e431e --- /dev/null +++ b/lib/Serializer.d.ts @@ -0,0 +1,6 @@ +export default class Serializer { + serialize(object: any): string; + deserialize(json: string): any; + ndserialize(array: any[]): string; + qserialize(object: any): string; +} diff --git a/lib/Transport.d.ts b/lib/Transport.d.ts new file mode 100644 index 000000000..8839ce3eb --- /dev/null +++ b/lib/Transport.d.ts @@ -0,0 +1,47 @@ +import ConnectionPool from './ConnectionPool'; +import Connection from './Connection'; +import Serializer from './Serializer'; + +declare type noopFn = (...args: any[]) => void; +declare type emitFn = (event: string | symbol, ...args: any[]) => boolean; + +interface TransportOptions { + emit: emitFn & noopFn; + connectionPool: ConnectionPool; + serializer: Serializer; + maxRetries: number; + requestTimeout: number | string; + suggestCompression: boolean; + sniffInterval: number; + sniffOnConnectionFault: boolean; + sniffEndpoint: string; + sniffOnStart: boolean; +} + +export interface ApiResponse { + body: any; + statusCode: number | null; + headers: any; + warnings: any[] | null; +} + +export default class Transport { + emit: emitFn & noopFn; + connectionPool: ConnectionPool; + serializer: Serializer; + maxRetries: number; + requestTimeout: number; + suggestCompression: boolean; + sniffInterval: number; + sniffOnConnectionFault: boolean; + sniffEndpoint: string; + _sniffEnabled: boolean; + _nextSniff: number; + _isSniffing: boolean; + constructor(opts: TransportOptions); + request(params: any, callback: (err: Error | null, result: ApiResponse) => void): any; + getConnection(): Connection | null; + sniff(callback?: (...args: any[]) => void): void; +} + +export {}; diff --git a/lib/errors.d.ts b/lib/errors.d.ts new file mode 100644 index 000000000..ec5a9f6b3 --- /dev/null +++ b/lib/errors.d.ts @@ -0,0 +1,48 @@ +export declare class TimeoutError extends Error { + name: string; + message: string; + request: any; + constructor(message: string, request: any); +} + +export declare class ConnectionError extends Error { + name: string; + message: string; + request: any; + constructor(message: string, request: any); +} + +export declare class NoLivingConnectionsError extends Error { + name: string; + message: string; + constructor(message: string); +} + +export declare class SerializationError extends Error { + name: string; + message: string; + constructor(message: string); +} + +export declare class DeserializationError extends Error { + name: string; + message: string; + constructor(message: string); +} + +export declare class ConfigurationError extends Error { + name: string; + message: string; + constructor(message: string); +} + +export declare class ResponseError extends Error { + name: string; + message: string; + body: any; + statusCode: number; + headers: any; + constructor({ body, statusCode, headers }: { + [key: string]: any; + }); +} diff --git a/lib/symbols.js b/lib/symbols.js deleted file mode 100644 index 313b6d4ce..000000000 --- a/lib/symbols.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict' - -const kTransport = Symbol('elasticsearch-transport') -const kConnection = Symbol('elasticsearch-connection') -const kConnectionPool = Symbol('elasticsearch-connection-pool') -const kSerializer = Symbol('elasticsearch-serializer') -const kSelector = Symbol('elasticsearch-selector') - -module.exports = { - kTransport, - kConnection, - kConnectionPool, - kSerializer, - kSelector -} diff --git a/package.json b/package.json index f6ed4979b..067af3ba8 100644 --- a/package.json +++ b/package.json @@ -15,9 +15,10 @@ "index" ], "scripts": { - "test": "npm run lint && npm run test:unit", + "test": "npm run lint && npm run test:unit && npm run test:types", "test:unit": "tap test/unit/*.test.js -J -T", "test:integration": "tap test/integration/index.js -T --harmony", + "test:types": "tsc --project ./test/types/tsconfig.json", "lint": "standard", "lint:fix": "standard --fix", "generate": "node scripts/run.js", @@ -33,6 +34,7 @@ "company": "Elasticsearch BV" }, "devDependencies": { + "@types/node": "^10.12.10", "dedent": "^0.7.0", "deepmerge": "^2.2.1", "into-stream": "^4.0.0", @@ -45,6 +47,7 @@ "standard": "^12.0.0", "stoppable": "^1.0.7", "tap": "^12.0.1", + "typescript": "^3.1.6", "workq": "^2.1.0" }, "dependencies": { diff --git a/scripts/run.js b/scripts/run.js index 0dc1ec61b..7776efba5 100644 --- a/scripts/run.js +++ b/scripts/run.js @@ -22,6 +22,7 @@ function start (opts) { const packageFolder = join(__dirname, '..', 'api') const apiOutputFolder = join(packageFolder, 'api') const mainOutputFile = join(packageFolder, 'index.js') + const typesOutputFile = join(packageFolder, 'generated.d.ts') log.text = 'Cleaning API folder...' rimraf.sync(join(apiOutputFolder, '*.js')) @@ -35,9 +36,15 @@ function start (opts) { readdirSync(apiFolder).forEach(generateApiFile(apiFolder, log)) readdirSync(xPackFolder).forEach(generateApiFile(xPackFolder, log)) + const { fn: factory, types } = genFactory(apiOutputFolder) writeFileSync( mainOutputFile, - genFactory(apiOutputFolder), + factory, + { encoding: 'utf8' } + ) + writeFileSync( + typesOutputFile, + types, { encoding: 'utf8' } ) lintFiles(log) @@ -69,6 +76,7 @@ function start (opts) { return log.fail(err.message) } log.succeed('Done!') + console.log('Remember to copy the generated types into the index.d.ts file') }) } } diff --git a/scripts/utils/genMain.js b/scripts/utils/genMain.js index 79d98fa66..419daf468 100644 --- a/scripts/utils/genMain.js +++ b/scripts/utils/genMain.js @@ -7,6 +7,28 @@ const deepmerge = require('deepmerge') function genFactory (folder) { // get all the API files const apiFiles = readdirSync(folder) + const types = apiFiles + .map(file => { + return file + .slice(0, -3) // remove `.js` extension + .split('.') + .reverse() + .reduce((acc, val) => { + const obj = { + [val]: acc === null + ? 'apiMethod' + : acc + } + if (isSnakeCased(val)) { + obj[camelify(val)] = acc === null + ? 'apiMethod' + : acc + } + return obj + }, null) + }) + .reduce((acc, val) => deepmerge(acc, val), {}) + const apis = apiFiles .map(file => { // const name = format(file.slice(0, -3)) @@ -38,6 +60,14 @@ function genFactory (folder) { // remove useless quotes .replace(/"/g, '') + // serialize the type object + const typesStr = Object.keys(types) + .map(key => `${key}: ${JSON.stringify(types[key], null, 2)}`) + .join('\n') + // remove useless quotes and commas + .replace(/"/g, '') + .replace(/,/g, '') + const fn = dedent` 'use strict' @@ -75,7 +105,7 @@ function genFactory (folder) { ` // new line at the end of file - return fn + '\n' + return { fn: fn + '\n', types: typesStr } } // from snake_case to camelCase diff --git a/test/types/index.ts b/test/types/index.ts new file mode 100644 index 000000000..ad9af76c2 --- /dev/null +++ b/test/types/index.ts @@ -0,0 +1,29 @@ +'use strict' + +import { Client, ApiResponse } from '../../index' + +const client = new Client({ node: 'http://localhost:9200' }) + +// Callbacks +client.info((err: Error | null, result: ApiResponse) => {}) + +client.index({ + index: 'test', + type: 'test', + id: 'test', + body: { hello: 'world' } +}, (err: Error | null, result: ApiResponse) => {}) + +// Promises +client.info() + .then((result: ApiResponse) => {}) + .catch((err: Error) => {}) + +client.index({ + index: 'test', + type: 'test', + id: 'test', + body: { hello: 'world' } +}) + .then((result: ApiResponse) => {}) + .catch((err: Error) => {}) diff --git a/test/types/tsconfig.json b/test/types/tsconfig.json new file mode 100644 index 000000000..46f366eb2 --- /dev/null +++ b/test/types/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "target": "es6", + "module": "commonjs", + "noEmit": true, + "strict": true + }, + "files": [ + "./index.ts" + ] +} diff --git a/test/unit/client.test.js b/test/unit/client.test.js index e59d83cab..95a87ffb4 100644 --- a/test/unit/client.test.js +++ b/test/unit/client.test.js @@ -2,15 +2,14 @@ const { test } = require('tap') const { URL } = require('url') -const { Client, symbols } = require('../../index') -const { kConnectionPool } = symbols +const { Client } = require('../../index') test('Configure host', t => { t.test('Single string', t => { const client = new Client({ node: 'http://localhost:9200' }) - const pool = client[kConnectionPool] + const pool = client.connectionPool t.match(pool.connections.get('http://localhost:9200/'), { url: new URL('http://localhost:9200'), id: 'http://localhost:9200/', @@ -32,7 +31,7 @@ test('Configure host', t => { const client = new Client({ nodes: ['http://localhost:9200', 'http://localhost:9201'] }) - const pool = client[kConnectionPool] + const pool = client.connectionPool t.match(pool.connections.get('http://localhost:9200/'), { url: new URL('http://localhost:9200'), id: 'http://localhost:9200/', @@ -77,7 +76,7 @@ test('Configure host', t => { ssl: 'ssl' } }) - const pool = client[kConnectionPool] + const pool = client.connectionPool t.match(pool.connections.get('node'), { url: new URL('http://localhost:9200'), id: 'node', @@ -112,7 +111,7 @@ test('Configure host', t => { ssl: 'ssl' }] }) - const pool = client[kConnectionPool] + const pool = client.connectionPool t.match(pool.connections.get('node1'), { url: new URL('http://localhost:9200'), id: 'node1', @@ -146,7 +145,7 @@ test('Configure host', t => { id: 'node' } }) - const pool = client[kConnectionPool] + const pool = client.connectionPool t.match(pool.connections.get('node'), { url: new URL('http://localhost:9200'), headers: { 'x-foo': 'bar' } From fd738f8425ed8f6884f5e3572582a52cdaabb770 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 3 Dec 2018 18:06:09 +0100 Subject: [PATCH 057/172] WIP: initial prototype - Standardized event emitters - Refactored transport.request to have a better handling of the state - Added sniff event - Improved abort handling --- index.d.ts | 1 + index.js | 9 ++- lib/Connection.js | 9 +++ lib/ConnectionPool.js | 1 + lib/Serializer.js | 1 + lib/Transport.js | 158 +++++++++++++++++++++++++----------------- 6 files changed, 112 insertions(+), 67 deletions(-) diff --git a/index.d.ts b/index.d.ts index 8cdb34cd8..9ac5b80f5 100644 --- a/index.d.ts +++ b/index.d.ts @@ -468,6 +468,7 @@ declare const events: { RESPONSE: string; REQUEST: string; ERROR: string; + SNIFF: string; }; export { Client, Transport, ConnectionPool, Connection, Serializer, events, ApiResponse }; diff --git a/index.js b/index.js index 7765ae8fb..3f8037659 100644 --- a/index.js +++ b/index.js @@ -5,7 +5,8 @@ const Transport = require('./lib/Transport') const Connection = require('./lib/Connection') const ConnectionPool = require('./lib/ConnectionPool') const Serializer = require('./lib/Serializer') -const { ConfigurationError } = require('./lib/errors') +const errors = require('./lib/errors') +const { ConfigurationError } = errors const buildApi = require('./api') @@ -94,7 +95,8 @@ class Client extends EventEmitter { const events = { RESPONSE: 'response', REQUEST: 'request', - ERROR: 'error' + ERROR: 'error', + SNIFF: 'sniff' } module.exports = { @@ -103,5 +105,6 @@ module.exports = { ConnectionPool, Connection, Serializer, - events + events, + errors } diff --git a/lib/Connection.js b/lib/Connection.js index 074132ef2..12beb7666 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -77,6 +77,15 @@ class Connection { } }) + // updates the ended state + request.on('abort', () => { + debug('Request aborted', params) + if (ended === false) { + ended = true + this._openRequests-- + } + }) + // Disables the Nagle algorithm request.setNoDelay(true) diff --git a/lib/ConnectionPool.js b/lib/ConnectionPool.js index 32dacfcca..39905a313 100644 --- a/lib/ConnectionPool.js +++ b/lib/ConnectionPool.js @@ -274,6 +274,7 @@ class ConnectionPool { /** * Transforms the nodes objects to a host object. + * TODO: handle ssl and agent options * * @param {object} nodes * @returns {array} hosts diff --git a/lib/Serializer.js b/lib/Serializer.js index de3e70721..a2fae9148 100644 --- a/lib/Serializer.js +++ b/lib/Serializer.js @@ -44,6 +44,7 @@ class Serializer { qserialize (object) { debug('qserialize', object) if (object == null) return '' + if (typeof object === 'string') return object // arrays should be serialized as comma separated list const keys = Object.keys(object) for (var i = 0, len = keys.length; i < len; i++) { diff --git a/lib/Transport.js b/lib/Transport.js index 2bd74f8c5..941e17c8f 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -11,7 +11,6 @@ const { } = require('./errors') const noop = () => {} -const kRemainingAttempts = Symbol('elasticsearch-remaining-attempts') class Transport { constructor (opts = {}) { @@ -36,78 +35,99 @@ class Transport { request (params, callback) { callback = once(callback) - const result = { body: null, statusCode: null, headers: null, warnings: null } - const attempts = params[kRemainingAttempts] || params.maxRetries || this.maxRetries - const connection = this.getConnection() - if (connection === null) { - return callback(new NoLivingConnectionsError('There are not living connections'), result) + const meta = { + connection: null, + request: null, + response: null, + attempts: 0, + aborted: false } + const result = { + body: null, + statusCode: null, + headers: null, + warnings: null + } + const maxRetries = params.maxRetries || this.maxRetries + var request = { abort: noop } - params.headers = params.headers || {} - // handle json body - if (params.body != null) { - if (shouldSerialize(params.body) === true) { - try { - params.body = this.serializer.serialize(params.body) - } catch (err) { - return callback(err, result) + const makeRequest = () => { + if (meta.aborted === true) return + meta.connection = this.getConnection() + if (meta.connection === null) { + return callback(new NoLivingConnectionsError('There are not living connections'), result) + } + + params.headers = params.headers || {} + // handle json body + if (params.body != null) { + if (shouldSerialize(params.body) === true) { + try { + params.body = this.serializer.serialize(params.body) + } catch (err) { + return callback(err, result) + } + } + params.headers['Content-Type'] = 'application/json' + if (isStream(params.body) === false) { + params.headers['Content-Length'] = '' + Buffer.byteLength(params.body) + } + // handle ndjson body + } else if (params.bulkBody != null) { + if (shouldSerialize(params.bulkBody) === true) { + try { + params.body = this.serializer.ndserialize(params.bulkBody) + } catch (err) { + return callback(err, result) + } + } else { + params.body = params.bulkBody + } + params.headers['Content-Type'] = 'application/x-ndjson' + if (isStream(params.body) === false) { + params.headers['Content-Length'] = '' + Buffer.byteLength(params.body) } } - params.headers['Content-Type'] = 'application/json' - if (isStream(params.body) === false) { - params.headers['Content-Length'] = '' + Buffer.byteLength(params.body) - } - // handle ndjson body - } else if (params.bulkBody != null) { - if (shouldSerialize(params.bulkBody) === true) { - try { - params.body = this.serializer.ndserialize(params.bulkBody) - } catch (err) { - return callback(err, result) - } - } else { - params.body = params.bulkBody - } - params.headers['Content-Type'] = 'application/x-ndjson' - if (isStream(params.body) === false) { - params.headers['Content-Length'] = '' + Buffer.byteLength(params.body) + + if (this.suggestCompression === true) { + params.headers['Accept-Encoding'] = 'gzip,deflate' } + + // serializes the querystring + params.querystring = this.serializer.qserialize(params.querystring) + // handles request timeout + params.timeout = toMs(params.requestTimeout || this.requestTimeout) + + meta.request = params + this.emit('request', meta) + + // perform the actual http request + return meta.connection.request(params, onResponse) } - if (this.suggestCompression === true) { - params.headers['Accept-Encoding'] = 'gzip,deflate' - } - - // serializes the querystring - params.querystring = this.serializer.qserialize(params.querystring) - // handles request timeout - params.timeout = toMs(params.requestTimeout || this.requestTimeout) - - this.emit('request', connection, params) - - // perform the actual http request - const request = connection.request(params, (err, response) => { - if (err != null) { + const onResponse = (err, response) => { + if (err !== null) { // if there is an error in the connection // let's mark the connection as dead - this.connectionPool.markDead(connection) + this.connectionPool.markDead(meta.connection) if (this.sniffOnConnectionFault === true) { this.sniff() } // retry logic - if (attempts > 0) { - debug(`Retrying request, there are still ${attempts} attempts`, params) - params[kRemainingAttempts] = attempts - 1 - return this.request(params, callback) + if (meta.attempts < maxRetries) { + meta.attempts++ + debug(`Retrying request, there are still ${maxRetries - meta.attempts} attempts`, params) + request = makeRequest(params, callback) + return } const error = err instanceof TimeoutError ? err : new ConnectionError(err.message, params) - this.emit('error', error, connection, params) + this.emit('error', error, meta) return callback(error, result) } @@ -121,7 +141,8 @@ class Transport { if (params.asStream === true) { result.body = response - this.emit('response', connection, params, result) + meta.response = result + this.emit('response', meta) callback(null, result) return } @@ -145,7 +166,7 @@ class Transport { try { result.body = this.serializer.deserialize(payload) } catch (err) { - this.emit('error', err, connection, params) + this.emit('error', err, meta) return callback(err, result) } } else { @@ -162,19 +183,22 @@ class Transport { (statusCode === 502 || statusCode === 503 || statusCode === 504)) { // if the statusCode is 502/3/4 we should run our retry strategy // and mark the connection as dead - this.connectionPool.markDead(connection) - if (attempts > 0) { - debug(`Retrying request, there are still ${attempts} attempts`, params) - params[kRemainingAttempts] = attempts - 1 - return this.request(params, callback) + this.connectionPool.markDead(meta.connection) + // retry logic + if (meta.attempts < maxRetries) { + meta.attempts++ + debug(`Retrying request, there are still ${maxRetries - meta.attempts} attempts`, params) + request = makeRequest(params, callback) + return } } else { // everything has worked as expected, let's mark // the connection as alive (or confirm it) - this.connectionPool.markAlive(connection) + this.connectionPool.markAlive(meta.connection) } - this.emit('response', connection, params, result) + meta.response = result + this.emit('response', meta) if (ignoreStatusCode === false && statusCode >= 400) { callback(new ResponseError(result), result) } else { @@ -185,12 +209,15 @@ class Transport { callback(null, result) } }) - }) + } + + request = makeRequest() return { abort: () => { + meta.aborted = true request.abort() - debug('Request aborted', params) + debug('Aborting request', params) } } } @@ -204,6 +231,8 @@ class Transport { return this.connectionPool.getConnection() } + // TODO: add sniff reason + // 'connection-fault', 'interval', 'start', ... sniff (callback = noop) { if (this._isSniffing === true) return this._isSniffing = true @@ -221,8 +250,8 @@ class Transport { } if (err != null) { - this.emit('error', err, null, request) debug('Sniffing errored', err) + this.emit('sniff', err, null) return callback(err) } @@ -230,6 +259,7 @@ class Transport { const hosts = this.connectionPool.nodesToHost(result.body.nodes) this.connectionPool.update(hosts) + this.emit('sniff', null, hosts) callback(null, hosts) }) } From bf4adf0546d9d658f804514a0afc759219886ee2 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 3 Dec 2018 18:08:20 +0100 Subject: [PATCH 058/172] Updated test --- test/unit/events.test.js | 86 +++++++++++++--------- test/unit/serializer.test.js | 14 ++++ test/unit/sniff.test.js | 137 +++++++++++++++++++++++++++++++++++ test/unit/transport.test.js | 100 +++++++++++++++++++++++++ test/utils/buildCluster.js | 79 ++++++++++++++++++++ test/utils/index.js | 2 + 6 files changed, 382 insertions(+), 36 deletions(-) create mode 100644 test/unit/sniff.test.js create mode 100644 test/utils/buildCluster.js diff --git a/test/unit/events.test.js b/test/unit/events.test.js index 2c8d8f17a..ab22b2b80 100644 --- a/test/unit/events.test.js +++ b/test/unit/events.test.js @@ -6,21 +6,26 @@ const { TimeoutError } = require('../../lib/errors') const { connection: { MockConnection, MockConnectionTimeout } } = require('../utils') test('Should emit a request event when a request is performed', t => { - t.plan(3) + t.plan(2) const client = new Client({ node: 'http://localhost:9200', Connection: MockConnection }) - client.on(events.REQUEST, (connection, request) => { - t.match(connection, { - id: 'http://localhost:9200' - }) - t.match(request, { - method: 'GET', - path: '/test/doc/_search', - querystring: 'q=foo%3Abar' + client.on(events.REQUEST, meta => { + t.match(meta, { + connection: { + id: 'http://localhost:9200' + }, + request: { + method: 'GET', + path: '/test/doc/_search', + querystring: 'q=foo%3Abar' + }, + response: null, + attempts: 0, + aborted: false }) }) @@ -34,30 +39,34 @@ test('Should emit a request event when a request is performed', t => { }) test('Should emit a response event in case of a successful response', t => { - t.plan(4) + t.plan(2) const client = new Client({ node: 'http://localhost:9200', Connection: MockConnection }) - client.on(events.RESPONSE, (connection, request, response) => { - t.match(connection, { - id: 'http://localhost:9200' - }) - t.match(request, { - method: 'GET', - path: '/test/doc/_search', - querystring: 'q=foo%3Abar' - }) - t.match(response, { - body: { hello: 'world' }, - statusCode: 200, - headers: { - 'content-type': 'application/json;utf=8', - 'connection': 'keep-alive' + client.on(events.RESPONSE, meta => { + t.match(meta, { + connection: { + id: 'http://localhost:9200' }, - warnings: null + request: { + method: 'GET', + path: '/test/doc/_search', + querystring: 'q=foo%3Abar' + }, + response: { + body: { hello: 'world' }, + statusCode: 200, + headers: { + 'content-type': 'application/json;utf=8', + 'connection': 'keep-alive' + }, + warnings: null + }, + attempts: 0, + aborted: false }) }) @@ -71,7 +80,7 @@ test('Should emit a response event in case of a successful response', t => { }) test('Should emit an error event in case of a failing response', t => { - t.plan(4) + t.plan(3) const client = new Client({ node: 'http://localhost:9200', @@ -79,19 +88,24 @@ test('Should emit an error event in case of a failing response', t => { maxRetries: 0 }) - client.on(events.RESPONSE, (connection, request, response) => { + client.on(events.RESPONSE, ({ connection, request, response }) => { t.fail('This should not be called') }) - client.on(events.ERROR, (error, connection, request) => { + client.on(events.ERROR, (error, meta) => { t.ok(error instanceof TimeoutError) - t.match(connection, { - id: 'http://localhost:9200' - }) - t.match(request, { - method: 'GET', - path: '/test/doc/_search', - querystring: 'q=foo%3Abar' + t.match(meta, { + connection: { + id: 'http://localhost:9200' + }, + request: { + method: 'GET', + path: '/test/doc/_search', + querystring: 'q=foo%3Abar' + }, + response: null, + attempts: 0, + aborted: false }) }) diff --git a/test/unit/serializer.test.js b/test/unit/serializer.test.js index cfbfb47da..4f6a491f6 100644 --- a/test/unit/serializer.test.js +++ b/test/unit/serializer.test.js @@ -74,6 +74,20 @@ test('qserialize (array)', t => { ) }) +test('qserialize (string)', t => { + t.plan(1) + const s = new Serializer() + const obj = { + hello: 'world', + you_know: 'for search' + } + + t.strictEqual( + s.qserialize(stringify(obj)), + stringify(obj) + ) +}) + test('SerializationError', t => { t.plan(1) const s = new Serializer() diff --git a/test/unit/sniff.test.js b/test/unit/sniff.test.js new file mode 100644 index 000000000..7819f7971 --- /dev/null +++ b/test/unit/sniff.test.js @@ -0,0 +1,137 @@ +'use strict' + +const { test } = require('tap') +const { URL } = require('url') +const { buildCluster } = require('../utils') +const { Client, Connection, events, errors } = require('../../index') + +test('Should update the connection pool', t => { + t.plan(8) + + buildCluster(({ nodes, shutdown }) => { + const client = new Client({ + node: nodes[Object.keys(nodes)[0]].url + }) + t.strictEqual(client.connectionPool.connections.size, 1) + + // run the sniffer + client.transport.sniff((err, hosts) => { + t.error(err) + t.strictEqual(hosts.length, 4) + + const ids = Object.keys(nodes) + for (var i = 0; i < hosts.length; i++) { + const id = ids[i] + t.deepEqual(hosts[i], { + url: new URL(nodes[id].url), + id: id, + roles: { + master: true, + data: true, + ingest: true + }, + ssl: null, + agent: null + }) + } + + t.strictEqual(client.connectionPool.connections.size, 4) + shutdown() + }) + }) +}) + +test('Sniff interval', t => { + t.plan(8) + + buildCluster(({ nodes, shutdown, kill }) => { + const client = new Client({ + node: nodes[Object.keys(nodes)[0]].url, + sniffInterval: 50 + }) + + // this event will be triggered by api calls + client.on(events.SNIFF, (err, hosts) => { + t.error(err) + t.strictEqual( + client.connectionPool.connections.size, + hosts.length + ) + }) + + t.strictEqual(client.connectionPool.connections.size, 1) + setTimeout(() => client.info(t.error), 60) + + setTimeout(() => { + // let's kill a node + kill('node1') + client.info(t.error) + }, 150) + + setTimeout(() => { + t.strictEqual(client.connectionPool.connections.size, 3) + shutdown() + }, 200) + }) +}) + +test('Should not close living connections', t => { + t.plan(3) + + buildCluster(({ nodes, shutdown, kill }) => { + class MyConnection extends Connection { + close () { + t.fail('Should not be called') + } + } + + const client = new Client({ + node: { + url: new URL(nodes[Object.keys(nodes)[0]].url), + id: 'node1' + }, + Connection: MyConnection + }) + + t.strictEqual(client.connectionPool.connections.size, 1) + client.transport.sniff((err, hosts) => { + t.error(err) + t.strictEqual( + client.connectionPool.connections.size, + hosts.length + ) + shutdown() + }) + }) +}) + +test('Sniff on connection fault', t => { + t.plan(4) + + buildCluster(({ nodes, shutdown }) => { + const client = new Client({ + nodes: [ + // TODO: this url may cause a flaky test + 'http://localhost:9200', + nodes[Object.keys(nodes)[0]].url + ], + maxRetries: 0, + sniffOnConnectionFault: true + }) + t.strictEqual(client.connectionPool.connections.size, 2) + + // this event will be triggered by the connection fault + client.on(events.SNIFF, (err, hosts) => { + t.error(err) + t.strictEqual( + client.connectionPool.connections.size, + hosts.length + ) + shutdown() + }) + + client.info((err, result) => { + t.ok(err instanceof errors.ConnectionError) + }) + }) +}) diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index 33c9427ec..48c341a90 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -468,6 +468,57 @@ test('Retry mechanism', t => { }) }) +test('Custom retry mechanism', t => { + t.plan(2) + + var count = 0 + function handler (req, res) { + res.setHeader('Content-Type', 'application/json;utf=8') + if (count > 0) { + res.end(JSON.stringify({ hello: 'world' })) + } else { + setTimeout(() => { + res.end(JSON.stringify({ hello: 'world' })) + }, 1000) + } + count++ + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ Connection }) + pool.addConnection([{ + url: new URL(`http://localhost:${port}`), + id: 'node1' + }, { + url: new URL(`http://localhost:${port}`), + id: 'node2' + }, { + url: new URL(`http://localhost:${port}`), + id: 'node3' + }]) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 0, + requestTimeout: 250, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello', + maxRetries: 1 + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + server.stop() + }) + }) +}) + test('Should call markAlive with a successful response', t => { t.plan(3) @@ -567,6 +618,55 @@ test('Should return a request aborter utility', t => { t.pass('ok') }) +test('Retry mechanism and abort', t => { + t.plan(1) + + function handler (req, res) { + setTimeout(() => { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + }, 1000) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ Connection }) + pool.addConnection([{ + url: new URL(`http://localhost:${port}`), + id: 'node1' + }, { + url: new URL(`http://localhost:${port}`), + id: 'node2' + }, { + url: new URL(`http://localhost:${port}`), + id: 'node3' + }]) + + var count = 0 + const transport = new Transport({ + emit: event => { + if (event === 'request' && count++ > 0) { + request.abort() + server.stop() + t.pass('ok') + } + }, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 2, + requestTimeout: 100, + sniffInterval: false, + sniffOnStart: false + }) + + const request = transport.request({ + method: 'GET', + path: '/hello' + }, (e, { body }) => { + t.fail('Should not be called') + }) + }) +}) + test('ResponseError', t => { t.plan(3) diff --git a/test/utils/buildCluster.js b/test/utils/buildCluster.js new file mode 100644 index 000000000..d9c071655 --- /dev/null +++ b/test/utils/buildCluster.js @@ -0,0 +1,79 @@ +'use strict' + +const workq = require('workq') +const buildServer = require('./buildServer') + +function buildCluster (opts, callback) { + if (typeof opts === 'function') { + callback = opts + opts = {} + } + + const q = workq() + const nodes = {} + const sniffResult = { nodes: {} } + + opts.numberOfNodes = opts.numberOfNodes || 4 + for (var i = 0; i < opts.numberOfNodes; i++) { + q.add(bootNode, { id: `node${i}` }) + } + + function bootNode (q, opts, done) { + function handler (req, res) { + res.setHeader('content-type', 'application/json') + if (req.url === '/_nodes/_all/http') { + res.end(JSON.stringify(sniffResult)) + } else { + res.end(JSON.stringify({ hello: 'world' })) + } + } + + buildServer(handler, ({ port }, server) => { + nodes[opts.id] = { + url: `http://localhost:${port}`, + server + } + sniffResult.nodes[opts.id] = { + http: { + publish_address: `http://localhost:${port}` + }, + roles: ['master', 'data', 'ingest'] + } + done() + }) + } + + function shutdown () { + Object.keys(nodes).forEach(id => { + nodes[id].server.stop() + }) + } + + function kill (id) { + nodes[id].server.stop() + delete nodes[id] + delete sniffResult.nodes[id] + } + + function spawn (id, callback) { + q.add(bootNode, { id }) + q.add((q, done) => { + callback() + done() + }) + } + + const cluster = { + nodes, + shutdown, + kill, + spawn + } + + q.drain(done => { + callback(cluster) + done() + }) +} + +module.exports = buildCluster diff --git a/test/utils/index.js b/test/utils/index.js index c35e6c5c4..0aa7c6a17 100644 --- a/test/utils/index.js +++ b/test/utils/index.js @@ -1,9 +1,11 @@ 'use strict' const buildServer = require('./buildServer') +const buildCluster = require('./buildCluster') const connection = require('./MockConnection') module.exports = { buildServer, + buildCluster, connection } From b60a716e009d74c5379229e50e5935a7f274835e Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 4 Dec 2018 14:29:40 +0100 Subject: [PATCH 059/172] WIP: initial prototype - Added sniff reason - Improved types --- index.d.ts | 15 +++++++-- lib/Transport.d.ts | 79 ++++++++++++++++++++++++++++------------------ lib/Transport.js | 27 +++++++++++----- 3 files changed, 80 insertions(+), 41 deletions(-) diff --git a/index.d.ts b/index.d.ts index 9ac5b80f5..2ba3adcc0 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2,11 +2,10 @@ import { EventEmitter } from 'events'; import { SecureContextOptions } from 'tls'; -import Transport from './lib/Transport'; +import Transport, { ApiResponse, EventMeta, SniffMeta } from './lib/Transport'; import Connection, { AgentOptions } from './lib/Connection'; import ConnectionPool, { nodeSelectorFn, nodeFilterFn } from './lib/ConnectionPool'; import Serializer from './lib/Serializer'; -import { ApiResponse } from './lib/Transport'; declare type anyObject = { [key: string]: any; @@ -471,4 +470,14 @@ declare const events: { SNIFF: string; }; -export { Client, Transport, ConnectionPool, Connection, Serializer, events, ApiResponse }; +export { + Client, + Transport, + ConnectionPool, + Connection, + Serializer, + events, + ApiResponse, + EventMeta, + SniffMeta +}; diff --git a/lib/Transport.d.ts b/lib/Transport.d.ts index 8839ce3eb..91099291f 100644 --- a/lib/Transport.d.ts +++ b/lib/Transport.d.ts @@ -6,42 +6,61 @@ declare type noopFn = (...args: any[]) => void; declare type emitFn = (event: string | symbol, ...args: any[]) => boolean; interface TransportOptions { - emit: emitFn & noopFn; - connectionPool: ConnectionPool; - serializer: Serializer; - maxRetries: number; - requestTimeout: number | string; - suggestCompression: boolean; - sniffInterval: number; - sniffOnConnectionFault: boolean; - sniffEndpoint: string; - sniffOnStart: boolean; + emit: emitFn & noopFn; + connectionPool: ConnectionPool; + serializer: Serializer; + maxRetries: number; + requestTimeout: number | string; + suggestCompression: boolean; + sniffInterval: number; + sniffOnConnectionFault: boolean; + sniffEndpoint: string; + sniffOnStart: boolean; } export interface ApiResponse { - body: any; - statusCode: number | null; - headers: any; - warnings: any[] | null; + body: any; + statusCode: number | null; + headers: any; + warnings: any[] | null; +} + +export interface EventMeta { + connection: Connection; + request: any; + response: ApiResponse; + attempts: number; + aborted: boolean; +} + +export interface SniffMeta { + hosts: any[]; + reason: string; } export default class Transport { - emit: emitFn & noopFn; - connectionPool: ConnectionPool; - serializer: Serializer; - maxRetries: number; - requestTimeout: number; - suggestCompression: boolean; - sniffInterval: number; - sniffOnConnectionFault: boolean; - sniffEndpoint: string; - _sniffEnabled: boolean; - _nextSniff: number; - _isSniffing: boolean; - constructor(opts: TransportOptions); - request(params: any, callback: (err: Error | null, result: ApiResponse) => void): any; - getConnection(): Connection | null; - sniff(callback?: (...args: any[]) => void): void; + static sniffReasons: { + SNIFF_ON_START: string; + SNIFF_INTERVAL: string; + SNIFF_ON_CONNECTION_FAULT: string; + DEFAULT: string; + }; + emit: emitFn & noopFn; + connectionPool: ConnectionPool; + serializer: Serializer; + maxRetries: number; + requestTimeout: number; + suggestCompression: boolean; + sniffInterval: number; + sniffOnConnectionFault: boolean; + sniffEndpoint: string; + _sniffEnabled: boolean; + _nextSniff: number; + _isSniffing: boolean; + constructor(opts: TransportOptions); + request(params: any, callback: (err: Error | null, result: ApiResponse) => void): any; + getConnection(): Connection | null; + sniff(callback?: (...args: any[]) => void): void; } export {}; diff --git a/lib/Transport.js b/lib/Transport.js index 941e17c8f..51f29667b 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -29,7 +29,7 @@ class Transport { this._isSniffing = false if (opts.sniffOnStart === true) { - this.sniff() + this.sniff(Transport.sniffReasons.SNIFF_ON_START) } } @@ -112,7 +112,7 @@ class Transport { this.connectionPool.markDead(meta.connection) if (this.sniffOnConnectionFault === true) { - this.sniff() + this.sniff(Transport.sniffReasons.SNIFF_ON_CONNECTION_FAULT) } // retry logic @@ -225,19 +225,22 @@ class Transport { getConnection () { const now = Date.now() if (this._sniffEnabled === true && now > this._nextSniff) { - this.sniff() + this.sniff(Transport.sniffReasons.SNIFF_INTERVAL) } this.connectionPool.resurrect(now) return this.connectionPool.getConnection() } - // TODO: add sniff reason - // 'connection-fault', 'interval', 'start', ... - sniff (callback = noop) { + sniff (reason = Transport.sniffReasons.DEFAULT, callback = noop) { if (this._isSniffing === true) return this._isSniffing = true debug('Started sniffing request') + if (typeof reason === 'function') { + callback = reason + reason = Transport.sniffReasons.DEFAULT + } + const request = { method: 'GET', path: this.sniffEndpoint @@ -251,7 +254,7 @@ class Transport { if (err != null) { debug('Sniffing errored', err) - this.emit('sniff', err, null) + this.emit('sniff', err, { hosts: [], reason }) return callback(err) } @@ -259,12 +262,20 @@ class Transport { const hosts = this.connectionPool.nodesToHost(result.body.nodes) this.connectionPool.update(hosts) - this.emit('sniff', null, hosts) + this.emit('sniff', null, { hosts, reason }) callback(null, hosts) }) } } +Transport.sniffReasons = { + SNIFF_ON_START: 'sniff-on-start', + SNIFF_INTERVAL: 'sniff-interval', + SNIFF_ON_CONNECTION_FAULT: 'sniff-on-connection-fault', + // TODO: find a better name + DEFAULT: 'default' +} + function toMs (time) { if (typeof time === 'string') { return ms(time) From 4b2df7504e312e55433d03f12fe29fbbdecb670d Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 4 Dec 2018 14:30:28 +0100 Subject: [PATCH 060/172] Updated test --- test/types/index.ts | 13 ++++++++++++- test/unit/sniff.test.js | 19 +++++++++++++------ test/utils/buildServer.js | 4 ++++ 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/test/types/index.ts b/test/types/index.ts index ad9af76c2..4e69ff176 100644 --- a/test/types/index.ts +++ b/test/types/index.ts @@ -1,9 +1,20 @@ 'use strict' -import { Client, ApiResponse } from '../../index' +import { + Client, + ApiResponse, + EventMeta, + SniffMeta, + events +} from '../../index' const client = new Client({ node: 'http://localhost:9200' }) +client.on(events.REQUEST, (meta: EventMeta) => {}) +client.on(events.RESPONSE, (meta: EventMeta) => {}) +client.on(events.ERROR, (err: Error, meta: EventMeta) => {}) +client.on(events.SNIFF, (err: Error, meta: SniffMeta) => {}) + // Callbacks client.info((err: Error | null, result: ApiResponse) => {}) diff --git a/test/unit/sniff.test.js b/test/unit/sniff.test.js index 7819f7971..14e818b57 100644 --- a/test/unit/sniff.test.js +++ b/test/unit/sniff.test.js @@ -3,10 +3,10 @@ const { test } = require('tap') const { URL } = require('url') const { buildCluster } = require('../utils') -const { Client, Connection, events, errors } = require('../../index') +const { Client, Connection, Transport, events, errors } = require('../../index') test('Should update the connection pool', t => { - t.plan(8) + t.plan(10) buildCluster(({ nodes, shutdown }) => { const client = new Client({ @@ -14,6 +14,11 @@ test('Should update the connection pool', t => { }) t.strictEqual(client.connectionPool.connections.size, 1) + client.on(events.SNIFF, (err, { reason }) => { + t.error(err) + t.strictEqual(reason, Transport.sniffReasons.DEFAULT) + }) + // run the sniffer client.transport.sniff((err, hosts) => { t.error(err) @@ -42,7 +47,7 @@ test('Should update the connection pool', t => { }) test('Sniff interval', t => { - t.plan(8) + t.plan(10) buildCluster(({ nodes, shutdown, kill }) => { const client = new Client({ @@ -51,12 +56,13 @@ test('Sniff interval', t => { }) // this event will be triggered by api calls - client.on(events.SNIFF, (err, hosts) => { + client.on(events.SNIFF, (err, { hosts, reason }) => { t.error(err) t.strictEqual( client.connectionPool.connections.size, hosts.length ) + t.strictEqual(reason, Transport.sniffReasons.SNIFF_INTERVAL) }) t.strictEqual(client.connectionPool.connections.size, 1) @@ -106,7 +112,7 @@ test('Should not close living connections', t => { }) test('Sniff on connection fault', t => { - t.plan(4) + t.plan(5) buildCluster(({ nodes, shutdown }) => { const client = new Client({ @@ -121,12 +127,13 @@ test('Sniff on connection fault', t => { t.strictEqual(client.connectionPool.connections.size, 2) // this event will be triggered by the connection fault - client.on(events.SNIFF, (err, hosts) => { + client.on(events.SNIFF, (err, { hosts, reason }) => { t.error(err) t.strictEqual( client.connectionPool.connections.size, hosts.length ) + t.strictEqual(reason, Transport.sniffReasons.SNIFF_ON_CONNECTION_FAULT) shutdown() }) diff --git a/test/utils/buildServer.js b/test/utils/buildServer.js index 3de966fcf..5dde978bf 100644 --- a/test/utils/buildServer.js +++ b/test/utils/buildServer.js @@ -26,6 +26,10 @@ function buildServer (handler, opts, cb) { : stoppable(http.createServer()) server.on('request', handler) + server.on('error', err => { + console.log('http server error', err) + process.exit(1) + }) server.listen(0, () => { const port = server.address().port cb(Object.assign({}, secureOpts, { port }), server) From 8fd49389f343031004fa22d487fd41f708c6fdc4 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 5 Dec 2018 11:06:57 +0100 Subject: [PATCH 061/172] Added debug logs in test --- .travis.yml | 3 +-- package.json | 2 +- test/utils/buildCluster.js | 13 ++++++++++--- test/utils/buildServer.js | 5 +++++ 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index b4de52bce..743820f04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,13 +18,12 @@ before_install: - wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz - tar -xzf elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz - ./elasticsearch-${ELASTICSEARCH_VERSION}/bin/elasticsearch -Enode.attr.testattr=test -Epath.repo=/tmp -Erepositories.url.allowed_urls='http://snapshot.*' &> /dev/null & - - ./scripts/wait-cluster.sh install: - npm install script: - - npm run lint && npm run test:unit && npm run test:integration + - npm run ci notifications: email: diff --git a/package.json b/package.json index 067af3ba8..49fff7e44 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ ], "scripts": { "test": "npm run lint && npm run test:unit && npm run test:types", - "test:unit": "tap test/unit/*.test.js -J -T", + "test:unit": "tap test/unit/*.test.js -T", "test:integration": "tap test/integration/index.js -T --harmony", "test:types": "tsc --project ./test/types/tsconfig.json", "lint": "standard", diff --git a/test/utils/buildCluster.js b/test/utils/buildCluster.js index d9c071655..79b0658ed 100644 --- a/test/utils/buildCluster.js +++ b/test/utils/buildCluster.js @@ -1,9 +1,13 @@ 'use strict' +const debug = require('debug')('elasticsearch-test') const workq = require('workq') const buildServer = require('./buildServer') +var id = 0 function buildCluster (opts, callback) { + const clusterId = id++ + debug(`Booting cluster '${clusterId}'`) if (typeof opts === 'function') { callback = opts opts = {} @@ -39,23 +43,25 @@ function buildCluster (opts, callback) { }, roles: ['master', 'data', 'ingest'] } + debug(`Booted cluster node '${opts.id}' on port ${port} (cluster id: '${clusterId}')`) done() }) } function shutdown () { - Object.keys(nodes).forEach(id => { - nodes[id].server.stop() - }) + debug(`Shutting down cluster '${clusterId}'`) + Object.keys(nodes).forEach(kill) } function kill (id) { + debug(`Shutting down cluster node '${id}' (cluster id: '${clusterId}')`) nodes[id].server.stop() delete nodes[id] delete sniffResult.nodes[id] } function spawn (id, callback) { + debug(`Spawning cluster node '${id}' (cluster id: '${clusterId}')`) q.add(bootNode, { id }) q.add((q, done) => { callback() @@ -71,6 +77,7 @@ function buildCluster (opts, callback) { } q.drain(done => { + debug(`Cluster '${clusterId}' booted with ${opts.numberOfNodes} nodes`) callback(cluster) done() }) diff --git a/test/utils/buildServer.js b/test/utils/buildServer.js index 5dde978bf..235195594 100644 --- a/test/utils/buildServer.js +++ b/test/utils/buildServer.js @@ -1,5 +1,6 @@ 'use strict' +const debug = require('debug')('elasticsearch-test') const stoppable = require('stoppable') // allow self signed certificates for testing purposes @@ -15,7 +16,10 @@ const secureOpts = { cert: readFileSync(join(__dirname, '..', 'fixtures', 'https.cert'), 'utf8') } +var id = 0 function buildServer (handler, opts, cb) { + const serverId = id++ + debug(`Booting server '${serverId}'`) if (cb == null) { cb = opts opts = {} @@ -32,6 +36,7 @@ function buildServer (handler, opts, cb) { }) server.listen(0, () => { const port = server.address().port + debug(`Server '${serverId}' booted on port ${port}`) cb(Object.assign({}, secureOpts, { port }), server) }) } From 18b8c3275861e8c3183870472946374442a8e5a4 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 5 Dec 2018 12:30:44 +0100 Subject: [PATCH 062/172] Added behavior test --- package.json | 5 +++-- test/{unit => behavior}/sniff.test.js | 21 +++++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) rename test/{unit => behavior}/sniff.test.js (88%) diff --git a/package.json b/package.json index 49fff7e44..4d4b9c666 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,9 @@ "index" ], "scripts": { - "test": "npm run lint && npm run test:unit && npm run test:types", - "test:unit": "tap test/unit/*.test.js -T", + "test": "npm run lint && npm run test:unit && npm run test:behavior && npm run test:types", + "test:unit": "tap test/unit/*.test.js -J -T", + "test:behavior": "tap test/behavior/*.test.js -J -T", "test:integration": "tap test/integration/index.js -T --harmony", "test:types": "tsc --project ./test/types/tsconfig.json", "lint": "standard", diff --git a/test/unit/sniff.test.js b/test/behavior/sniff.test.js similarity index 88% rename from test/unit/sniff.test.js rename to test/behavior/sniff.test.js index 14e818b57..97e184126 100644 --- a/test/unit/sniff.test.js +++ b/test/behavior/sniff.test.js @@ -5,6 +5,16 @@ const { URL } = require('url') const { buildCluster } = require('../utils') const { Client, Connection, Transport, events, errors } = require('../../index') +/** + * The aim of this test is to verify how the sniffer behaves + * in a multi node situation. + * The `buildCluster` utility can boot an arbitrary number + * of nodes, that you can kill or spawn at your will. + * The sniffer component can be tested with its callback + * or by using the `sniff` event (to handle automatically + * triggered sniff). + */ + test('Should update the connection pool', t => { t.plan(10) @@ -41,8 +51,8 @@ test('Should update the connection pool', t => { } t.strictEqual(client.connectionPool.connections.size, 4) - shutdown() }) + t.teardown(shutdown) }) }) @@ -76,8 +86,9 @@ test('Sniff interval', t => { setTimeout(() => { t.strictEqual(client.connectionPool.connections.size, 3) - shutdown() }, 200) + + t.teardown(shutdown) }) }) @@ -106,8 +117,9 @@ test('Should not close living connections', t => { client.connectionPool.connections.size, hosts.length ) - shutdown() }) + + t.teardown(shutdown) }) }) @@ -134,11 +146,12 @@ test('Sniff on connection fault', t => { hosts.length ) t.strictEqual(reason, Transport.sniffReasons.SNIFF_ON_CONNECTION_FAULT) - shutdown() }) client.info((err, result) => { t.ok(err instanceof errors.ConnectionError) }) + + t.teardown(shutdown) }) }) From 7e35f6a9037bc1f33cfd34bb944643176ead8c71 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 5 Dec 2018 17:29:21 +0100 Subject: [PATCH 063/172] Updated behavior test --- package.json | 4 ++-- test/behavior/sniff.test.js | 42 +++++++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 4d4b9c666..8c20128fe 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,8 @@ ], "scripts": { "test": "npm run lint && npm run test:unit && npm run test:behavior && npm run test:types", - "test:unit": "tap test/unit/*.test.js -J -T", - "test:behavior": "tap test/behavior/*.test.js -J -T", + "test:unit": "tap test/unit/*.test.js -J -t 300", + "test:behavior": "tap test/behavior/*.test.js -J -t 300", "test:integration": "tap test/integration/index.js -T --harmony", "test:types": "tsc --project ./test/types/tsconfig.json", "lint": "standard", diff --git a/test/behavior/sniff.test.js b/test/behavior/sniff.test.js index 97e184126..c6ec1334f 100644 --- a/test/behavior/sniff.test.js +++ b/test/behavior/sniff.test.js @@ -92,6 +92,29 @@ test('Sniff interval', t => { }) }) +test('Sniff on start', t => { + t.plan(4) + + buildCluster(({ nodes, shutdown, kill }) => { + const client = new Client({ + node: nodes[Object.keys(nodes)[0]].url, + sniffOnStart: true + }) + + client.on(events.SNIFF, (err, { hosts, reason }) => { + t.error(err) + t.strictEqual( + client.connectionPool.connections.size, + hosts.length + ) + t.strictEqual(reason, Transport.sniffReasons.SNIFF_ON_START) + }) + + t.strictEqual(client.connectionPool.connections.size, 1) + t.teardown(shutdown) + }) +}) + test('Should not close living connections', t => { t.plan(3) @@ -126,18 +149,29 @@ test('Should not close living connections', t => { test('Sniff on connection fault', t => { t.plan(5) - buildCluster(({ nodes, shutdown }) => { + buildCluster(({ nodes, shutdown, kill }) => { + class MyConnection extends Connection { + request (params, callback) { + if (this.id === 'http://localhost:9200/') { + callback(new Error('kaboom'), null) + return {} + } else { + return super.request(params, callback) + } + } + } + const client = new Client({ nodes: [ - // TODO: this url may cause a flaky test 'http://localhost:9200', nodes[Object.keys(nodes)[0]].url ], maxRetries: 0, - sniffOnConnectionFault: true + sniffOnConnectionFault: true, + Connection: MyConnection }) - t.strictEqual(client.connectionPool.connections.size, 2) + t.strictEqual(client.connectionPool.connections.size, 2) // this event will be triggered by the connection fault client.on(events.SNIFF, (err, { hosts, reason }) => { t.error(err) From aa5977b153c37e9a2194dc22b9d9be9bd0e05f59 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 5 Dec 2018 22:16:16 +0100 Subject: [PATCH 064/172] WIP: initial prototype - Added error parameter to request and response event - Dropped error event - Updated typescript indentation --- index.d.ts | 9 +- index.js | 7 -- lib/Connection.d.ts | 80 +++++++-------- lib/ConnectionPool.d.ts | 218 ++++++++++++++++++++-------------------- lib/Serializer.d.ts | 8 +- lib/Transport.d.ts | 8 +- lib/Transport.js | 20 ++-- lib/errors.d.ts | 56 +++++------ 8 files changed, 202 insertions(+), 204 deletions(-) diff --git a/index.d.ts b/index.d.ts index 2ba3adcc0..acb52b595 100644 --- a/index.d.ts +++ b/index.d.ts @@ -8,7 +8,7 @@ import ConnectionPool, { nodeSelectorFn, nodeFilterFn } from './lib/ConnectionPo import Serializer from './lib/Serializer'; declare type anyObject = { - [key: string]: any; + [key: string]: any; }; declare type callbackFn = (err: Error | null, result: ApiResponse) => void; declare type apiMethod = (params?: anyObject | callbackFn, callback?: callbackFn) => any; @@ -464,10 +464,9 @@ declare class Client extends EventEmitter { } declare const events: { - RESPONSE: string; - REQUEST: string; - ERROR: string; - SNIFF: string; + RESPONSE: string; + REQUEST: string; + SNIFF: string; }; export { diff --git a/index.js b/index.js index 3f8037659..a54b93bfa 100644 --- a/index.js +++ b/index.js @@ -23,12 +23,6 @@ class Client extends EventEmitter { this.on('error', console.log) } - // The logging is exposed via events, which the user can - // listen to and log the message its preferred way - // we add a fake listener to the error event to avoid - // the "unhandled error event" error. - this.on('error', () => {}) - const options = Object.assign({}, { Connection, ConnectionPool, @@ -95,7 +89,6 @@ class Client extends EventEmitter { const events = { RESPONSE: 'response', REQUEST: 'request', - ERROR: 'error', SNIFF: 'sniff' } diff --git a/lib/Connection.d.ts b/lib/Connection.d.ts index f746940de..80953fd40 100644 --- a/lib/Connection.d.ts +++ b/lib/Connection.d.ts @@ -5,52 +5,52 @@ import * as http from 'http'; import { SecureContextOptions } from 'tls'; interface ConnectionOptions { - url: URL; - ssl?: SecureContextOptions; - id?: string; - headers?: any; - agent?: AgentOptions; - status?: string; - roles?: any; + url: URL; + ssl?: SecureContextOptions; + id?: string; + headers?: any; + agent?: AgentOptions; + status?: string; + roles?: any; } export interface AgentOptions { - keepAlive: boolean; - keepAliveMsecs: number; - maxSockets: number; - maxFreeSockets: number; + keepAlive: boolean; + keepAliveMsecs: number; + maxSockets: number; + maxFreeSockets: number; } export default class Connection { - static statuses: { - ALIVE: string; - DEAD: string; - }; - static roles: { - MASTER: string; - DATA: string; - INGEST: string; - COORDINATING: string; - MACHINE_LEARNING: string; - }; - url: URL; - ssl: SecureContextOptions | null; - id: string; - headers: any; - deadCount: number; - resurrectTimeout: number; - statuses: any; - roles: any; - makeRequest: any; - _openRequests: number; - _status: string; - _agent: http.Agent; - constructor(opts?: ConnectionOptions); - request(params: any, callback: (err: Error | null, response: http.IncomingMessage | null) => void): http.ClientRequest; - close(): Connection; - setRole(role: string, enabled: boolean): Connection; - status: string; - buildRequestObject(params: any): http.ClientRequestArgs; + static statuses: { + ALIVE: string; + DEAD: string; + }; + static roles: { + MASTER: string; + DATA: string; + INGEST: string; + COORDINATING: string; + MACHINE_LEARNING: string; + }; + url: URL; + ssl: SecureContextOptions | null; + id: string; + headers: any; + deadCount: number; + resurrectTimeout: number; + statuses: any; + roles: any; + makeRequest: any; + _openRequests: number; + _status: string; + _agent: http.Agent; + constructor(opts?: ConnectionOptions); + request(params: any, callback: (err: Error | null, response: http.IncomingMessage | null) => void): http.ClientRequest; + close(): Connection; + setRole(role: string, enabled: boolean): Connection; + status: string; + buildRequestObject(params: any): http.ClientRequestArgs; } export {}; diff --git a/lib/ConnectionPool.d.ts b/lib/ConnectionPool.d.ts index e4ad414c6..94ffaae34 100644 --- a/lib/ConnectionPool.d.ts +++ b/lib/ConnectionPool.d.ts @@ -4,124 +4,124 @@ import { SecureContextOptions } from 'tls'; import Connection, { AgentOptions } from './Connection'; export interface nodeSelectorFn { - (connections: Connection[]): Connection; + (connections: Connection[]): Connection; } export interface nodeFilterFn { - (connection: Connection): boolean; + (connection: Connection): boolean; } interface ConnectionPoolOptions { - ssl?: SecureContextOptions; - agent?: AgentOptions; - pingTimeout?: number; - randomizeHost?: boolean; - Connection: typeof Connection; - resurrectStrategy?: string; - nodeFilter?: nodeFilterFn; - nodeSelector?: string | nodeSelectorFn; + ssl?: SecureContextOptions; + agent?: AgentOptions; + pingTimeout?: number; + randomizeHost?: boolean; + Connection: typeof Connection; + resurrectStrategy?: string; + nodeFilter?: nodeFilterFn; + nodeSelector?: string | nodeSelectorFn; } export interface getConnectionOptions { - filter?: nodeFilterFn; - selector?: nodeSelectorFn; + filter?: nodeFilterFn; + selector?: nodeSelectorFn; } export default class ConnectionPool { - static resurrectStrategies: { - none: number; - ping: number; - optimistic: number; - }; - connections: any; - dead: string[]; - _ssl: SecureContextOptions | null; - _agent: AgentOptions | null; - resurrectTimeout: number; - resurrectTimeoutCutoff: number; - pingTimeout: number; - randomizeHost: boolean; - nodeFilter: nodeFilterFn; - nodeSelector: nodeSelectorFn; - Connection: typeof Connection; - resurrectStrategy: number; - constructor(opts?: ConnectionPoolOptions); - /** - * Marks a connection as 'alive'. - * If needed removes the connection from the dead list - * and then resets the `deadCount`. - * - * @param {object} connection - */ - markAlive(connection: Connection): void; - /** - * Marks a connection as 'dead'. - * If needed adds the connection to the dead list - * and then increments the `deadCount`. - * - * @param {object} connection - */ - markDead(connection: Connection): void; - /** - * If enabled, tries to resurrect a connection with the given - * resurrect strategy ('ping', 'optimistic', 'none'). - * - * @param {number} epoch - * @param {function} callback (isAlive, connection) - */ - resurrect(now?: number, callback?: (isAlive: boolean | null, connection: Connection | null) => void): void; - /** - * Returns an alive connection if present, - * otherwise returns null. - * By default it filters the `master` only nodes. - * It uses the selector to choose which - * connection return. - * - * @param {object} options (filter and selector) - * @returns {object|null} connection - */ - getConnection(opts?: getConnectionOptions): Connection | null; - /** - * Adds a new connection to the pool. - * - * @param {object|string} host - * @returns {ConnectionPool} - */ - addConnection(opts: any): Connection | void; - /** - * Removes a new connection to the pool. - * - * @param {object} connection - * @returns {ConnectionPool} - */ - removeConnection(connection: Connection): ConnectionPool; - /** - * Empties the connection pool. - * - * @returns {ConnectionPool} - */ - empty(): ConnectionPool; - /** - * Update the ConnectionPool with new connections. - * - * @param {array} array of connections - * @returns {ConnectionPool} - */ - update(connections: Connection[]): ConnectionPool; - /** - * Transforms the nodes objects to a host object. - * - * @param {object} nodes - * @returns {array} hosts - */ - nodesToHost(nodes: any): any[]; - /** - * Transforms an url string to a host object - * - * @param {string} url - * @returns {object} host - */ - urlToHost(url: string): any; + static resurrectStrategies: { + none: number; + ping: number; + optimistic: number; + }; + connections: any; + dead: string[]; + _ssl: SecureContextOptions | null; + _agent: AgentOptions | null; + resurrectTimeout: number; + resurrectTimeoutCutoff: number; + pingTimeout: number; + randomizeHost: boolean; + nodeFilter: nodeFilterFn; + nodeSelector: nodeSelectorFn; + Connection: typeof Connection; + resurrectStrategy: number; + constructor(opts?: ConnectionPoolOptions); + /** + * Marks a connection as 'alive'. + * If needed removes the connection from the dead list + * and then resets the `deadCount`. + * + * @param {object} connection + */ + markAlive(connection: Connection): void; + /** + * Marks a connection as 'dead'. + * If needed adds the connection to the dead list + * and then increments the `deadCount`. + * + * @param {object} connection + */ + markDead(connection: Connection): void; + /** + * If enabled, tries to resurrect a connection with the given + * resurrect strategy ('ping', 'optimistic', 'none'). + * + * @param {number} epoch + * @param {function} callback (isAlive, connection) + */ + resurrect(now?: number, callback?: (isAlive: boolean | null, connection: Connection | null) => void): void; + /** + * Returns an alive connection if present, + * otherwise returns null. + * By default it filters the `master` only nodes. + * It uses the selector to choose which + * connection return. + * + * @param {object} options (filter and selector) + * @returns {object|null} connection + */ + getConnection(opts?: getConnectionOptions): Connection | null; + /** + * Adds a new connection to the pool. + * + * @param {object|string} host + * @returns {ConnectionPool} + */ + addConnection(opts: any): Connection | void; + /** + * Removes a new connection to the pool. + * + * @param {object} connection + * @returns {ConnectionPool} + */ + removeConnection(connection: Connection): ConnectionPool; + /** + * Empties the connection pool. + * + * @returns {ConnectionPool} + */ + empty(): ConnectionPool; + /** + * Update the ConnectionPool with new connections. + * + * @param {array} array of connections + * @returns {ConnectionPool} + */ + update(connections: Connection[]): ConnectionPool; + /** + * Transforms the nodes objects to a host object. + * + * @param {object} nodes + * @returns {array} hosts + */ + nodesToHost(nodes: any): any[]; + /** + * Transforms an url string to a host object + * + * @param {string} url + * @returns {object} host + */ + urlToHost(url: string): any; } declare function defaultNodeFilter(node: Connection): boolean; @@ -129,9 +129,9 @@ declare function roundRobinSelector(): (connections: Connection[]) => Connection declare function randomSelector(connections: Connection[]): Connection; export declare const internals: { - defaultNodeFilter: typeof defaultNodeFilter; - roundRobinSelector: typeof roundRobinSelector; - randomSelector: typeof randomSelector; + defaultNodeFilter: typeof defaultNodeFilter; + roundRobinSelector: typeof roundRobinSelector; + randomSelector: typeof randomSelector; }; export {}; diff --git a/lib/Serializer.d.ts b/lib/Serializer.d.ts index 0a05e431e..542081d2c 100644 --- a/lib/Serializer.d.ts +++ b/lib/Serializer.d.ts @@ -1,6 +1,6 @@ export default class Serializer { - serialize(object: any): string; - deserialize(json: string): any; - ndserialize(array: any[]): string; - qserialize(object: any): string; + serialize(object: any): string; + deserialize(json: string): any; + ndserialize(array: any[]): string; + qserialize(object: any): string; } diff --git a/lib/Transport.d.ts b/lib/Transport.d.ts index 91099291f..1a3493991 100644 --- a/lib/Transport.d.ts +++ b/lib/Transport.d.ts @@ -40,10 +40,10 @@ export interface SniffMeta { export default class Transport { static sniffReasons: { - SNIFF_ON_START: string; - SNIFF_INTERVAL: string; - SNIFF_ON_CONNECTION_FAULT: string; - DEFAULT: string; + SNIFF_ON_START: string; + SNIFF_INTERVAL: string; + SNIFF_ON_CONNECTION_FAULT: string; + DEFAULT: string; }; emit: emitFn & noopFn; connectionPool: ConnectionPool; diff --git a/lib/Transport.js b/lib/Transport.js index 51f29667b..b15857d99 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -99,7 +99,7 @@ class Transport { params.timeout = toMs(params.requestTimeout || this.requestTimeout) meta.request = params - this.emit('request', meta) + this.emit('request', null, meta) // perform the actual http request return meta.connection.request(params, onResponse) @@ -127,7 +127,7 @@ class Transport { ? err : new ConnectionError(err.message, params) - this.emit('error', error, meta) + this.emit('response', error, meta) return callback(error, result) } @@ -142,7 +142,7 @@ class Transport { if (params.asStream === true) { result.body = response meta.response = result - this.emit('response', meta) + this.emit('response', null, meta) callback(null, result) return } @@ -151,7 +151,11 @@ class Transport { // collect the payload response.setEncoding('utf8') response.on('data', chunk => { payload += chunk }) - response.on('error', err => callback(new ConnectionError(err.message, params), result)) + response.on('error', err => { + const error = new ConnectionError(err.message, params) + this.emit('response', error, meta) + callback(error, result) + }) response.on('end', () => { const isHead = params.method === 'HEAD' // we should attempt the payload deserialization only if: @@ -166,7 +170,7 @@ class Transport { try { result.body = this.serializer.deserialize(payload) } catch (err) { - this.emit('error', err, meta) + this.emit('response', err, meta) return callback(err, result) } } else { @@ -198,14 +202,16 @@ class Transport { } meta.response = result - this.emit('response', meta) if (ignoreStatusCode === false && statusCode >= 400) { - callback(new ResponseError(result), result) + const error = new ResponseError(result) + this.emit('response', error, meta) + callback(error, result) } else { // cast to boolean if the request method was HEAD if (isHead === true && statusCode === 404) { result.body = false } + this.emit('response', null, meta) callback(null, result) } }) diff --git a/lib/errors.d.ts b/lib/errors.d.ts index ec5a9f6b3..9bd88ae1c 100644 --- a/lib/errors.d.ts +++ b/lib/errors.d.ts @@ -1,48 +1,48 @@ export declare class TimeoutError extends Error { - name: string; - message: string; - request: any; - constructor(message: string, request: any); + name: string; + message: string; + request: any; + constructor(message: string, request: any); } export declare class ConnectionError extends Error { - name: string; - message: string; - request: any; - constructor(message: string, request: any); + name: string; + message: string; + request: any; + constructor(message: string, request: any); } export declare class NoLivingConnectionsError extends Error { - name: string; - message: string; - constructor(message: string); + name: string; + message: string; + constructor(message: string); } export declare class SerializationError extends Error { - name: string; - message: string; - constructor(message: string); + name: string; + message: string; + constructor(message: string); } export declare class DeserializationError extends Error { - name: string; - message: string; - constructor(message: string); + name: string; + message: string; + constructor(message: string); } export declare class ConfigurationError extends Error { - name: string; - message: string; - constructor(message: string); + name: string; + message: string; + constructor(message: string); } export declare class ResponseError extends Error { - name: string; - message: string; - body: any; - statusCode: number; - headers: any; - constructor({ body, statusCode, headers }: { - [key: string]: any; - }); + name: string; + message: string; + body: any; + statusCode: number; + headers: any; + constructor({ body, statusCode, headers }: { + [key: string]: any; + }); } From 3b737f8e2b1267e92fca077e02f785fd6d28b06e Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 5 Dec 2018 22:17:50 +0100 Subject: [PATCH 065/172] Updated test --- test/types/index.ts | 7 +++---- test/unit/events.test.js | 20 +++++++++----------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/test/types/index.ts b/test/types/index.ts index 4e69ff176..e23aed952 100644 --- a/test/types/index.ts +++ b/test/types/index.ts @@ -10,10 +10,9 @@ import { const client = new Client({ node: 'http://localhost:9200' }) -client.on(events.REQUEST, (meta: EventMeta) => {}) -client.on(events.RESPONSE, (meta: EventMeta) => {}) -client.on(events.ERROR, (err: Error, meta: EventMeta) => {}) -client.on(events.SNIFF, (err: Error, meta: SniffMeta) => {}) +client.on(events.REQUEST, (err: Error | null, meta: EventMeta) => {}) +client.on(events.RESPONSE, (err: Error | null, meta: EventMeta) => {}) +client.on(events.SNIFF, (err: Error | null, meta: SniffMeta) => {}) // Callbacks client.info((err: Error | null, result: ApiResponse) => {}) diff --git a/test/unit/events.test.js b/test/unit/events.test.js index ab22b2b80..56c7d24a2 100644 --- a/test/unit/events.test.js +++ b/test/unit/events.test.js @@ -6,14 +6,15 @@ const { TimeoutError } = require('../../lib/errors') const { connection: { MockConnection, MockConnectionTimeout } } = require('../utils') test('Should emit a request event when a request is performed', t => { - t.plan(2) + t.plan(3) const client = new Client({ node: 'http://localhost:9200', Connection: MockConnection }) - client.on(events.REQUEST, meta => { + client.on(events.REQUEST, (err, meta) => { + t.error(err) t.match(meta, { connection: { id: 'http://localhost:9200' @@ -39,14 +40,15 @@ test('Should emit a request event when a request is performed', t => { }) test('Should emit a response event in case of a successful response', t => { - t.plan(2) + t.plan(3) const client = new Client({ node: 'http://localhost:9200', Connection: MockConnection }) - client.on(events.RESPONSE, meta => { + client.on(events.RESPONSE, (err, meta) => { + t.error(err) t.match(meta, { connection: { id: 'http://localhost:9200' @@ -79,7 +81,7 @@ test('Should emit a response event in case of a successful response', t => { }) }) -test('Should emit an error event in case of a failing response', t => { +test('Should emit a response event with the error set', t => { t.plan(3) const client = new Client({ @@ -88,12 +90,8 @@ test('Should emit an error event in case of a failing response', t => { maxRetries: 0 }) - client.on(events.RESPONSE, ({ connection, request, response }) => { - t.fail('This should not be called') - }) - - client.on(events.ERROR, (error, meta) => { - t.ok(error instanceof TimeoutError) + client.on(events.RESPONSE, (err, meta) => { + t.ok(err instanceof TimeoutError) t.match(meta, { connection: { id: 'http://localhost:9200' From 4c8df2d4c0dc11967eda406f5947d221a174d727 Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 6 Dec 2018 10:17:27 +0100 Subject: [PATCH 066/172] Bumped v0.1.0-alpha.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8c20128fe..a19bbf75b 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "The official Elasticsearch client for Node.js", "main": "index.js", "homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html", - "version": "0.1.0-alpha.2", + "version": "0.1.0-alpha.3", "keywords": [ "elasticsearch", "elastic", From a9e621721eb4885315e650057c20651715524766 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 10 Dec 2018 20:12:25 +0100 Subject: [PATCH 067/172] WIP: initial prototype - Added client.close API - Added resurrect event - Improved resurrect ping strategy - Updated types --- index.d.ts | 7 +++++-- index.js | 16 ++++++++++++++-- lib/Connection.d.ts | 2 +- lib/Connection.js | 7 ++++--- lib/ConnectionPool.d.ts | 6 ++++++ lib/ConnectionPool.js | 11 +++++++++-- 6 files changed, 39 insertions(+), 10 deletions(-) diff --git a/index.d.ts b/index.d.ts index acb52b595..e5daecd42 100644 --- a/index.d.ts +++ b/index.d.ts @@ -4,7 +4,7 @@ import { EventEmitter } from 'events'; import { SecureContextOptions } from 'tls'; import Transport, { ApiResponse, EventMeta, SniffMeta } from './lib/Transport'; import Connection, { AgentOptions } from './lib/Connection'; -import ConnectionPool, { nodeSelectorFn, nodeFilterFn } from './lib/ConnectionPool'; +import ConnectionPool, { nodeSelectorFn, nodeFilterFn, ResurrectMeta } from './lib/ConnectionPool'; import Serializer from './lib/Serializer'; declare type anyObject = { @@ -461,12 +461,14 @@ declare class Client extends EventEmitter { } } constructor(opts?: ClientOptions); + close(callback?: Function): Promise | void; } declare const events: { RESPONSE: string; REQUEST: string; SNIFF: string; + RESURRECT: string; }; export { @@ -478,5 +480,6 @@ export { events, ApiResponse, EventMeta, - SniffMeta + SniffMeta, + ResurrectMeta }; diff --git a/index.js b/index.js index a54b93bfa..a889aa2f6 100644 --- a/index.js +++ b/index.js @@ -55,7 +55,8 @@ class Client extends EventEmitter { nodeFilter: options.nodeFilter, nodeWeighter: options.nodeWeighter, nodeSelector: options.nodeSelector, - Connection: options.Connection + Connection: options.Connection, + emit: this.emit.bind(this) }) // Add the connections before initialize the Transport @@ -84,12 +85,23 @@ class Client extends EventEmitter { this[api] = apis[api] }) } + + close (callback) { + if (callback == null) { + return new Promise((resolve, reject) => { + this.close(resolve) + }) + } + this.connectionPool.empty() + callback() + } } const events = { RESPONSE: 'response', REQUEST: 'request', - SNIFF: 'sniff' + SNIFF: 'sniff', + RESURRECT: 'resurrect' } module.exports = { diff --git a/lib/Connection.d.ts b/lib/Connection.d.ts index 80953fd40..0bf386563 100644 --- a/lib/Connection.d.ts +++ b/lib/Connection.d.ts @@ -46,7 +46,7 @@ export default class Connection { _status: string; _agent: http.Agent; constructor(opts?: ConnectionOptions); - request(params: any, callback: (err: Error | null, response: http.IncomingMessage | null) => void): http.ClientRequest; + request(params: http.ClientRequestArgs, callback: (err: Error | null, response: http.IncomingMessage | null) => void): http.ClientRequest; close(): Connection; setRole(role: string, enabled: boolean): Connection; status: string; diff --git a/lib/Connection.js b/lib/Connection.js index 12beb7666..678e7f1e5 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -64,7 +64,7 @@ class Connection { ended = true this._openRequests-- request.abort() - callback(new TimeoutError('Request timed out', params)) + callback(new TimeoutError('Request timed out', params), null) } }) @@ -73,7 +73,7 @@ class Connection { if (ended === false) { ended = true this._openRequests-- - callback(err) + callback(err, null) } }) @@ -95,7 +95,7 @@ class Connection { if (err != null && ended === false) { ended = true this._openRequests-- - callback(err) + callback(err, null) } }) } else { @@ -152,6 +152,7 @@ class Connection { pathname: url.pathname, path: '', href: url.href, + origin: url.origin, port: url.port, headers: this.headers, auth: !!url.username === true || !!url.password === true diff --git a/lib/ConnectionPool.d.ts b/lib/ConnectionPool.d.ts index 94ffaae34..83cddbb84 100644 --- a/lib/ConnectionPool.d.ts +++ b/lib/ConnectionPool.d.ts @@ -27,6 +27,12 @@ export interface getConnectionOptions { selector?: nodeSelectorFn; } +export interface ResurrectMeta { + strategy: string; + isAlive: boolean; + connection: Connection; +} + export default class ConnectionPool { static resurrectStrategies: { none: number; diff --git a/lib/ConnectionPool.js b/lib/ConnectionPool.js index 39905a313..40d6f48cf 100644 --- a/lib/ConnectionPool.js +++ b/lib/ConnectionPool.js @@ -26,6 +26,7 @@ class ConnectionPool { this.randomizeHost = opts.randomizeHost === true this.nodeFilter = opts.nodeFilter || defaultNodeFilter this.Connection = opts.Connection + this.emit = opts.emit || noop if (typeof opts.nodeSelector === 'function') { this.nodeSelector = opts.nodeSelector @@ -107,6 +108,7 @@ class ConnectionPool { */ resurrect (now = Date.now(), callback = noop) { if (this.resurrectStrategy === 0 || this.dead.length === 0) { + debug('Nothing to resurrect') callback(null, null) return } @@ -116,6 +118,7 @@ class ConnectionPool { const connection = this.connections.get(this.dead[0]) if (now < connection.resurrectTimeout) { debug('Nothing to resurrect') + callback(null, null) return } @@ -127,9 +130,11 @@ class ConnectionPool { method: 'HEAD', path: '/', timeout: this.pingTimeout - }, (err, res) => { + }, (err, response) => { var isAlive = true - if (err != null) { + const statusCode = response !== null ? response.statusCode : 0 + if (err != null || + (statusCode === 502 || statusCode === 503 || statusCode === 504)) { debug(`Resurrect: connection '${id}' is still dead`) this.markDead(connection) isAlive = false @@ -137,6 +142,7 @@ class ConnectionPool { debug(`Resurrect: connection '${id}' is now alive`) this.markAlive(connection) } + this.emit('resurrect', null, { strategy: 'ping', isAlive, connection }) callback(isAlive, connection) }) // optimistic strategy @@ -144,6 +150,7 @@ class ConnectionPool { debug(`Resurrect: optimistic resurrection for connection '${id}'`) this.dead.splice(this.dead.indexOf(id), 1) connection.status = Connection.statuses.ALIVE + this.emit('resurrect', null, { strategy: 'optimistic', isAlive: true, connection }) // eslint-disable-next-line standard/no-callback-literal callback(true, connection) } From 230b08ab8697ba15ee36009f4011c662d5c02879 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 10 Dec 2018 20:14:51 +0100 Subject: [PATCH 068/172] Updated test --- package.json | 1 + test/behavior/resurrect.test.js | 190 ++++++++++++++++++++++++++++++++ test/types/index.ts | 2 + test/unit/client.test.js | 64 ++++++++++- test/utils/buildCluster.js | 16 +-- 5 files changed, 264 insertions(+), 9 deletions(-) create mode 100644 test/behavior/resurrect.test.js diff --git a/package.json b/package.json index a19bbf75b..992edb292 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "deepmerge": "^2.2.1", "into-stream": "^4.0.0", "js-yaml": "^3.12.0", + "lolex": "^3.0.0", "minimist": "^1.2.0", "ora": "^3.0.0", "rimraf": "^2.6.2", diff --git a/test/behavior/resurrect.test.js b/test/behavior/resurrect.test.js new file mode 100644 index 000000000..2a1c412d0 --- /dev/null +++ b/test/behavior/resurrect.test.js @@ -0,0 +1,190 @@ +'use strict' + +const { test } = require('tap') +const { URL } = require('url') +const lolex = require('lolex') +const workq = require('workq') +const { buildCluster } = require('../utils') +const { Client, events } = require('../../index') + +/** + * The aim of this test is to verify how the resurrect logic behaves + * in a multi node situation. + * The `buildCluster` utility can boot an arbitrary number + * of nodes, that you can kill or spawn at your will. + * The resurrect API can be tested with its callback + * or by using the `resurrect` event (to handle automatically + * triggered resurrections). + */ + +test('Should execute the recurrect API with the ping strategy', t => { + t.plan(6) + + const clock = lolex.install({ toFake: ['Date'] }) + const q = workq() + + buildCluster({ numberOfNodes: 2 }, cluster => { + const client = new Client({ + nodes: [{ + url: new URL(cluster.nodes[Object.keys(cluster.nodes)[0]].url), + id: 'node0' + }, { + url: new URL(cluster.nodes[Object.keys(cluster.nodes)[1]].url), + id: 'node1' + }], + maxRetries: 0 + }) + + client.on(events.RESURRECT, (err, meta) => { + t.error(err) + t.strictEqual(meta.strategy, 'ping') + t.false(meta.isAlive) + t.strictEqual(meta.connection.id, 'node0') + }) + + q.add((q, done) => { + cluster.kill('node0') + setTimeout(done, 100) + }) + + q.add((q, done) => { + client.info((err, result) => { + t.ok(err) + done() + }) + }) + + q.add((q, done) => { + clock.tick(10) + client.info((err, result) => { + t.error(err) + done() + }) + }) + + t.teardown(() => { + clock.uninstall() + cluster.shutdown() + }) + }) +}) + +test('Resurrect a node and handle 502/3/4 status code', t => { + t.plan(11) + + const clock = lolex.install({ toFake: ['Date'] }) + const q = workq() + + var count = 0 + function handler (req, res) { + res.statusCode = count < 2 ? 502 : 200 + res.setHeader('content-type', 'application/json') + res.end(JSON.stringify({ hello: 'world' })) + count++ + } + + buildCluster({ handler, numberOfNodes: 2 }, ({ nodes, shutdown }) => { + const client = new Client({ + nodes: [{ + url: new URL(nodes[Object.keys(nodes)[0]].url), + id: 'node0' + }, { + url: new URL(nodes[Object.keys(nodes)[1]].url), + id: 'node1' + }], + maxRetries: 0 + }) + + client.on(events.RESURRECT, (err, meta) => { + t.error(err) + t.strictEqual(meta.strategy, 'ping') + t.strictEqual(meta.connection.id, 'node0') + if (count < 3) { + t.false(meta.isAlive) + } else { + t.true(meta.isAlive) + } + }) + + q.add((q, done) => { + client.info((err, result) => { + t.ok(err) + done() + }) + }) + + q.add((q, done) => { + clock.tick(10) + client.info((err, result) => { + t.error(err) + done() + }) + }) + + q.add((q, done) => { + clock.tick(150000) + client.info((err, result) => { + t.error(err) + done() + }) + }) + + t.teardown(() => { + clock.uninstall() + shutdown() + }) + }) +}) + +test('Should execute the recurrect API with the optimistic strategy', t => { + t.plan(6) + + const clock = lolex.install({ toFake: ['Date'] }) + const q = workq() + + buildCluster({ numberOfNodes: 2 }, cluster => { + const client = new Client({ + nodes: [{ + url: new URL(cluster.nodes[Object.keys(cluster.nodes)[0]].url), + id: 'node0' + }, { + url: new URL(cluster.nodes[Object.keys(cluster.nodes)[1]].url), + id: 'node1' + }], + maxRetries: 0, + resurrectStrategy: 'optimistic' + }) + + client.on(events.RESURRECT, (err, meta) => { + t.error(err) + t.strictEqual(meta.strategy, 'optimistic') + t.true(meta.isAlive) + t.strictEqual(meta.connection.id, 'node0') + }) + + q.add((q, done) => { + cluster.kill('node0') + setTimeout(done, 100) + }) + + q.add((q, done) => { + client.info((err, result) => { + t.ok(err) + done() + }) + }) + + q.add((q, done) => { + clock.tick(10) + client.info((err, result) => { + t.error(err) + done() + }) + }) + + t.teardown(() => { + clock.uninstall() + cluster.shutdown() + }) + }) +}) diff --git a/test/types/index.ts b/test/types/index.ts index e23aed952..30629eeb5 100644 --- a/test/types/index.ts +++ b/test/types/index.ts @@ -5,6 +5,7 @@ import { ApiResponse, EventMeta, SniffMeta, + ResurrectMeta, events } from '../../index' @@ -13,6 +14,7 @@ const client = new Client({ node: 'http://localhost:9200' }) client.on(events.REQUEST, (err: Error | null, meta: EventMeta) => {}) client.on(events.RESPONSE, (err: Error | null, meta: EventMeta) => {}) client.on(events.SNIFF, (err: Error | null, meta: SniffMeta) => {}) +client.on(events.RESURRECT, (err: Error | null, meta: ResurrectMeta) => {}) // Callbacks client.info((err: Error | null, result: ApiResponse) => {}) diff --git a/test/unit/client.test.js b/test/unit/client.test.js index 95a87ffb4..100669d0a 100644 --- a/test/unit/client.test.js +++ b/test/unit/client.test.js @@ -2,7 +2,8 @@ const { test } = require('tap') const { URL } = require('url') -const { Client } = require('../../index') +const { Client, ConnectionPool } = require('../../index') +const { buildServer } = require('../utils') test('Configure host', t => { t.test('Single string', t => { @@ -165,3 +166,64 @@ test('Configure host', t => { t.end() }) + +test('Node with auth data in the url', t => { + t.plan(3) + + function handler (req, res) { + t.match(req.headers, { + authorization: 'Basic Zm9vOmJhcg==' + }) + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const client = new Client({ + node: `http://foo:bar@localhost:${port}` + }) + + client.info((err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + server.stop() + }) + }) +}) + +test('Client close', t => { + t.plan(2) + + class MyConnectionPool extends ConnectionPool { + empty () { + t.ok('called') + super.empty() + } + } + + const client = new Client({ + node: 'http://localhost:9200', + ConnectionPool: MyConnectionPool + }) + + client.close(() => t.pass('Closed')) +}) + +test('Client close (promise)', t => { + t.plan(2) + + class MyConnectionPool extends ConnectionPool { + empty () { + t.ok('called') + super.empty() + } + } + + const client = new Client({ + node: 'http://localhost:9200', + ConnectionPool: MyConnectionPool + }) + + client.close() + .then(() => t.pass('Closed')) +}) diff --git a/test/utils/buildCluster.js b/test/utils/buildCluster.js index 79b0658ed..13c208f9f 100644 --- a/test/utils/buildCluster.js +++ b/test/utils/buildCluster.js @@ -5,20 +5,20 @@ const workq = require('workq') const buildServer = require('./buildServer') var id = 0 -function buildCluster (opts, callback) { +function buildCluster (options, callback) { const clusterId = id++ debug(`Booting cluster '${clusterId}'`) - if (typeof opts === 'function') { - callback = opts - opts = {} + if (typeof options === 'function') { + callback = options + options = {} } const q = workq() const nodes = {} const sniffResult = { nodes: {} } - opts.numberOfNodes = opts.numberOfNodes || 4 - for (var i = 0; i < opts.numberOfNodes; i++) { + options.numberOfNodes = options.numberOfNodes || 4 + for (var i = 0; i < options.numberOfNodes; i++) { q.add(bootNode, { id: `node${i}` }) } @@ -32,7 +32,7 @@ function buildCluster (opts, callback) { } } - buildServer(handler, ({ port }, server) => { + buildServer(options.handler || handler, ({ port }, server) => { nodes[opts.id] = { url: `http://localhost:${port}`, server @@ -77,7 +77,7 @@ function buildCluster (opts, callback) { } q.drain(done => { - debug(`Cluster '${clusterId}' booted with ${opts.numberOfNodes} nodes`) + debug(`Cluster '${clusterId}' booted with ${options.numberOfNodes} nodes`) callback(cluster) done() }) From ab90797b65ac4d5e7e0d9431b2b0cb31f1dfc713 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 12 Dec 2018 16:46:44 +0100 Subject: [PATCH 069/172] API generation --- api/api/bulk.js | 25 +++++++++++++------ api/api/cat.aliases.js | 25 +++++++++++++------ api/api/cat.allocation.js | 25 +++++++++++++------ api/api/cat.count.js | 25 +++++++++++++------ api/api/cat.fielddata.js | 25 +++++++++++++------ api/api/cat.health.js | 25 +++++++++++++------ api/api/cat.help.js | 25 +++++++++++++------ api/api/cat.indices.js | 25 +++++++++++++------ api/api/cat.master.js | 25 +++++++++++++------ api/api/cat.nodeattrs.js | 25 +++++++++++++------ api/api/cat.nodes.js | 25 +++++++++++++------ api/api/cat.pending_tasks.js | 25 +++++++++++++------ api/api/cat.plugins.js | 25 +++++++++++++------ api/api/cat.recovery.js | 25 +++++++++++++------ api/api/cat.repositories.js | 25 +++++++++++++------ api/api/cat.segments.js | 25 +++++++++++++------ api/api/cat.shards.js | 25 +++++++++++++------ api/api/cat.snapshots.js | 25 +++++++++++++------ api/api/cat.tasks.js | 25 +++++++++++++------ api/api/cat.templates.js | 25 +++++++++++++------ api/api/cat.thread_pool.js | 25 +++++++++++++------ api/api/ccr.delete_auto_follow_pattern.js | 25 +++++++++++++------ api/api/ccr.follow.js | 25 +++++++++++++------ api/api/ccr.follow_stats.js | 25 +++++++++++++------ api/api/ccr.get_auto_follow_pattern.js | 25 +++++++++++++------ api/api/ccr.pause_follow.js | 25 +++++++++++++------ api/api/ccr.put_auto_follow_pattern.js | 25 +++++++++++++------ api/api/ccr.resume_follow.js | 25 +++++++++++++------ api/api/ccr.stats.js | 25 +++++++++++++------ api/api/ccr.unfollow.js | 25 +++++++++++++------ api/api/clear_scroll.js | 25 +++++++++++++------ api/api/cluster.allocation_explain.js | 25 +++++++++++++------ api/api/cluster.get_settings.js | 25 +++++++++++++------ api/api/cluster.health.js | 25 +++++++++++++------ api/api/cluster.pending_tasks.js | 25 +++++++++++++------ api/api/cluster.put_settings.js | 25 +++++++++++++------ api/api/cluster.remote_info.js | 25 +++++++++++++------ api/api/cluster.reroute.js | 25 +++++++++++++------ api/api/cluster.state.js | 25 +++++++++++++------ api/api/cluster.stats.js | 25 +++++++++++++------ api/api/count.js | 25 +++++++++++++------ api/api/create.js | 25 +++++++++++++------ api/api/delete.js | 25 +++++++++++++------ api/api/delete_by_query.js | 25 +++++++++++++------ api/api/delete_by_query_rethrottle.js | 25 +++++++++++++------ api/api/delete_script.js | 25 +++++++++++++------ api/api/exists.js | 25 +++++++++++++------ api/api/exists_source.js | 25 +++++++++++++------ api/api/explain.js | 25 +++++++++++++------ api/api/field_caps.js | 25 +++++++++++++------ api/api/get.js | 25 +++++++++++++------ api/api/get_script.js | 25 +++++++++++++------ api/api/get_source.js | 25 +++++++++++++------ api/api/index.js | 25 +++++++++++++------ api/api/indices.analyze.js | 25 +++++++++++++------ api/api/indices.clear_cache.js | 25 +++++++++++++------ api/api/indices.close.js | 25 +++++++++++++------ api/api/indices.create.js | 25 +++++++++++++------ api/api/indices.delete.js | 25 +++++++++++++------ api/api/indices.delete_alias.js | 25 +++++++++++++------ api/api/indices.delete_template.js | 25 +++++++++++++------ api/api/indices.exists.js | 25 +++++++++++++------ api/api/indices.exists_alias.js | 25 +++++++++++++------ api/api/indices.exists_template.js | 25 +++++++++++++------ api/api/indices.exists_type.js | 25 +++++++++++++------ api/api/indices.flush.js | 25 +++++++++++++------ api/api/indices.flush_synced.js | 25 +++++++++++++------ api/api/indices.forcemerge.js | 25 +++++++++++++------ api/api/indices.get.js | 25 +++++++++++++------ api/api/indices.get_alias.js | 25 +++++++++++++------ api/api/indices.get_field_mapping.js | 25 +++++++++++++------ api/api/indices.get_mapping.js | 25 +++++++++++++------ api/api/indices.get_settings.js | 25 +++++++++++++------ api/api/indices.get_template.js | 25 +++++++++++++------ api/api/indices.get_upgrade.js | 25 +++++++++++++------ api/api/indices.open.js | 25 +++++++++++++------ api/api/indices.put_alias.js | 25 +++++++++++++------ api/api/indices.put_mapping.js | 25 +++++++++++++------ api/api/indices.put_settings.js | 25 +++++++++++++------ api/api/indices.put_template.js | 25 +++++++++++++------ api/api/indices.recovery.js | 25 +++++++++++++------ api/api/indices.refresh.js | 25 +++++++++++++------ api/api/indices.rollover.js | 25 +++++++++++++------ api/api/indices.segments.js | 25 +++++++++++++------ api/api/indices.shard_stores.js | 25 +++++++++++++------ api/api/indices.shrink.js | 25 +++++++++++++------ api/api/indices.split.js | 25 +++++++++++++------ api/api/indices.stats.js | 25 +++++++++++++------ api/api/indices.update_aliases.js | 25 +++++++++++++------ api/api/indices.upgrade.js | 25 +++++++++++++------ api/api/indices.validate_query.js | 25 +++++++++++++------ api/api/info.js | 25 +++++++++++++------ api/api/ingest.delete_pipeline.js | 25 +++++++++++++------ api/api/ingest.get_pipeline.js | 25 +++++++++++++------ api/api/ingest.processor_grok.js | 25 +++++++++++++------ api/api/ingest.put_pipeline.js | 25 +++++++++++++------ api/api/ingest.simulate.js | 25 +++++++++++++------ api/api/mget.js | 25 +++++++++++++------ api/api/msearch.js | 25 +++++++++++++------ api/api/msearch_template.js | 25 +++++++++++++------ api/api/mtermvectors.js | 25 +++++++++++++------ api/api/nodes.hot_threads.js | 25 +++++++++++++------ api/api/nodes.info.js | 25 +++++++++++++------ api/api/nodes.reload_secure_settings.js | 25 +++++++++++++------ api/api/nodes.stats.js | 25 +++++++++++++------ api/api/nodes.usage.js | 25 +++++++++++++------ api/api/ping.js | 25 +++++++++++++------ api/api/put_script.js | 25 +++++++++++++------ api/api/rank_eval.js | 25 +++++++++++++------ api/api/reindex.js | 25 +++++++++++++------ api/api/reindex_rethrottle.js | 25 +++++++++++++------ api/api/render_search_template.js | 25 +++++++++++++------ api/api/scripts_painless_execute.js | 25 +++++++++++++------ api/api/scroll.js | 25 +++++++++++++------ api/api/search.js | 25 +++++++++++++------ api/api/search_shards.js | 25 +++++++++++++------ api/api/search_template.js | 25 +++++++++++++------ api/api/snapshot.create.js | 25 +++++++++++++------ api/api/snapshot.create_repository.js | 25 +++++++++++++------ api/api/snapshot.delete.js | 25 +++++++++++++------ api/api/snapshot.delete_repository.js | 25 +++++++++++++------ api/api/snapshot.get.js | 25 +++++++++++++------ api/api/snapshot.get_repository.js | 25 +++++++++++++------ api/api/snapshot.restore.js | 25 +++++++++++++------ api/api/snapshot.status.js | 25 +++++++++++++------ api/api/snapshot.verify_repository.js | 25 +++++++++++++------ api/api/tasks.cancel.js | 25 +++++++++++++------ api/api/tasks.get.js | 25 +++++++++++++------ api/api/tasks.list.js | 25 +++++++++++++------ api/api/termvectors.js | 25 +++++++++++++------ api/api/update.js | 25 +++++++++++++------ api/api/update_by_query.js | 25 +++++++++++++------ api/api/update_by_query_rethrottle.js | 25 +++++++++++++------ api/api/xpack.graph.explore.js | 25 +++++++++++++------ api/api/xpack.info.js | 25 +++++++++++++------ api/api/xpack.license.delete.js | 25 +++++++++++++------ api/api/xpack.license.get.js | 25 +++++++++++++------ api/api/xpack.license.get_basic_status.js | 25 +++++++++++++------ api/api/xpack.license.get_trial_status.js | 25 +++++++++++++------ api/api/xpack.license.post.js | 25 +++++++++++++------ api/api/xpack.license.post_start_basic.js | 25 +++++++++++++------ api/api/xpack.license.post_start_trial.js | 25 +++++++++++++------ api/api/xpack.migration.deprecations.js | 25 +++++++++++++------ api/api/xpack.migration.get_assistance.js | 25 +++++++++++++------ api/api/xpack.migration.upgrade.js | 25 +++++++++++++------ api/api/xpack.ml.close_job.js | 25 +++++++++++++------ api/api/xpack.ml.delete_calendar.js | 25 +++++++++++++------ api/api/xpack.ml.delete_calendar_event.js | 25 +++++++++++++------ api/api/xpack.ml.delete_calendar_job.js | 25 +++++++++++++------ api/api/xpack.ml.delete_datafeed.js | 25 +++++++++++++------ api/api/xpack.ml.delete_expired_data.js | 25 +++++++++++++------ api/api/xpack.ml.delete_filter.js | 25 +++++++++++++------ api/api/xpack.ml.delete_forecast.js | 25 +++++++++++++------ api/api/xpack.ml.delete_job.js | 25 +++++++++++++------ api/api/xpack.ml.delete_model_snapshot.js | 25 +++++++++++++------ api/api/xpack.ml.find_file_structure.js | 25 +++++++++++++------ api/api/xpack.ml.flush_job.js | 25 +++++++++++++------ api/api/xpack.ml.forecast.js | 25 +++++++++++++------ api/api/xpack.ml.get_buckets.js | 25 +++++++++++++------ api/api/xpack.ml.get_calendar_events.js | 25 +++++++++++++------ api/api/xpack.ml.get_calendars.js | 25 +++++++++++++------ api/api/xpack.ml.get_categories.js | 25 +++++++++++++------ api/api/xpack.ml.get_datafeed_stats.js | 25 +++++++++++++------ api/api/xpack.ml.get_datafeeds.js | 25 +++++++++++++------ api/api/xpack.ml.get_filters.js | 25 +++++++++++++------ api/api/xpack.ml.get_influencers.js | 25 +++++++++++++------ api/api/xpack.ml.get_job_stats.js | 25 +++++++++++++------ api/api/xpack.ml.get_jobs.js | 25 +++++++++++++------ api/api/xpack.ml.get_model_snapshots.js | 25 +++++++++++++------ api/api/xpack.ml.get_overall_buckets.js | 25 +++++++++++++------ api/api/xpack.ml.get_records.js | 25 +++++++++++++------ api/api/xpack.ml.info.js | 25 +++++++++++++------ api/api/xpack.ml.open_job.js | 25 +++++++++++++------ api/api/xpack.ml.post_calendar_events.js | 25 +++++++++++++------ api/api/xpack.ml.post_data.js | 25 +++++++++++++------ api/api/xpack.ml.preview_datafeed.js | 25 +++++++++++++------ api/api/xpack.ml.put_calendar.js | 25 +++++++++++++------ api/api/xpack.ml.put_calendar_job.js | 25 +++++++++++++------ api/api/xpack.ml.put_datafeed.js | 25 +++++++++++++------ api/api/xpack.ml.put_filter.js | 25 +++++++++++++------ api/api/xpack.ml.put_job.js | 25 +++++++++++++------ api/api/xpack.ml.revert_model_snapshot.js | 25 +++++++++++++------ api/api/xpack.ml.start_datafeed.js | 25 +++++++++++++------ api/api/xpack.ml.stop_datafeed.js | 25 +++++++++++++------ api/api/xpack.ml.update_datafeed.js | 25 +++++++++++++------ api/api/xpack.ml.update_filter.js | 25 +++++++++++++------ api/api/xpack.ml.update_job.js | 25 +++++++++++++------ api/api/xpack.ml.update_model_snapshot.js | 25 +++++++++++++------ api/api/xpack.ml.validate.js | 25 +++++++++++++------ api/api/xpack.ml.validate_detector.js | 25 +++++++++++++------ api/api/xpack.monitoring.bulk.js | 25 +++++++++++++------ api/api/xpack.rollup.delete_job.js | 25 +++++++++++++------ api/api/xpack.rollup.get_jobs.js | 25 +++++++++++++------ api/api/xpack.rollup.get_rollup_caps.js | 25 +++++++++++++------ api/api/xpack.rollup.get_rollup_index_caps.js | 25 +++++++++++++------ api/api/xpack.rollup.put_job.js | 25 +++++++++++++------ api/api/xpack.rollup.rollup_search.js | 25 +++++++++++++------ api/api/xpack.rollup.start_job.js | 25 +++++++++++++------ api/api/xpack.rollup.stop_job.js | 25 +++++++++++++------ api/api/xpack.security.authenticate.js | 25 +++++++++++++------ api/api/xpack.security.change_password.js | 25 +++++++++++++------ api/api/xpack.security.clear_cached_realms.js | 25 +++++++++++++------ api/api/xpack.security.clear_cached_roles.js | 25 +++++++++++++------ api/api/xpack.security.delete_privileges.js | 25 +++++++++++++------ api/api/xpack.security.delete_role.js | 25 +++++++++++++------ api/api/xpack.security.delete_role_mapping.js | 25 +++++++++++++------ api/api/xpack.security.delete_user.js | 25 +++++++++++++------ api/api/xpack.security.disable_user.js | 25 +++++++++++++------ api/api/xpack.security.enable_user.js | 25 +++++++++++++------ api/api/xpack.security.get_privileges.js | 25 +++++++++++++------ api/api/xpack.security.get_role.js | 25 +++++++++++++------ api/api/xpack.security.get_role_mapping.js | 25 +++++++++++++------ api/api/xpack.security.get_token.js | 25 +++++++++++++------ api/api/xpack.security.get_user.js | 25 +++++++++++++------ api/api/xpack.security.get_user_privileges.js | 25 +++++++++++++------ api/api/xpack.security.has_privileges.js | 25 +++++++++++++------ api/api/xpack.security.invalidate_token.js | 25 +++++++++++++------ api/api/xpack.security.put_privileges.js | 25 +++++++++++++------ api/api/xpack.security.put_role.js | 25 +++++++++++++------ api/api/xpack.security.put_role_mapping.js | 25 +++++++++++++------ api/api/xpack.security.put_user.js | 25 +++++++++++++------ api/api/xpack.sql.clear_cursor.js | 25 +++++++++++++------ api/api/xpack.sql.query.js | 25 +++++++++++++------ api/api/xpack.sql.translate.js | 25 +++++++++++++------ api/api/xpack.ssl.certificates.js | 25 +++++++++++++------ api/api/xpack.usage.js | 25 +++++++++++++------ api/api/xpack.watcher.ack_watch.js | 25 +++++++++++++------ api/api/xpack.watcher.activate_watch.js | 25 +++++++++++++------ api/api/xpack.watcher.deactivate_watch.js | 25 +++++++++++++------ api/api/xpack.watcher.delete_watch.js | 25 +++++++++++++------ api/api/xpack.watcher.execute_watch.js | 25 +++++++++++++------ api/api/xpack.watcher.get_watch.js | 25 +++++++++++++------ api/api/xpack.watcher.put_watch.js | 25 +++++++++++++------ api/api/xpack.watcher.restart.js | 25 +++++++++++++------ api/api/xpack.watcher.start.js | 25 +++++++++++++------ api/api/xpack.watcher.stats.js | 25 +++++++++++++------ api/api/xpack.watcher.stop.js | 25 +++++++++++++------ api/index.js | 4 +-- 238 files changed, 4268 insertions(+), 1661 deletions(-) diff --git a/api/api/bulk.js b/api/api/bulk.js index bef088340..1c494f4ca 100644 --- a/api/api/bulk.js +++ b/api/api/bulk.js @@ -20,15 +20,21 @@ function buildBulk (opts) { * @param {string} pipeline - The pipeline id to preprocess incoming documents with * @param {object} body - The operation definition and data (action-data pairs), separated by newlines */ - return function bulk (params, callback) { + return function bulk (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - bulk(params, (err, body) => { + bulk(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -114,7 +120,7 @@ function buildBulk (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -126,12 +132,17 @@ function buildBulk (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, bulkBody: params.body, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cat.aliases.js b/api/api/cat.aliases.js index 0d3548c9e..ea89f4c82 100644 --- a/api/api/cat.aliases.js +++ b/api/api/cat.aliases.js @@ -15,15 +15,21 @@ function buildCatAliases (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ - return function catAliases (params, callback) { + return function catAliases (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - catAliases(params, (err, body) => { + catAliases(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -95,7 +101,7 @@ function buildCatAliases (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -107,12 +113,17 @@ function buildCatAliases (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cat.allocation.js b/api/api/cat.allocation.js index ba1228750..c5d6389d9 100644 --- a/api/api/cat.allocation.js +++ b/api/api/cat.allocation.js @@ -16,15 +16,21 @@ function buildCatAllocation (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ - return function catAllocation (params, callback) { + return function catAllocation (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - catAllocation(params, (err, body) => { + catAllocation(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -98,7 +104,7 @@ function buildCatAllocation (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -110,12 +116,17 @@ function buildCatAllocation (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cat.count.js b/api/api/cat.count.js index deb204ad8..d7aa9b990 100644 --- a/api/api/cat.count.js +++ b/api/api/cat.count.js @@ -15,15 +15,21 @@ function buildCatCount (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ - return function catCount (params, callback) { + return function catCount (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - catCount(params, (err, body) => { + catCount(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -95,7 +101,7 @@ function buildCatCount (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -107,12 +113,17 @@ function buildCatCount (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cat.fielddata.js b/api/api/cat.fielddata.js index 40fb7d402..3b441de4e 100644 --- a/api/api/cat.fielddata.js +++ b/api/api/cat.fielddata.js @@ -17,15 +17,21 @@ function buildCatFielddata (opts) { * @param {boolean} v - Verbose mode. Display column headers * @param {list} fields - A comma-separated list of fields to return in the output */ - return function catFielddata (params, callback) { + return function catFielddata (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - catFielddata(params, (err, body) => { + catFielddata(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -101,7 +107,7 @@ function buildCatFielddata (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -113,12 +119,17 @@ function buildCatFielddata (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cat.health.js b/api/api/cat.health.js index df1d07a5a..e2a833683 100644 --- a/api/api/cat.health.js +++ b/api/api/cat.health.js @@ -15,15 +15,21 @@ function buildCatHealth (opts) { * @param {boolean} ts - Set to false to disable timestamping * @param {boolean} v - Verbose mode. Display column headers */ - return function catHealth (params, callback) { + return function catHealth (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - catHealth(params, (err, body) => { + catHealth(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -97,7 +103,7 @@ function buildCatHealth (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -109,12 +115,17 @@ function buildCatHealth (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cat.help.js b/api/api/cat.help.js index 71f953e0a..5320853c0 100644 --- a/api/api/cat.help.js +++ b/api/api/cat.help.js @@ -9,15 +9,21 @@ function buildCatHelp (opts) { * @param {boolean} help - Return help information * @param {list} s - Comma-separated list of column names or column aliases to sort by */ - return function catHelp (params, callback) { + return function catHelp (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - catHelp(params, (err, body) => { + catHelp(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -79,7 +85,7 @@ function buildCatHelp (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -91,12 +97,17 @@ function buildCatHelp (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cat.indices.js b/api/api/cat.indices.js index b619582ca..86cb1ce7a 100644 --- a/api/api/cat.indices.js +++ b/api/api/cat.indices.js @@ -18,15 +18,21 @@ function buildCatIndices (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ - return function catIndices (params, callback) { + return function catIndices (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - catIndices(params, (err, body) => { + catIndices(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -104,7 +110,7 @@ function buildCatIndices (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -116,12 +122,17 @@ function buildCatIndices (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cat.master.js b/api/api/cat.master.js index a20f8a393..2a1dec0d0 100644 --- a/api/api/cat.master.js +++ b/api/api/cat.master.js @@ -14,15 +14,21 @@ function buildCatMaster (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ - return function catMaster (params, callback) { + return function catMaster (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - catMaster(params, (err, body) => { + catMaster(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -94,7 +100,7 @@ function buildCatMaster (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -106,12 +112,17 @@ function buildCatMaster (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cat.nodeattrs.js b/api/api/cat.nodeattrs.js index 86252b0d7..7e1e05918 100644 --- a/api/api/cat.nodeattrs.js +++ b/api/api/cat.nodeattrs.js @@ -14,15 +14,21 @@ function buildCatNodeattrs (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ - return function catNodeattrs (params, callback) { + return function catNodeattrs (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - catNodeattrs(params, (err, body) => { + catNodeattrs(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -94,7 +100,7 @@ function buildCatNodeattrs (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -106,12 +112,17 @@ function buildCatNodeattrs (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cat.nodes.js b/api/api/cat.nodes.js index 3d326c147..6dd74dd63 100644 --- a/api/api/cat.nodes.js +++ b/api/api/cat.nodes.js @@ -15,15 +15,21 @@ function buildCatNodes (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ - return function catNodes (params, callback) { + return function catNodes (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - catNodes(params, (err, body) => { + catNodes(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -97,7 +103,7 @@ function buildCatNodes (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -109,12 +115,17 @@ function buildCatNodes (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cat.pending_tasks.js b/api/api/cat.pending_tasks.js index 06b8c792f..df3f416ae 100644 --- a/api/api/cat.pending_tasks.js +++ b/api/api/cat.pending_tasks.js @@ -14,15 +14,21 @@ function buildCatPendingTasks (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ - return function catPendingTasks (params, callback) { + return function catPendingTasks (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - catPendingTasks(params, (err, body) => { + catPendingTasks(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -94,7 +100,7 @@ function buildCatPendingTasks (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -106,12 +112,17 @@ function buildCatPendingTasks (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cat.plugins.js b/api/api/cat.plugins.js index 157fcd4cc..d7e0b3a91 100644 --- a/api/api/cat.plugins.js +++ b/api/api/cat.plugins.js @@ -14,15 +14,21 @@ function buildCatPlugins (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ - return function catPlugins (params, callback) { + return function catPlugins (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - catPlugins(params, (err, body) => { + catPlugins(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -94,7 +100,7 @@ function buildCatPlugins (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -106,12 +112,17 @@ function buildCatPlugins (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cat.recovery.js b/api/api/cat.recovery.js index 31f58751b..5647c88b4 100644 --- a/api/api/cat.recovery.js +++ b/api/api/cat.recovery.js @@ -15,15 +15,21 @@ function buildCatRecovery (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ - return function catRecovery (params, callback) { + return function catRecovery (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - catRecovery(params, (err, body) => { + catRecovery(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -95,7 +101,7 @@ function buildCatRecovery (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -107,12 +113,17 @@ function buildCatRecovery (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cat.repositories.js b/api/api/cat.repositories.js index c0c8146c7..a57097b8e 100644 --- a/api/api/cat.repositories.js +++ b/api/api/cat.repositories.js @@ -14,15 +14,21 @@ function buildCatRepositories (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ - return function catRepositories (params, callback) { + return function catRepositories (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - catRepositories(params, (err, body) => { + catRepositories(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -94,7 +100,7 @@ function buildCatRepositories (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -106,12 +112,17 @@ function buildCatRepositories (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cat.segments.js b/api/api/cat.segments.js index 32ba290cb..6111e17a4 100644 --- a/api/api/cat.segments.js +++ b/api/api/cat.segments.js @@ -14,15 +14,21 @@ function buildCatSegments (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ - return function catSegments (params, callback) { + return function catSegments (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - catSegments(params, (err, body) => { + catSegments(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -92,7 +98,7 @@ function buildCatSegments (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -104,12 +110,17 @@ function buildCatSegments (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cat.shards.js b/api/api/cat.shards.js index 31b6ae138..0e4bac3d4 100644 --- a/api/api/cat.shards.js +++ b/api/api/cat.shards.js @@ -16,15 +16,21 @@ function buildCatShards (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ - return function catShards (params, callback) { + return function catShards (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - catShards(params, (err, body) => { + catShards(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -98,7 +104,7 @@ function buildCatShards (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -110,12 +116,17 @@ function buildCatShards (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cat.snapshots.js b/api/api/cat.snapshots.js index bb4539fe9..8d1f6eca8 100644 --- a/api/api/cat.snapshots.js +++ b/api/api/cat.snapshots.js @@ -15,15 +15,21 @@ function buildCatSnapshots (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ - return function catSnapshots (params, callback) { + return function catSnapshots (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - catSnapshots(params, (err, body) => { + catSnapshots(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -95,7 +101,7 @@ function buildCatSnapshots (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -107,12 +113,17 @@ function buildCatSnapshots (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cat.tasks.js b/api/api/cat.tasks.js index 69146dc5f..4894328b2 100644 --- a/api/api/cat.tasks.js +++ b/api/api/cat.tasks.js @@ -16,15 +16,21 @@ function buildCatTasks (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ - return function catTasks (params, callback) { + return function catTasks (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - catTasks(params, (err, body) => { + catTasks(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -100,7 +106,7 @@ function buildCatTasks (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -112,12 +118,17 @@ function buildCatTasks (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cat.templates.js b/api/api/cat.templates.js index 2fadb773e..e94613412 100644 --- a/api/api/cat.templates.js +++ b/api/api/cat.templates.js @@ -15,15 +15,21 @@ function buildCatTemplates (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ - return function catTemplates (params, callback) { + return function catTemplates (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - catTemplates(params, (err, body) => { + catTemplates(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -95,7 +101,7 @@ function buildCatTemplates (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -107,12 +113,17 @@ function buildCatTemplates (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cat.thread_pool.js b/api/api/cat.thread_pool.js index 18ad2f6ab..1e35efd04 100644 --- a/api/api/cat.thread_pool.js +++ b/api/api/cat.thread_pool.js @@ -16,15 +16,21 @@ function buildCatThreadPool (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ - return function catThreadPool (params, callback) { + return function catThreadPool (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - catThreadPool(params, (err, body) => { + catThreadPool(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -98,7 +104,7 @@ function buildCatThreadPool (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -110,12 +116,17 @@ function buildCatThreadPool (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/ccr.delete_auto_follow_pattern.js b/api/api/ccr.delete_auto_follow_pattern.js index e1fc80d4c..1e997385b 100644 --- a/api/api/ccr.delete_auto_follow_pattern.js +++ b/api/api/ccr.delete_auto_follow_pattern.js @@ -8,15 +8,21 @@ function buildCcrDeleteAutoFollowPattern (opts) { * * @param {string} name - The name of the auto follow pattern. */ - return function ccrDeleteAutoFollowPattern (params, callback) { + return function ccrDeleteAutoFollowPattern (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - ccrDeleteAutoFollowPattern(params, (err, body) => { + ccrDeleteAutoFollowPattern(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildCcrDeleteAutoFollowPattern (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildCcrDeleteAutoFollowPattern (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/ccr.follow.js b/api/api/ccr.follow.js index 2c02acde8..3d8206b2a 100644 --- a/api/api/ccr.follow.js +++ b/api/api/ccr.follow.js @@ -9,15 +9,21 @@ function buildCcrFollow (opts) { * @param {string} index - The name of the follower index * @param {object} body - The name of the leader index and other optional ccr related parameters */ - return function ccrFollow (params, callback) { + return function ccrFollow (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - ccrFollow(params, (err, body) => { + ccrFollow(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildCcrFollow (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildCcrFollow (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/ccr.follow_stats.js b/api/api/ccr.follow_stats.js index b762fd549..86f8f5d00 100644 --- a/api/api/ccr.follow_stats.js +++ b/api/api/ccr.follow_stats.js @@ -8,15 +8,21 @@ function buildCcrFollowStats (opts) { * * @param {list} index - A comma-separated list of index patterns; use `_all` to perform the operation on all indices */ - return function ccrFollowStats (params, callback) { + return function ccrFollowStats (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - ccrFollowStats(params, (err, body) => { + ccrFollowStats(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -58,7 +64,7 @@ function buildCcrFollowStats (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -70,12 +76,17 @@ function buildCcrFollowStats (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/ccr.get_auto_follow_pattern.js b/api/api/ccr.get_auto_follow_pattern.js index 010e3cf40..5e948e077 100644 --- a/api/api/ccr.get_auto_follow_pattern.js +++ b/api/api/ccr.get_auto_follow_pattern.js @@ -8,15 +8,21 @@ function buildCcrGetAutoFollowPattern (opts) { * * @param {string} name - The name of the auto follow pattern. */ - return function ccrGetAutoFollowPattern (params, callback) { + return function ccrGetAutoFollowPattern (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - ccrGetAutoFollowPattern(params, (err, body) => { + ccrGetAutoFollowPattern(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -58,7 +64,7 @@ function buildCcrGetAutoFollowPattern (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -70,12 +76,17 @@ function buildCcrGetAutoFollowPattern (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/ccr.pause_follow.js b/api/api/ccr.pause_follow.js index fbf050432..33d8b168a 100644 --- a/api/api/ccr.pause_follow.js +++ b/api/api/ccr.pause_follow.js @@ -8,15 +8,21 @@ function buildCcrPauseFollow (opts) { * * @param {string} index - The name of the follower index that should pause following its leader index. */ - return function ccrPauseFollow (params, callback) { + return function ccrPauseFollow (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - ccrPauseFollow(params, (err, body) => { + ccrPauseFollow(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildCcrPauseFollow (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildCcrPauseFollow (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/ccr.put_auto_follow_pattern.js b/api/api/ccr.put_auto_follow_pattern.js index 55b12438a..99b4f8e64 100644 --- a/api/api/ccr.put_auto_follow_pattern.js +++ b/api/api/ccr.put_auto_follow_pattern.js @@ -9,15 +9,21 @@ function buildCcrPutAutoFollowPattern (opts) { * @param {string} name - The name of the auto follow pattern. * @param {object} body - The specification of the auto follow pattern */ - return function ccrPutAutoFollowPattern (params, callback) { + return function ccrPutAutoFollowPattern (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - ccrPutAutoFollowPattern(params, (err, body) => { + ccrPutAutoFollowPattern(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildCcrPutAutoFollowPattern (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildCcrPutAutoFollowPattern (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/ccr.resume_follow.js b/api/api/ccr.resume_follow.js index 942fc5ae9..cbd91abec 100644 --- a/api/api/ccr.resume_follow.js +++ b/api/api/ccr.resume_follow.js @@ -9,15 +9,21 @@ function buildCcrResumeFollow (opts) { * @param {string} index - The name of the follow index to resume following. * @param {object} body - The name of the leader index and other optional ccr related parameters */ - return function ccrResumeFollow (params, callback) { + return function ccrResumeFollow (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - ccrResumeFollow(params, (err, body) => { + ccrResumeFollow(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildCcrResumeFollow (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildCcrResumeFollow (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/ccr.stats.js b/api/api/ccr.stats.js index 6b20d6dd1..89856e6b3 100644 --- a/api/api/ccr.stats.js +++ b/api/api/ccr.stats.js @@ -7,15 +7,21 @@ function buildCcrStats (opts) { * Perform a [ccr.stats](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html) request * */ - return function ccrStats (params, callback) { + return function ccrStats (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - ccrStats(params, (err, body) => { + ccrStats(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -57,7 +63,7 @@ function buildCcrStats (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -69,12 +75,17 @@ function buildCcrStats (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/ccr.unfollow.js b/api/api/ccr.unfollow.js index d12c23946..d608fb140 100644 --- a/api/api/ccr.unfollow.js +++ b/api/api/ccr.unfollow.js @@ -8,15 +8,21 @@ function buildCcrUnfollow (opts) { * * @param {string} index - The name of the follower index that should be turned into a regular index. */ - return function ccrUnfollow (params, callback) { + return function ccrUnfollow (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - ccrUnfollow(params, (err, body) => { + ccrUnfollow(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildCcrUnfollow (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildCcrUnfollow (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/clear_scroll.js b/api/api/clear_scroll.js index 8b83b745c..cd9e2aba8 100644 --- a/api/api/clear_scroll.js +++ b/api/api/clear_scroll.js @@ -9,15 +9,21 @@ function buildClearScroll (opts) { * @param {list} scroll_id - A comma-separated list of scroll IDs to clear * @param {object} body - A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter */ - return function clearScroll (params, callback) { + return function clearScroll (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - clearScroll(params, (err, body) => { + clearScroll(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -67,7 +73,7 @@ function buildClearScroll (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -79,12 +85,17 @@ function buildClearScroll (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cluster.allocation_explain.js b/api/api/cluster.allocation_explain.js index 026757f3a..37f8adf61 100644 --- a/api/api/cluster.allocation_explain.js +++ b/api/api/cluster.allocation_explain.js @@ -10,15 +10,21 @@ function buildClusterAllocationExplain (opts) { * @param {boolean} include_disk_info - Return information about disk usage and shard sizes (default: false) * @param {object} body - The index, shard, and primary flag to explain. Empty means 'explain the first unassigned shard' */ - return function clusterAllocationExplain (params, callback) { + return function clusterAllocationExplain (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - clusterAllocationExplain(params, (err, body) => { + clusterAllocationExplain(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -72,7 +78,7 @@ function buildClusterAllocationExplain (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -84,12 +90,17 @@ function buildClusterAllocationExplain (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cluster.get_settings.js b/api/api/cluster.get_settings.js index 72514b9b9..26fc4a07e 100644 --- a/api/api/cluster.get_settings.js +++ b/api/api/cluster.get_settings.js @@ -11,15 +11,21 @@ function buildClusterGetSettings (opts) { * @param {time} timeout - Explicit operation timeout * @param {boolean} include_defaults - Whether to return all default clusters setting. */ - return function clusterGetSettings (params, callback) { + return function clusterGetSettings (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - clusterGetSettings(params, (err, body) => { + clusterGetSettings(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -85,7 +91,7 @@ function buildClusterGetSettings (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -97,12 +103,17 @@ function buildClusterGetSettings (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cluster.health.js b/api/api/cluster.health.js index 98361352c..88850cc4d 100644 --- a/api/api/cluster.health.js +++ b/api/api/cluster.health.js @@ -18,15 +18,21 @@ function buildClusterHealth (opts) { * @param {boolean} wait_for_no_initializing_shards - Whether to wait until there are no initializing shards in the cluster * @param {enum} wait_for_status - Wait until cluster is in a specific state */ - return function clusterHealth (params, callback) { + return function clusterHealth (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - clusterHealth(params, (err, body) => { + clusterHealth(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -104,7 +110,7 @@ function buildClusterHealth (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -116,12 +122,17 @@ function buildClusterHealth (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cluster.pending_tasks.js b/api/api/cluster.pending_tasks.js index f8faf7fda..ea6cd5617 100644 --- a/api/api/cluster.pending_tasks.js +++ b/api/api/cluster.pending_tasks.js @@ -9,15 +9,21 @@ function buildClusterPendingTasks (opts) { * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) * @param {time} master_timeout - Specify timeout for connection to master */ - return function clusterPendingTasks (params, callback) { + return function clusterPendingTasks (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - clusterPendingTasks(params, (err, body) => { + clusterPendingTasks(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -79,7 +85,7 @@ function buildClusterPendingTasks (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -91,12 +97,17 @@ function buildClusterPendingTasks (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cluster.put_settings.js b/api/api/cluster.put_settings.js index 659fddac3..7d4878eee 100644 --- a/api/api/cluster.put_settings.js +++ b/api/api/cluster.put_settings.js @@ -11,15 +11,21 @@ function buildClusterPutSettings (opts) { * @param {time} timeout - Explicit operation timeout * @param {object} body - The settings to be updated. Can be either `transient` or `persistent` (survives cluster restart). */ - return function clusterPutSettings (params, callback) { + return function clusterPutSettings (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - clusterPutSettings(params, (err, body) => { + clusterPutSettings(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -83,7 +89,7 @@ function buildClusterPutSettings (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -95,12 +101,17 @@ function buildClusterPutSettings (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cluster.remote_info.js b/api/api/cluster.remote_info.js index 9fd4f98d8..d4a91bd8a 100644 --- a/api/api/cluster.remote_info.js +++ b/api/api/cluster.remote_info.js @@ -7,15 +7,21 @@ function buildClusterRemoteInfo (opts) { * Perform a [cluster.remote_info](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-remote-info.html) request * */ - return function clusterRemoteInfo (params, callback) { + return function clusterRemoteInfo (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - clusterRemoteInfo(params, (err, body) => { + clusterRemoteInfo(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildClusterRemoteInfo (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildClusterRemoteInfo (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cluster.reroute.js b/api/api/cluster.reroute.js index 0f9281a40..3cd46a339 100644 --- a/api/api/cluster.reroute.js +++ b/api/api/cluster.reroute.js @@ -14,15 +14,21 @@ function buildClusterReroute (opts) { * @param {time} timeout - Explicit operation timeout * @param {object} body - The definition of `commands` to perform (`move`, `cancel`, `allocate`) */ - return function clusterReroute (params, callback) { + return function clusterReroute (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - clusterReroute(params, (err, body) => { + clusterReroute(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,7 +90,7 @@ function buildClusterReroute (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -96,12 +102,17 @@ function buildClusterReroute (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cluster.state.js b/api/api/cluster.state.js index 98eba742f..954e0f03b 100644 --- a/api/api/cluster.state.js +++ b/api/api/cluster.state.js @@ -15,15 +15,21 @@ function buildClusterState (opts) { * @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. */ - return function clusterState (params, callback) { + return function clusterState (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - clusterState(params, (err, body) => { + clusterState(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -101,7 +107,7 @@ function buildClusterState (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -113,12 +119,17 @@ function buildClusterState (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/cluster.stats.js b/api/api/cluster.stats.js index cb1f7f9bd..772f121ca 100644 --- a/api/api/cluster.stats.js +++ b/api/api/cluster.stats.js @@ -10,15 +10,21 @@ function buildClusterStats (opts) { * @param {boolean} flat_settings - Return settings in flat format (default: false) * @param {time} timeout - Explicit operation timeout */ - return function clusterStats (params, callback) { + return function clusterStats (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - clusterStats(params, (err, body) => { + clusterStats(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -80,7 +86,7 @@ function buildClusterStats (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -94,12 +100,17 @@ function buildClusterStats (opts) { : '/_cluster/stats', querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/count.js b/api/api/count.js index dce62b73b..33bafea0f 100644 --- a/api/api/count.js +++ b/api/api/count.js @@ -23,15 +23,21 @@ function buildCount (opts) { * @param {number} terminate_after - The maximum count for each shard, upon reaching which the query execution will terminate early * @param {object} body - A query to restrict the results specified with the Query DSL (optional) */ - return function count (params, callback) { + return function count (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - count(params, (err, body) => { + count(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -115,7 +121,7 @@ function buildCount (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -127,12 +133,17 @@ function buildCount (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/create.js b/api/api/create.js index f426ab593..79fbd5242 100644 --- a/api/api/create.js +++ b/api/api/create.js @@ -19,15 +19,21 @@ function buildCreate (opts) { * @param {string} pipeline - The pipeline id to preprocess incoming documents with * @param {object} body - The document */ - return function create (params, callback) { + return function create (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - create(params, (err, body) => { + create(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -132,7 +138,7 @@ function buildCreate (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -144,12 +150,17 @@ function buildCreate (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/delete.js b/api/api/delete.js index 68ce7ae3c..b7a1c8560 100644 --- a/api/api/delete.js +++ b/api/api/delete.js @@ -17,15 +17,21 @@ function buildDelete (opts) { * @param {number} version - Explicit version number for concurrency control * @param {enum} version_type - Specific version type */ - return function _delete (params, callback) { + return function _delete (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - _delete(params, (err, body) => { + _delete(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -128,7 +134,7 @@ function buildDelete (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -140,12 +146,17 @@ function buildDelete (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/delete_by_query.js b/api/api/delete_by_query.js index 042b1eced..ddde407aa 100644 --- a/api/api/delete_by_query.js +++ b/api/api/delete_by_query.js @@ -42,15 +42,21 @@ function buildDeleteByQuery (opts) { * @param {number} slices - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. * @param {object} body - The search definition using the Query DSL */ - return function deleteByQuery (params, callback) { + return function deleteByQuery (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - deleteByQuery(params, (err, body) => { + deleteByQuery(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -186,7 +192,7 @@ function buildDeleteByQuery (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -198,12 +204,17 @@ function buildDeleteByQuery (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/delete_by_query_rethrottle.js b/api/api/delete_by_query_rethrottle.js index c54f37ede..186b0e2ee 100644 --- a/api/api/delete_by_query_rethrottle.js +++ b/api/api/delete_by_query_rethrottle.js @@ -9,15 +9,21 @@ function buildDeleteByQueryRethrottle (opts) { * @param {string} task_id - The task id to rethrottle * @param {number} requests_per_second - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. */ - return function deleteByQueryRethrottle (params, callback) { + return function deleteByQueryRethrottle (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - deleteByQueryRethrottle(params, (err, body) => { + deleteByQueryRethrottle(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -89,7 +95,7 @@ function buildDeleteByQueryRethrottle (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -101,12 +107,17 @@ function buildDeleteByQueryRethrottle (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/delete_script.js b/api/api/delete_script.js index 8ab1f560e..561ab0327 100644 --- a/api/api/delete_script.js +++ b/api/api/delete_script.js @@ -10,15 +10,21 @@ function buildDeleteScript (opts) { * @param {time} timeout - Explicit operation timeout * @param {time} master_timeout - Specify timeout for connection to master */ - return function deleteScript (params, callback) { + return function deleteScript (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - deleteScript(params, (err, body) => { + deleteScript(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -86,7 +92,7 @@ function buildDeleteScript (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -98,12 +104,17 @@ function buildDeleteScript (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/exists.js b/api/api/exists.js index 1c40895d7..200be7062 100644 --- a/api/api/exists.js +++ b/api/api/exists.js @@ -21,15 +21,21 @@ function buildExists (opts) { * @param {number} version - Explicit version number for concurrency control * @param {enum} version_type - Specific version type */ - return function exists (params, callback) { + return function exists (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - exists(params, (err, body) => { + exists(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -140,7 +146,7 @@ function buildExists (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -152,12 +158,17 @@ function buildExists (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/exists_source.js b/api/api/exists_source.js index d3c752c2f..1d6c8dc7f 100644 --- a/api/api/exists_source.js +++ b/api/api/exists_source.js @@ -20,15 +20,21 @@ function buildExistsSource (opts) { * @param {number} version - Explicit version number for concurrency control * @param {enum} version_type - Specific version type */ - return function existsSource (params, callback) { + return function existsSource (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - existsSource(params, (err, body) => { + existsSource(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -137,7 +143,7 @@ function buildExistsSource (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -149,12 +155,17 @@ function buildExistsSource (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/explain.js b/api/api/explain.js index 30b08562b..843d316ab 100644 --- a/api/api/explain.js +++ b/api/api/explain.js @@ -24,15 +24,21 @@ function buildExplain (opts) { * @param {list} _source_include - A list of fields to extract and return from the _source field * @param {object} body - The query definition using the Query DSL */ - return function explain (params, callback) { + return function explain (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - explain(params, (err, body) => { + explain(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -141,7 +147,7 @@ function buildExplain (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -153,12 +159,17 @@ function buildExplain (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/field_caps.js b/api/api/field_caps.js index fdfcd2907..c1803c0b3 100644 --- a/api/api/field_caps.js +++ b/api/api/field_caps.js @@ -13,15 +13,21 @@ function buildFieldCaps (opts) { * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {object} body - Field json objects containing an array of field names */ - return function fieldCaps (params, callback) { + return function fieldCaps (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - fieldCaps(params, (err, body) => { + fieldCaps(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -79,7 +85,7 @@ function buildFieldCaps (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -91,12 +97,17 @@ function buildFieldCaps (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/get.js b/api/api/get.js index 999a1d992..26b6c6e2d 100644 --- a/api/api/get.js +++ b/api/api/get.js @@ -21,15 +21,21 @@ function buildGet (opts) { * @param {number} version - Explicit version number for concurrency control * @param {enum} version_type - Specific version type */ - return function get (params, callback) { + return function get (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - get(params, (err, body) => { + get(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -140,7 +146,7 @@ function buildGet (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -152,12 +158,17 @@ function buildGet (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/get_script.js b/api/api/get_script.js index f743b84fb..8481e4330 100644 --- a/api/api/get_script.js +++ b/api/api/get_script.js @@ -9,15 +9,21 @@ function buildGetScript (opts) { * @param {string} id - Script ID * @param {time} master_timeout - Specify timeout for connection to master */ - return function getScript (params, callback) { + return function getScript (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - getScript(params, (err, body) => { + getScript(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -83,7 +89,7 @@ function buildGetScript (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -95,12 +101,17 @@ function buildGetScript (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/get_source.js b/api/api/get_source.js index 016fd450c..75794298d 100644 --- a/api/api/get_source.js +++ b/api/api/get_source.js @@ -20,15 +20,21 @@ function buildGetSource (opts) { * @param {number} version - Explicit version number for concurrency control * @param {enum} version_type - Specific version type */ - return function getSource (params, callback) { + return function getSource (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - getSource(params, (err, body) => { + getSource(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -137,7 +143,7 @@ function buildGetSource (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -149,12 +155,17 @@ function buildGetSource (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/index.js b/api/api/index.js index 413f5d60b..243234c9f 100644 --- a/api/api/index.js +++ b/api/api/index.js @@ -20,15 +20,21 @@ function buildIndex (opts) { * @param {string} pipeline - The pipeline id to preprocess incoming documents with * @param {object} body - The document */ - return function index (params, callback) { + return function index (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - index(params, (err, body) => { + index(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -129,7 +135,7 @@ function buildIndex (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -141,12 +147,17 @@ function buildIndex (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.analyze.js b/api/api/indices.analyze.js index b4a48c878..89228daaf 100644 --- a/api/api/indices.analyze.js +++ b/api/api/indices.analyze.js @@ -10,15 +10,21 @@ function buildIndicesAnalyze (opts) { * @param {string} index - The name of the index to scope the operation * @param {object} body - Define analyzer/tokenizer parameters and the text on which the analysis should be performed */ - return function indicesAnalyze (params, callback) { + return function indicesAnalyze (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesAnalyze(params, (err, body) => { + indicesAnalyze(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -70,7 +76,7 @@ function buildIndicesAnalyze (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -82,12 +88,17 @@ function buildIndicesAnalyze (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.clear_cache.js b/api/api/indices.clear_cache.js index 3fe9fb597..db8bc7815 100644 --- a/api/api/indices.clear_cache.js +++ b/api/api/indices.clear_cache.js @@ -18,15 +18,21 @@ function buildIndicesClearCache (opts) { * @param {boolean} request_cache - Clear request cache * @param {boolean} request - Clear request cache */ - return function indicesClearCache (params, callback) { + return function indicesClearCache (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesClearCache(params, (err, body) => { + indicesClearCache(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -104,7 +110,7 @@ function buildIndicesClearCache (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -116,12 +122,17 @@ function buildIndicesClearCache (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.close.js b/api/api/indices.close.js index 738786c2d..5d10102c1 100644 --- a/api/api/indices.close.js +++ b/api/api/indices.close.js @@ -13,15 +13,21 @@ function buildIndicesClose (opts) { * @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. */ - return function indicesClose (params, callback) { + return function indicesClose (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesClose(params, (err, body) => { + indicesClose(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -95,7 +101,7 @@ function buildIndicesClose (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -107,12 +113,17 @@ function buildIndicesClose (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.create.js b/api/api/indices.create.js index f6cdb6780..5b4cffe37 100644 --- a/api/api/indices.create.js +++ b/api/api/indices.create.js @@ -13,15 +13,21 @@ function buildIndicesCreate (opts) { * @param {boolean} update_all_types - Whether to update the mapping for all fields with the same name across all types or not * @param {object} body - The configuration for the index (`settings` and `mappings`) */ - return function indicesCreate (params, callback) { + return function indicesCreate (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesCreate(params, (err, body) => { + indicesCreate(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -87,7 +93,7 @@ function buildIndicesCreate (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -99,12 +105,17 @@ function buildIndicesCreate (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.delete.js b/api/api/indices.delete.js index 04ef7250b..2c3a809c9 100644 --- a/api/api/indices.delete.js +++ b/api/api/indices.delete.js @@ -13,15 +13,21 @@ function buildIndicesDelete (opts) { * @param {boolean} allow_no_indices - Ignore if a wildcard expression resolves to no concrete indices (default: false) * @param {enum} expand_wildcards - Whether wildcard expressions should get expanded to open or closed indices (default: open) */ - return function indicesDelete (params, callback) { + return function indicesDelete (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesDelete(params, (err, body) => { + indicesDelete(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -95,7 +101,7 @@ function buildIndicesDelete (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -107,12 +113,17 @@ function buildIndicesDelete (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.delete_alias.js b/api/api/indices.delete_alias.js index f3a9e8130..844d87e5e 100644 --- a/api/api/indices.delete_alias.js +++ b/api/api/indices.delete_alias.js @@ -11,15 +11,21 @@ function buildIndicesDeleteAlias (opts) { * @param {time} timeout - Explicit timestamp for the document * @param {time} master_timeout - Specify timeout for connection to master */ - return function indicesDeleteAlias (params, callback) { + return function indicesDeleteAlias (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesDeleteAlias(params, (err, body) => { + indicesDeleteAlias(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -101,7 +107,7 @@ function buildIndicesDeleteAlias (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -115,12 +121,17 @@ function buildIndicesDeleteAlias (opts) { : '/{index}/_alias/{name}', querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.delete_template.js b/api/api/indices.delete_template.js index 4d3066e14..88c76a15c 100644 --- a/api/api/indices.delete_template.js +++ b/api/api/indices.delete_template.js @@ -10,15 +10,21 @@ function buildIndicesDeleteTemplate (opts) { * @param {time} timeout - Explicit operation timeout * @param {time} master_timeout - Specify timeout for connection to master */ - return function indicesDeleteTemplate (params, callback) { + return function indicesDeleteTemplate (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesDeleteTemplate(params, (err, body) => { + indicesDeleteTemplate(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -86,7 +92,7 @@ function buildIndicesDeleteTemplate (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -98,12 +104,17 @@ function buildIndicesDeleteTemplate (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.exists.js b/api/api/indices.exists.js index 53df35461..0856d4cdd 100644 --- a/api/api/indices.exists.js +++ b/api/api/indices.exists.js @@ -14,15 +14,21 @@ function buildIndicesExists (opts) { * @param {boolean} flat_settings - Return settings in flat format (default: false) * @param {boolean} include_defaults - Whether to return all default setting for each of the indices. */ - return function indicesExists (params, callback) { + return function indicesExists (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesExists(params, (err, body) => { + indicesExists(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -98,7 +104,7 @@ function buildIndicesExists (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -110,12 +116,17 @@ function buildIndicesExists (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.exists_alias.js b/api/api/indices.exists_alias.js index 4f5cdcdf7..51d45f871 100644 --- a/api/api/indices.exists_alias.js +++ b/api/api/indices.exists_alias.js @@ -13,15 +13,21 @@ function buildIndicesExistsAlias (opts) { * @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) */ - return function indicesExistsAlias (params, callback) { + return function indicesExistsAlias (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesExistsAlias(params, (err, body) => { + indicesExistsAlias(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -93,7 +99,7 @@ function buildIndicesExistsAlias (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -105,12 +111,17 @@ function buildIndicesExistsAlias (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.exists_template.js b/api/api/indices.exists_template.js index 71cb9b5b7..8c49c1f28 100644 --- a/api/api/indices.exists_template.js +++ b/api/api/indices.exists_template.js @@ -11,15 +11,21 @@ function buildIndicesExistsTemplate (opts) { * @param {time} master_timeout - Explicit operation timeout for connection to master node * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) */ - return function indicesExistsTemplate (params, callback) { + return function indicesExistsTemplate (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesExistsTemplate(params, (err, body) => { + indicesExistsTemplate(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -89,7 +95,7 @@ function buildIndicesExistsTemplate (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -101,12 +107,17 @@ function buildIndicesExistsTemplate (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.exists_type.js b/api/api/indices.exists_type.js index 7a5303247..4d3a729b5 100644 --- a/api/api/indices.exists_type.js +++ b/api/api/indices.exists_type.js @@ -13,15 +13,21 @@ function buildIndicesExistsType (opts) { * @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) */ - return function indicesExistsType (params, callback) { + return function indicesExistsType (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesExistsType(params, (err, body) => { + indicesExistsType(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -107,7 +113,7 @@ function buildIndicesExistsType (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -119,12 +125,17 @@ function buildIndicesExistsType (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.flush.js b/api/api/indices.flush.js index 3c273b3a0..372e5dfde 100644 --- a/api/api/indices.flush.js +++ b/api/api/indices.flush.js @@ -13,15 +13,21 @@ function buildIndicesFlush (opts) { * @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. */ - return function indicesFlush (params, callback) { + return function indicesFlush (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesFlush(params, (err, body) => { + indicesFlush(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -89,7 +95,7 @@ function buildIndicesFlush (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -101,12 +107,17 @@ function buildIndicesFlush (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.flush_synced.js b/api/api/indices.flush_synced.js index d73deb4a2..3acf8e25b 100644 --- a/api/api/indices.flush_synced.js +++ b/api/api/indices.flush_synced.js @@ -11,15 +11,21 @@ function buildIndicesFlushSynced (opts) { * @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. */ - return function indicesFlushSynced (params, callback) { + return function indicesFlushSynced (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesFlushSynced(params, (err, body) => { + indicesFlushSynced(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -83,7 +89,7 @@ function buildIndicesFlushSynced (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -95,12 +101,17 @@ function buildIndicesFlushSynced (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.forcemerge.js b/api/api/indices.forcemerge.js index 2e89e64b7..297917d7f 100644 --- a/api/api/indices.forcemerge.js +++ b/api/api/indices.forcemerge.js @@ -14,15 +14,21 @@ function buildIndicesForcemerge (opts) { * @param {number} max_num_segments - The number of segments the index should be merged into (default: dynamic) * @param {boolean} only_expunge_deletes - Specify whether the operation should only expunge deleted documents */ - return function indicesForcemerge (params, callback) { + return function indicesForcemerge (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesForcemerge(params, (err, body) => { + indicesForcemerge(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -92,7 +98,7 @@ function buildIndicesForcemerge (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -104,12 +110,17 @@ function buildIndicesForcemerge (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.get.js b/api/api/indices.get.js index 5b02972ec..b615d64c1 100644 --- a/api/api/indices.get.js +++ b/api/api/indices.get.js @@ -15,15 +15,21 @@ function buildIndicesGet (opts) { * @param {boolean} include_defaults - Whether to return all default setting for each of the indices. * @param {time} master_timeout - Specify timeout for connection to master */ - return function indicesGet (params, callback) { + return function indicesGet (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesGet(params, (err, body) => { + indicesGet(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -101,7 +107,7 @@ function buildIndicesGet (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -113,12 +119,17 @@ function buildIndicesGet (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.get_alias.js b/api/api/indices.get_alias.js index 5ab7c2c63..aa4a01155 100644 --- a/api/api/indices.get_alias.js +++ b/api/api/indices.get_alias.js @@ -13,15 +13,21 @@ function buildIndicesGetAlias (opts) { * @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) */ - return function indicesGetAlias (params, callback) { + 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 = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesGetAlias(params, (err, body) => { + indicesGetAlias(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -87,7 +93,7 @@ function buildIndicesGetAlias (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -99,12 +105,17 @@ function buildIndicesGetAlias (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.get_field_mapping.js b/api/api/indices.get_field_mapping.js index 5812d30a7..1d186649c 100644 --- a/api/api/indices.get_field_mapping.js +++ b/api/api/indices.get_field_mapping.js @@ -15,15 +15,21 @@ function buildIndicesGetFieldMapping (opts) { * @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) */ - return function indicesGetFieldMapping (params, callback) { + return function indicesGetFieldMapping (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesGetFieldMapping(params, (err, body) => { + indicesGetFieldMapping(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -97,7 +103,7 @@ function buildIndicesGetFieldMapping (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -109,12 +115,17 @@ function buildIndicesGetFieldMapping (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.get_mapping.js b/api/api/indices.get_mapping.js index 39ea555a9..708ad5991 100644 --- a/api/api/indices.get_mapping.js +++ b/api/api/indices.get_mapping.js @@ -14,15 +14,21 @@ function buildIndicesGetMapping (opts) { * @param {time} master_timeout - Specify timeout for connection to master * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) */ - return function indicesGetMapping (params, callback) { + return function indicesGetMapping (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesGetMapping(params, (err, body) => { + indicesGetMapping(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -90,7 +96,7 @@ function buildIndicesGetMapping (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -102,12 +108,17 @@ function buildIndicesGetMapping (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.get_settings.js b/api/api/indices.get_settings.js index 31857139c..3fc5c9cf5 100644 --- a/api/api/indices.get_settings.js +++ b/api/api/indices.get_settings.js @@ -16,15 +16,21 @@ function buildIndicesGetSettings (opts) { * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) * @param {boolean} include_defaults - Whether to return all default setting for each of the indices. */ - return function indicesGetSettings (params, callback) { + return function indicesGetSettings (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesGetSettings(params, (err, body) => { + indicesGetSettings(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -96,7 +102,7 @@ function buildIndicesGetSettings (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -108,12 +114,17 @@ function buildIndicesGetSettings (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.get_template.js b/api/api/indices.get_template.js index d88d5ce2d..e4e35a00b 100644 --- a/api/api/indices.get_template.js +++ b/api/api/indices.get_template.js @@ -11,15 +11,21 @@ function buildIndicesGetTemplate (opts) { * @param {time} master_timeout - Explicit operation timeout for connection to master node * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) */ - return function indicesGetTemplate (params, callback) { + return function indicesGetTemplate (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesGetTemplate(params, (err, body) => { + indicesGetTemplate(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -83,7 +89,7 @@ function buildIndicesGetTemplate (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -95,12 +101,17 @@ function buildIndicesGetTemplate (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.get_upgrade.js b/api/api/indices.get_upgrade.js index 115e562ce..b7e1e40b1 100644 --- a/api/api/indices.get_upgrade.js +++ b/api/api/indices.get_upgrade.js @@ -11,15 +11,21 @@ function buildIndicesGetUpgrade (opts) { * @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. */ - return function indicesGetUpgrade (params, callback) { + return function indicesGetUpgrade (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesGetUpgrade(params, (err, body) => { + indicesGetUpgrade(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -83,7 +89,7 @@ function buildIndicesGetUpgrade (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -95,12 +101,17 @@ function buildIndicesGetUpgrade (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.open.js b/api/api/indices.open.js index ca34197d9..4e681d6e7 100644 --- a/api/api/indices.open.js +++ b/api/api/indices.open.js @@ -14,15 +14,21 @@ function buildIndicesOpen (opts) { * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {string} wait_for_active_shards - Sets the number of active shards to wait for before the operation returns. */ - return function indicesOpen (params, callback) { + return function indicesOpen (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesOpen(params, (err, body) => { + indicesOpen(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -98,7 +104,7 @@ function buildIndicesOpen (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -110,12 +116,17 @@ function buildIndicesOpen (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.put_alias.js b/api/api/indices.put_alias.js index 0377acdfc..981e294c2 100644 --- a/api/api/indices.put_alias.js +++ b/api/api/indices.put_alias.js @@ -12,15 +12,21 @@ function buildIndicesPutAlias (opts) { * @param {time} master_timeout - Specify timeout for connection to master * @param {object} body - The settings for the alias, such as `routing` or `filter` */ - return function indicesPutAlias (params, callback) { + return function indicesPutAlias (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesPutAlias(params, (err, body) => { + indicesPutAlias(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -96,7 +102,7 @@ function buildIndicesPutAlias (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -110,12 +116,17 @@ function buildIndicesPutAlias (opts) { : '/{index}/_alias/{name}', querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.put_mapping.js b/api/api/indices.put_mapping.js index 4cb58c7d4..8568e53df 100644 --- a/api/api/indices.put_mapping.js +++ b/api/api/indices.put_mapping.js @@ -16,15 +16,21 @@ function buildIndicesPutMapping (opts) { * @param {boolean} update_all_types - Whether to update the mapping for all fields with the same name across all types or not * @param {object} body - The mapping definition */ - return function indicesPutMapping (params, callback) { + return function indicesPutMapping (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesPutMapping(params, (err, body) => { + indicesPutMapping(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -100,7 +106,7 @@ function buildIndicesPutMapping (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -112,12 +118,17 @@ function buildIndicesPutMapping (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.put_settings.js b/api/api/indices.put_settings.js index 4471c0f49..e111172ca 100644 --- a/api/api/indices.put_settings.js +++ b/api/api/indices.put_settings.js @@ -16,15 +16,21 @@ function buildIndicesPutSettings (opts) { * @param {boolean} flat_settings - Return settings in flat format (default: false) * @param {object} body - The index settings to be updated */ - return function indicesPutSettings (params, callback) { + return function indicesPutSettings (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesPutSettings(params, (err, body) => { + indicesPutSettings(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -96,7 +102,7 @@ function buildIndicesPutSettings (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -108,12 +114,17 @@ function buildIndicesPutSettings (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.put_template.js b/api/api/indices.put_template.js index ad7f126de..873cb9bb1 100644 --- a/api/api/indices.put_template.js +++ b/api/api/indices.put_template.js @@ -14,15 +14,21 @@ function buildIndicesPutTemplate (opts) { * @param {boolean} flat_settings - Return settings in flat format (default: false) * @param {object} body - The template definition */ - return function indicesPutTemplate (params, callback) { + return function indicesPutTemplate (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesPutTemplate(params, (err, body) => { + indicesPutTemplate(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -96,7 +102,7 @@ function buildIndicesPutTemplate (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -108,12 +114,17 @@ function buildIndicesPutTemplate (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.recovery.js b/api/api/indices.recovery.js index eeb9e1b82..23d4726a8 100644 --- a/api/api/indices.recovery.js +++ b/api/api/indices.recovery.js @@ -10,15 +10,21 @@ function buildIndicesRecovery (opts) { * @param {boolean} detailed - Whether to display detailed information about shard recovery * @param {boolean} active_only - Display only those recoveries that are currently on-going */ - return function indicesRecovery (params, callback) { + return function indicesRecovery (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesRecovery(params, (err, body) => { + indicesRecovery(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -80,7 +86,7 @@ function buildIndicesRecovery (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -92,12 +98,17 @@ function buildIndicesRecovery (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.refresh.js b/api/api/indices.refresh.js index 946a086f4..3e5ce990e 100644 --- a/api/api/indices.refresh.js +++ b/api/api/indices.refresh.js @@ -11,15 +11,21 @@ function buildIndicesRefresh (opts) { * @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. */ - return function indicesRefresh (params, callback) { + return function indicesRefresh (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesRefresh(params, (err, body) => { + indicesRefresh(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -83,7 +89,7 @@ function buildIndicesRefresh (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -95,12 +101,17 @@ function buildIndicesRefresh (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.rollover.js b/api/api/indices.rollover.js index abd79472c..e5bec5bb0 100644 --- a/api/api/indices.rollover.js +++ b/api/api/indices.rollover.js @@ -14,15 +14,21 @@ function buildIndicesRollover (opts) { * @param {string} wait_for_active_shards - Set the number of active shards to wait for on the newly created rollover index before the operation returns. * @param {object} body - The conditions that needs to be met for executing rollover */ - return function indicesRollover (params, callback) { + return function indicesRollover (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesRollover(params, (err, body) => { + indicesRollover(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -96,7 +102,7 @@ function buildIndicesRollover (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -108,12 +114,17 @@ function buildIndicesRollover (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.segments.js b/api/api/indices.segments.js index d636e4280..f15bc55e2 100644 --- a/api/api/indices.segments.js +++ b/api/api/indices.segments.js @@ -12,15 +12,21 @@ function buildIndicesSegments (opts) { * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {boolean} verbose - Includes detailed memory usage by Lucene. */ - return function indicesSegments (params, callback) { + return function indicesSegments (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesSegments(params, (err, body) => { + indicesSegments(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -86,7 +92,7 @@ function buildIndicesSegments (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -98,12 +104,17 @@ function buildIndicesSegments (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.shard_stores.js b/api/api/indices.shard_stores.js index 835c211f1..fb37d4784 100644 --- a/api/api/indices.shard_stores.js +++ b/api/api/indices.shard_stores.js @@ -12,15 +12,21 @@ function buildIndicesShardStores (opts) { * @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. */ - return function indicesShardStores (params, callback) { + return function indicesShardStores (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesShardStores(params, (err, body) => { + indicesShardStores(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -86,7 +92,7 @@ function buildIndicesShardStores (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -98,12 +104,17 @@ function buildIndicesShardStores (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.shrink.js b/api/api/indices.shrink.js index 72c6f8a2f..721721c99 100644 --- a/api/api/indices.shrink.js +++ b/api/api/indices.shrink.js @@ -14,15 +14,21 @@ function buildIndicesShrink (opts) { * @param {string} wait_for_active_shards - Set the number of active shards to wait for on the shrunken index before the operation returns. * @param {object} body - The configuration for the target index (`settings` and `aliases`) */ - return function indicesShrink (params, callback) { + return function indicesShrink (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesShrink(params, (err, body) => { + indicesShrink(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -102,7 +108,7 @@ function buildIndicesShrink (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -114,12 +120,17 @@ function buildIndicesShrink (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.split.js b/api/api/indices.split.js index 0f282669c..7e41e56f3 100644 --- a/api/api/indices.split.js +++ b/api/api/indices.split.js @@ -14,15 +14,21 @@ function buildIndicesSplit (opts) { * @param {string} wait_for_active_shards - Set the number of active shards to wait for on the shrunken index before the operation returns. * @param {object} body - The configuration for the target index (`settings` and `aliases`) */ - return function indicesSplit (params, callback) { + return function indicesSplit (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesSplit(params, (err, body) => { + indicesSplit(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -102,7 +108,7 @@ function buildIndicesSplit (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -114,12 +120,17 @@ function buildIndicesSplit (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.stats.js b/api/api/indices.stats.js index 0effc56cb..972fabaac 100644 --- a/api/api/indices.stats.js +++ b/api/api/indices.stats.js @@ -16,15 +16,21 @@ function buildIndicesStats (opts) { * @param {list} types - A comma-separated list of document types for the `indexing` index metric * @param {boolean} include_segment_file_sizes - Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) */ - return function indicesStats (params, callback) { + return function indicesStats (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesStats(params, (err, body) => { + indicesStats(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -96,7 +102,7 @@ function buildIndicesStats (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -108,12 +114,17 @@ function buildIndicesStats (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.update_aliases.js b/api/api/indices.update_aliases.js index be335a46d..58e5a380c 100644 --- a/api/api/indices.update_aliases.js +++ b/api/api/indices.update_aliases.js @@ -10,15 +10,21 @@ function buildIndicesUpdateAliases (opts) { * @param {time} master_timeout - Specify timeout for connection to master * @param {object} body - The definition of `actions` to perform */ - return function indicesUpdateAliases (params, callback) { + return function indicesUpdateAliases (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesUpdateAliases(params, (err, body) => { + indicesUpdateAliases(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -80,7 +86,7 @@ function buildIndicesUpdateAliases (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -92,12 +98,17 @@ function buildIndicesUpdateAliases (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.upgrade.js b/api/api/indices.upgrade.js index b0f4433cb..4ae382482 100644 --- a/api/api/indices.upgrade.js +++ b/api/api/indices.upgrade.js @@ -13,15 +13,21 @@ function buildIndicesUpgrade (opts) { * @param {boolean} wait_for_completion - Specify whether the request should block until the all segments are upgraded (default: false) * @param {boolean} only_ancient_segments - If true, only ancient (an older Lucene major release) segments will be upgraded */ - return function indicesUpgrade (params, callback) { + return function indicesUpgrade (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesUpgrade(params, (err, body) => { + indicesUpgrade(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -89,7 +95,7 @@ function buildIndicesUpgrade (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -101,12 +107,17 @@ function buildIndicesUpgrade (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/indices.validate_query.js b/api/api/indices.validate_query.js index 8741b272e..6438214cc 100644 --- a/api/api/indices.validate_query.js +++ b/api/api/indices.validate_query.js @@ -22,15 +22,21 @@ function buildIndicesValidateQuery (opts) { * @param {boolean} all_shards - Execute validation on all shards instead of one random shard per index * @param {object} body - The query definition specified with the Query DSL */ - return function indicesValidateQuery (params, callback) { + return function indicesValidateQuery (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - indicesValidateQuery(params, (err, body) => { + indicesValidateQuery(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -112,7 +118,7 @@ function buildIndicesValidateQuery (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -124,12 +130,17 @@ function buildIndicesValidateQuery (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/info.js b/api/api/info.js index 8f276a7a4..1c879bca1 100644 --- a/api/api/info.js +++ b/api/api/info.js @@ -7,15 +7,21 @@ function buildInfo (opts) { * Perform a [info](http://www.elastic.co/guide/) request * */ - return function info (params, callback) { + return function info (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - info(params, (err, body) => { + info(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildInfo (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildInfo (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/ingest.delete_pipeline.js b/api/api/ingest.delete_pipeline.js index ad583cf00..dfad9ba3d 100644 --- a/api/api/ingest.delete_pipeline.js +++ b/api/api/ingest.delete_pipeline.js @@ -10,15 +10,21 @@ function buildIngestDeletePipeline (opts) { * @param {time} master_timeout - Explicit operation timeout for connection to master node * @param {time} timeout - Explicit operation timeout */ - return function ingestDeletePipeline (params, callback) { + return function ingestDeletePipeline (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - ingestDeletePipeline(params, (err, body) => { + ingestDeletePipeline(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -86,7 +92,7 @@ function buildIngestDeletePipeline (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -98,12 +104,17 @@ function buildIngestDeletePipeline (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/ingest.get_pipeline.js b/api/api/ingest.get_pipeline.js index db737e802..4b51643a5 100644 --- a/api/api/ingest.get_pipeline.js +++ b/api/api/ingest.get_pipeline.js @@ -9,15 +9,21 @@ function buildIngestGetPipeline (opts) { * @param {string} id - Comma separated list of pipeline ids. Wildcards supported * @param {time} master_timeout - Explicit operation timeout for connection to master node */ - return function ingestGetPipeline (params, callback) { + return function ingestGetPipeline (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - ingestGetPipeline(params, (err, body) => { + ingestGetPipeline(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -77,7 +83,7 @@ function buildIngestGetPipeline (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -89,12 +95,17 @@ function buildIngestGetPipeline (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/ingest.processor_grok.js b/api/api/ingest.processor_grok.js index a21146a18..71e8b2374 100644 --- a/api/api/ingest.processor_grok.js +++ b/api/api/ingest.processor_grok.js @@ -7,15 +7,21 @@ function buildIngestProcessorGrok (opts) { * Perform a [ingest.processor_grok](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request * */ - return function ingestProcessorGrok (params, callback) { + return function ingestProcessorGrok (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - ingestProcessorGrok(params, (err, body) => { + ingestProcessorGrok(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildIngestProcessorGrok (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildIngestProcessorGrok (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/ingest.put_pipeline.js b/api/api/ingest.put_pipeline.js index dfe3d69d6..5af734ee3 100644 --- a/api/api/ingest.put_pipeline.js +++ b/api/api/ingest.put_pipeline.js @@ -11,15 +11,21 @@ function buildIngestPutPipeline (opts) { * @param {time} timeout - Explicit operation timeout * @param {object} body - The ingest definition */ - return function ingestPutPipeline (params, callback) { + return function ingestPutPipeline (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - ingestPutPipeline(params, (err, body) => { + ingestPutPipeline(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -87,7 +93,7 @@ function buildIngestPutPipeline (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -99,12 +105,17 @@ function buildIngestPutPipeline (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/ingest.simulate.js b/api/api/ingest.simulate.js index c9adf74ba..b92be2c1c 100644 --- a/api/api/ingest.simulate.js +++ b/api/api/ingest.simulate.js @@ -10,15 +10,21 @@ function buildIngestSimulate (opts) { * @param {boolean} verbose - Verbose mode. Display data output for each processor in executed pipeline * @param {object} body - The simulate definition */ - return function ingestSimulate (params, callback) { + return function ingestSimulate (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - ingestSimulate(params, (err, body) => { + ingestSimulate(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -78,7 +84,7 @@ function buildIngestSimulate (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -90,12 +96,17 @@ function buildIngestSimulate (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/mget.js b/api/api/mget.js index 590af1638..f56ec92ee 100644 --- a/api/api/mget.js +++ b/api/api/mget.js @@ -18,15 +18,21 @@ function buildMget (opts) { * @param {list} _source_include - A list of fields to extract and return from the _source field * @param {object} body - Document identifiers; can be either `docs` (containing full document information) or `ids` (when index and type is provided in the URL. */ - return function mget (params, callback) { + return function mget (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - mget(params, (err, body) => { + mget(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -108,7 +114,7 @@ function buildMget (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -120,12 +126,17 @@ function buildMget (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/msearch.js b/api/api/msearch.js index d201b9d3b..383887dd4 100644 --- a/api/api/msearch.js +++ b/api/api/msearch.js @@ -15,15 +15,21 @@ function buildMsearch (opts) { * @param {number} max_concurrent_shard_requests - The number of concurrent shard requests each sub search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests * @param {object} body - The request definitions (metadata-search request definition pairs), separated by newlines */ - return function msearch (params, callback) { + return function msearch (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - msearch(params, (err, body) => { + msearch(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -99,7 +105,7 @@ function buildMsearch (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -111,12 +117,17 @@ function buildMsearch (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, bulkBody: params.body, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/msearch_template.js b/api/api/msearch_template.js index f0ae1ea03..b8375a927 100644 --- a/api/api/msearch_template.js +++ b/api/api/msearch_template.js @@ -13,15 +13,21 @@ function buildMsearchTemplate (opts) { * @param {number} max_concurrent_searches - Controls the maximum number of concurrent searches the multi search api will execute * @param {object} body - The request definitions (metadata-search request definition pairs), separated by newlines */ - return function msearchTemplate (params, callback) { + return function msearchTemplate (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - msearchTemplate(params, (err, body) => { + msearchTemplate(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -93,7 +99,7 @@ function buildMsearchTemplate (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -105,12 +111,17 @@ function buildMsearchTemplate (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, bulkBody: params.body, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/mtermvectors.js b/api/api/mtermvectors.js index 11e711f62..9a967f293 100644 --- a/api/api/mtermvectors.js +++ b/api/api/mtermvectors.js @@ -23,15 +23,21 @@ function buildMtermvectors (opts) { * @param {enum} version_type - Specific version type * @param {object} body - Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation. */ - return function mtermvectors (params, callback) { + return function mtermvectors (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - mtermvectors(params, (err, body) => { + mtermvectors(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -115,7 +121,7 @@ function buildMtermvectors (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -127,12 +133,17 @@ function buildMtermvectors (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/nodes.hot_threads.js b/api/api/nodes.hot_threads.js index 977c2a0de..089bdcadb 100644 --- a/api/api/nodes.hot_threads.js +++ b/api/api/nodes.hot_threads.js @@ -14,15 +14,21 @@ function buildNodesHotThreads (opts) { * @param {enum} type - The type to sample (default: cpu) * @param {time} timeout - Explicit operation timeout */ - return function nodesHotThreads (params, callback) { + return function nodesHotThreads (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - nodesHotThreads(params, (err, body) => { + nodesHotThreads(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -92,7 +98,7 @@ function buildNodesHotThreads (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -106,12 +112,17 @@ function buildNodesHotThreads (opts) { : '/_nodes/hot_threads', querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/nodes.info.js b/api/api/nodes.info.js index 786ab8bd5..22aee5980 100644 --- a/api/api/nodes.info.js +++ b/api/api/nodes.info.js @@ -11,15 +11,21 @@ function buildNodesInfo (opts) { * @param {boolean} flat_settings - Return settings in flat format (default: false) * @param {time} timeout - Explicit operation timeout */ - return function nodesInfo (params, callback) { + return function nodesInfo (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - nodesInfo(params, (err, body) => { + nodesInfo(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -81,7 +87,7 @@ function buildNodesInfo (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -93,12 +99,17 @@ function buildNodesInfo (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/nodes.reload_secure_settings.js b/api/api/nodes.reload_secure_settings.js index 37c682b31..8fe846f04 100644 --- a/api/api/nodes.reload_secure_settings.js +++ b/api/api/nodes.reload_secure_settings.js @@ -9,15 +9,21 @@ function buildNodesReloadSecureSettings (opts) { * @param {list} node_id - A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes. * @param {time} timeout - Explicit operation timeout */ - return function nodesReloadSecureSettings (params, callback) { + return function nodesReloadSecureSettings (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - nodesReloadSecureSettings(params, (err, body) => { + nodesReloadSecureSettings(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -77,7 +83,7 @@ function buildNodesReloadSecureSettings (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -89,12 +95,17 @@ function buildNodesReloadSecureSettings (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/nodes.stats.js b/api/api/nodes.stats.js index 09a84e2f9..7b0ef2670 100644 --- a/api/api/nodes.stats.js +++ b/api/api/nodes.stats.js @@ -18,15 +18,21 @@ function buildNodesStats (opts) { * @param {time} timeout - Explicit operation timeout * @param {boolean} include_segment_file_sizes - Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) */ - return function nodesStats (params, callback) { + return function nodesStats (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - nodesStats(params, (err, body) => { + nodesStats(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -100,7 +106,7 @@ function buildNodesStats (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -112,12 +118,17 @@ function buildNodesStats (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/nodes.usage.js b/api/api/nodes.usage.js index 352f1ee62..99f1cb98c 100644 --- a/api/api/nodes.usage.js +++ b/api/api/nodes.usage.js @@ -10,15 +10,21 @@ function buildNodesUsage (opts) { * @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes * @param {time} timeout - Explicit operation timeout */ - return function nodesUsage (params, callback) { + return function nodesUsage (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - nodesUsage(params, (err, body) => { + nodesUsage(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -78,7 +84,7 @@ function buildNodesUsage (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -90,12 +96,17 @@ function buildNodesUsage (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/ping.js b/api/api/ping.js index 5679c5976..56c9562e8 100644 --- a/api/api/ping.js +++ b/api/api/ping.js @@ -7,15 +7,21 @@ function buildPing (opts) { * Perform a [ping](http://www.elastic.co/guide/) request * */ - return function ping (params, callback) { + return function ping (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - ping(params, (err, body) => { + ping(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildPing (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildPing (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/put_script.js b/api/api/put_script.js index 17a0048c8..e30752c63 100644 --- a/api/api/put_script.js +++ b/api/api/put_script.js @@ -13,15 +13,21 @@ function buildPutScript (opts) { * @param {string} context - Context name to compile script against * @param {object} body - The document */ - return function putScript (params, callback) { + return function putScript (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - putScript(params, (err, body) => { + putScript(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -99,7 +105,7 @@ function buildPutScript (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -111,12 +117,17 @@ function buildPutScript (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/rank_eval.js b/api/api/rank_eval.js index 3c1ac5022..b701d2e40 100644 --- a/api/api/rank_eval.js +++ b/api/api/rank_eval.js @@ -12,15 +12,21 @@ function buildRankEval (opts) { * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {object} body - The ranking evaluation search definition, including search requests, document ratings and ranking metric definition. */ - return function rankEval (params, callback) { + return function rankEval (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - rankEval(params, (err, body) => { + rankEval(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,7 +90,7 @@ function buildRankEval (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -96,12 +102,17 @@ function buildRankEval (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/reindex.js b/api/api/reindex.js index 4a618cfd4..c39f30c5f 100644 --- a/api/api/reindex.js +++ b/api/api/reindex.js @@ -14,15 +14,21 @@ function buildReindex (opts) { * @param {number} slices - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. * @param {object} body - The search definition using the Query DSL and the prototype for the index request. */ - return function reindex (params, callback) { + return function reindex (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - reindex(params, (err, body) => { + reindex(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -92,7 +98,7 @@ function buildReindex (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -104,12 +110,17 @@ function buildReindex (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/reindex_rethrottle.js b/api/api/reindex_rethrottle.js index ce6bf9b27..1c54e9ed8 100644 --- a/api/api/reindex_rethrottle.js +++ b/api/api/reindex_rethrottle.js @@ -9,15 +9,21 @@ function buildReindexRethrottle (opts) { * @param {string} task_id - The task id to rethrottle * @param {number} requests_per_second - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. */ - return function reindexRethrottle (params, callback) { + return function reindexRethrottle (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - reindexRethrottle(params, (err, body) => { + reindexRethrottle(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -89,7 +95,7 @@ function buildReindexRethrottle (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -101,12 +107,17 @@ function buildReindexRethrottle (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/render_search_template.js b/api/api/render_search_template.js index e0bcd4d4f..12ca3805a 100644 --- a/api/api/render_search_template.js +++ b/api/api/render_search_template.js @@ -9,15 +9,21 @@ function buildRenderSearchTemplate (opts) { * @param {string} id - The id of the stored search template * @param {object} body - The search definition template and its params */ - return function renderSearchTemplate (params, callback) { + return function renderSearchTemplate (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - renderSearchTemplate(params, (err, body) => { + renderSearchTemplate(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -67,7 +73,7 @@ function buildRenderSearchTemplate (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -79,12 +85,17 @@ function buildRenderSearchTemplate (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/scripts_painless_execute.js b/api/api/scripts_painless_execute.js index fcbfc56a1..e26683bde 100644 --- a/api/api/scripts_painless_execute.js +++ b/api/api/scripts_painless_execute.js @@ -8,15 +8,21 @@ function buildScriptsPainlessExecute (opts) { * * @param {object} body - The script to execute */ - return function scriptsPainlessExecute (params, callback) { + return function scriptsPainlessExecute (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - scriptsPainlessExecute(params, (err, body) => { + scriptsPainlessExecute(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildScriptsPainlessExecute (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildScriptsPainlessExecute (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/scroll.js b/api/api/scroll.js index b41c47dc3..0d6f9f1ab 100644 --- a/api/api/scroll.js +++ b/api/api/scroll.js @@ -11,15 +11,21 @@ function buildScroll (opts) { * @param {string} scroll_id - The scroll ID for scrolled search * @param {object} body - The scroll ID if not passed by URL or query parameter. */ - return function scroll (params, callback) { + return function scroll (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - scroll(params, (err, body) => { + scroll(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildScroll (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildScroll (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/search.js b/api/api/search.js index 706f59387..3a1ba231e 100644 --- a/api/api/search.js +++ b/api/api/search.js @@ -48,15 +48,21 @@ function buildSearch (opts) { * @param {number} pre_filter_shard_size - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on it's rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. * @param {object} body - The search definition using the Query DSL */ - return function search (params, callback) { + return function search (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - search(params, (err, body) => { + search(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -190,7 +196,7 @@ function buildSearch (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -202,12 +208,17 @@ function buildSearch (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/search_shards.js b/api/api/search_shards.js index 8aab7c88b..5e6a29832 100644 --- a/api/api/search_shards.js +++ b/api/api/search_shards.js @@ -14,15 +14,21 @@ function buildSearchShards (opts) { * @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. */ - return function searchShards (params, callback) { + return function searchShards (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - searchShards(params, (err, body) => { + searchShards(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -92,7 +98,7 @@ function buildSearchShards (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -104,12 +110,17 @@ function buildSearchShards (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/search_template.js b/api/api/search_template.js index 103b736ad..f9aca5107 100644 --- a/api/api/search_template.js +++ b/api/api/search_template.js @@ -20,15 +20,21 @@ function buildSearchTemplate (opts) { * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response * @param {object} body - The search definition template and its params */ - return function searchTemplate (params, callback) { + return function searchTemplate (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - searchTemplate(params, (err, body) => { + searchTemplate(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -114,7 +120,7 @@ function buildSearchTemplate (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -126,12 +132,17 @@ function buildSearchTemplate (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/snapshot.create.js b/api/api/snapshot.create.js index 5508bec03..873e2e6f0 100644 --- a/api/api/snapshot.create.js +++ b/api/api/snapshot.create.js @@ -12,15 +12,21 @@ function buildSnapshotCreate (opts) { * @param {boolean} wait_for_completion - Should this request wait until the operation has completed before returning * @param {object} body - The snapshot definition */ - return function snapshotCreate (params, callback) { + return function snapshotCreate (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - snapshotCreate(params, (err, body) => { + snapshotCreate(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -96,7 +102,7 @@ function buildSnapshotCreate (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -108,12 +114,17 @@ function buildSnapshotCreate (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/snapshot.create_repository.js b/api/api/snapshot.create_repository.js index b18ad893a..0fd7cac1d 100644 --- a/api/api/snapshot.create_repository.js +++ b/api/api/snapshot.create_repository.js @@ -12,15 +12,21 @@ function buildSnapshotCreateRepository (opts) { * @param {boolean} verify - Whether to verify the repository after creation * @param {object} body - The repository definition */ - return function snapshotCreateRepository (params, callback) { + return function snapshotCreateRepository (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - snapshotCreateRepository(params, (err, body) => { + snapshotCreateRepository(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -90,7 +96,7 @@ function buildSnapshotCreateRepository (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -102,12 +108,17 @@ function buildSnapshotCreateRepository (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/snapshot.delete.js b/api/api/snapshot.delete.js index f9d1064ca..047b2f92a 100644 --- a/api/api/snapshot.delete.js +++ b/api/api/snapshot.delete.js @@ -10,15 +10,21 @@ function buildSnapshotDelete (opts) { * @param {string} snapshot - A snapshot name * @param {time} master_timeout - Explicit operation timeout for connection to master node */ - return function snapshotDelete (params, callback) { + return function snapshotDelete (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - snapshotDelete(params, (err, body) => { + snapshotDelete(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -98,7 +104,7 @@ function buildSnapshotDelete (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -110,12 +116,17 @@ function buildSnapshotDelete (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/snapshot.delete_repository.js b/api/api/snapshot.delete_repository.js index a1b025aa3..bf4884d64 100644 --- a/api/api/snapshot.delete_repository.js +++ b/api/api/snapshot.delete_repository.js @@ -10,15 +10,21 @@ function buildSnapshotDeleteRepository (opts) { * @param {time} master_timeout - Explicit operation timeout for connection to master node * @param {time} timeout - Explicit operation timeout */ - return function snapshotDeleteRepository (params, callback) { + return function snapshotDeleteRepository (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - snapshotDeleteRepository(params, (err, body) => { + snapshotDeleteRepository(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -86,7 +92,7 @@ function buildSnapshotDeleteRepository (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -98,12 +104,17 @@ function buildSnapshotDeleteRepository (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/snapshot.get.js b/api/api/snapshot.get.js index 694410fab..68a869c3c 100644 --- a/api/api/snapshot.get.js +++ b/api/api/snapshot.get.js @@ -12,15 +12,21 @@ function buildSnapshotGet (opts) { * @param {boolean} ignore_unavailable - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown * @param {boolean} verbose - Whether to show verbose snapshot info or only show the basic info found in the repository index blob */ - return function snapshotGet (params, callback) { + return function snapshotGet (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - snapshotGet(params, (err, body) => { + snapshotGet(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -104,7 +110,7 @@ function buildSnapshotGet (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -116,12 +122,17 @@ function buildSnapshotGet (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/snapshot.get_repository.js b/api/api/snapshot.get_repository.js index 12571520a..f127a7cb1 100644 --- a/api/api/snapshot.get_repository.js +++ b/api/api/snapshot.get_repository.js @@ -10,15 +10,21 @@ function buildSnapshotGetRepository (opts) { * @param {time} master_timeout - Explicit operation timeout for connection to master node * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) */ - return function snapshotGetRepository (params, callback) { + return function snapshotGetRepository (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - snapshotGetRepository(params, (err, body) => { + snapshotGetRepository(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -80,7 +86,7 @@ function buildSnapshotGetRepository (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -92,12 +98,17 @@ function buildSnapshotGetRepository (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/snapshot.restore.js b/api/api/snapshot.restore.js index 5a947a1b6..a6f90e34d 100644 --- a/api/api/snapshot.restore.js +++ b/api/api/snapshot.restore.js @@ -12,15 +12,21 @@ function buildSnapshotRestore (opts) { * @param {boolean} wait_for_completion - Should this request wait until the operation has completed before returning * @param {object} body - Details of what to restore */ - return function snapshotRestore (params, callback) { + return function snapshotRestore (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - snapshotRestore(params, (err, body) => { + snapshotRestore(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -96,7 +102,7 @@ function buildSnapshotRestore (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -108,12 +114,17 @@ function buildSnapshotRestore (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/snapshot.status.js b/api/api/snapshot.status.js index 456e32f5c..190a9df1d 100644 --- a/api/api/snapshot.status.js +++ b/api/api/snapshot.status.js @@ -11,15 +11,21 @@ function buildSnapshotStatus (opts) { * @param {time} master_timeout - Explicit operation timeout for connection to master node * @param {boolean} ignore_unavailable - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown */ - return function snapshotStatus (params, callback) { + return function snapshotStatus (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - snapshotStatus(params, (err, body) => { + snapshotStatus(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -89,7 +95,7 @@ function buildSnapshotStatus (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -101,12 +107,17 @@ function buildSnapshotStatus (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/snapshot.verify_repository.js b/api/api/snapshot.verify_repository.js index 52d302c5c..ae407b982 100644 --- a/api/api/snapshot.verify_repository.js +++ b/api/api/snapshot.verify_repository.js @@ -10,15 +10,21 @@ function buildSnapshotVerifyRepository (opts) { * @param {time} master_timeout - Explicit operation timeout for connection to master node * @param {time} timeout - Explicit operation timeout */ - return function snapshotVerifyRepository (params, callback) { + return function snapshotVerifyRepository (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - snapshotVerifyRepository(params, (err, body) => { + snapshotVerifyRepository(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -86,7 +92,7 @@ function buildSnapshotVerifyRepository (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -98,12 +104,17 @@ function buildSnapshotVerifyRepository (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/tasks.cancel.js b/api/api/tasks.cancel.js index 13d4f65d6..4c18305a8 100644 --- a/api/api/tasks.cancel.js +++ b/api/api/tasks.cancel.js @@ -11,15 +11,21 @@ function buildTasksCancel (opts) { * @param {list} actions - A comma-separated list of actions that should be cancelled. Leave empty to cancel all. * @param {string} parent_task_id - Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all. */ - return function tasksCancel (params, callback) { + return function tasksCancel (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - tasksCancel(params, (err, body) => { + tasksCancel(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -83,7 +89,7 @@ function buildTasksCancel (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -95,12 +101,17 @@ function buildTasksCancel (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/tasks.get.js b/api/api/tasks.get.js index 1a566b2f4..ee39d1208 100644 --- a/api/api/tasks.get.js +++ b/api/api/tasks.get.js @@ -10,15 +10,21 @@ function buildTasksGet (opts) { * @param {boolean} wait_for_completion - Wait for the matching tasks to complete (default: false) * @param {time} timeout - Explicit operation timeout */ - return function tasksGet (params, callback) { + return function tasksGet (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - tasksGet(params, (err, body) => { + tasksGet(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -86,7 +92,7 @@ function buildTasksGet (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -98,12 +104,17 @@ function buildTasksGet (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/tasks.list.js b/api/api/tasks.list.js index 171bd139c..4a7d20ef9 100644 --- a/api/api/tasks.list.js +++ b/api/api/tasks.list.js @@ -14,15 +14,21 @@ function buildTasksList (opts) { * @param {enum} group_by - Group tasks by nodes or parent/child relationships * @param {time} timeout - Explicit operation timeout */ - return function tasksList (params, callback) { + return function tasksList (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - tasksList(params, (err, body) => { + tasksList(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -94,7 +100,7 @@ function buildTasksList (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -106,12 +112,17 @@ function buildTasksList (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/termvectors.js b/api/api/termvectors.js index 378326516..851ef79ff 100644 --- a/api/api/termvectors.js +++ b/api/api/termvectors.js @@ -23,15 +23,21 @@ function buildTermvectors (opts) { * @param {enum} version_type - Specific version type * @param {object} body - Define parameters and or supply a document to get termvectors for. See documentation. */ - return function termvectors (params, callback) { + return function termvectors (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - termvectors(params, (err, body) => { + termvectors(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -132,7 +138,7 @@ function buildTermvectors (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -144,12 +150,17 @@ function buildTermvectors (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/update.js b/api/api/update.js index 8ff23b6d5..273da583c 100644 --- a/api/api/update.js +++ b/api/api/update.js @@ -24,15 +24,21 @@ function buildUpdate (opts) { * @param {enum} version_type - Specific version type * @param {object} body - The request definition requires either `script` or partial `doc` */ - return function update (params, callback) { + return function update (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - update(params, (err, body) => { + update(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -147,7 +153,7 @@ function buildUpdate (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -159,12 +165,17 @@ function buildUpdate (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/update_by_query.js b/api/api/update_by_query.js index 5cd1ae79f..4904cd226 100644 --- a/api/api/update_by_query.js +++ b/api/api/update_by_query.js @@ -44,15 +44,21 @@ function buildUpdateByQuery (opts) { * @param {number} slices - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. * @param {object} body - The search definition using the Query DSL */ - return function updateByQuery (params, callback) { + return function updateByQuery (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - updateByQuery(params, (err, body) => { + updateByQuery(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -186,7 +192,7 @@ function buildUpdateByQuery (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -198,12 +204,17 @@ function buildUpdateByQuery (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/update_by_query_rethrottle.js b/api/api/update_by_query_rethrottle.js index b2c5acff2..5f90384a5 100644 --- a/api/api/update_by_query_rethrottle.js +++ b/api/api/update_by_query_rethrottle.js @@ -9,15 +9,21 @@ function buildUpdateByQueryRethrottle (opts) { * @param {string} task_id - The task id to rethrottle * @param {number} requests_per_second - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. */ - return function updateByQueryRethrottle (params, callback) { + return function updateByQueryRethrottle (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - updateByQueryRethrottle(params, (err, body) => { + updateByQueryRethrottle(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -89,7 +95,7 @@ function buildUpdateByQueryRethrottle (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -101,12 +107,17 @@ function buildUpdateByQueryRethrottle (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.graph.explore.js b/api/api/xpack.graph.explore.js index ec3c90010..dd65d8af3 100644 --- a/api/api/xpack.graph.explore.js +++ b/api/api/xpack.graph.explore.js @@ -12,15 +12,21 @@ function buildXpackGraphExplore (opts) { * @param {time} timeout - Explicit operation timeout * @param {object} body - Graph Query DSL */ - return function xpackGraphExplore (params, callback) { + return function xpackGraphExplore (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackGraphExplore(params, (err, body) => { + xpackGraphExplore(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -72,7 +78,7 @@ function buildXpackGraphExplore (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -84,12 +90,17 @@ function buildXpackGraphExplore (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.info.js b/api/api/xpack.info.js index aabfd6dbd..a6d2c27e4 100644 --- a/api/api/xpack.info.js +++ b/api/api/xpack.info.js @@ -8,15 +8,21 @@ function buildXpackInfo (opts) { * * @param {list} categories - Comma-separated list of info categories. Can be any of: build, license, features */ - return function xpackInfo (params, callback) { + return function xpackInfo (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackInfo(params, (err, body) => { + xpackInfo(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildXpackInfo (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildXpackInfo (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.license.delete.js b/api/api/xpack.license.delete.js index 622fc7d85..6bca3d074 100644 --- a/api/api/xpack.license.delete.js +++ b/api/api/xpack.license.delete.js @@ -7,15 +7,21 @@ function buildXpackLicenseDelete (opts) { * Perform a [xpack.license.delete](https://www.elastic.co/guide/en/x-pack/current/license-management.html) request * */ - return function xpackLicenseDelete (params, callback) { + return function xpackLicenseDelete (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackLicenseDelete(params, (err, body) => { + xpackLicenseDelete(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -65,7 +71,7 @@ function buildXpackLicenseDelete (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -77,12 +83,17 @@ function buildXpackLicenseDelete (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.license.get.js b/api/api/xpack.license.get.js index 161ebcc02..110a5c8a9 100644 --- a/api/api/xpack.license.get.js +++ b/api/api/xpack.license.get.js @@ -8,15 +8,21 @@ function buildXpackLicenseGet (opts) { * * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) */ - return function xpackLicenseGet (params, callback) { + return function xpackLicenseGet (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackLicenseGet(params, (err, body) => { + xpackLicenseGet(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildXpackLicenseGet (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildXpackLicenseGet (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.license.get_basic_status.js b/api/api/xpack.license.get_basic_status.js index 92b117b74..7c0c67e6a 100644 --- a/api/api/xpack.license.get_basic_status.js +++ b/api/api/xpack.license.get_basic_status.js @@ -7,15 +7,21 @@ function buildXpackLicenseGetBasicStatus (opts) { * Perform a [xpack.license.get_basic_status](https://www.elastic.co/guide/en/x-pack/current/license-management.html) request * */ - return function xpackLicenseGetBasicStatus (params, callback) { + return function xpackLicenseGetBasicStatus (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackLicenseGetBasicStatus(params, (err, body) => { + xpackLicenseGetBasicStatus(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -65,7 +71,7 @@ function buildXpackLicenseGetBasicStatus (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -77,12 +83,17 @@ function buildXpackLicenseGetBasicStatus (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.license.get_trial_status.js b/api/api/xpack.license.get_trial_status.js index 277bfb74b..d9c2927ae 100644 --- a/api/api/xpack.license.get_trial_status.js +++ b/api/api/xpack.license.get_trial_status.js @@ -7,15 +7,21 @@ function buildXpackLicenseGetTrialStatus (opts) { * Perform a [xpack.license.get_trial_status](https://www.elastic.co/guide/en/x-pack/current/license-management.html) request * */ - return function xpackLicenseGetTrialStatus (params, callback) { + return function xpackLicenseGetTrialStatus (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackLicenseGetTrialStatus(params, (err, body) => { + xpackLicenseGetTrialStatus(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -65,7 +71,7 @@ function buildXpackLicenseGetTrialStatus (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -77,12 +83,17 @@ function buildXpackLicenseGetTrialStatus (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.license.post.js b/api/api/xpack.license.post.js index 0902f3611..26a31b031 100644 --- a/api/api/xpack.license.post.js +++ b/api/api/xpack.license.post.js @@ -9,15 +9,21 @@ function buildXpackLicensePost (opts) { * @param {boolean} acknowledge - whether the user has acknowledged acknowledge messages (default: false) * @param {object} body - licenses to be installed */ - return function xpackLicensePost (params, callback) { + return function xpackLicensePost (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackLicensePost(params, (err, body) => { + xpackLicensePost(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -59,7 +65,7 @@ function buildXpackLicensePost (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -71,12 +77,17 @@ function buildXpackLicensePost (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.license.post_start_basic.js b/api/api/xpack.license.post_start_basic.js index 3212e99cf..5762ad8a2 100644 --- a/api/api/xpack.license.post_start_basic.js +++ b/api/api/xpack.license.post_start_basic.js @@ -8,15 +8,21 @@ function buildXpackLicensePostStartBasic (opts) { * * @param {boolean} acknowledge - whether the user has acknowledged acknowledge messages (default: false) */ - return function xpackLicensePostStartBasic (params, callback) { + return function xpackLicensePostStartBasic (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackLicensePostStartBasic(params, (err, body) => { + xpackLicensePostStartBasic(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildXpackLicensePostStartBasic (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildXpackLicensePostStartBasic (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.license.post_start_trial.js b/api/api/xpack.license.post_start_trial.js index 66f75ec9a..d3b602202 100644 --- a/api/api/xpack.license.post_start_trial.js +++ b/api/api/xpack.license.post_start_trial.js @@ -9,15 +9,21 @@ function buildXpackLicensePostStartTrial (opts) { * @param {string} type - The type of trial license to generate (default: "trial") * @param {boolean} acknowledge - whether the user has acknowledged acknowledge messages (default: false) */ - return function xpackLicensePostStartTrial (params, callback) { + return function xpackLicensePostStartTrial (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackLicensePostStartTrial(params, (err, body) => { + xpackLicensePostStartTrial(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -69,7 +75,7 @@ function buildXpackLicensePostStartTrial (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -81,12 +87,17 @@ function buildXpackLicensePostStartTrial (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.migration.deprecations.js b/api/api/xpack.migration.deprecations.js index 927ef5432..e9fc7799e 100644 --- a/api/api/xpack.migration.deprecations.js +++ b/api/api/xpack.migration.deprecations.js @@ -8,15 +8,21 @@ function buildXpackMigrationDeprecations (opts) { * * @param {string} index - Index pattern */ - return function xpackMigrationDeprecations (params, callback) { + return function xpackMigrationDeprecations (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMigrationDeprecations(params, (err, body) => { + xpackMigrationDeprecations(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildXpackMigrationDeprecations (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildXpackMigrationDeprecations (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.migration.get_assistance.js b/api/api/xpack.migration.get_assistance.js index abe6ed6d5..2b43ef82f 100644 --- a/api/api/xpack.migration.get_assistance.js +++ b/api/api/xpack.migration.get_assistance.js @@ -11,15 +11,21 @@ function buildXpackMigrationGetAssistance (opts) { * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) */ - return function xpackMigrationGetAssistance (params, callback) { + return function xpackMigrationGetAssistance (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMigrationGetAssistance(params, (err, body) => { + xpackMigrationGetAssistance(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -65,7 +71,7 @@ function buildXpackMigrationGetAssistance (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -77,12 +83,17 @@ function buildXpackMigrationGetAssistance (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.migration.upgrade.js b/api/api/xpack.migration.upgrade.js index 57eb6b480..5477f42a7 100644 --- a/api/api/xpack.migration.upgrade.js +++ b/api/api/xpack.migration.upgrade.js @@ -9,15 +9,21 @@ function buildXpackMigrationUpgrade (opts) { * @param {string} index - The name of the index * @param {boolean} wait_for_completion - Should the request block until the upgrade operation is completed */ - return function xpackMigrationUpgrade (params, callback) { + return function xpackMigrationUpgrade (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMigrationUpgrade(params, (err, body) => { + xpackMigrationUpgrade(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -67,7 +73,7 @@ function buildXpackMigrationUpgrade (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -79,12 +85,17 @@ function buildXpackMigrationUpgrade (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.close_job.js b/api/api/xpack.ml.close_job.js index 54e2a41b6..22a2afd14 100644 --- a/api/api/xpack.ml.close_job.js +++ b/api/api/xpack.ml.close_job.js @@ -11,15 +11,21 @@ function buildXpackMlCloseJob (opts) { * @param {boolean} force - True if the job should be forcefully closed * @param {time} timeout - Controls the time to wait until a job has closed. Default to 30 minutes */ - return function xpackMlCloseJob (params, callback) { + return function xpackMlCloseJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlCloseJob(params, (err, body) => { + xpackMlCloseJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildXpackMlCloseJob (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildXpackMlCloseJob (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.delete_calendar.js b/api/api/xpack.ml.delete_calendar.js index 047a4047d..07d876fc2 100644 --- a/api/api/xpack.ml.delete_calendar.js +++ b/api/api/xpack.ml.delete_calendar.js @@ -8,15 +8,21 @@ function buildXpackMlDeleteCalendar (opts) { * * @param {string} calendar_id - The ID of the calendar to delete */ - return function xpackMlDeleteCalendar (params, callback) { + return function xpackMlDeleteCalendar (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteCalendar(params, (err, body) => { + xpackMlDeleteCalendar(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -72,7 +78,7 @@ function buildXpackMlDeleteCalendar (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -84,12 +90,17 @@ function buildXpackMlDeleteCalendar (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.delete_calendar_event.js b/api/api/xpack.ml.delete_calendar_event.js index 5f519b3f3..5c30de9eb 100644 --- a/api/api/xpack.ml.delete_calendar_event.js +++ b/api/api/xpack.ml.delete_calendar_event.js @@ -9,15 +9,21 @@ function buildXpackMlDeleteCalendarEvent (opts) { * @param {string} calendar_id - The ID of the calendar to modify * @param {string} event_id - The ID of the event to remove from the calendar */ - return function xpackMlDeleteCalendarEvent (params, callback) { + return function xpackMlDeleteCalendarEvent (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteCalendarEvent(params, (err, body) => { + xpackMlDeleteCalendarEvent(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -87,7 +93,7 @@ function buildXpackMlDeleteCalendarEvent (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -99,12 +105,17 @@ function buildXpackMlDeleteCalendarEvent (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.delete_calendar_job.js b/api/api/xpack.ml.delete_calendar_job.js index 312c4ab3f..669bf6a9e 100644 --- a/api/api/xpack.ml.delete_calendar_job.js +++ b/api/api/xpack.ml.delete_calendar_job.js @@ -9,15 +9,21 @@ function buildXpackMlDeleteCalendarJob (opts) { * @param {string} calendar_id - The ID of the calendar to modify * @param {string} job_id - The ID of the job to remove from the calendar */ - return function xpackMlDeleteCalendarJob (params, callback) { + return function xpackMlDeleteCalendarJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteCalendarJob(params, (err, body) => { + xpackMlDeleteCalendarJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -87,7 +93,7 @@ function buildXpackMlDeleteCalendarJob (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -99,12 +105,17 @@ function buildXpackMlDeleteCalendarJob (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.delete_datafeed.js b/api/api/xpack.ml.delete_datafeed.js index 0887d5709..52f70eb87 100644 --- a/api/api/xpack.ml.delete_datafeed.js +++ b/api/api/xpack.ml.delete_datafeed.js @@ -9,15 +9,21 @@ function buildXpackMlDeleteDatafeed (opts) { * @param {string} datafeed_id - The ID of the datafeed to delete * @param {boolean} force - True if the datafeed should be forcefully deleted */ - return function xpackMlDeleteDatafeed (params, callback) { + return function xpackMlDeleteDatafeed (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteDatafeed(params, (err, body) => { + xpackMlDeleteDatafeed(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildXpackMlDeleteDatafeed (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildXpackMlDeleteDatafeed (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.delete_expired_data.js b/api/api/xpack.ml.delete_expired_data.js index ecb653c55..ac0a613b8 100644 --- a/api/api/xpack.ml.delete_expired_data.js +++ b/api/api/xpack.ml.delete_expired_data.js @@ -7,15 +7,21 @@ function buildXpackMlDeleteExpiredData (opts) { * Perform a [xpack.ml.delete_expired_data](undefined) request * */ - return function xpackMlDeleteExpiredData (params, callback) { + return function xpackMlDeleteExpiredData (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteExpiredData(params, (err, body) => { + xpackMlDeleteExpiredData(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -65,7 +71,7 @@ function buildXpackMlDeleteExpiredData (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -77,12 +83,17 @@ function buildXpackMlDeleteExpiredData (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.delete_filter.js b/api/api/xpack.ml.delete_filter.js index c448e6555..66cfdf449 100644 --- a/api/api/xpack.ml.delete_filter.js +++ b/api/api/xpack.ml.delete_filter.js @@ -8,15 +8,21 @@ function buildXpackMlDeleteFilter (opts) { * * @param {string} filter_id - The ID of the filter to delete */ - return function xpackMlDeleteFilter (params, callback) { + return function xpackMlDeleteFilter (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteFilter(params, (err, body) => { + xpackMlDeleteFilter(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -72,7 +78,7 @@ function buildXpackMlDeleteFilter (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -84,12 +90,17 @@ function buildXpackMlDeleteFilter (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.delete_forecast.js b/api/api/xpack.ml.delete_forecast.js index 7ebba4f81..9a517fc72 100644 --- a/api/api/xpack.ml.delete_forecast.js +++ b/api/api/xpack.ml.delete_forecast.js @@ -11,15 +11,21 @@ function buildXpackMlDeleteForecast (opts) { * @param {boolean} allow_no_forecasts - Whether to ignore if `_all` matches no forecasts * @param {time} timeout - Controls the time to wait until the forecast(s) are deleted. Default to 30 seconds */ - return function xpackMlDeleteForecast (params, callback) { + return function xpackMlDeleteForecast (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteForecast(params, (err, body) => { + xpackMlDeleteForecast(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -85,7 +91,7 @@ function buildXpackMlDeleteForecast (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -97,12 +103,17 @@ function buildXpackMlDeleteForecast (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.delete_job.js b/api/api/xpack.ml.delete_job.js index b6bb053d7..f2236043e 100644 --- a/api/api/xpack.ml.delete_job.js +++ b/api/api/xpack.ml.delete_job.js @@ -10,15 +10,21 @@ function buildXpackMlDeleteJob (opts) { * @param {boolean} force - True if the job should be forcefully deleted * @param {boolean} wait_for_completion - Should this request wait until the operation has completed before returning */ - return function xpackMlDeleteJob (params, callback) { + return function xpackMlDeleteJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteJob(params, (err, body) => { + xpackMlDeleteJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -76,7 +82,7 @@ function buildXpackMlDeleteJob (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -88,12 +94,17 @@ function buildXpackMlDeleteJob (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.delete_model_snapshot.js b/api/api/xpack.ml.delete_model_snapshot.js index 616491dc7..986782fd8 100644 --- a/api/api/xpack.ml.delete_model_snapshot.js +++ b/api/api/xpack.ml.delete_model_snapshot.js @@ -9,15 +9,21 @@ function buildXpackMlDeleteModelSnapshot (opts) { * @param {string} job_id - The ID of the job to fetch * @param {string} snapshot_id - The ID of the snapshot to delete */ - return function xpackMlDeleteModelSnapshot (params, callback) { + return function xpackMlDeleteModelSnapshot (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteModelSnapshot(params, (err, body) => { + xpackMlDeleteModelSnapshot(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -87,7 +93,7 @@ function buildXpackMlDeleteModelSnapshot (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -99,12 +105,17 @@ function buildXpackMlDeleteModelSnapshot (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.find_file_structure.js b/api/api/xpack.ml.find_file_structure.js index 3e3cdb580..163a7490a 100644 --- a/api/api/xpack.ml.find_file_structure.js +++ b/api/api/xpack.ml.find_file_structure.js @@ -21,15 +21,21 @@ function buildXpackMlFindFileStructure (opts) { * @param {boolean} explain - Whether to include a commentary on how the structure was derived * @param {object} body - The contents of the file to be analyzed */ - return function xpackMlFindFileStructure (params, callback) { + return function xpackMlFindFileStructure (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlFindFileStructure(params, (err, body) => { + xpackMlFindFileStructure(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -103,7 +109,7 @@ function buildXpackMlFindFileStructure (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -115,12 +121,17 @@ function buildXpackMlFindFileStructure (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.flush_job.js b/api/api/xpack.ml.flush_job.js index 692e0b696..623da1fed 100644 --- a/api/api/xpack.ml.flush_job.js +++ b/api/api/xpack.ml.flush_job.js @@ -14,15 +14,21 @@ function buildXpackMlFlushJob (opts) { * @param {string} skip_time - Skips time to the given value without generating results or updating the model for the skipped interval * @param {object} body - Flush parameters */ - return function xpackMlFlushJob (params, callback) { + return function xpackMlFlushJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlFlushJob(params, (err, body) => { + xpackMlFlushJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -80,7 +86,7 @@ function buildXpackMlFlushJob (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -92,12 +98,17 @@ function buildXpackMlFlushJob (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.forecast.js b/api/api/xpack.ml.forecast.js index 60b7c4785..531b2106d 100644 --- a/api/api/xpack.ml.forecast.js +++ b/api/api/xpack.ml.forecast.js @@ -10,15 +10,21 @@ function buildXpackMlForecast (opts) { * @param {time} duration - The duration of the forecast * @param {time} expires_in - The time interval after which the forecast expires. Expired forecasts will be deleted at the first opportunity. */ - return function xpackMlForecast (params, callback) { + return function xpackMlForecast (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlForecast(params, (err, body) => { + xpackMlForecast(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -76,7 +82,7 @@ function buildXpackMlForecast (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -88,12 +94,17 @@ function buildXpackMlForecast (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.get_buckets.js b/api/api/xpack.ml.get_buckets.js index 49b3c1111..1d8ba2253 100644 --- a/api/api/xpack.ml.get_buckets.js +++ b/api/api/xpack.ml.get_buckets.js @@ -19,15 +19,21 @@ function buildXpackMlGetBuckets (opts) { * @param {boolean} desc - Set the sort direction * @param {object} body - Bucket selection details if not provided in URI */ - return function xpackMlGetBuckets (params, callback) { + return function xpackMlGetBuckets (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetBuckets(params, (err, body) => { + xpackMlGetBuckets(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -101,7 +107,7 @@ function buildXpackMlGetBuckets (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -113,12 +119,17 @@ function buildXpackMlGetBuckets (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.get_calendar_events.js b/api/api/xpack.ml.get_calendar_events.js index f0d15cef7..40081df89 100644 --- a/api/api/xpack.ml.get_calendar_events.js +++ b/api/api/xpack.ml.get_calendar_events.js @@ -13,15 +13,21 @@ function buildXpackMlGetCalendarEvents (opts) { * @param {int} from - Skips a number of events * @param {int} size - Specifies a max number of events to get */ - return function xpackMlGetCalendarEvents (params, callback) { + return function xpackMlGetCalendarEvents (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetCalendarEvents(params, (err, body) => { + xpackMlGetCalendarEvents(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -85,7 +91,7 @@ function buildXpackMlGetCalendarEvents (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -97,12 +103,17 @@ function buildXpackMlGetCalendarEvents (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.get_calendars.js b/api/api/xpack.ml.get_calendars.js index 30f8c2c9f..919f21101 100644 --- a/api/api/xpack.ml.get_calendars.js +++ b/api/api/xpack.ml.get_calendars.js @@ -10,15 +10,21 @@ function buildXpackMlGetCalendars (opts) { * @param {int} from - skips a number of calendars * @param {int} size - specifies a max number of calendars to get */ - return function xpackMlGetCalendars (params, callback) { + return function xpackMlGetCalendars (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetCalendars(params, (err, body) => { + xpackMlGetCalendars(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -70,7 +76,7 @@ function buildXpackMlGetCalendars (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -82,12 +88,17 @@ function buildXpackMlGetCalendars (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.get_categories.js b/api/api/xpack.ml.get_categories.js index c0f09458f..563cf6a62 100644 --- a/api/api/xpack.ml.get_categories.js +++ b/api/api/xpack.ml.get_categories.js @@ -12,15 +12,21 @@ function buildXpackMlGetCategories (opts) { * @param {int} size - specifies a max number of categories to get * @param {object} body - Category selection details if not provided in URI */ - return function xpackMlGetCategories (params, callback) { + return function xpackMlGetCategories (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetCategories(params, (err, body) => { + xpackMlGetCategories(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -72,7 +78,7 @@ function buildXpackMlGetCategories (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -86,12 +92,17 @@ function buildXpackMlGetCategories (opts) { : '/_xpack/ml/anomaly_detectors/{job_id}/results/categories/{category_id}', querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.get_datafeed_stats.js b/api/api/xpack.ml.get_datafeed_stats.js index 36df79e43..6766bf1ac 100644 --- a/api/api/xpack.ml.get_datafeed_stats.js +++ b/api/api/xpack.ml.get_datafeed_stats.js @@ -9,15 +9,21 @@ function buildXpackMlGetDatafeedStats (opts) { * @param {string} datafeed_id - The ID of the datafeeds stats to fetch * @param {boolean} allow_no_datafeeds - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) */ - return function xpackMlGetDatafeedStats (params, callback) { + return function xpackMlGetDatafeedStats (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetDatafeedStats(params, (err, body) => { + xpackMlGetDatafeedStats(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -67,7 +73,7 @@ function buildXpackMlGetDatafeedStats (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -79,12 +85,17 @@ function buildXpackMlGetDatafeedStats (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.get_datafeeds.js b/api/api/xpack.ml.get_datafeeds.js index 15b54754c..ab5de887b 100644 --- a/api/api/xpack.ml.get_datafeeds.js +++ b/api/api/xpack.ml.get_datafeeds.js @@ -9,15 +9,21 @@ function buildXpackMlGetDatafeeds (opts) { * @param {string} datafeed_id - The ID of the datafeeds to fetch * @param {boolean} allow_no_datafeeds - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) */ - return function xpackMlGetDatafeeds (params, callback) { + return function xpackMlGetDatafeeds (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetDatafeeds(params, (err, body) => { + xpackMlGetDatafeeds(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -67,7 +73,7 @@ function buildXpackMlGetDatafeeds (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -79,12 +85,17 @@ function buildXpackMlGetDatafeeds (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.get_filters.js b/api/api/xpack.ml.get_filters.js index 11f3bb0bb..054265fce 100644 --- a/api/api/xpack.ml.get_filters.js +++ b/api/api/xpack.ml.get_filters.js @@ -10,15 +10,21 @@ function buildXpackMlGetFilters (opts) { * @param {int} from - skips a number of filters * @param {int} size - specifies a max number of filters to get */ - return function xpackMlGetFilters (params, callback) { + return function xpackMlGetFilters (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetFilters(params, (err, body) => { + xpackMlGetFilters(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -70,7 +76,7 @@ function buildXpackMlGetFilters (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -82,12 +88,17 @@ function buildXpackMlGetFilters (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.get_influencers.js b/api/api/xpack.ml.get_influencers.js index c88357dfd..7b769d0db 100644 --- a/api/api/xpack.ml.get_influencers.js +++ b/api/api/xpack.ml.get_influencers.js @@ -17,15 +17,21 @@ function buildXpackMlGetInfluencers (opts) { * @param {boolean} desc - whether the results should be sorted in decending order * @param {object} body - Influencer selection criteria */ - return function xpackMlGetInfluencers (params, callback) { + return function xpackMlGetInfluencers (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetInfluencers(params, (err, body) => { + xpackMlGetInfluencers(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -89,7 +95,7 @@ function buildXpackMlGetInfluencers (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -101,12 +107,17 @@ function buildXpackMlGetInfluencers (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.get_job_stats.js b/api/api/xpack.ml.get_job_stats.js index 93a13d7eb..62c715b19 100644 --- a/api/api/xpack.ml.get_job_stats.js +++ b/api/api/xpack.ml.get_job_stats.js @@ -9,15 +9,21 @@ function buildXpackMlGetJobStats (opts) { * @param {string} job_id - The ID of the jobs stats to fetch * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) */ - return function xpackMlGetJobStats (params, callback) { + return function xpackMlGetJobStats (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetJobStats(params, (err, body) => { + xpackMlGetJobStats(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -67,7 +73,7 @@ function buildXpackMlGetJobStats (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -79,12 +85,17 @@ function buildXpackMlGetJobStats (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.get_jobs.js b/api/api/xpack.ml.get_jobs.js index eec7b4580..d87a86c94 100644 --- a/api/api/xpack.ml.get_jobs.js +++ b/api/api/xpack.ml.get_jobs.js @@ -9,15 +9,21 @@ function buildXpackMlGetJobs (opts) { * @param {string} job_id - The ID of the jobs to fetch * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) */ - return function xpackMlGetJobs (params, callback) { + return function xpackMlGetJobs (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetJobs(params, (err, body) => { + xpackMlGetJobs(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -67,7 +73,7 @@ function buildXpackMlGetJobs (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -79,12 +85,17 @@ function buildXpackMlGetJobs (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.get_model_snapshots.js b/api/api/xpack.ml.get_model_snapshots.js index cd0d55a10..b17323927 100644 --- a/api/api/xpack.ml.get_model_snapshots.js +++ b/api/api/xpack.ml.get_model_snapshots.js @@ -16,15 +16,21 @@ function buildXpackMlGetModelSnapshots (opts) { * @param {boolean} desc - True if the results should be sorted in descending order * @param {object} body - Model snapshot selection criteria */ - return function xpackMlGetModelSnapshots (params, callback) { + return function xpackMlGetModelSnapshots (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetModelSnapshots(params, (err, body) => { + xpackMlGetModelSnapshots(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -92,7 +98,7 @@ function buildXpackMlGetModelSnapshots (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -104,12 +110,17 @@ function buildXpackMlGetModelSnapshots (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.get_overall_buckets.js b/api/api/xpack.ml.get_overall_buckets.js index 5dcb98d45..0bc89ff55 100644 --- a/api/api/xpack.ml.get_overall_buckets.js +++ b/api/api/xpack.ml.get_overall_buckets.js @@ -16,15 +16,21 @@ function buildXpackMlGetOverallBuckets (opts) { * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) * @param {object} body - Overall bucket selection details if not provided in URI */ - return function xpackMlGetOverallBuckets (params, callback) { + return function xpackMlGetOverallBuckets (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetOverallBuckets(params, (err, body) => { + xpackMlGetOverallBuckets(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -86,7 +92,7 @@ function buildXpackMlGetOverallBuckets (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -98,12 +104,17 @@ function buildXpackMlGetOverallBuckets (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.get_records.js b/api/api/xpack.ml.get_records.js index 4128ea678..8aa744819 100644 --- a/api/api/xpack.ml.get_records.js +++ b/api/api/xpack.ml.get_records.js @@ -17,15 +17,21 @@ function buildXpackMlGetRecords (opts) { * @param {boolean} desc - Set the sort direction * @param {object} body - Record selection criteria */ - return function xpackMlGetRecords (params, callback) { + return function xpackMlGetRecords (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetRecords(params, (err, body) => { + xpackMlGetRecords(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -89,7 +95,7 @@ function buildXpackMlGetRecords (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -101,12 +107,17 @@ function buildXpackMlGetRecords (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.info.js b/api/api/xpack.ml.info.js index e25d043d7..444fa7cf5 100644 --- a/api/api/xpack.ml.info.js +++ b/api/api/xpack.ml.info.js @@ -7,15 +7,21 @@ function buildXpackMlInfo (opts) { * Perform a [xpack.ml.info](undefined) request * */ - return function xpackMlInfo (params, callback) { + return function xpackMlInfo (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlInfo(params, (err, body) => { + xpackMlInfo(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -57,7 +63,7 @@ function buildXpackMlInfo (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -69,12 +75,17 @@ function buildXpackMlInfo (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.open_job.js b/api/api/xpack.ml.open_job.js index f1bfa8404..db0b8662f 100644 --- a/api/api/xpack.ml.open_job.js +++ b/api/api/xpack.ml.open_job.js @@ -10,15 +10,21 @@ function buildXpackMlOpenJob (opts) { * @param {boolean} ignore_downtime - Controls if gaps in data are treated as anomalous or as a maintenance window after a job re-start * @param {time} timeout - Controls the time to wait until a job has opened. Default to 30 minutes */ - return function xpackMlOpenJob (params, callback) { + return function xpackMlOpenJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlOpenJob(params, (err, body) => { + xpackMlOpenJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -74,7 +80,7 @@ function buildXpackMlOpenJob (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -86,12 +92,17 @@ function buildXpackMlOpenJob (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.post_calendar_events.js b/api/api/xpack.ml.post_calendar_events.js index 1f5f1b9e4..eee4a7fef 100644 --- a/api/api/xpack.ml.post_calendar_events.js +++ b/api/api/xpack.ml.post_calendar_events.js @@ -9,15 +9,21 @@ function buildXpackMlPostCalendarEvents (opts) { * @param {string} calendar_id - The ID of the calendar to modify * @param {object} body - A list of events */ - return function xpackMlPostCalendarEvents (params, callback) { + return function xpackMlPostCalendarEvents (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPostCalendarEvents(params, (err, body) => { + xpackMlPostCalendarEvents(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildXpackMlPostCalendarEvents (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildXpackMlPostCalendarEvents (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.post_data.js b/api/api/xpack.ml.post_data.js index a7cb0f074..b6eb4bdec 100644 --- a/api/api/xpack.ml.post_data.js +++ b/api/api/xpack.ml.post_data.js @@ -11,15 +11,21 @@ function buildXpackMlPostData (opts) { * @param {string} reset_end - Optional parameter to specify the end of the bucket resetting range * @param {object} body - The data to process */ - return function xpackMlPostData (params, callback) { + return function xpackMlPostData (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPostData(params, (err, body) => { + xpackMlPostData(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -77,7 +83,7 @@ function buildXpackMlPostData (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -89,12 +95,17 @@ function buildXpackMlPostData (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.preview_datafeed.js b/api/api/xpack.ml.preview_datafeed.js index 57a9a174b..02ad7f38e 100644 --- a/api/api/xpack.ml.preview_datafeed.js +++ b/api/api/xpack.ml.preview_datafeed.js @@ -8,15 +8,21 @@ function buildXpackMlPreviewDatafeed (opts) { * * @param {string} datafeed_id - The ID of the datafeed to preview */ - return function xpackMlPreviewDatafeed (params, callback) { + return function xpackMlPreviewDatafeed (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPreviewDatafeed(params, (err, body) => { + xpackMlPreviewDatafeed(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -72,7 +78,7 @@ function buildXpackMlPreviewDatafeed (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -84,12 +90,17 @@ function buildXpackMlPreviewDatafeed (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.put_calendar.js b/api/api/xpack.ml.put_calendar.js index 6022adea8..29f97382b 100644 --- a/api/api/xpack.ml.put_calendar.js +++ b/api/api/xpack.ml.put_calendar.js @@ -9,15 +9,21 @@ function buildXpackMlPutCalendar (opts) { * @param {string} calendar_id - The ID of the calendar to create * @param {object} body - The calendar details */ - return function xpackMlPutCalendar (params, callback) { + return function xpackMlPutCalendar (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPutCalendar(params, (err, body) => { + xpackMlPutCalendar(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -67,7 +73,7 @@ function buildXpackMlPutCalendar (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -79,12 +85,17 @@ function buildXpackMlPutCalendar (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.put_calendar_job.js b/api/api/xpack.ml.put_calendar_job.js index d224e14c6..c2926e228 100644 --- a/api/api/xpack.ml.put_calendar_job.js +++ b/api/api/xpack.ml.put_calendar_job.js @@ -9,15 +9,21 @@ function buildXpackMlPutCalendarJob (opts) { * @param {string} calendar_id - The ID of the calendar to modify * @param {string} job_id - The ID of the job to add to the calendar */ - return function xpackMlPutCalendarJob (params, callback) { + return function xpackMlPutCalendarJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPutCalendarJob(params, (err, body) => { + xpackMlPutCalendarJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -87,7 +93,7 @@ function buildXpackMlPutCalendarJob (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -99,12 +105,17 @@ function buildXpackMlPutCalendarJob (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.put_datafeed.js b/api/api/xpack.ml.put_datafeed.js index 11110736f..4b038f079 100644 --- a/api/api/xpack.ml.put_datafeed.js +++ b/api/api/xpack.ml.put_datafeed.js @@ -9,15 +9,21 @@ function buildXpackMlPutDatafeed (opts) { * @param {string} datafeed_id - The ID of the datafeed to create * @param {object} body - The datafeed config */ - return function xpackMlPutDatafeed (params, callback) { + return function xpackMlPutDatafeed (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPutDatafeed(params, (err, body) => { + xpackMlPutDatafeed(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildXpackMlPutDatafeed (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildXpackMlPutDatafeed (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.put_filter.js b/api/api/xpack.ml.put_filter.js index 3fb862d56..9486f00e8 100644 --- a/api/api/xpack.ml.put_filter.js +++ b/api/api/xpack.ml.put_filter.js @@ -9,15 +9,21 @@ function buildXpackMlPutFilter (opts) { * @param {string} filter_id - The ID of the filter to create * @param {object} body - The filter details */ - return function xpackMlPutFilter (params, callback) { + return function xpackMlPutFilter (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPutFilter(params, (err, body) => { + xpackMlPutFilter(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildXpackMlPutFilter (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildXpackMlPutFilter (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.put_job.js b/api/api/xpack.ml.put_job.js index a33ef0785..b0900ac56 100644 --- a/api/api/xpack.ml.put_job.js +++ b/api/api/xpack.ml.put_job.js @@ -9,15 +9,21 @@ function buildXpackMlPutJob (opts) { * @param {string} job_id - The ID of the job to create * @param {object} body - The job */ - return function xpackMlPutJob (params, callback) { + return function xpackMlPutJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPutJob(params, (err, body) => { + xpackMlPutJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildXpackMlPutJob (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildXpackMlPutJob (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.revert_model_snapshot.js b/api/api/xpack.ml.revert_model_snapshot.js index 8cc7a50d6..1a8a108d9 100644 --- a/api/api/xpack.ml.revert_model_snapshot.js +++ b/api/api/xpack.ml.revert_model_snapshot.js @@ -11,15 +11,21 @@ function buildXpackMlRevertModelSnapshot (opts) { * @param {boolean} delete_intervening_results - Should we reset the results back to the time of the snapshot? * @param {object} body - Reversion options */ - return function xpackMlRevertModelSnapshot (params, callback) { + return function xpackMlRevertModelSnapshot (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlRevertModelSnapshot(params, (err, body) => { + xpackMlRevertModelSnapshot(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -83,7 +89,7 @@ function buildXpackMlRevertModelSnapshot (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -95,12 +101,17 @@ function buildXpackMlRevertModelSnapshot (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.start_datafeed.js b/api/api/xpack.ml.start_datafeed.js index 6067f8cdb..71e4c456e 100644 --- a/api/api/xpack.ml.start_datafeed.js +++ b/api/api/xpack.ml.start_datafeed.js @@ -12,15 +12,21 @@ function buildXpackMlStartDatafeed (opts) { * @param {time} timeout - Controls the time to wait until a datafeed has started. Default to 20 seconds * @param {object} body - The start datafeed parameters */ - return function xpackMlStartDatafeed (params, callback) { + return function xpackMlStartDatafeed (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlStartDatafeed(params, (err, body) => { + xpackMlStartDatafeed(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -74,7 +80,7 @@ function buildXpackMlStartDatafeed (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -86,12 +92,17 @@ function buildXpackMlStartDatafeed (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.stop_datafeed.js b/api/api/xpack.ml.stop_datafeed.js index d97f93c83..49effa5bd 100644 --- a/api/api/xpack.ml.stop_datafeed.js +++ b/api/api/xpack.ml.stop_datafeed.js @@ -11,15 +11,21 @@ function buildXpackMlStopDatafeed (opts) { * @param {boolean} force - True if the datafeed should be forcefully stopped. * @param {time} timeout - Controls the time to wait until a datafeed has stopped. Default to 20 seconds */ - return function xpackMlStopDatafeed (params, callback) { + return function xpackMlStopDatafeed (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlStopDatafeed(params, (err, body) => { + xpackMlStopDatafeed(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildXpackMlStopDatafeed (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildXpackMlStopDatafeed (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.update_datafeed.js b/api/api/xpack.ml.update_datafeed.js index dbbceba53..217c0a928 100644 --- a/api/api/xpack.ml.update_datafeed.js +++ b/api/api/xpack.ml.update_datafeed.js @@ -9,15 +9,21 @@ function buildXpackMlUpdateDatafeed (opts) { * @param {string} datafeed_id - The ID of the datafeed to update * @param {object} body - The datafeed update settings */ - return function xpackMlUpdateDatafeed (params, callback) { + return function xpackMlUpdateDatafeed (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlUpdateDatafeed(params, (err, body) => { + xpackMlUpdateDatafeed(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildXpackMlUpdateDatafeed (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildXpackMlUpdateDatafeed (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.update_filter.js b/api/api/xpack.ml.update_filter.js index 4555df771..31aa277f7 100644 --- a/api/api/xpack.ml.update_filter.js +++ b/api/api/xpack.ml.update_filter.js @@ -9,15 +9,21 @@ function buildXpackMlUpdateFilter (opts) { * @param {string} filter_id - The ID of the filter to update * @param {object} body - The filter update */ - return function xpackMlUpdateFilter (params, callback) { + return function xpackMlUpdateFilter (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlUpdateFilter(params, (err, body) => { + xpackMlUpdateFilter(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildXpackMlUpdateFilter (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildXpackMlUpdateFilter (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.update_job.js b/api/api/xpack.ml.update_job.js index 86bb0ef7b..bd31ad2ed 100644 --- a/api/api/xpack.ml.update_job.js +++ b/api/api/xpack.ml.update_job.js @@ -9,15 +9,21 @@ function buildXpackMlUpdateJob (opts) { * @param {string} job_id - The ID of the job to create * @param {object} body - The job update settings */ - return function xpackMlUpdateJob (params, callback) { + return function xpackMlUpdateJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlUpdateJob(params, (err, body) => { + xpackMlUpdateJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildXpackMlUpdateJob (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildXpackMlUpdateJob (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.update_model_snapshot.js b/api/api/xpack.ml.update_model_snapshot.js index 2bbffe196..7d2bcfc9c 100644 --- a/api/api/xpack.ml.update_model_snapshot.js +++ b/api/api/xpack.ml.update_model_snapshot.js @@ -10,15 +10,21 @@ function buildXpackMlUpdateModelSnapshot (opts) { * @param {string} snapshot_id - The ID of the snapshot to update * @param {object} body - The model snapshot properties to update */ - return function xpackMlUpdateModelSnapshot (params, callback) { + return function xpackMlUpdateModelSnapshot (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlUpdateModelSnapshot(params, (err, body) => { + xpackMlUpdateModelSnapshot(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -88,7 +94,7 @@ function buildXpackMlUpdateModelSnapshot (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -100,12 +106,17 @@ function buildXpackMlUpdateModelSnapshot (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.validate.js b/api/api/xpack.ml.validate.js index f192dbb67..f8935900c 100644 --- a/api/api/xpack.ml.validate.js +++ b/api/api/xpack.ml.validate.js @@ -8,15 +8,21 @@ function buildXpackMlValidate (opts) { * * @param {object} body - The job config */ - return function xpackMlValidate (params, callback) { + return function xpackMlValidate (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlValidate(params, (err, body) => { + xpackMlValidate(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildXpackMlValidate (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildXpackMlValidate (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ml.validate_detector.js b/api/api/xpack.ml.validate_detector.js index c0f1e3f74..2d6bbf7b4 100644 --- a/api/api/xpack.ml.validate_detector.js +++ b/api/api/xpack.ml.validate_detector.js @@ -8,15 +8,21 @@ function buildXpackMlValidateDetector (opts) { * * @param {object} body - The detector */ - return function xpackMlValidateDetector (params, callback) { + return function xpackMlValidateDetector (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlValidateDetector(params, (err, body) => { + xpackMlValidateDetector(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildXpackMlValidateDetector (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildXpackMlValidateDetector (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.monitoring.bulk.js b/api/api/xpack.monitoring.bulk.js index 874fd3e33..74ea937e3 100644 --- a/api/api/xpack.monitoring.bulk.js +++ b/api/api/xpack.monitoring.bulk.js @@ -12,15 +12,21 @@ function buildXpackMonitoringBulk (opts) { * @param {string} interval - Collection interval (e.g., '10s' or '10000ms') of the payload * @param {object} body - The operation definition and data (action-data pairs), separated by newlines */ - return function xpackMonitoringBulk (params, callback) { + return function xpackMonitoringBulk (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMonitoringBulk(params, (err, body) => { + xpackMonitoringBulk(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -74,7 +80,7 @@ function buildXpackMonitoringBulk (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -86,12 +92,17 @@ function buildXpackMonitoringBulk (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.rollup.delete_job.js b/api/api/xpack.rollup.delete_job.js index 9d69aa0d6..9f7a66fd0 100644 --- a/api/api/xpack.rollup.delete_job.js +++ b/api/api/xpack.rollup.delete_job.js @@ -8,15 +8,21 @@ function buildXpackRollupDeleteJob (opts) { * * @param {string} id - The ID of the job to delete */ - return function xpackRollupDeleteJob (params, callback) { + return function xpackRollupDeleteJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackRollupDeleteJob(params, (err, body) => { + xpackRollupDeleteJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildXpackRollupDeleteJob (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildXpackRollupDeleteJob (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.rollup.get_jobs.js b/api/api/xpack.rollup.get_jobs.js index 3eed24003..5e9b93d08 100644 --- a/api/api/xpack.rollup.get_jobs.js +++ b/api/api/xpack.rollup.get_jobs.js @@ -8,15 +8,21 @@ function buildXpackRollupGetJobs (opts) { * * @param {string} id - The ID of the job(s) to fetch. Accepts glob patterns, or left blank for all jobs */ - return function xpackRollupGetJobs (params, callback) { + return function xpackRollupGetJobs (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackRollupGetJobs(params, (err, body) => { + xpackRollupGetJobs(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -58,7 +64,7 @@ function buildXpackRollupGetJobs (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -70,12 +76,17 @@ function buildXpackRollupGetJobs (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.rollup.get_rollup_caps.js b/api/api/xpack.rollup.get_rollup_caps.js index c198f852d..33edcf745 100644 --- a/api/api/xpack.rollup.get_rollup_caps.js +++ b/api/api/xpack.rollup.get_rollup_caps.js @@ -8,15 +8,21 @@ function buildXpackRollupGetRollupCaps (opts) { * * @param {string} id - The ID of the index to check rollup capabilities on, or left blank for all jobs */ - return function xpackRollupGetRollupCaps (params, callback) { + return function xpackRollupGetRollupCaps (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackRollupGetRollupCaps(params, (err, body) => { + xpackRollupGetRollupCaps(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -58,7 +64,7 @@ function buildXpackRollupGetRollupCaps (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -70,12 +76,17 @@ function buildXpackRollupGetRollupCaps (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.rollup.get_rollup_index_caps.js b/api/api/xpack.rollup.get_rollup_index_caps.js index c1ddd2ad4..9364bfd41 100644 --- a/api/api/xpack.rollup.get_rollup_index_caps.js +++ b/api/api/xpack.rollup.get_rollup_index_caps.js @@ -8,15 +8,21 @@ function buildXpackRollupGetRollupIndexCaps (opts) { * * @param {string} index - The rollup index or index pattern to obtain rollup capabilities from. */ - return function xpackRollupGetRollupIndexCaps (params, callback) { + return function xpackRollupGetRollupIndexCaps (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackRollupGetRollupIndexCaps(params, (err, body) => { + xpackRollupGetRollupIndexCaps(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildXpackRollupGetRollupIndexCaps (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildXpackRollupGetRollupIndexCaps (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.rollup.put_job.js b/api/api/xpack.rollup.put_job.js index 80e5d8cb7..46717e464 100644 --- a/api/api/xpack.rollup.put_job.js +++ b/api/api/xpack.rollup.put_job.js @@ -9,15 +9,21 @@ function buildXpackRollupPutJob (opts) { * @param {string} id - The ID of the job to create * @param {object} body - The job configuration */ - return function xpackRollupPutJob (params, callback) { + return function xpackRollupPutJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackRollupPutJob(params, (err, body) => { + xpackRollupPutJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildXpackRollupPutJob (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildXpackRollupPutJob (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.rollup.rollup_search.js b/api/api/xpack.rollup.rollup_search.js index b5dfbeafb..0ac7c331b 100644 --- a/api/api/xpack.rollup.rollup_search.js +++ b/api/api/xpack.rollup.rollup_search.js @@ -10,15 +10,21 @@ function buildXpackRollupRollupSearch (opts) { * @param {string} type - The doc type inside the index * @param {object} body - The search request body */ - return function xpackRollupRollupSearch (params, callback) { + return function xpackRollupRollupSearch (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackRollupRollupSearch(params, (err, body) => { + xpackRollupRollupSearch(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -82,7 +88,7 @@ function buildXpackRollupRollupSearch (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -96,12 +102,17 @@ function buildXpackRollupRollupSearch (opts) { : '/{index}/_rollup_search', querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.rollup.start_job.js b/api/api/xpack.rollup.start_job.js index f9e230d2e..1b9b33a83 100644 --- a/api/api/xpack.rollup.start_job.js +++ b/api/api/xpack.rollup.start_job.js @@ -8,15 +8,21 @@ function buildXpackRollupStartJob (opts) { * * @param {string} id - The ID of the job to start */ - return function xpackRollupStartJob (params, callback) { + return function xpackRollupStartJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackRollupStartJob(params, (err, body) => { + xpackRollupStartJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildXpackRollupStartJob (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildXpackRollupStartJob (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.rollup.stop_job.js b/api/api/xpack.rollup.stop_job.js index 9a0aa470c..92d2f1b86 100644 --- a/api/api/xpack.rollup.stop_job.js +++ b/api/api/xpack.rollup.stop_job.js @@ -8,15 +8,21 @@ function buildXpackRollupStopJob (opts) { * * @param {string} id - The ID of the job to stop */ - return function xpackRollupStopJob (params, callback) { + return function xpackRollupStopJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackRollupStopJob(params, (err, body) => { + xpackRollupStopJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildXpackRollupStopJob (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildXpackRollupStopJob (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.authenticate.js b/api/api/xpack.security.authenticate.js index b1564e6b9..62e766010 100644 --- a/api/api/xpack.security.authenticate.js +++ b/api/api/xpack.security.authenticate.js @@ -7,15 +7,21 @@ function buildXpackSecurityAuthenticate (opts) { * Perform a [xpack.security.authenticate](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-authenticate.html) request * */ - return function xpackSecurityAuthenticate (params, callback) { + return function xpackSecurityAuthenticate (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityAuthenticate(params, (err, body) => { + xpackSecurityAuthenticate(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -65,7 +71,7 @@ function buildXpackSecurityAuthenticate (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -77,12 +83,17 @@ function buildXpackSecurityAuthenticate (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.change_password.js b/api/api/xpack.security.change_password.js index b0853aa9a..0ad182cc8 100644 --- a/api/api/xpack.security.change_password.js +++ b/api/api/xpack.security.change_password.js @@ -10,15 +10,21 @@ function buildXpackSecurityChangePassword (opts) { * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. * @param {object} body - the new password for the user */ - return function xpackSecurityChangePassword (params, callback) { + return function xpackSecurityChangePassword (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityChangePassword(params, (err, body) => { + xpackSecurityChangePassword(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -68,7 +74,7 @@ function buildXpackSecurityChangePassword (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -80,12 +86,17 @@ function buildXpackSecurityChangePassword (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.clear_cached_realms.js b/api/api/xpack.security.clear_cached_realms.js index 27b96dad3..44e65460f 100644 --- a/api/api/xpack.security.clear_cached_realms.js +++ b/api/api/xpack.security.clear_cached_realms.js @@ -9,15 +9,21 @@ function buildXpackSecurityClearCachedRealms (opts) { * @param {list} realms - Comma-separated list of realms to clear * @param {list} usernames - Comma-separated list of usernames to clear from the cache */ - return function xpackSecurityClearCachedRealms (params, callback) { + return function xpackSecurityClearCachedRealms (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityClearCachedRealms(params, (err, body) => { + xpackSecurityClearCachedRealms(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildXpackSecurityClearCachedRealms (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildXpackSecurityClearCachedRealms (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.clear_cached_roles.js b/api/api/xpack.security.clear_cached_roles.js index e0d2c87eb..05700a5db 100644 --- a/api/api/xpack.security.clear_cached_roles.js +++ b/api/api/xpack.security.clear_cached_roles.js @@ -8,15 +8,21 @@ function buildXpackSecurityClearCachedRoles (opts) { * * @param {list} name - Role name */ - return function xpackSecurityClearCachedRoles (params, callback) { + return function xpackSecurityClearCachedRoles (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityClearCachedRoles(params, (err, body) => { + xpackSecurityClearCachedRoles(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -72,7 +78,7 @@ function buildXpackSecurityClearCachedRoles (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -84,12 +90,17 @@ function buildXpackSecurityClearCachedRoles (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.delete_privileges.js b/api/api/xpack.security.delete_privileges.js index 4333e87d2..ef0944f08 100644 --- a/api/api/xpack.security.delete_privileges.js +++ b/api/api/xpack.security.delete_privileges.js @@ -10,15 +10,21 @@ function buildXpackSecurityDeletePrivileges (opts) { * @param {string} name - Privilege name * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ - return function xpackSecurityDeletePrivileges (params, callback) { + return function xpackSecurityDeletePrivileges (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityDeletePrivileges(params, (err, body) => { + xpackSecurityDeletePrivileges(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -88,7 +94,7 @@ function buildXpackSecurityDeletePrivileges (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -100,12 +106,17 @@ function buildXpackSecurityDeletePrivileges (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.delete_role.js b/api/api/xpack.security.delete_role.js index 8967a3ebc..00a5f1533 100644 --- a/api/api/xpack.security.delete_role.js +++ b/api/api/xpack.security.delete_role.js @@ -9,15 +9,21 @@ function buildXpackSecurityDeleteRole (opts) { * @param {string} name - Role name * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ - return function xpackSecurityDeleteRole (params, callback) { + return function xpackSecurityDeleteRole (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityDeleteRole(params, (err, body) => { + xpackSecurityDeleteRole(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildXpackSecurityDeleteRole (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildXpackSecurityDeleteRole (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.delete_role_mapping.js b/api/api/xpack.security.delete_role_mapping.js index 8747d94ca..d1ce3fea7 100644 --- a/api/api/xpack.security.delete_role_mapping.js +++ b/api/api/xpack.security.delete_role_mapping.js @@ -9,15 +9,21 @@ function buildXpackSecurityDeleteRoleMapping (opts) { * @param {string} name - Role-mapping name * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ - return function xpackSecurityDeleteRoleMapping (params, callback) { + return function xpackSecurityDeleteRoleMapping (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityDeleteRoleMapping(params, (err, body) => { + xpackSecurityDeleteRoleMapping(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildXpackSecurityDeleteRoleMapping (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildXpackSecurityDeleteRoleMapping (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.delete_user.js b/api/api/xpack.security.delete_user.js index 3bed165bc..54960d79f 100644 --- a/api/api/xpack.security.delete_user.js +++ b/api/api/xpack.security.delete_user.js @@ -9,15 +9,21 @@ function buildXpackSecurityDeleteUser (opts) { * @param {string} username - username * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ - return function xpackSecurityDeleteUser (params, callback) { + return function xpackSecurityDeleteUser (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityDeleteUser(params, (err, body) => { + xpackSecurityDeleteUser(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildXpackSecurityDeleteUser (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildXpackSecurityDeleteUser (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.disable_user.js b/api/api/xpack.security.disable_user.js index 30d154981..5f850ae81 100644 --- a/api/api/xpack.security.disable_user.js +++ b/api/api/xpack.security.disable_user.js @@ -9,15 +9,21 @@ function buildXpackSecurityDisableUser (opts) { * @param {string} username - The username of the user to disable * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ - return function xpackSecurityDisableUser (params, callback) { + return function xpackSecurityDisableUser (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityDisableUser(params, (err, body) => { + xpackSecurityDisableUser(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -67,7 +73,7 @@ function buildXpackSecurityDisableUser (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -79,12 +85,17 @@ function buildXpackSecurityDisableUser (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.enable_user.js b/api/api/xpack.security.enable_user.js index 4df443a29..a416332a3 100644 --- a/api/api/xpack.security.enable_user.js +++ b/api/api/xpack.security.enable_user.js @@ -9,15 +9,21 @@ function buildXpackSecurityEnableUser (opts) { * @param {string} username - The username of the user to enable * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ - return function xpackSecurityEnableUser (params, callback) { + return function xpackSecurityEnableUser (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityEnableUser(params, (err, body) => { + xpackSecurityEnableUser(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -67,7 +73,7 @@ function buildXpackSecurityEnableUser (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -79,12 +85,17 @@ function buildXpackSecurityEnableUser (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.get_privileges.js b/api/api/xpack.security.get_privileges.js index 4ba715bac..7a303c24e 100644 --- a/api/api/xpack.security.get_privileges.js +++ b/api/api/xpack.security.get_privileges.js @@ -9,15 +9,21 @@ function buildXpackSecurityGetPrivileges (opts) { * @param {string} application - Application name * @param {string} name - Privilege name */ - return function xpackSecurityGetPrivileges (params, callback) { + return function xpackSecurityGetPrivileges (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityGetPrivileges(params, (err, body) => { + xpackSecurityGetPrivileges(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -75,7 +81,7 @@ function buildXpackSecurityGetPrivileges (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -87,12 +93,17 @@ function buildXpackSecurityGetPrivileges (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.get_role.js b/api/api/xpack.security.get_role.js index 85a75abc5..be44eedc5 100644 --- a/api/api/xpack.security.get_role.js +++ b/api/api/xpack.security.get_role.js @@ -8,15 +8,21 @@ function buildXpackSecurityGetRole (opts) { * * @param {string} name - Role name */ - return function xpackSecurityGetRole (params, callback) { + return function xpackSecurityGetRole (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityGetRole(params, (err, body) => { + xpackSecurityGetRole(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildXpackSecurityGetRole (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildXpackSecurityGetRole (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.get_role_mapping.js b/api/api/xpack.security.get_role_mapping.js index dea05f037..227bbc895 100644 --- a/api/api/xpack.security.get_role_mapping.js +++ b/api/api/xpack.security.get_role_mapping.js @@ -8,15 +8,21 @@ function buildXpackSecurityGetRoleMapping (opts) { * * @param {string} name - Role-Mapping name */ - return function xpackSecurityGetRoleMapping (params, callback) { + return function xpackSecurityGetRoleMapping (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityGetRoleMapping(params, (err, body) => { + xpackSecurityGetRoleMapping(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildXpackSecurityGetRoleMapping (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildXpackSecurityGetRoleMapping (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.get_token.js b/api/api/xpack.security.get_token.js index 913e8c83b..8124174c1 100644 --- a/api/api/xpack.security.get_token.js +++ b/api/api/xpack.security.get_token.js @@ -8,15 +8,21 @@ function buildXpackSecurityGetToken (opts) { * * @param {object} body - The token request to get */ - return function xpackSecurityGetToken (params, callback) { + return function xpackSecurityGetToken (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityGetToken(params, (err, body) => { + xpackSecurityGetToken(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildXpackSecurityGetToken (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildXpackSecurityGetToken (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.get_user.js b/api/api/xpack.security.get_user.js index 4ee4a2493..264fe16df 100644 --- a/api/api/xpack.security.get_user.js +++ b/api/api/xpack.security.get_user.js @@ -8,15 +8,21 @@ function buildXpackSecurityGetUser (opts) { * * @param {list} username - A comma-separated list of usernames */ - return function xpackSecurityGetUser (params, callback) { + return function xpackSecurityGetUser (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityGetUser(params, (err, body) => { + xpackSecurityGetUser(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildXpackSecurityGetUser (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildXpackSecurityGetUser (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.get_user_privileges.js b/api/api/xpack.security.get_user_privileges.js index a0f8da0b9..8a4d0a380 100644 --- a/api/api/xpack.security.get_user_privileges.js +++ b/api/api/xpack.security.get_user_privileges.js @@ -7,15 +7,21 @@ function buildXpackSecurityGetUserPrivileges (opts) { * Perform a [xpack.security.get_user_privileges](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-privileges.html) request * */ - return function xpackSecurityGetUserPrivileges (params, callback) { + return function xpackSecurityGetUserPrivileges (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityGetUserPrivileges(params, (err, body) => { + xpackSecurityGetUserPrivileges(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -65,7 +71,7 @@ function buildXpackSecurityGetUserPrivileges (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -77,12 +83,17 @@ function buildXpackSecurityGetUserPrivileges (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.has_privileges.js b/api/api/xpack.security.has_privileges.js index e772571da..ec31ac697 100644 --- a/api/api/xpack.security.has_privileges.js +++ b/api/api/xpack.security.has_privileges.js @@ -9,15 +9,21 @@ function buildXpackSecurityHasPrivileges (opts) { * @param {string} user - Username * @param {object} body - The privileges to test */ - return function xpackSecurityHasPrivileges (params, callback) { + return function xpackSecurityHasPrivileges (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityHasPrivileges(params, (err, body) => { + xpackSecurityHasPrivileges(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -67,7 +73,7 @@ function buildXpackSecurityHasPrivileges (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -79,12 +85,17 @@ function buildXpackSecurityHasPrivileges (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.invalidate_token.js b/api/api/xpack.security.invalidate_token.js index 52d7cd7dd..587ff3ce3 100644 --- a/api/api/xpack.security.invalidate_token.js +++ b/api/api/xpack.security.invalidate_token.js @@ -8,15 +8,21 @@ function buildXpackSecurityInvalidateToken (opts) { * * @param {object} body - The token to invalidate */ - return function xpackSecurityInvalidateToken (params, callback) { + return function xpackSecurityInvalidateToken (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityInvalidateToken(params, (err, body) => { + xpackSecurityInvalidateToken(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildXpackSecurityInvalidateToken (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildXpackSecurityInvalidateToken (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.put_privileges.js b/api/api/xpack.security.put_privileges.js index 0b1c6637b..abbeb79c9 100644 --- a/api/api/xpack.security.put_privileges.js +++ b/api/api/xpack.security.put_privileges.js @@ -9,15 +9,21 @@ function buildXpackSecurityPutPrivileges (opts) { * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. * @param {object} body - The privilege(s) to add */ - return function xpackSecurityPutPrivileges (params, callback) { + return function xpackSecurityPutPrivileges (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityPutPrivileges(params, (err, body) => { + xpackSecurityPutPrivileges(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -67,7 +73,7 @@ function buildXpackSecurityPutPrivileges (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -79,12 +85,17 @@ function buildXpackSecurityPutPrivileges (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.put_role.js b/api/api/xpack.security.put_role.js index ddd30ab09..356ebcb34 100644 --- a/api/api/xpack.security.put_role.js +++ b/api/api/xpack.security.put_role.js @@ -10,15 +10,21 @@ function buildXpackSecurityPutRole (opts) { * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. * @param {object} body - The role to add */ - return function xpackSecurityPutRole (params, callback) { + return function xpackSecurityPutRole (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityPutRole(params, (err, body) => { + xpackSecurityPutRole(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -74,7 +80,7 @@ function buildXpackSecurityPutRole (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -86,12 +92,17 @@ function buildXpackSecurityPutRole (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.put_role_mapping.js b/api/api/xpack.security.put_role_mapping.js index 3cacc94b7..d4429ea8b 100644 --- a/api/api/xpack.security.put_role_mapping.js +++ b/api/api/xpack.security.put_role_mapping.js @@ -10,15 +10,21 @@ function buildXpackSecurityPutRoleMapping (opts) { * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. * @param {object} body - The role to add */ - return function xpackSecurityPutRoleMapping (params, callback) { + return function xpackSecurityPutRoleMapping (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityPutRoleMapping(params, (err, body) => { + xpackSecurityPutRoleMapping(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -74,7 +80,7 @@ function buildXpackSecurityPutRoleMapping (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -86,12 +92,17 @@ function buildXpackSecurityPutRoleMapping (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.security.put_user.js b/api/api/xpack.security.put_user.js index 7c92ddf60..5d219852f 100644 --- a/api/api/xpack.security.put_user.js +++ b/api/api/xpack.security.put_user.js @@ -10,15 +10,21 @@ function buildXpackSecurityPutUser (opts) { * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. * @param {object} body - The user to add */ - return function xpackSecurityPutUser (params, callback) { + return function xpackSecurityPutUser (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityPutUser(params, (err, body) => { + xpackSecurityPutUser(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -74,7 +80,7 @@ function buildXpackSecurityPutUser (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -86,12 +92,17 @@ function buildXpackSecurityPutUser (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.sql.clear_cursor.js b/api/api/xpack.sql.clear_cursor.js index 69ae7dbdb..bb9e30704 100644 --- a/api/api/xpack.sql.clear_cursor.js +++ b/api/api/xpack.sql.clear_cursor.js @@ -8,15 +8,21 @@ function buildXpackSqlClearCursor (opts) { * * @param {object} body - Specify the cursor value in the `cursor` element to clean the cursor. */ - return function xpackSqlClearCursor (params, callback) { + return function xpackSqlClearCursor (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSqlClearCursor(params, (err, body) => { + xpackSqlClearCursor(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildXpackSqlClearCursor (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildXpackSqlClearCursor (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.sql.query.js b/api/api/xpack.sql.query.js index 1397aaa28..2fa2028f4 100644 --- a/api/api/xpack.sql.query.js +++ b/api/api/xpack.sql.query.js @@ -9,15 +9,21 @@ function buildXpackSqlQuery (opts) { * @param {string} format - a short version of the Accept header, e.g. json, yaml * @param {object} body - Use the `query` element to start a query. Use the `cursor` element to continue a query. */ - return function xpackSqlQuery (params, callback) { + return function xpackSqlQuery (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSqlQuery(params, (err, body) => { + xpackSqlQuery(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -67,7 +73,7 @@ function buildXpackSqlQuery (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -79,12 +85,17 @@ function buildXpackSqlQuery (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.sql.translate.js b/api/api/xpack.sql.translate.js index 74fc9f25a..3147f6ee9 100644 --- a/api/api/xpack.sql.translate.js +++ b/api/api/xpack.sql.translate.js @@ -8,15 +8,21 @@ function buildXpackSqlTranslate (opts) { * * @param {object} body - Specify the query in the `query` element. */ - return function xpackSqlTranslate (params, callback) { + return function xpackSqlTranslate (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSqlTranslate(params, (err, body) => { + xpackSqlTranslate(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildXpackSqlTranslate (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildXpackSqlTranslate (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.ssl.certificates.js b/api/api/xpack.ssl.certificates.js index f7a2e25ef..1231db124 100644 --- a/api/api/xpack.ssl.certificates.js +++ b/api/api/xpack.ssl.certificates.js @@ -7,15 +7,21 @@ function buildXpackSslCertificates (opts) { * Perform a [xpack.ssl.certificates](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-ssl.html) request * */ - return function xpackSslCertificates (params, callback) { + return function xpackSslCertificates (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSslCertificates(params, (err, body) => { + xpackSslCertificates(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -65,7 +71,7 @@ function buildXpackSslCertificates (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -77,12 +83,17 @@ function buildXpackSslCertificates (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.usage.js b/api/api/xpack.usage.js index c7c61d359..e1b187d2d 100644 --- a/api/api/xpack.usage.js +++ b/api/api/xpack.usage.js @@ -8,15 +8,21 @@ function buildXpackUsage (opts) { * * @param {time} master_timeout - Specify timeout for watch write operation */ - return function xpackUsage (params, callback) { + return function xpackUsage (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackUsage(params, (err, body) => { + xpackUsage(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -66,7 +72,7 @@ function buildXpackUsage (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -78,12 +84,17 @@ function buildXpackUsage (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.watcher.ack_watch.js b/api/api/xpack.watcher.ack_watch.js index afd799396..eed6d5b80 100644 --- a/api/api/xpack.watcher.ack_watch.js +++ b/api/api/xpack.watcher.ack_watch.js @@ -10,15 +10,21 @@ function buildXpackWatcherAckWatch (opts) { * @param {list} action_id - A comma-separated list of the action ids to be acked * @param {time} master_timeout - Explicit operation timeout for connection to master node */ - return function xpackWatcherAckWatch (params, callback) { + return function xpackWatcherAckWatch (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackWatcherAckWatch(params, (err, body) => { + xpackWatcherAckWatch(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -82,7 +88,7 @@ function buildXpackWatcherAckWatch (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -94,12 +100,17 @@ function buildXpackWatcherAckWatch (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.watcher.activate_watch.js b/api/api/xpack.watcher.activate_watch.js index f972b5c0a..633406804 100644 --- a/api/api/xpack.watcher.activate_watch.js +++ b/api/api/xpack.watcher.activate_watch.js @@ -9,15 +9,21 @@ function buildXpackWatcherActivateWatch (opts) { * @param {string} watch_id - Watch ID * @param {time} master_timeout - Explicit operation timeout for connection to master node */ - return function xpackWatcherActivateWatch (params, callback) { + return function xpackWatcherActivateWatch (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackWatcherActivateWatch(params, (err, body) => { + xpackWatcherActivateWatch(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildXpackWatcherActivateWatch (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildXpackWatcherActivateWatch (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.watcher.deactivate_watch.js b/api/api/xpack.watcher.deactivate_watch.js index b51feb1c1..21b96e27e 100644 --- a/api/api/xpack.watcher.deactivate_watch.js +++ b/api/api/xpack.watcher.deactivate_watch.js @@ -9,15 +9,21 @@ function buildXpackWatcherDeactivateWatch (opts) { * @param {string} watch_id - Watch ID * @param {time} master_timeout - Explicit operation timeout for connection to master node */ - return function xpackWatcherDeactivateWatch (params, callback) { + return function xpackWatcherDeactivateWatch (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackWatcherDeactivateWatch(params, (err, body) => { + xpackWatcherDeactivateWatch(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildXpackWatcherDeactivateWatch (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildXpackWatcherDeactivateWatch (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.watcher.delete_watch.js b/api/api/xpack.watcher.delete_watch.js index 2215270e2..15fcf0894 100644 --- a/api/api/xpack.watcher.delete_watch.js +++ b/api/api/xpack.watcher.delete_watch.js @@ -9,15 +9,21 @@ function buildXpackWatcherDeleteWatch (opts) { * @param {string} id - Watch ID * @param {time} master_timeout - Explicit operation timeout for connection to master node */ - return function xpackWatcherDeleteWatch (params, callback) { + return function xpackWatcherDeleteWatch (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackWatcherDeleteWatch(params, (err, body) => { + xpackWatcherDeleteWatch(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -73,7 +79,7 @@ function buildXpackWatcherDeleteWatch (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -85,12 +91,17 @@ function buildXpackWatcherDeleteWatch (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.watcher.execute_watch.js b/api/api/xpack.watcher.execute_watch.js index 092ae039e..a98d7e390 100644 --- a/api/api/xpack.watcher.execute_watch.js +++ b/api/api/xpack.watcher.execute_watch.js @@ -10,15 +10,21 @@ function buildXpackWatcherExecuteWatch (opts) { * @param {boolean} debug - indicates whether the watch should execute in debug mode * @param {object} body - Execution control */ - return function xpackWatcherExecuteWatch (params, callback) { + return function xpackWatcherExecuteWatch (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackWatcherExecuteWatch(params, (err, body) => { + xpackWatcherExecuteWatch(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -60,7 +66,7 @@ function buildXpackWatcherExecuteWatch (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -72,12 +78,17 @@ function buildXpackWatcherExecuteWatch (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.watcher.get_watch.js b/api/api/xpack.watcher.get_watch.js index 13a950765..53c0a4a91 100644 --- a/api/api/xpack.watcher.get_watch.js +++ b/api/api/xpack.watcher.get_watch.js @@ -8,15 +8,21 @@ function buildXpackWatcherGetWatch (opts) { * * @param {string} id - Watch ID */ - return function xpackWatcherGetWatch (params, callback) { + return function xpackWatcherGetWatch (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackWatcherGetWatch(params, (err, body) => { + xpackWatcherGetWatch(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -72,7 +78,7 @@ function buildXpackWatcherGetWatch (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -84,12 +90,17 @@ function buildXpackWatcherGetWatch (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.watcher.put_watch.js b/api/api/xpack.watcher.put_watch.js index 63d0dc939..849110e18 100644 --- a/api/api/xpack.watcher.put_watch.js +++ b/api/api/xpack.watcher.put_watch.js @@ -12,15 +12,21 @@ function buildXpackWatcherPutWatch (opts) { * @param {number} version - Explicit version number for concurrency control * @param {object} body - The watch */ - return function xpackWatcherPutWatch (params, callback) { + return function xpackWatcherPutWatch (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackWatcherPutWatch(params, (err, body) => { + xpackWatcherPutWatch(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -74,7 +80,7 @@ function buildXpackWatcherPutWatch (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -86,12 +92,17 @@ function buildXpackWatcherPutWatch (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: params.body || '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.watcher.restart.js b/api/api/xpack.watcher.restart.js index 4b3730710..f8831deb0 100644 --- a/api/api/xpack.watcher.restart.js +++ b/api/api/xpack.watcher.restart.js @@ -7,15 +7,21 @@ function buildXpackWatcherRestart (opts) { * Perform a [xpack.watcher.restart](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-restart.html) request * */ - return function xpackWatcherRestart (params, callback) { + return function xpackWatcherRestart (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackWatcherRestart(params, (err, body) => { + xpackWatcherRestart(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -65,7 +71,7 @@ function buildXpackWatcherRestart (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -77,12 +83,17 @@ function buildXpackWatcherRestart (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.watcher.start.js b/api/api/xpack.watcher.start.js index aa81b5af0..5f6ea3368 100644 --- a/api/api/xpack.watcher.start.js +++ b/api/api/xpack.watcher.start.js @@ -7,15 +7,21 @@ function buildXpackWatcherStart (opts) { * Perform a [xpack.watcher.start](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-start.html) request * */ - return function xpackWatcherStart (params, callback) { + return function xpackWatcherStart (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackWatcherStart(params, (err, body) => { + xpackWatcherStart(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -65,7 +71,7 @@ function buildXpackWatcherStart (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -77,12 +83,17 @@ function buildXpackWatcherStart (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.watcher.stats.js b/api/api/xpack.watcher.stats.js index 37d4366b3..a6e20d6b4 100644 --- a/api/api/xpack.watcher.stats.js +++ b/api/api/xpack.watcher.stats.js @@ -10,15 +10,21 @@ function buildXpackWatcherStats (opts) { * @param {enum} metric - Controls what additional stat metrics should be include in the response * @param {boolean} emit_stacktraces - Emits stack traces of currently running watches */ - return function xpackWatcherStats (params, callback) { + return function xpackWatcherStats (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackWatcherStats(params, (err, body) => { + xpackWatcherStats(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -70,7 +76,7 @@ function buildXpackWatcherStats (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -82,12 +88,17 @@ function buildXpackWatcherStats (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: null, - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/api/xpack.watcher.stop.js b/api/api/xpack.watcher.stop.js index a712ad342..b7e2a861e 100644 --- a/api/api/xpack.watcher.stop.js +++ b/api/api/xpack.watcher.stop.js @@ -7,15 +7,21 @@ function buildXpackWatcherStop (opts) { * Perform a [xpack.watcher.stop](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stop.html) request * */ - return function xpackWatcherStop (params, callback) { + return function xpackWatcherStop (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackWatcherStop(params, (err, body) => { + xpackWatcherStop(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -65,7 +71,7 @@ function buildXpackWatcherStop (opts) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -77,12 +83,17 @@ function buildXpackWatcherStop (opts) { path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), querystring, body: '', - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } } diff --git a/api/index.js b/api/index.js index 878b8e497..0f4bb3df9 100644 --- a/api/index.js +++ b/api/index.js @@ -442,11 +442,11 @@ function ESAPI (opts) { // of js closures to have a simple cache with the least overhead. function lazyLoad (file, opts) { var fn = null - return function _lazyLoad (params, callback) { + return function _lazyLoad (params, options, callback) { if (fn === null) { fn = require(file)(opts) } - return fn(params, callback) + return fn(params, options, callback) } } From 7c1b58d703eb5e0c6f9598064ffa9953c525f6ce Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 12 Dec 2018 16:47:09 +0100 Subject: [PATCH 070/172] Updated scripts --- scripts/utils/genMain.js | 8 ++++---- scripts/utils/generate.js | 25 ++++++++++++++++++------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/scripts/utils/genMain.js b/scripts/utils/genMain.js index 419daf468..ed36ceaa9 100644 --- a/scripts/utils/genMain.js +++ b/scripts/utils/genMain.js @@ -16,12 +16,12 @@ function genFactory (folder) { .reduce((acc, val) => { const obj = { [val]: acc === null - ? 'apiMethod' + ? 'ApiMethod' : acc } if (isSnakeCased(val)) { obj[camelify(val)] = acc === null - ? 'apiMethod' + ? 'ApiMethod' : acc } return obj @@ -93,11 +93,11 @@ function genFactory (folder) { // of js closures to have a simple cache with the least overhead. function lazyLoad (file, opts) { var fn = null - return function _lazyLoad (params, callback) { + return function _lazyLoad (params, options, callback) { if (fn === null) { fn = require(file)(opts) } - return fn(params, callback) + return fn(params, options, callback) } } diff --git a/scripts/utils/generate.js b/scripts/utils/generate.js index e3be22b72..53895b120 100644 --- a/scripts/utils/generate.js +++ b/scripts/utils/generate.js @@ -66,15 +66,21 @@ function generate (spec, common) { } const code = ` - function ${safeWords(name)} (params, callback) { + function ${safeWords(name)} (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } if (typeof params === 'function' || params == null) { callback = params params = {} + options = {} } // promises support if (callback == null) { return new Promise((resolve, reject) => { - ${safeWords(name)}(params, (err, body) => { + ${safeWords(name)}(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -120,7 +126,7 @@ function generate (spec, common) { ) } - var ignore = params.ignore || null + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] } @@ -132,12 +138,17 @@ function generate (spec, common) { ${buildPath(api)} querystring, ${genBody(api, methods, spec[api].body)} - headers: params.headers || null, - ignore, - requestTimeout: params.requestTimeout || null + headers: params.headers || null } - return makeRequest(request, callback) + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false + } + + return makeRequest(request, requestOptions, callback) } `.trim() // always call trim to avoid newlines From b91b1ad1de1ca60d5993fe280fca7d6ede97964e Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 12 Dec 2018 16:47:29 +0100 Subject: [PATCH 071/172] WIP: initial prototype - Added options parameter in API methods - Updated typings --- index.d.ts | 773 ++++++++++++++++++++++---------------------- lib/Connection.d.ts | 6 +- lib/Transport.d.ts | 9 +- lib/Transport.js | 16 +- 4 files changed, 413 insertions(+), 391 deletions(-) diff --git a/index.d.ts b/index.d.ts index e5daecd42..2455073e5 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2,7 +2,7 @@ import { EventEmitter } from 'events'; import { SecureContextOptions } from 'tls'; -import Transport, { ApiResponse, EventMeta, SniffMeta } from './lib/Transport'; +import Transport, { ApiResponse, EventMeta, SniffMeta, RequestOptions } from './lib/Transport'; import Connection, { AgentOptions } from './lib/Connection'; import ConnectionPool, { nodeSelectorFn, nodeFilterFn, ResurrectMeta } from './lib/ConnectionPool'; import Serializer from './lib/Serializer'; @@ -11,7 +11,12 @@ declare type anyObject = { [key: string]: any; }; declare type callbackFn = (err: Error | null, result: ApiResponse) => void; -declare type apiMethod = (params?: anyObject | callbackFn, callback?: callbackFn) => any; + +interface ApiMethod { + (callback?: callbackFn): any; + (params: anyObject, callback?: callbackFn): any; + (params: anyObject, options: RequestOptions, callback?: callbackFn): any; +} interface ClientOptions { node?: string | string[]; @@ -40,424 +45,424 @@ declare class Client extends EventEmitter { connectionPool: ConnectionPool; transport: Transport; serializer: Serializer - bulk: apiMethod + bulk: ApiMethod cat: { - aliases: apiMethod - allocation: apiMethod - count: apiMethod - fielddata: apiMethod - health: apiMethod - help: apiMethod - indices: apiMethod - master: apiMethod - nodeattrs: apiMethod - nodes: apiMethod - pending_tasks: apiMethod - pendingTasks: apiMethod - plugins: apiMethod - recovery: apiMethod - repositories: apiMethod - segments: apiMethod - shards: apiMethod - snapshots: apiMethod - tasks: apiMethod - templates: apiMethod - thread_pool: apiMethod - threadPool: apiMethod + aliases: ApiMethod + allocation: ApiMethod + count: ApiMethod + fielddata: ApiMethod + health: ApiMethod + help: ApiMethod + indices: ApiMethod + master: ApiMethod + nodeattrs: ApiMethod + nodes: ApiMethod + pending_tasks: ApiMethod + pendingTasks: ApiMethod + plugins: ApiMethod + recovery: ApiMethod + repositories: ApiMethod + segments: ApiMethod + shards: ApiMethod + snapshots: ApiMethod + tasks: ApiMethod + templates: ApiMethod + thread_pool: ApiMethod + threadPool: ApiMethod } ccr: { - delete_auto_follow_pattern: apiMethod - deleteAutoFollowPattern: apiMethod - follow: apiMethod - follow_stats: apiMethod - followStats: apiMethod - get_auto_follow_pattern: apiMethod - getAutoFollowPattern: apiMethod - pause_follow: apiMethod - pauseFollow: apiMethod - put_auto_follow_pattern: apiMethod - putAutoFollowPattern: apiMethod - resume_follow: apiMethod - resumeFollow: apiMethod - stats: apiMethod - unfollow: apiMethod + delete_auto_follow_pattern: ApiMethod + deleteAutoFollowPattern: ApiMethod + follow: ApiMethod + follow_stats: ApiMethod + followStats: ApiMethod + get_auto_follow_pattern: ApiMethod + getAutoFollowPattern: ApiMethod + pause_follow: ApiMethod + pauseFollow: ApiMethod + put_auto_follow_pattern: ApiMethod + putAutoFollowPattern: ApiMethod + resume_follow: ApiMethod + resumeFollow: ApiMethod + stats: ApiMethod + unfollow: ApiMethod } - clear_scroll: apiMethod - clearScroll: apiMethod + clear_scroll: ApiMethod + clearScroll: ApiMethod cluster: { - allocation_explain: apiMethod - allocationExplain: apiMethod - get_settings: apiMethod - getSettings: apiMethod - health: apiMethod - pending_tasks: apiMethod - pendingTasks: apiMethod - put_settings: apiMethod - putSettings: apiMethod - remote_info: apiMethod - remoteInfo: apiMethod - reroute: apiMethod - state: apiMethod - stats: apiMethod + allocation_explain: ApiMethod + allocationExplain: ApiMethod + get_settings: ApiMethod + getSettings: ApiMethod + health: ApiMethod + pending_tasks: ApiMethod + pendingTasks: ApiMethod + put_settings: ApiMethod + putSettings: ApiMethod + remote_info: ApiMethod + remoteInfo: ApiMethod + reroute: ApiMethod + state: ApiMethod + stats: ApiMethod } - count: apiMethod - create: apiMethod - delete: apiMethod - delete_by_query: apiMethod - deleteByQuery: apiMethod - delete_by_query_rethrottle: apiMethod - deleteByQueryRethrottle: apiMethod - delete_script: apiMethod - deleteScript: apiMethod - exists: apiMethod - exists_source: apiMethod - existsSource: apiMethod - explain: apiMethod - field_caps: apiMethod - fieldCaps: apiMethod - get: apiMethod - get_script: apiMethod - getScript: apiMethod - get_source: apiMethod - getSource: apiMethod - index: apiMethod + count: ApiMethod + create: ApiMethod + delete: ApiMethod + delete_by_query: ApiMethod + deleteByQuery: ApiMethod + delete_by_query_rethrottle: ApiMethod + deleteByQueryRethrottle: ApiMethod + delete_script: ApiMethod + deleteScript: ApiMethod + exists: ApiMethod + exists_source: ApiMethod + existsSource: ApiMethod + explain: ApiMethod + field_caps: ApiMethod + fieldCaps: ApiMethod + get: ApiMethod + get_script: ApiMethod + getScript: ApiMethod + get_source: ApiMethod + getSource: ApiMethod + index: ApiMethod indices: { - analyze: apiMethod - clear_cache: apiMethod - clearCache: apiMethod - close: apiMethod - create: apiMethod - delete: apiMethod - delete_alias: apiMethod - deleteAlias: apiMethod - delete_template: apiMethod - deleteTemplate: apiMethod - exists: apiMethod - exists_alias: apiMethod - existsAlias: apiMethod - exists_template: apiMethod - existsTemplate: apiMethod - exists_type: apiMethod - existsType: apiMethod - flush: apiMethod - flush_synced: apiMethod - flushSynced: apiMethod - forcemerge: apiMethod - get: apiMethod - get_alias: apiMethod - getAlias: apiMethod - get_field_mapping: apiMethod - getFieldMapping: apiMethod - get_mapping: apiMethod - getMapping: apiMethod - get_settings: apiMethod - getSettings: apiMethod - get_template: apiMethod - getTemplate: apiMethod - get_upgrade: apiMethod - getUpgrade: apiMethod - open: apiMethod - put_alias: apiMethod - putAlias: apiMethod - put_mapping: apiMethod - putMapping: apiMethod - put_settings: apiMethod - putSettings: apiMethod - put_template: apiMethod - putTemplate: apiMethod - recovery: apiMethod - refresh: apiMethod - rollover: apiMethod - segments: apiMethod - shard_stores: apiMethod - shardStores: apiMethod - shrink: apiMethod - split: apiMethod - stats: apiMethod - update_aliases: apiMethod - updateAliases: apiMethod - upgrade: apiMethod - validate_query: apiMethod - validateQuery: apiMethod + analyze: ApiMethod + clear_cache: ApiMethod + clearCache: ApiMethod + close: ApiMethod + create: ApiMethod + delete: ApiMethod + delete_alias: ApiMethod + deleteAlias: ApiMethod + delete_template: ApiMethod + deleteTemplate: ApiMethod + exists: ApiMethod + exists_alias: ApiMethod + existsAlias: ApiMethod + exists_template: ApiMethod + existsTemplate: ApiMethod + exists_type: ApiMethod + existsType: ApiMethod + flush: ApiMethod + flush_synced: ApiMethod + flushSynced: ApiMethod + forcemerge: ApiMethod + get: ApiMethod + get_alias: ApiMethod + getAlias: ApiMethod + get_field_mapping: ApiMethod + getFieldMapping: ApiMethod + get_mapping: ApiMethod + getMapping: ApiMethod + get_settings: ApiMethod + getSettings: ApiMethod + get_template: ApiMethod + getTemplate: ApiMethod + get_upgrade: ApiMethod + getUpgrade: ApiMethod + open: ApiMethod + put_alias: ApiMethod + putAlias: ApiMethod + put_mapping: ApiMethod + putMapping: ApiMethod + put_settings: ApiMethod + putSettings: ApiMethod + put_template: ApiMethod + putTemplate: ApiMethod + recovery: ApiMethod + refresh: ApiMethod + rollover: ApiMethod + segments: ApiMethod + shard_stores: ApiMethod + shardStores: ApiMethod + shrink: ApiMethod + split: ApiMethod + stats: ApiMethod + update_aliases: ApiMethod + updateAliases: ApiMethod + upgrade: ApiMethod + validate_query: ApiMethod + validateQuery: ApiMethod } - info: apiMethod + info: ApiMethod ingest: { - delete_pipeline: apiMethod - deletePipeline: apiMethod - get_pipeline: apiMethod - getPipeline: apiMethod - processor_grok: apiMethod - processorGrok: apiMethod - put_pipeline: apiMethod - putPipeline: apiMethod - simulate: apiMethod + delete_pipeline: ApiMethod + deletePipeline: ApiMethod + get_pipeline: ApiMethod + getPipeline: ApiMethod + processor_grok: ApiMethod + processorGrok: ApiMethod + put_pipeline: ApiMethod + putPipeline: ApiMethod + simulate: ApiMethod } - mget: apiMethod - msearch: apiMethod - msearch_template: apiMethod - msearchTemplate: apiMethod - mtermvectors: apiMethod + mget: ApiMethod + msearch: ApiMethod + msearch_template: ApiMethod + msearchTemplate: ApiMethod + mtermvectors: ApiMethod nodes: { - hot_threads: apiMethod - hotThreads: apiMethod - info: apiMethod - reload_secure_settings: apiMethod - reloadSecureSettings: apiMethod - stats: apiMethod - usage: apiMethod + hot_threads: ApiMethod + hotThreads: ApiMethod + info: ApiMethod + reload_secure_settings: ApiMethod + reloadSecureSettings: ApiMethod + stats: ApiMethod + usage: ApiMethod } - ping: apiMethod - put_script: apiMethod - putScript: apiMethod - rank_eval: apiMethod - rankEval: apiMethod - reindex: apiMethod - reindex_rethrottle: apiMethod - reindexRethrottle: apiMethod - render_search_template: apiMethod - renderSearchTemplate: apiMethod - scripts_painless_execute: apiMethod - scriptsPainlessExecute: apiMethod - scroll: apiMethod - search: apiMethod - search_shards: apiMethod - searchShards: apiMethod - search_template: apiMethod - searchTemplate: apiMethod + ping: ApiMethod + put_script: ApiMethod + putScript: ApiMethod + rank_eval: ApiMethod + rankEval: ApiMethod + reindex: ApiMethod + reindex_rethrottle: ApiMethod + reindexRethrottle: ApiMethod + render_search_template: ApiMethod + renderSearchTemplate: ApiMethod + scripts_painless_execute: ApiMethod + scriptsPainlessExecute: ApiMethod + scroll: ApiMethod + search: ApiMethod + search_shards: ApiMethod + searchShards: ApiMethod + search_template: ApiMethod + searchTemplate: ApiMethod snapshot: { - create: apiMethod - create_repository: apiMethod - createRepository: apiMethod - delete: apiMethod - delete_repository: apiMethod - deleteRepository: apiMethod - get: apiMethod - get_repository: apiMethod - getRepository: apiMethod - restore: apiMethod - status: apiMethod - verify_repository: apiMethod - verifyRepository: apiMethod + create: ApiMethod + create_repository: ApiMethod + createRepository: ApiMethod + delete: ApiMethod + delete_repository: ApiMethod + deleteRepository: ApiMethod + get: ApiMethod + get_repository: ApiMethod + getRepository: ApiMethod + restore: ApiMethod + status: ApiMethod + verify_repository: ApiMethod + verifyRepository: ApiMethod } tasks: { - cancel: apiMethod - get: apiMethod - list: apiMethod + cancel: ApiMethod + get: ApiMethod + list: ApiMethod } - termvectors: apiMethod - update: apiMethod - update_by_query: apiMethod - updateByQuery: apiMethod - update_by_query_rethrottle: apiMethod - updateByQueryRethrottle: apiMethod + termvectors: ApiMethod + update: ApiMethod + update_by_query: ApiMethod + updateByQuery: ApiMethod + update_by_query_rethrottle: ApiMethod + updateByQueryRethrottle: ApiMethod xpack: { graph: { - explore: apiMethod + explore: ApiMethod } - info: apiMethod + info: ApiMethod license: { - delete: apiMethod - get: apiMethod - get_basic_status: apiMethod - getBasicStatus: apiMethod - get_trial_status: apiMethod - getTrialStatus: apiMethod - post: apiMethod - post_start_basic: apiMethod - postStartBasic: apiMethod - post_start_trial: apiMethod - postStartTrial: apiMethod + delete: ApiMethod + get: ApiMethod + get_basic_status: ApiMethod + getBasicStatus: ApiMethod + get_trial_status: ApiMethod + getTrialStatus: ApiMethod + post: ApiMethod + post_start_basic: ApiMethod + postStartBasic: ApiMethod + post_start_trial: ApiMethod + postStartTrial: ApiMethod } migration: { - deprecations: apiMethod - get_assistance: apiMethod - getAssistance: apiMethod - upgrade: apiMethod + deprecations: ApiMethod + get_assistance: ApiMethod + getAssistance: ApiMethod + upgrade: ApiMethod } ml: { - close_job: apiMethod - closeJob: apiMethod - delete_calendar: apiMethod - deleteCalendar: apiMethod - delete_calendar_event: apiMethod - deleteCalendarEvent: apiMethod - delete_calendar_job: apiMethod - deleteCalendarJob: apiMethod - delete_datafeed: apiMethod - deleteDatafeed: apiMethod - delete_expired_data: apiMethod - deleteExpiredData: apiMethod - delete_filter: apiMethod - deleteFilter: apiMethod - delete_forecast: apiMethod - deleteForecast: apiMethod - delete_job: apiMethod - deleteJob: apiMethod - delete_model_snapshot: apiMethod - deleteModelSnapshot: apiMethod - find_file_structure: apiMethod - findFileStructure: apiMethod - flush_job: apiMethod - flushJob: apiMethod - forecast: apiMethod - get_buckets: apiMethod - getBuckets: apiMethod - get_calendar_events: apiMethod - getCalendarEvents: apiMethod - get_calendars: apiMethod - getCalendars: apiMethod - get_categories: apiMethod - getCategories: apiMethod - get_datafeed_stats: apiMethod - getDatafeedStats: apiMethod - get_datafeeds: apiMethod - getDatafeeds: apiMethod - get_filters: apiMethod - getFilters: apiMethod - get_influencers: apiMethod - getInfluencers: apiMethod - get_job_stats: apiMethod - getJobStats: apiMethod - get_jobs: apiMethod - getJobs: apiMethod - get_model_snapshots: apiMethod - getModelSnapshots: apiMethod - get_overall_buckets: apiMethod - getOverallBuckets: apiMethod - get_records: apiMethod - getRecords: apiMethod - info: apiMethod - open_job: apiMethod - openJob: apiMethod - post_calendar_events: apiMethod - postCalendarEvents: apiMethod - post_data: apiMethod - postData: apiMethod - preview_datafeed: apiMethod - previewDatafeed: apiMethod - put_calendar: apiMethod - putCalendar: apiMethod - put_calendar_job: apiMethod - putCalendarJob: apiMethod - put_datafeed: apiMethod - putDatafeed: apiMethod - put_filter: apiMethod - putFilter: apiMethod - put_job: apiMethod - putJob: apiMethod - revert_model_snapshot: apiMethod - revertModelSnapshot: apiMethod - start_datafeed: apiMethod - startDatafeed: apiMethod - stop_datafeed: apiMethod - stopDatafeed: apiMethod - update_datafeed: apiMethod - updateDatafeed: apiMethod - update_filter: apiMethod - updateFilter: apiMethod - update_job: apiMethod - updateJob: apiMethod - update_model_snapshot: apiMethod - updateModelSnapshot: apiMethod - validate: apiMethod - validate_detector: apiMethod - validateDetector: apiMethod + close_job: ApiMethod + closeJob: ApiMethod + delete_calendar: ApiMethod + deleteCalendar: ApiMethod + delete_calendar_event: ApiMethod + deleteCalendarEvent: ApiMethod + delete_calendar_job: ApiMethod + deleteCalendarJob: ApiMethod + delete_datafeed: ApiMethod + deleteDatafeed: ApiMethod + delete_expired_data: ApiMethod + deleteExpiredData: ApiMethod + delete_filter: ApiMethod + deleteFilter: ApiMethod + delete_forecast: ApiMethod + deleteForecast: ApiMethod + delete_job: ApiMethod + deleteJob: ApiMethod + delete_model_snapshot: ApiMethod + deleteModelSnapshot: ApiMethod + find_file_structure: ApiMethod + findFileStructure: ApiMethod + flush_job: ApiMethod + flushJob: ApiMethod + forecast: ApiMethod + get_buckets: ApiMethod + getBuckets: ApiMethod + get_calendar_events: ApiMethod + getCalendarEvents: ApiMethod + get_calendars: ApiMethod + getCalendars: ApiMethod + get_categories: ApiMethod + getCategories: ApiMethod + get_datafeed_stats: ApiMethod + getDatafeedStats: ApiMethod + get_datafeeds: ApiMethod + getDatafeeds: ApiMethod + get_filters: ApiMethod + getFilters: ApiMethod + get_influencers: ApiMethod + getInfluencers: ApiMethod + get_job_stats: ApiMethod + getJobStats: ApiMethod + get_jobs: ApiMethod + getJobs: ApiMethod + get_model_snapshots: ApiMethod + getModelSnapshots: ApiMethod + get_overall_buckets: ApiMethod + getOverallBuckets: ApiMethod + get_records: ApiMethod + getRecords: ApiMethod + info: ApiMethod + open_job: ApiMethod + openJob: ApiMethod + post_calendar_events: ApiMethod + postCalendarEvents: ApiMethod + post_data: ApiMethod + postData: ApiMethod + preview_datafeed: ApiMethod + previewDatafeed: ApiMethod + put_calendar: ApiMethod + putCalendar: ApiMethod + put_calendar_job: ApiMethod + putCalendarJob: ApiMethod + put_datafeed: ApiMethod + putDatafeed: ApiMethod + put_filter: ApiMethod + putFilter: ApiMethod + put_job: ApiMethod + putJob: ApiMethod + revert_model_snapshot: ApiMethod + revertModelSnapshot: ApiMethod + start_datafeed: ApiMethod + startDatafeed: ApiMethod + stop_datafeed: ApiMethod + stopDatafeed: ApiMethod + update_datafeed: ApiMethod + updateDatafeed: ApiMethod + update_filter: ApiMethod + updateFilter: ApiMethod + update_job: ApiMethod + updateJob: ApiMethod + update_model_snapshot: ApiMethod + updateModelSnapshot: ApiMethod + validate: ApiMethod + validate_detector: ApiMethod + validateDetector: ApiMethod } monitoring: { - bulk: apiMethod + bulk: ApiMethod } rollup: { - delete_job: apiMethod - deleteJob: apiMethod - get_jobs: apiMethod - getJobs: apiMethod - get_rollup_caps: apiMethod - getRollupCaps: apiMethod - get_rollup_index_caps: apiMethod - getRollupIndexCaps: apiMethod - put_job: apiMethod - putJob: apiMethod - rollup_search: apiMethod - rollupSearch: apiMethod - start_job: apiMethod - startJob: apiMethod - stop_job: apiMethod - stopJob: apiMethod + delete_job: ApiMethod + deleteJob: ApiMethod + get_jobs: ApiMethod + getJobs: ApiMethod + get_rollup_caps: ApiMethod + getRollupCaps: ApiMethod + get_rollup_index_caps: ApiMethod + getRollupIndexCaps: ApiMethod + put_job: ApiMethod + putJob: ApiMethod + rollup_search: ApiMethod + rollupSearch: ApiMethod + start_job: ApiMethod + startJob: ApiMethod + stop_job: ApiMethod + stopJob: ApiMethod } security: { - authenticate: apiMethod - change_password: apiMethod - changePassword: apiMethod - clear_cached_realms: apiMethod - clearCachedRealms: apiMethod - clear_cached_roles: apiMethod - clearCachedRoles: apiMethod - delete_privileges: apiMethod - deletePrivileges: apiMethod - delete_role: apiMethod - deleteRole: apiMethod - delete_role_mapping: apiMethod - deleteRoleMapping: apiMethod - delete_user: apiMethod - deleteUser: apiMethod - disable_user: apiMethod - disableUser: apiMethod - enable_user: apiMethod - enableUser: apiMethod - get_privileges: apiMethod - getPrivileges: apiMethod - get_role: apiMethod - getRole: apiMethod - get_role_mapping: apiMethod - getRoleMapping: apiMethod - get_token: apiMethod - getToken: apiMethod - get_user: apiMethod - getUser: apiMethod - get_user_privileges: apiMethod - getUserPrivileges: apiMethod - has_privileges: apiMethod - hasPrivileges: apiMethod - invalidate_token: apiMethod - invalidateToken: apiMethod - put_privileges: apiMethod - putPrivileges: apiMethod - put_role: apiMethod - putRole: apiMethod - put_role_mapping: apiMethod - putRoleMapping: apiMethod - put_user: apiMethod - putUser: apiMethod + authenticate: ApiMethod + change_password: ApiMethod + changePassword: ApiMethod + clear_cached_realms: ApiMethod + clearCachedRealms: ApiMethod + clear_cached_roles: ApiMethod + clearCachedRoles: ApiMethod + delete_privileges: ApiMethod + deletePrivileges: ApiMethod + delete_role: ApiMethod + deleteRole: ApiMethod + delete_role_mapping: ApiMethod + deleteRoleMapping: ApiMethod + delete_user: ApiMethod + deleteUser: ApiMethod + disable_user: ApiMethod + disableUser: ApiMethod + enable_user: ApiMethod + enableUser: ApiMethod + get_privileges: ApiMethod + getPrivileges: ApiMethod + get_role: ApiMethod + getRole: ApiMethod + get_role_mapping: ApiMethod + getRoleMapping: ApiMethod + get_token: ApiMethod + getToken: ApiMethod + get_user: ApiMethod + getUser: ApiMethod + get_user_privileges: ApiMethod + getUserPrivileges: ApiMethod + has_privileges: ApiMethod + hasPrivileges: ApiMethod + invalidate_token: ApiMethod + invalidateToken: ApiMethod + put_privileges: ApiMethod + putPrivileges: ApiMethod + put_role: ApiMethod + putRole: ApiMethod + put_role_mapping: ApiMethod + putRoleMapping: ApiMethod + put_user: ApiMethod + putUser: ApiMethod } sql: { - clear_cursor: apiMethod - clearCursor: apiMethod - query: apiMethod - translate: apiMethod + clear_cursor: ApiMethod + clearCursor: ApiMethod + query: ApiMethod + translate: ApiMethod } ssl: { - certificates: apiMethod + certificates: ApiMethod } - usage: apiMethod + usage: ApiMethod watcher: { - ack_watch: apiMethod - ackWatch: apiMethod - activate_watch: apiMethod - activateWatch: apiMethod - deactivate_watch: apiMethod - deactivateWatch: apiMethod - delete_watch: apiMethod - deleteWatch: apiMethod - execute_watch: apiMethod - executeWatch: apiMethod - get_watch: apiMethod - getWatch: apiMethod - put_watch: apiMethod - putWatch: apiMethod - restart: apiMethod - start: apiMethod - stats: apiMethod - stop: apiMethod + ack_watch: ApiMethod + ackWatch: ApiMethod + activate_watch: ApiMethod + activateWatch: ApiMethod + deactivate_watch: ApiMethod + deactivateWatch: ApiMethod + delete_watch: ApiMethod + deleteWatch: ApiMethod + execute_watch: ApiMethod + executeWatch: ApiMethod + get_watch: ApiMethod + getWatch: ApiMethod + put_watch: ApiMethod + putWatch: ApiMethod + restart: ApiMethod + start: ApiMethod + stats: ApiMethod + stop: ApiMethod } } constructor(opts?: ClientOptions); diff --git a/lib/Connection.d.ts b/lib/Connection.d.ts index 0bf386563..6cfda0ed2 100644 --- a/lib/Connection.d.ts +++ b/lib/Connection.d.ts @@ -14,6 +14,10 @@ interface ConnectionOptions { roles?: any; } +interface RequestOptions extends http.ClientRequestArgs { + asStream?: boolean; +} + export interface AgentOptions { keepAlive: boolean; keepAliveMsecs: number; @@ -46,7 +50,7 @@ export default class Connection { _status: string; _agent: http.Agent; constructor(opts?: ConnectionOptions); - request(params: http.ClientRequestArgs, callback: (err: Error | null, response: http.IncomingMessage | null) => void): http.ClientRequest; + request(params: RequestOptions, callback: (err: Error | null, response: http.IncomingMessage | null) => void): http.ClientRequest; close(): Connection; setRole(role: string, enabled: boolean): Connection; status: string; diff --git a/lib/Transport.d.ts b/lib/Transport.d.ts index 1a3493991..dc935dd1c 100644 --- a/lib/Transport.d.ts +++ b/lib/Transport.d.ts @@ -38,6 +38,13 @@ export interface SniffMeta { reason: string; } +export interface RequestOptions { + ignore?: number | number[]; + requestTimeout?: number | string; + maxRetries?: number; + asStream?: boolean; +} + export default class Transport { static sniffReasons: { SNIFF_ON_START: string; @@ -58,7 +65,7 @@ export default class Transport { _nextSniff: number; _isSniffing: boolean; constructor(opts: TransportOptions); - request(params: any, callback: (err: Error | null, result: ApiResponse) => void): any; + request(params: any, options: RequestOptions, callback: (err: Error | null, result: ApiResponse) => void): any; getConnection(): Connection | null; sniff(callback?: (...args: any[]) => void): void; } diff --git a/lib/Transport.js b/lib/Transport.js index b15857d99..22fe090db 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -33,8 +33,13 @@ class Transport { } } - request (params, callback) { + request (params, options, callback) { + if (typeof options === 'function') { + callback = options + options = {} + } callback = once(callback) + // TODO: return in the result the metadata const meta = { connection: null, request: null, @@ -48,7 +53,7 @@ class Transport { headers: null, warnings: null } - const maxRetries = params.maxRetries || this.maxRetries + const maxRetries = options.maxRetries || this.maxRetries var request = { abort: noop } const makeRequest = () => { @@ -96,11 +101,12 @@ class Transport { // serializes the querystring params.querystring = this.serializer.qserialize(params.querystring) // handles request timeout - params.timeout = toMs(params.requestTimeout || this.requestTimeout) + params.timeout = toMs(options.requestTimeout || this.requestTimeout) meta.request = params this.emit('request', null, meta) + if (options.asStream === true) params.asStream = true // perform the actual http request return meta.connection.request(params, onResponse) } @@ -139,7 +145,7 @@ class Transport { result.warnings = headers['warning'].split(/(?!\B"[^"]*),(?![^"]*"\B)/) } - if (params.asStream === true) { + if (options.asStream === true) { result.body = response meta.response = result this.emit('response', null, meta) @@ -180,7 +186,7 @@ class Transport { // we should ignore the statusCode if the user has configured the `ignore` field with // the statusCode we just got or if the request method is HEAD and the statusCode is 404 - const ignoreStatusCode = (Array.isArray(params.ignore) && params.ignore.indexOf(statusCode) > -1) || + const ignoreStatusCode = (Array.isArray(options.ignore) && options.ignore.indexOf(statusCode) > -1) || (isHead === true && statusCode === 404) if (ignoreStatusCode === false && From a86a552a85c97a3b9fdd56a530b6f1519bb8ce06 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 12 Dec 2018 16:49:06 +0100 Subject: [PATCH 072/172] Updated test --- test/integration/index.js | 2 +- test/integration/test-runner.js | 3 +- test/types/index.ts | 26 +++++++++++++++ test/unit/api.test.js | 56 +++++++++++++++++++++++++++++++++ test/unit/transport.test.js | 21 ++++++++----- 5 files changed, 99 insertions(+), 9 deletions(-) diff --git a/test/integration/index.js b/test/integration/index.js index 9b5a353c0..67f5a1473 100644 --- a/test/integration/index.js +++ b/test/integration/index.js @@ -46,7 +46,7 @@ Runner.prototype.start = function () { client.info((err, { body }) => { if (err) { this.log.fail(err.message) - return + process.exit(1) } const { number: version, build_hash: sha } = body.version diff --git a/test/integration/test-runner.js b/test/integration/test-runner.js index 228eadf35..4c227b366 100644 --- a/test/integration/test-runner.js +++ b/test/integration/test-runner.js @@ -252,7 +252,8 @@ TestRunner.prototype.set = function (key, name) { TestRunner.prototype.do = function (action, done) { const cmd = this.parseDo(action) const api = delve(this.client, cmd.method).bind(this.client) - api(cmd.params, (err, { body, warnings }) => { + const options = { ignore: cmd.params.ignore } + api(cmd.params, options, (err, { body, warnings }) => { if (action.warnings && warnings === null) { this.tap.fail('We should get a warning header', action.warnings) } else if (!action.warnings && warnings !== null) { diff --git a/test/types/index.ts b/test/types/index.ts index 30629eeb5..17e6669a3 100644 --- a/test/types/index.ts +++ b/test/types/index.ts @@ -26,6 +26,18 @@ client.index({ body: { hello: 'world' } }, (err: Error | null, result: ApiResponse) => {}) +// request options +client.index({ + index: 'test', + type: 'test', + id: 'test', + body: { hello: 'world' } +}, { + maxRetries: 2, + ignore: [404], + requestTimeout: 2000 +}, (err: Error | null, result: ApiResponse) => {}) + // Promises client.info() .then((result: ApiResponse) => {}) @@ -39,3 +51,17 @@ client.index({ }) .then((result: ApiResponse) => {}) .catch((err: Error) => {}) + +// request options +client.index({ + index: 'test', + type: 'test', + id: 'test', + body: { hello: 'world' } +}, { + maxRetries: 2, + ignore: [404], + requestTimeout: 2000 +}) + .then((result: ApiResponse) => {}) + .catch((err: Error) => {}) diff --git a/test/unit/api.test.js b/test/unit/api.test.js index 4ce2ca6e2..13264379f 100644 --- a/test/unit/api.test.js +++ b/test/unit/api.test.js @@ -165,3 +165,59 @@ test('Abort is not supported in promises', t => { t.type(request.abort, 'undefined') }) }) + +test('Basic (options and callback)', t => { + t.plan(2) + + function handler (req, res) { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const client = new Client({ + node: `http://localhost:${port}` + }) + + client.search({ + index: 'test', + type: 'doc', + q: 'foo:bar' + }, { + requestTimeout: 10000 + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + server.stop() + }) + }) +}) + +test('Basic (options and promises)', t => { + t.plan(1) + + function handler (req, res) { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const client = new Client({ + node: `http://localhost:${port}` + }) + + client + .search({ + index: 'test', + type: 'doc', + q: 'foo:bar' + }, { + requestTimeout: 10000 + }) + .then(({ body }) => { + t.deepEqual(body, { hello: 'world' }) + server.stop() + }) + .catch(t.fail) + }) +}) diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index 48c341a90..108ed0d14 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -509,7 +509,8 @@ test('Custom retry mechanism', t => { transport.request({ method: 'GET', - path: '/hello', + path: '/hello' + }, { maxRetries: 1 }, (err, { body }) => { t.error(err) @@ -727,7 +728,8 @@ test('Override requestTimeout', t => { transport.request({ method: 'GET', - path: '/hello', + path: '/hello' + }, { requestTimeout: 2000 }, (err, { body }) => { t.error(err) @@ -1028,7 +1030,8 @@ test('Ignore status code', t => { transport.request({ method: 'GET', - path: '/404', + path: '/404' + }, { ignore: [404] }, (err, { body }) => { t.error(err) @@ -1044,7 +1047,8 @@ test('Ignore status code', t => { transport.request({ method: 'GET', - path: '/404', + path: '/404' + }, { ignore: [403, 405] }, (err, { body }) => { t.ok(err instanceof ResponseError) @@ -1148,7 +1152,8 @@ test('timeout option', t => { transport.request({ method: 'GET', - path: '/hello', + path: '/hello' + }, { requestTimeout: 500 }, (err, { body }) => { t.ok(err instanceof TimeoutError) @@ -1213,7 +1218,8 @@ test('timeout option', t => { transport.request({ method: 'GET', - path: '/hello', + path: '/hello' + }, { requestTimeout: '0.5s' }, (err, { body }) => { t.ok(err instanceof TimeoutError) @@ -1499,7 +1505,8 @@ test('asStream set to true', t => { transport.request({ method: 'GET', - path: '/hello', + path: '/hello' + }, { asStream: true }, (err, { body, headers }) => { t.error(err) From f6020e68a4dd20447c002e14bdeb007ad9db2771 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 12 Dec 2018 19:47:33 +0100 Subject: [PATCH 073/172] WIP: initial prototype - Do not serilize keys with undefined values in querystring - Added promises support in Transport.request --- lib/Serializer.js | 5 ++++- lib/Transport.js | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/Serializer.js b/lib/Serializer.js index a2fae9148..5bb84adfb 100644 --- a/lib/Serializer.js +++ b/lib/Serializer.js @@ -49,7 +49,10 @@ class Serializer { const keys = Object.keys(object) for (var i = 0, len = keys.length; i < len; i++) { var key = keys[i] - if (Array.isArray(object[key]) === true) { + // elasticsearch will complain for keys without a value + if (object[key] === undefined) { + delete object[key] + } else if (Array.isArray(object[key]) === true) { object[key] = object[key].join(',') } } diff --git a/lib/Transport.js b/lib/Transport.js index 22fe090db..eec669d3f 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -34,10 +34,21 @@ class Transport { } request (params, options, callback) { + options = options || {} if (typeof options === 'function') { callback = options options = {} } + + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + this.request(params, options, (err, result) => { + err ? reject(err) : resolve(result) + }) + }) + } + callback = once(callback) // TODO: return in the result the metadata const meta = { From 4bf9128cac1afe2c4284c35af461e26284b169f3 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 12 Dec 2018 19:48:27 +0100 Subject: [PATCH 074/172] Updated test --- test/benchmarks/basic.bench.js | 125 +++++++++++++++++++++++++++++++++ test/unit/serializer.test.js | 15 ++++ test/unit/transport.test.js | 56 +++++++++++++++ 3 files changed, 196 insertions(+) create mode 100644 test/benchmarks/basic.bench.js diff --git a/test/benchmarks/basic.bench.js b/test/benchmarks/basic.bench.js new file mode 100644 index 000000000..6a070ed8d --- /dev/null +++ b/test/benchmarks/basic.bench.js @@ -0,0 +1,125 @@ +'use strict' + +const bench = require('nanobench') +const { Client } = require('../../index') +const { connection } = require('../utils') + +bench('Initialization', { repetitions: 5 }, b => { + const client = new Client({ // eslint-disable-line + node: 'http://localhost:9200' + }) + b.end() +}) + +bench('Call api with lazy loading', { repetitions: 5 }, b => { + const client = new Client({ + node: 'http://localhost:9200', + Connection: connection.MockConnection + }) + + b.start() + client.info((err, result) => { + if (err) { + b.error(err) + return + } + + b.end() + }) +}) + +bench('Call api without lazy loading', { repetitions: 5 }, b => { + const client = new Client({ + node: 'http://localhost:9200', + Connection: connection.MockConnection + }) + + client.info((err, result) => { + if (err) { + b.error(err) + return + } + + b.start() + client.info((err, result) => { + if (err) { + b.error(err) + return + } + + b.end() + }) + }) +}) + +bench('Basic get', { repetitions: 5 }, b => { + const client = new Client({ + node: 'http://localhost:9200', + Connection: connection.MockConnection + }) + + // we run the method twice to skip the lazy loading overhead + client.search({ + index: 'test', + type: 'doc', + q: 'foo:bar' + }, (err, result) => { + if (err) { + b.error(err) + return + } + + b.start() + client.search({ + index: 'test', + type: 'doc', + q: 'foo:bar' + }, (err, result) => { + if (err) { + b.error(err) + return + } + b.end() + }) + }) +}) + +bench('Basic post', { repetitions: 5 }, b => { + const client = new Client({ + node: 'http://localhost:9200', + Connection: connection.MockConnection + }) + + // we run the method twice to skip the lazy loading overhead + client.search({ + index: 'test', + type: 'doc', + body: { + query: { + match: { foo: 'bar' } + } + } + }, (err, result) => { + if (err) { + b.error(err) + return + } + + b.start() + client.search({ + index: 'test', + type: 'doc', + body: { + query: { + match: { foo: 'bar' } + } + } + }, (err, result) => { + if (err) { + b.error(err) + return + } + b.end() + }) + }) +}) diff --git a/test/unit/serializer.test.js b/test/unit/serializer.test.js index 4f6a491f6..369b94ca9 100644 --- a/test/unit/serializer.test.js +++ b/test/unit/serializer.test.js @@ -88,6 +88,21 @@ test('qserialize (string)', t => { ) }) +test('qserialize (key with undefined value)', t => { + t.plan(1) + const s = new Serializer() + const obj = { + hello: 'world', + key: undefined, + foo: 'bar' + } + + t.strictEqual( + s.qserialize(obj), + 'hello=world&foo=bar' + ) +}) + test('SerializationError', t => { t.plan(1) const s = new Serializer() diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index 108ed0d14..70ceb7b20 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -53,6 +53,62 @@ test('Basic', t => { }) }) +test('Basic (promises support)', t => { + t.plan(1) + + const pool = new ConnectionPool({ Connection: MockConnection }) + pool.addConnection('http://localhost:9200') + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport + .request({ + method: 'GET', + path: '/hello' + }) + .then(({ body }) => { + t.deepEqual(body, { hello: 'world' }) + }) + .catch(t.fail) +}) + +test('Basic (options + promises support)', t => { + t.plan(1) + + const pool = new ConnectionPool({ Connection: MockConnection }) + pool.addConnection('http://localhost:9200') + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport + .request({ + method: 'GET', + path: '/hello' + }, { + requestTimeout: 1000 + }) + .then(({ body }) => { + t.deepEqual(body, { hello: 'world' }) + }) + .catch(t.fail) +}) + test('Send POST', t => { t.plan(4) function handler (req, res) { From e014e186f96634ef8aab4a834d706c93857524f7 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 12 Dec 2018 19:48:52 +0100 Subject: [PATCH 075/172] Added basic benchmarks --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index 992edb292..79ba1eb66 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "test:behavior": "tap test/behavior/*.test.js -J -t 300", "test:integration": "tap test/integration/index.js -T --harmony", "test:types": "tsc --project ./test/types/tsconfig.json", + "test:benchmarks": "nanobench test/benchmarks/*.bench.js", "lint": "standard", "lint:fix": "standard --fix", "generate": "node scripts/run.js", @@ -42,6 +43,7 @@ "js-yaml": "^3.12.0", "lolex": "^3.0.0", "minimist": "^1.2.0", + "nanobench": "github:delvedor/nanobench#repetitions", "ora": "^3.0.0", "rimraf": "^2.6.2", "semver": "^5.6.0", From 396686ee77ec18d59639ee81e7765fa9c8940f39 Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 13 Dec 2018 16:53:21 +0100 Subject: [PATCH 076/172] API generation --- api/api/bulk.js | 6 +++--- api/api/cat.aliases.js | 6 +++--- api/api/cat.allocation.js | 6 +++--- api/api/cat.count.js | 6 +++--- api/api/cat.fielddata.js | 6 +++--- api/api/cat.health.js | 6 +++--- api/api/cat.help.js | 6 +++--- api/api/cat.indices.js | 6 +++--- api/api/cat.master.js | 6 +++--- api/api/cat.nodeattrs.js | 6 +++--- api/api/cat.nodes.js | 6 +++--- api/api/cat.pending_tasks.js | 6 +++--- api/api/cat.plugins.js | 6 +++--- api/api/cat.recovery.js | 6 +++--- api/api/cat.repositories.js | 6 +++--- api/api/cat.segments.js | 6 +++--- api/api/cat.shards.js | 6 +++--- api/api/cat.snapshots.js | 6 +++--- api/api/cat.tasks.js | 6 +++--- api/api/cat.templates.js | 6 +++--- api/api/cat.thread_pool.js | 6 +++--- api/api/ccr.delete_auto_follow_pattern.js | 6 +++--- api/api/ccr.follow.js | 6 +++--- api/api/ccr.follow_stats.js | 6 +++--- api/api/ccr.get_auto_follow_pattern.js | 6 +++--- api/api/ccr.pause_follow.js | 6 +++--- api/api/ccr.put_auto_follow_pattern.js | 6 +++--- api/api/ccr.resume_follow.js | 6 +++--- api/api/ccr.stats.js | 6 +++--- api/api/ccr.unfollow.js | 6 +++--- api/api/clear_scroll.js | 6 +++--- api/api/cluster.allocation_explain.js | 6 +++--- api/api/cluster.get_settings.js | 6 +++--- api/api/cluster.health.js | 6 +++--- api/api/cluster.pending_tasks.js | 6 +++--- api/api/cluster.put_settings.js | 6 +++--- api/api/cluster.remote_info.js | 6 +++--- api/api/cluster.reroute.js | 6 +++--- api/api/cluster.state.js | 6 +++--- api/api/cluster.stats.js | 6 +++--- api/api/count.js | 6 +++--- api/api/create.js | 6 +++--- api/api/delete.js | 6 +++--- api/api/delete_by_query.js | 6 +++--- api/api/delete_by_query_rethrottle.js | 6 +++--- api/api/delete_script.js | 6 +++--- api/api/exists.js | 6 +++--- api/api/exists_source.js | 6 +++--- api/api/explain.js | 6 +++--- api/api/field_caps.js | 6 +++--- api/api/get.js | 6 +++--- api/api/get_script.js | 6 +++--- api/api/get_source.js | 6 +++--- api/api/index.js | 6 +++--- api/api/indices.analyze.js | 6 +++--- api/api/indices.clear_cache.js | 6 +++--- api/api/indices.close.js | 6 +++--- api/api/indices.create.js | 6 +++--- api/api/indices.delete.js | 6 +++--- api/api/indices.delete_alias.js | 6 +++--- api/api/indices.delete_template.js | 6 +++--- api/api/indices.exists.js | 6 +++--- api/api/indices.exists_alias.js | 6 +++--- api/api/indices.exists_template.js | 6 +++--- api/api/indices.exists_type.js | 6 +++--- api/api/indices.flush.js | 6 +++--- api/api/indices.flush_synced.js | 6 +++--- api/api/indices.forcemerge.js | 6 +++--- api/api/indices.get.js | 6 +++--- api/api/indices.get_alias.js | 6 +++--- api/api/indices.get_field_mapping.js | 6 +++--- api/api/indices.get_mapping.js | 6 +++--- api/api/indices.get_settings.js | 6 +++--- api/api/indices.get_template.js | 6 +++--- api/api/indices.get_upgrade.js | 6 +++--- api/api/indices.open.js | 6 +++--- api/api/indices.put_alias.js | 6 +++--- api/api/indices.put_mapping.js | 6 +++--- api/api/indices.put_settings.js | 6 +++--- api/api/indices.put_template.js | 6 +++--- api/api/indices.recovery.js | 6 +++--- api/api/indices.refresh.js | 6 +++--- api/api/indices.rollover.js | 6 +++--- api/api/indices.segments.js | 6 +++--- api/api/indices.shard_stores.js | 6 +++--- api/api/indices.shrink.js | 6 +++--- api/api/indices.split.js | 6 +++--- api/api/indices.stats.js | 6 +++--- api/api/indices.update_aliases.js | 6 +++--- api/api/indices.upgrade.js | 6 +++--- api/api/indices.validate_query.js | 6 +++--- api/api/info.js | 6 +++--- api/api/ingest.delete_pipeline.js | 6 +++--- api/api/ingest.get_pipeline.js | 6 +++--- api/api/ingest.processor_grok.js | 6 +++--- api/api/ingest.put_pipeline.js | 6 +++--- api/api/ingest.simulate.js | 6 +++--- api/api/mget.js | 6 +++--- api/api/msearch.js | 6 +++--- api/api/msearch_template.js | 6 +++--- api/api/mtermvectors.js | 6 +++--- api/api/nodes.hot_threads.js | 6 +++--- api/api/nodes.info.js | 6 +++--- api/api/nodes.reload_secure_settings.js | 6 +++--- api/api/nodes.stats.js | 6 +++--- api/api/nodes.usage.js | 6 +++--- api/api/ping.js | 6 +++--- api/api/put_script.js | 6 +++--- api/api/rank_eval.js | 6 +++--- api/api/reindex.js | 6 +++--- api/api/reindex_rethrottle.js | 6 +++--- api/api/render_search_template.js | 6 +++--- api/api/scripts_painless_execute.js | 6 +++--- api/api/scroll.js | 6 +++--- api/api/search.js | 6 +++--- api/api/search_shards.js | 6 +++--- api/api/search_template.js | 6 +++--- api/api/snapshot.create.js | 6 +++--- api/api/snapshot.create_repository.js | 6 +++--- api/api/snapshot.delete.js | 6 +++--- api/api/snapshot.delete_repository.js | 6 +++--- api/api/snapshot.get.js | 6 +++--- api/api/snapshot.get_repository.js | 6 +++--- api/api/snapshot.restore.js | 6 +++--- api/api/snapshot.status.js | 6 +++--- api/api/snapshot.verify_repository.js | 6 +++--- api/api/tasks.cancel.js | 6 +++--- api/api/tasks.get.js | 6 +++--- api/api/tasks.list.js | 6 +++--- api/api/termvectors.js | 6 +++--- api/api/update.js | 6 +++--- api/api/update_by_query.js | 6 +++--- api/api/update_by_query_rethrottle.js | 6 +++--- api/api/xpack.graph.explore.js | 6 +++--- api/api/xpack.info.js | 6 +++--- api/api/xpack.license.delete.js | 6 +++--- api/api/xpack.license.get.js | 6 +++--- api/api/xpack.license.get_basic_status.js | 6 +++--- api/api/xpack.license.get_trial_status.js | 6 +++--- api/api/xpack.license.post.js | 6 +++--- api/api/xpack.license.post_start_basic.js | 6 +++--- api/api/xpack.license.post_start_trial.js | 6 +++--- api/api/xpack.migration.deprecations.js | 6 +++--- api/api/xpack.migration.get_assistance.js | 6 +++--- api/api/xpack.migration.upgrade.js | 6 +++--- api/api/xpack.ml.close_job.js | 6 +++--- api/api/xpack.ml.delete_calendar.js | 6 +++--- api/api/xpack.ml.delete_calendar_event.js | 6 +++--- api/api/xpack.ml.delete_calendar_job.js | 6 +++--- api/api/xpack.ml.delete_datafeed.js | 6 +++--- api/api/xpack.ml.delete_expired_data.js | 6 +++--- api/api/xpack.ml.delete_filter.js | 6 +++--- api/api/xpack.ml.delete_forecast.js | 6 +++--- api/api/xpack.ml.delete_job.js | 6 +++--- api/api/xpack.ml.delete_model_snapshot.js | 6 +++--- api/api/xpack.ml.find_file_structure.js | 6 +++--- api/api/xpack.ml.flush_job.js | 6 +++--- api/api/xpack.ml.forecast.js | 6 +++--- api/api/xpack.ml.get_buckets.js | 6 +++--- api/api/xpack.ml.get_calendar_events.js | 6 +++--- api/api/xpack.ml.get_calendars.js | 6 +++--- api/api/xpack.ml.get_categories.js | 6 +++--- api/api/xpack.ml.get_datafeed_stats.js | 6 +++--- api/api/xpack.ml.get_datafeeds.js | 6 +++--- api/api/xpack.ml.get_filters.js | 6 +++--- api/api/xpack.ml.get_influencers.js | 6 +++--- api/api/xpack.ml.get_job_stats.js | 6 +++--- api/api/xpack.ml.get_jobs.js | 6 +++--- api/api/xpack.ml.get_model_snapshots.js | 6 +++--- api/api/xpack.ml.get_overall_buckets.js | 6 +++--- api/api/xpack.ml.get_records.js | 6 +++--- api/api/xpack.ml.info.js | 6 +++--- api/api/xpack.ml.open_job.js | 6 +++--- api/api/xpack.ml.post_calendar_events.js | 6 +++--- api/api/xpack.ml.post_data.js | 6 +++--- api/api/xpack.ml.preview_datafeed.js | 6 +++--- api/api/xpack.ml.put_calendar.js | 6 +++--- api/api/xpack.ml.put_calendar_job.js | 6 +++--- api/api/xpack.ml.put_datafeed.js | 6 +++--- api/api/xpack.ml.put_filter.js | 6 +++--- api/api/xpack.ml.put_job.js | 6 +++--- api/api/xpack.ml.revert_model_snapshot.js | 6 +++--- api/api/xpack.ml.start_datafeed.js | 6 +++--- api/api/xpack.ml.stop_datafeed.js | 6 +++--- api/api/xpack.ml.update_datafeed.js | 6 +++--- api/api/xpack.ml.update_filter.js | 6 +++--- api/api/xpack.ml.update_job.js | 6 +++--- api/api/xpack.ml.update_model_snapshot.js | 6 +++--- api/api/xpack.ml.validate.js | 6 +++--- api/api/xpack.ml.validate_detector.js | 6 +++--- api/api/xpack.monitoring.bulk.js | 6 +++--- api/api/xpack.rollup.delete_job.js | 6 +++--- api/api/xpack.rollup.get_jobs.js | 6 +++--- api/api/xpack.rollup.get_rollup_caps.js | 6 +++--- api/api/xpack.rollup.get_rollup_index_caps.js | 6 +++--- api/api/xpack.rollup.put_job.js | 6 +++--- api/api/xpack.rollup.rollup_search.js | 6 +++--- api/api/xpack.rollup.start_job.js | 6 +++--- api/api/xpack.rollup.stop_job.js | 6 +++--- api/api/xpack.security.authenticate.js | 6 +++--- api/api/xpack.security.change_password.js | 6 +++--- api/api/xpack.security.clear_cached_realms.js | 6 +++--- api/api/xpack.security.clear_cached_roles.js | 6 +++--- api/api/xpack.security.delete_privileges.js | 6 +++--- api/api/xpack.security.delete_role.js | 6 +++--- api/api/xpack.security.delete_role_mapping.js | 6 +++--- api/api/xpack.security.delete_user.js | 6 +++--- api/api/xpack.security.disable_user.js | 6 +++--- api/api/xpack.security.enable_user.js | 6 +++--- api/api/xpack.security.get_privileges.js | 6 +++--- api/api/xpack.security.get_role.js | 6 +++--- api/api/xpack.security.get_role_mapping.js | 6 +++--- api/api/xpack.security.get_token.js | 6 +++--- api/api/xpack.security.get_user.js | 6 +++--- api/api/xpack.security.get_user_privileges.js | 6 +++--- api/api/xpack.security.has_privileges.js | 6 +++--- api/api/xpack.security.invalidate_token.js | 6 +++--- api/api/xpack.security.put_privileges.js | 6 +++--- api/api/xpack.security.put_role.js | 6 +++--- api/api/xpack.security.put_role_mapping.js | 6 +++--- api/api/xpack.security.put_user.js | 6 +++--- api/api/xpack.sql.clear_cursor.js | 6 +++--- api/api/xpack.sql.query.js | 6 +++--- api/api/xpack.sql.translate.js | 6 +++--- api/api/xpack.ssl.certificates.js | 6 +++--- api/api/xpack.usage.js | 6 +++--- api/api/xpack.watcher.ack_watch.js | 6 +++--- api/api/xpack.watcher.activate_watch.js | 6 +++--- api/api/xpack.watcher.deactivate_watch.js | 6 +++--- api/api/xpack.watcher.delete_watch.js | 6 +++--- api/api/xpack.watcher.execute_watch.js | 6 +++--- api/api/xpack.watcher.get_watch.js | 6 +++--- api/api/xpack.watcher.put_watch.js | 6 +++--- api/api/xpack.watcher.restart.js | 6 +++--- api/api/xpack.watcher.start.js | 6 +++--- api/api/xpack.watcher.stats.js | 6 +++--- api/api/xpack.watcher.stop.js | 6 +++--- 237 files changed, 711 insertions(+), 711 deletions(-) diff --git a/api/api/bulk.js b/api/api/bulk.js index 1c494f4ca..45165b1c2 100644 --- a/api/api/bulk.js +++ b/api/api/bulk.js @@ -130,16 +130,16 @@ function buildBulk (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, bulkBody: params.body, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cat.aliases.js b/api/api/cat.aliases.js index ea89f4c82..5a55df2a2 100644 --- a/api/api/cat.aliases.js +++ b/api/api/cat.aliases.js @@ -111,16 +111,16 @@ function buildCatAliases (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cat.allocation.js b/api/api/cat.allocation.js index c5d6389d9..71e73aa9c 100644 --- a/api/api/cat.allocation.js +++ b/api/api/cat.allocation.js @@ -114,16 +114,16 @@ function buildCatAllocation (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cat.count.js b/api/api/cat.count.js index d7aa9b990..31d497340 100644 --- a/api/api/cat.count.js +++ b/api/api/cat.count.js @@ -111,16 +111,16 @@ function buildCatCount (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cat.fielddata.js b/api/api/cat.fielddata.js index 3b441de4e..0a6cc1d59 100644 --- a/api/api/cat.fielddata.js +++ b/api/api/cat.fielddata.js @@ -117,16 +117,16 @@ function buildCatFielddata (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cat.health.js b/api/api/cat.health.js index e2a833683..fbb4c5946 100644 --- a/api/api/cat.health.js +++ b/api/api/cat.health.js @@ -113,16 +113,16 @@ function buildCatHealth (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cat.help.js b/api/api/cat.help.js index 5320853c0..6b671f2b2 100644 --- a/api/api/cat.help.js +++ b/api/api/cat.help.js @@ -95,16 +95,16 @@ function buildCatHelp (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cat.indices.js b/api/api/cat.indices.js index 86cb1ce7a..0b0370fbb 100644 --- a/api/api/cat.indices.js +++ b/api/api/cat.indices.js @@ -120,16 +120,16 @@ function buildCatIndices (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cat.master.js b/api/api/cat.master.js index 2a1dec0d0..a313a0c6e 100644 --- a/api/api/cat.master.js +++ b/api/api/cat.master.js @@ -110,16 +110,16 @@ function buildCatMaster (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cat.nodeattrs.js b/api/api/cat.nodeattrs.js index 7e1e05918..31234406e 100644 --- a/api/api/cat.nodeattrs.js +++ b/api/api/cat.nodeattrs.js @@ -110,16 +110,16 @@ function buildCatNodeattrs (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cat.nodes.js b/api/api/cat.nodes.js index 6dd74dd63..4785a9e93 100644 --- a/api/api/cat.nodes.js +++ b/api/api/cat.nodes.js @@ -113,16 +113,16 @@ function buildCatNodes (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cat.pending_tasks.js b/api/api/cat.pending_tasks.js index df3f416ae..bd355ebef 100644 --- a/api/api/cat.pending_tasks.js +++ b/api/api/cat.pending_tasks.js @@ -110,16 +110,16 @@ function buildCatPendingTasks (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cat.plugins.js b/api/api/cat.plugins.js index d7e0b3a91..eaf9874a1 100644 --- a/api/api/cat.plugins.js +++ b/api/api/cat.plugins.js @@ -110,16 +110,16 @@ function buildCatPlugins (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cat.recovery.js b/api/api/cat.recovery.js index 5647c88b4..c453e4703 100644 --- a/api/api/cat.recovery.js +++ b/api/api/cat.recovery.js @@ -111,16 +111,16 @@ function buildCatRecovery (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cat.repositories.js b/api/api/cat.repositories.js index a57097b8e..f022ca815 100644 --- a/api/api/cat.repositories.js +++ b/api/api/cat.repositories.js @@ -110,16 +110,16 @@ function buildCatRepositories (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cat.segments.js b/api/api/cat.segments.js index 6111e17a4..6075d045e 100644 --- a/api/api/cat.segments.js +++ b/api/api/cat.segments.js @@ -108,16 +108,16 @@ function buildCatSegments (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cat.shards.js b/api/api/cat.shards.js index 0e4bac3d4..dc2cd6cb8 100644 --- a/api/api/cat.shards.js +++ b/api/api/cat.shards.js @@ -114,16 +114,16 @@ function buildCatShards (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cat.snapshots.js b/api/api/cat.snapshots.js index 8d1f6eca8..4d192d79c 100644 --- a/api/api/cat.snapshots.js +++ b/api/api/cat.snapshots.js @@ -111,16 +111,16 @@ function buildCatSnapshots (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cat.tasks.js b/api/api/cat.tasks.js index 4894328b2..9546b0166 100644 --- a/api/api/cat.tasks.js +++ b/api/api/cat.tasks.js @@ -116,16 +116,16 @@ function buildCatTasks (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cat.templates.js b/api/api/cat.templates.js index e94613412..ce2ffbd18 100644 --- a/api/api/cat.templates.js +++ b/api/api/cat.templates.js @@ -111,16 +111,16 @@ function buildCatTemplates (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cat.thread_pool.js b/api/api/cat.thread_pool.js index 1e35efd04..edba83157 100644 --- a/api/api/cat.thread_pool.js +++ b/api/api/cat.thread_pool.js @@ -114,16 +114,16 @@ function buildCatThreadPool (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/ccr.delete_auto_follow_pattern.js b/api/api/ccr.delete_auto_follow_pattern.js index 1e997385b..d676aa96a 100644 --- a/api/api/ccr.delete_auto_follow_pattern.js +++ b/api/api/ccr.delete_auto_follow_pattern.js @@ -82,16 +82,16 @@ function buildCcrDeleteAutoFollowPattern (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/ccr.follow.js b/api/api/ccr.follow.js index 3d8206b2a..344e12a83 100644 --- a/api/api/ccr.follow.js +++ b/api/api/ccr.follow.js @@ -89,16 +89,16 @@ function buildCcrFollow (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/ccr.follow_stats.js b/api/api/ccr.follow_stats.js index 86f8f5d00..a073af9fc 100644 --- a/api/api/ccr.follow_stats.js +++ b/api/api/ccr.follow_stats.js @@ -74,16 +74,16 @@ function buildCcrFollowStats (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/ccr.get_auto_follow_pattern.js b/api/api/ccr.get_auto_follow_pattern.js index 5e948e077..e0b15f89e 100644 --- a/api/api/ccr.get_auto_follow_pattern.js +++ b/api/api/ccr.get_auto_follow_pattern.js @@ -74,16 +74,16 @@ function buildCcrGetAutoFollowPattern (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/ccr.pause_follow.js b/api/api/ccr.pause_follow.js index 33d8b168a..e0f646809 100644 --- a/api/api/ccr.pause_follow.js +++ b/api/api/ccr.pause_follow.js @@ -82,16 +82,16 @@ function buildCcrPauseFollow (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/ccr.put_auto_follow_pattern.js b/api/api/ccr.put_auto_follow_pattern.js index 99b4f8e64..766a24d9e 100644 --- a/api/api/ccr.put_auto_follow_pattern.js +++ b/api/api/ccr.put_auto_follow_pattern.js @@ -89,16 +89,16 @@ function buildCcrPutAutoFollowPattern (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/ccr.resume_follow.js b/api/api/ccr.resume_follow.js index cbd91abec..989e04e1a 100644 --- a/api/api/ccr.resume_follow.js +++ b/api/api/ccr.resume_follow.js @@ -89,16 +89,16 @@ function buildCcrResumeFollow (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/ccr.stats.js b/api/api/ccr.stats.js index 89856e6b3..786a130cb 100644 --- a/api/api/ccr.stats.js +++ b/api/api/ccr.stats.js @@ -73,16 +73,16 @@ function buildCcrStats (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/ccr.unfollow.js b/api/api/ccr.unfollow.js index d608fb140..92f192de4 100644 --- a/api/api/ccr.unfollow.js +++ b/api/api/ccr.unfollow.js @@ -82,16 +82,16 @@ function buildCcrUnfollow (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/clear_scroll.js b/api/api/clear_scroll.js index cd9e2aba8..439a07481 100644 --- a/api/api/clear_scroll.js +++ b/api/api/clear_scroll.js @@ -83,16 +83,16 @@ function buildClearScroll (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cluster.allocation_explain.js b/api/api/cluster.allocation_explain.js index 37f8adf61..799658e2a 100644 --- a/api/api/cluster.allocation_explain.js +++ b/api/api/cluster.allocation_explain.js @@ -88,16 +88,16 @@ function buildClusterAllocationExplain (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cluster.get_settings.js b/api/api/cluster.get_settings.js index 26fc4a07e..8897c47c7 100644 --- a/api/api/cluster.get_settings.js +++ b/api/api/cluster.get_settings.js @@ -101,16 +101,16 @@ function buildClusterGetSettings (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cluster.health.js b/api/api/cluster.health.js index 88850cc4d..018a91159 100644 --- a/api/api/cluster.health.js +++ b/api/api/cluster.health.js @@ -120,16 +120,16 @@ function buildClusterHealth (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cluster.pending_tasks.js b/api/api/cluster.pending_tasks.js index ea6cd5617..2310d4313 100644 --- a/api/api/cluster.pending_tasks.js +++ b/api/api/cluster.pending_tasks.js @@ -95,16 +95,16 @@ function buildClusterPendingTasks (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cluster.put_settings.js b/api/api/cluster.put_settings.js index 7d4878eee..a5b5edc1b 100644 --- a/api/api/cluster.put_settings.js +++ b/api/api/cluster.put_settings.js @@ -99,16 +99,16 @@ function buildClusterPutSettings (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cluster.remote_info.js b/api/api/cluster.remote_info.js index d4a91bd8a..89eb5a8c2 100644 --- a/api/api/cluster.remote_info.js +++ b/api/api/cluster.remote_info.js @@ -89,16 +89,16 @@ function buildClusterRemoteInfo (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cluster.reroute.js b/api/api/cluster.reroute.js index 3cd46a339..3749abcde 100644 --- a/api/api/cluster.reroute.js +++ b/api/api/cluster.reroute.js @@ -100,16 +100,16 @@ function buildClusterReroute (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cluster.state.js b/api/api/cluster.state.js index 954e0f03b..e749f4a17 100644 --- a/api/api/cluster.state.js +++ b/api/api/cluster.state.js @@ -117,16 +117,16 @@ function buildClusterState (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/cluster.stats.js b/api/api/cluster.stats.js index 772f121ca..8c37aba10 100644 --- a/api/api/cluster.stats.js +++ b/api/api/cluster.stats.js @@ -98,16 +98,16 @@ function buildClusterStats (opts) { path: (params['node_id'] || params['nodeId']) != null ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') : '/_cluster/stats', - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/count.js b/api/api/count.js index 33bafea0f..568a403b6 100644 --- a/api/api/count.js +++ b/api/api/count.js @@ -131,16 +131,16 @@ function buildCount (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/create.js b/api/api/create.js index 79fbd5242..38c40df49 100644 --- a/api/api/create.js +++ b/api/api/create.js @@ -148,16 +148,16 @@ function buildCreate (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/delete.js b/api/api/delete.js index b7a1c8560..a6545c05c 100644 --- a/api/api/delete.js +++ b/api/api/delete.js @@ -144,16 +144,16 @@ function buildDelete (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/delete_by_query.js b/api/api/delete_by_query.js index ddde407aa..e0b984a53 100644 --- a/api/api/delete_by_query.js +++ b/api/api/delete_by_query.js @@ -202,16 +202,16 @@ function buildDeleteByQuery (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/delete_by_query_rethrottle.js b/api/api/delete_by_query_rethrottle.js index 186b0e2ee..423144942 100644 --- a/api/api/delete_by_query_rethrottle.js +++ b/api/api/delete_by_query_rethrottle.js @@ -105,16 +105,16 @@ function buildDeleteByQueryRethrottle (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/delete_script.js b/api/api/delete_script.js index 561ab0327..0459738b7 100644 --- a/api/api/delete_script.js +++ b/api/api/delete_script.js @@ -102,16 +102,16 @@ function buildDeleteScript (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/exists.js b/api/api/exists.js index 200be7062..b2b27dcb5 100644 --- a/api/api/exists.js +++ b/api/api/exists.js @@ -156,16 +156,16 @@ function buildExists (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/exists_source.js b/api/api/exists_source.js index 1d6c8dc7f..188d53ed4 100644 --- a/api/api/exists_source.js +++ b/api/api/exists_source.js @@ -153,16 +153,16 @@ function buildExistsSource (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/explain.js b/api/api/explain.js index 843d316ab..a0ffea3e3 100644 --- a/api/api/explain.js +++ b/api/api/explain.js @@ -157,16 +157,16 @@ function buildExplain (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/field_caps.js b/api/api/field_caps.js index c1803c0b3..b69b053e2 100644 --- a/api/api/field_caps.js +++ b/api/api/field_caps.js @@ -95,16 +95,16 @@ function buildFieldCaps (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/get.js b/api/api/get.js index 26b6c6e2d..da4e07579 100644 --- a/api/api/get.js +++ b/api/api/get.js @@ -156,16 +156,16 @@ function buildGet (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/get_script.js b/api/api/get_script.js index 8481e4330..852df3d5c 100644 --- a/api/api/get_script.js +++ b/api/api/get_script.js @@ -99,16 +99,16 @@ function buildGetScript (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/get_source.js b/api/api/get_source.js index 75794298d..37300e8b5 100644 --- a/api/api/get_source.js +++ b/api/api/get_source.js @@ -153,16 +153,16 @@ function buildGetSource (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/index.js b/api/api/index.js index 243234c9f..ab0c1a920 100644 --- a/api/api/index.js +++ b/api/api/index.js @@ -145,16 +145,16 @@ function buildIndex (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.analyze.js b/api/api/indices.analyze.js index 89228daaf..37fd178ce 100644 --- a/api/api/indices.analyze.js +++ b/api/api/indices.analyze.js @@ -86,16 +86,16 @@ function buildIndicesAnalyze (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.clear_cache.js b/api/api/indices.clear_cache.js index db8bc7815..6e0ed7555 100644 --- a/api/api/indices.clear_cache.js +++ b/api/api/indices.clear_cache.js @@ -120,16 +120,16 @@ function buildIndicesClearCache (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.close.js b/api/api/indices.close.js index 5d10102c1..3d8c33f86 100644 --- a/api/api/indices.close.js +++ b/api/api/indices.close.js @@ -111,16 +111,16 @@ function buildIndicesClose (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.create.js b/api/api/indices.create.js index 5b4cffe37..a855bafec 100644 --- a/api/api/indices.create.js +++ b/api/api/indices.create.js @@ -103,16 +103,16 @@ function buildIndicesCreate (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.delete.js b/api/api/indices.delete.js index 2c3a809c9..06b649926 100644 --- a/api/api/indices.delete.js +++ b/api/api/indices.delete.js @@ -111,16 +111,16 @@ function buildIndicesDelete (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.delete_alias.js b/api/api/indices.delete_alias.js index 844d87e5e..43447d915 100644 --- a/api/api/indices.delete_alias.js +++ b/api/api/indices.delete_alias.js @@ -119,16 +119,16 @@ function buildIndicesDeleteAlias (opts) { path: params['index'] != null && params['name'] != null ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') : '/{index}/_alias/{name}', - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.delete_template.js b/api/api/indices.delete_template.js index 88c76a15c..3c4dd12ea 100644 --- a/api/api/indices.delete_template.js +++ b/api/api/indices.delete_template.js @@ -102,16 +102,16 @@ function buildIndicesDeleteTemplate (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.exists.js b/api/api/indices.exists.js index 0856d4cdd..dc2fe554a 100644 --- a/api/api/indices.exists.js +++ b/api/api/indices.exists.js @@ -114,16 +114,16 @@ function buildIndicesExists (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.exists_alias.js b/api/api/indices.exists_alias.js index 51d45f871..d827db77c 100644 --- a/api/api/indices.exists_alias.js +++ b/api/api/indices.exists_alias.js @@ -109,16 +109,16 @@ function buildIndicesExistsAlias (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.exists_template.js b/api/api/indices.exists_template.js index 8c49c1f28..78d5056ba 100644 --- a/api/api/indices.exists_template.js +++ b/api/api/indices.exists_template.js @@ -105,16 +105,16 @@ function buildIndicesExistsTemplate (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.exists_type.js b/api/api/indices.exists_type.js index 4d3a729b5..00c2f3036 100644 --- a/api/api/indices.exists_type.js +++ b/api/api/indices.exists_type.js @@ -123,16 +123,16 @@ function buildIndicesExistsType (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.flush.js b/api/api/indices.flush.js index 372e5dfde..df05b411b 100644 --- a/api/api/indices.flush.js +++ b/api/api/indices.flush.js @@ -105,16 +105,16 @@ function buildIndicesFlush (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.flush_synced.js b/api/api/indices.flush_synced.js index 3acf8e25b..aa5a65bdc 100644 --- a/api/api/indices.flush_synced.js +++ b/api/api/indices.flush_synced.js @@ -99,16 +99,16 @@ function buildIndicesFlushSynced (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.forcemerge.js b/api/api/indices.forcemerge.js index 297917d7f..3631441d6 100644 --- a/api/api/indices.forcemerge.js +++ b/api/api/indices.forcemerge.js @@ -108,16 +108,16 @@ function buildIndicesForcemerge (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.get.js b/api/api/indices.get.js index b615d64c1..0322a28d7 100644 --- a/api/api/indices.get.js +++ b/api/api/indices.get.js @@ -117,16 +117,16 @@ function buildIndicesGet (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.get_alias.js b/api/api/indices.get_alias.js index aa4a01155..e7904cc2c 100644 --- a/api/api/indices.get_alias.js +++ b/api/api/indices.get_alias.js @@ -103,16 +103,16 @@ function buildIndicesGetAlias (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.get_field_mapping.js b/api/api/indices.get_field_mapping.js index 1d186649c..003ac8f3c 100644 --- a/api/api/indices.get_field_mapping.js +++ b/api/api/indices.get_field_mapping.js @@ -113,16 +113,16 @@ function buildIndicesGetFieldMapping (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.get_mapping.js b/api/api/indices.get_mapping.js index 708ad5991..0a6870540 100644 --- a/api/api/indices.get_mapping.js +++ b/api/api/indices.get_mapping.js @@ -106,16 +106,16 @@ function buildIndicesGetMapping (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.get_settings.js b/api/api/indices.get_settings.js index 3fc5c9cf5..76d8a13a9 100644 --- a/api/api/indices.get_settings.js +++ b/api/api/indices.get_settings.js @@ -112,16 +112,16 @@ function buildIndicesGetSettings (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.get_template.js b/api/api/indices.get_template.js index e4e35a00b..d392de288 100644 --- a/api/api/indices.get_template.js +++ b/api/api/indices.get_template.js @@ -99,16 +99,16 @@ function buildIndicesGetTemplate (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.get_upgrade.js b/api/api/indices.get_upgrade.js index b7e1e40b1..1a8b2a1a5 100644 --- a/api/api/indices.get_upgrade.js +++ b/api/api/indices.get_upgrade.js @@ -99,16 +99,16 @@ function buildIndicesGetUpgrade (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.open.js b/api/api/indices.open.js index 4e681d6e7..addc18a50 100644 --- a/api/api/indices.open.js +++ b/api/api/indices.open.js @@ -114,16 +114,16 @@ function buildIndicesOpen (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.put_alias.js b/api/api/indices.put_alias.js index 981e294c2..48cb6d31e 100644 --- a/api/api/indices.put_alias.js +++ b/api/api/indices.put_alias.js @@ -114,16 +114,16 @@ function buildIndicesPutAlias (opts) { path: params['index'] != null && params['name'] != null ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') : '/{index}/_alias/{name}', - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.put_mapping.js b/api/api/indices.put_mapping.js index 8568e53df..e2c12da00 100644 --- a/api/api/indices.put_mapping.js +++ b/api/api/indices.put_mapping.js @@ -116,16 +116,16 @@ function buildIndicesPutMapping (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.put_settings.js b/api/api/indices.put_settings.js index e111172ca..dc4c28656 100644 --- a/api/api/indices.put_settings.js +++ b/api/api/indices.put_settings.js @@ -112,16 +112,16 @@ function buildIndicesPutSettings (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.put_template.js b/api/api/indices.put_template.js index 873cb9bb1..962c3814a 100644 --- a/api/api/indices.put_template.js +++ b/api/api/indices.put_template.js @@ -112,16 +112,16 @@ function buildIndicesPutTemplate (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.recovery.js b/api/api/indices.recovery.js index 23d4726a8..efa854df6 100644 --- a/api/api/indices.recovery.js +++ b/api/api/indices.recovery.js @@ -96,16 +96,16 @@ function buildIndicesRecovery (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.refresh.js b/api/api/indices.refresh.js index 3e5ce990e..90bb65a31 100644 --- a/api/api/indices.refresh.js +++ b/api/api/indices.refresh.js @@ -99,16 +99,16 @@ function buildIndicesRefresh (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.rollover.js b/api/api/indices.rollover.js index e5bec5bb0..9a50a7543 100644 --- a/api/api/indices.rollover.js +++ b/api/api/indices.rollover.js @@ -112,16 +112,16 @@ function buildIndicesRollover (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.segments.js b/api/api/indices.segments.js index f15bc55e2..18a80b030 100644 --- a/api/api/indices.segments.js +++ b/api/api/indices.segments.js @@ -102,16 +102,16 @@ function buildIndicesSegments (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.shard_stores.js b/api/api/indices.shard_stores.js index fb37d4784..bfc958c1e 100644 --- a/api/api/indices.shard_stores.js +++ b/api/api/indices.shard_stores.js @@ -102,16 +102,16 @@ function buildIndicesShardStores (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.shrink.js b/api/api/indices.shrink.js index 721721c99..670806137 100644 --- a/api/api/indices.shrink.js +++ b/api/api/indices.shrink.js @@ -118,16 +118,16 @@ function buildIndicesShrink (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.split.js b/api/api/indices.split.js index 7e41e56f3..831d3ed08 100644 --- a/api/api/indices.split.js +++ b/api/api/indices.split.js @@ -118,16 +118,16 @@ function buildIndicesSplit (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.stats.js b/api/api/indices.stats.js index 972fabaac..d7a4d0f0d 100644 --- a/api/api/indices.stats.js +++ b/api/api/indices.stats.js @@ -112,16 +112,16 @@ function buildIndicesStats (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.update_aliases.js b/api/api/indices.update_aliases.js index 58e5a380c..f507ae604 100644 --- a/api/api/indices.update_aliases.js +++ b/api/api/indices.update_aliases.js @@ -96,16 +96,16 @@ function buildIndicesUpdateAliases (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.upgrade.js b/api/api/indices.upgrade.js index 4ae382482..9741684d5 100644 --- a/api/api/indices.upgrade.js +++ b/api/api/indices.upgrade.js @@ -105,16 +105,16 @@ function buildIndicesUpgrade (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/indices.validate_query.js b/api/api/indices.validate_query.js index 6438214cc..cbd783b86 100644 --- a/api/api/indices.validate_query.js +++ b/api/api/indices.validate_query.js @@ -128,16 +128,16 @@ function buildIndicesValidateQuery (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/info.js b/api/api/info.js index 1c879bca1..6e6c58746 100644 --- a/api/api/info.js +++ b/api/api/info.js @@ -89,16 +89,16 @@ function buildInfo (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/ingest.delete_pipeline.js b/api/api/ingest.delete_pipeline.js index dfad9ba3d..78b6cbc33 100644 --- a/api/api/ingest.delete_pipeline.js +++ b/api/api/ingest.delete_pipeline.js @@ -102,16 +102,16 @@ function buildIngestDeletePipeline (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/ingest.get_pipeline.js b/api/api/ingest.get_pipeline.js index 4b51643a5..2f15be8f9 100644 --- a/api/api/ingest.get_pipeline.js +++ b/api/api/ingest.get_pipeline.js @@ -93,16 +93,16 @@ function buildIngestGetPipeline (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/ingest.processor_grok.js b/api/api/ingest.processor_grok.js index 71e8b2374..c9c40f32c 100644 --- a/api/api/ingest.processor_grok.js +++ b/api/api/ingest.processor_grok.js @@ -89,16 +89,16 @@ function buildIngestProcessorGrok (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/ingest.put_pipeline.js b/api/api/ingest.put_pipeline.js index 5af734ee3..6a14d4637 100644 --- a/api/api/ingest.put_pipeline.js +++ b/api/api/ingest.put_pipeline.js @@ -103,16 +103,16 @@ function buildIngestPutPipeline (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/ingest.simulate.js b/api/api/ingest.simulate.js index b92be2c1c..fb0c0a1a6 100644 --- a/api/api/ingest.simulate.js +++ b/api/api/ingest.simulate.js @@ -94,16 +94,16 @@ function buildIngestSimulate (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/mget.js b/api/api/mget.js index f56ec92ee..1327af217 100644 --- a/api/api/mget.js +++ b/api/api/mget.js @@ -124,16 +124,16 @@ function buildMget (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/msearch.js b/api/api/msearch.js index 383887dd4..b4aa9faea 100644 --- a/api/api/msearch.js +++ b/api/api/msearch.js @@ -115,16 +115,16 @@ function buildMsearch (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, bulkBody: params.body, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/msearch_template.js b/api/api/msearch_template.js index b8375a927..2d7331260 100644 --- a/api/api/msearch_template.js +++ b/api/api/msearch_template.js @@ -109,16 +109,16 @@ function buildMsearchTemplate (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, bulkBody: params.body, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/mtermvectors.js b/api/api/mtermvectors.js index 9a967f293..a2628e6a0 100644 --- a/api/api/mtermvectors.js +++ b/api/api/mtermvectors.js @@ -131,16 +131,16 @@ function buildMtermvectors (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/nodes.hot_threads.js b/api/api/nodes.hot_threads.js index 089bdcadb..b19169efe 100644 --- a/api/api/nodes.hot_threads.js +++ b/api/api/nodes.hot_threads.js @@ -110,16 +110,16 @@ function buildNodesHotThreads (opts) { path: (params['node_id'] || params['nodeId']) != null ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') : '/_nodes/hot_threads', - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/nodes.info.js b/api/api/nodes.info.js index 22aee5980..c2ef92c6d 100644 --- a/api/api/nodes.info.js +++ b/api/api/nodes.info.js @@ -97,16 +97,16 @@ function buildNodesInfo (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/nodes.reload_secure_settings.js b/api/api/nodes.reload_secure_settings.js index 8fe846f04..98d3f5c3a 100644 --- a/api/api/nodes.reload_secure_settings.js +++ b/api/api/nodes.reload_secure_settings.js @@ -93,16 +93,16 @@ function buildNodesReloadSecureSettings (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/nodes.stats.js b/api/api/nodes.stats.js index 7b0ef2670..b4faa6ba4 100644 --- a/api/api/nodes.stats.js +++ b/api/api/nodes.stats.js @@ -116,16 +116,16 @@ function buildNodesStats (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/nodes.usage.js b/api/api/nodes.usage.js index 99f1cb98c..37b7244de 100644 --- a/api/api/nodes.usage.js +++ b/api/api/nodes.usage.js @@ -94,16 +94,16 @@ function buildNodesUsage (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/ping.js b/api/api/ping.js index 56c9562e8..98af2d2d4 100644 --- a/api/api/ping.js +++ b/api/api/ping.js @@ -89,16 +89,16 @@ function buildPing (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/put_script.js b/api/api/put_script.js index e30752c63..be52f8e01 100644 --- a/api/api/put_script.js +++ b/api/api/put_script.js @@ -115,16 +115,16 @@ function buildPutScript (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/rank_eval.js b/api/api/rank_eval.js index b701d2e40..3b693eaf4 100644 --- a/api/api/rank_eval.js +++ b/api/api/rank_eval.js @@ -100,16 +100,16 @@ function buildRankEval (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/reindex.js b/api/api/reindex.js index c39f30c5f..c61ca9587 100644 --- a/api/api/reindex.js +++ b/api/api/reindex.js @@ -108,16 +108,16 @@ function buildReindex (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/reindex_rethrottle.js b/api/api/reindex_rethrottle.js index 1c54e9ed8..1d80eeddf 100644 --- a/api/api/reindex_rethrottle.js +++ b/api/api/reindex_rethrottle.js @@ -105,16 +105,16 @@ function buildReindexRethrottle (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/render_search_template.js b/api/api/render_search_template.js index 12ca3805a..a6c50ec8b 100644 --- a/api/api/render_search_template.js +++ b/api/api/render_search_template.js @@ -83,16 +83,16 @@ function buildRenderSearchTemplate (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/scripts_painless_execute.js b/api/api/scripts_painless_execute.js index e26683bde..028e3e479 100644 --- a/api/api/scripts_painless_execute.js +++ b/api/api/scripts_painless_execute.js @@ -82,16 +82,16 @@ function buildScriptsPainlessExecute (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/scroll.js b/api/api/scroll.js index 0d6f9f1ab..0f09babcd 100644 --- a/api/api/scroll.js +++ b/api/api/scroll.js @@ -89,16 +89,16 @@ function buildScroll (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/search.js b/api/api/search.js index 3a1ba231e..48bc3702a 100644 --- a/api/api/search.js +++ b/api/api/search.js @@ -206,16 +206,16 @@ function buildSearch (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/search_shards.js b/api/api/search_shards.js index 5e6a29832..cc1ec72ff 100644 --- a/api/api/search_shards.js +++ b/api/api/search_shards.js @@ -108,16 +108,16 @@ function buildSearchShards (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/search_template.js b/api/api/search_template.js index f9aca5107..66af6e928 100644 --- a/api/api/search_template.js +++ b/api/api/search_template.js @@ -130,16 +130,16 @@ function buildSearchTemplate (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/snapshot.create.js b/api/api/snapshot.create.js index 873e2e6f0..873982d68 100644 --- a/api/api/snapshot.create.js +++ b/api/api/snapshot.create.js @@ -112,16 +112,16 @@ function buildSnapshotCreate (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/snapshot.create_repository.js b/api/api/snapshot.create_repository.js index 0fd7cac1d..9a6aefde6 100644 --- a/api/api/snapshot.create_repository.js +++ b/api/api/snapshot.create_repository.js @@ -106,16 +106,16 @@ function buildSnapshotCreateRepository (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/snapshot.delete.js b/api/api/snapshot.delete.js index 047b2f92a..22a5c691d 100644 --- a/api/api/snapshot.delete.js +++ b/api/api/snapshot.delete.js @@ -114,16 +114,16 @@ function buildSnapshotDelete (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/snapshot.delete_repository.js b/api/api/snapshot.delete_repository.js index bf4884d64..fa26f7174 100644 --- a/api/api/snapshot.delete_repository.js +++ b/api/api/snapshot.delete_repository.js @@ -102,16 +102,16 @@ function buildSnapshotDeleteRepository (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/snapshot.get.js b/api/api/snapshot.get.js index 68a869c3c..5fbded88b 100644 --- a/api/api/snapshot.get.js +++ b/api/api/snapshot.get.js @@ -120,16 +120,16 @@ function buildSnapshotGet (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/snapshot.get_repository.js b/api/api/snapshot.get_repository.js index f127a7cb1..4eb197991 100644 --- a/api/api/snapshot.get_repository.js +++ b/api/api/snapshot.get_repository.js @@ -96,16 +96,16 @@ function buildSnapshotGetRepository (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/snapshot.restore.js b/api/api/snapshot.restore.js index a6f90e34d..d0577e954 100644 --- a/api/api/snapshot.restore.js +++ b/api/api/snapshot.restore.js @@ -112,16 +112,16 @@ function buildSnapshotRestore (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/snapshot.status.js b/api/api/snapshot.status.js index 190a9df1d..8c618f622 100644 --- a/api/api/snapshot.status.js +++ b/api/api/snapshot.status.js @@ -105,16 +105,16 @@ function buildSnapshotStatus (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/snapshot.verify_repository.js b/api/api/snapshot.verify_repository.js index ae407b982..b93250b38 100644 --- a/api/api/snapshot.verify_repository.js +++ b/api/api/snapshot.verify_repository.js @@ -102,16 +102,16 @@ function buildSnapshotVerifyRepository (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/tasks.cancel.js b/api/api/tasks.cancel.js index 4c18305a8..d2ed6a011 100644 --- a/api/api/tasks.cancel.js +++ b/api/api/tasks.cancel.js @@ -99,16 +99,16 @@ function buildTasksCancel (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/tasks.get.js b/api/api/tasks.get.js index ee39d1208..0fab38d31 100644 --- a/api/api/tasks.get.js +++ b/api/api/tasks.get.js @@ -102,16 +102,16 @@ function buildTasksGet (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/tasks.list.js b/api/api/tasks.list.js index 4a7d20ef9..90cabbcc4 100644 --- a/api/api/tasks.list.js +++ b/api/api/tasks.list.js @@ -110,16 +110,16 @@ function buildTasksList (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/termvectors.js b/api/api/termvectors.js index 851ef79ff..ec2354fc4 100644 --- a/api/api/termvectors.js +++ b/api/api/termvectors.js @@ -148,16 +148,16 @@ function buildTermvectors (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/update.js b/api/api/update.js index 273da583c..13e8539ee 100644 --- a/api/api/update.js +++ b/api/api/update.js @@ -163,16 +163,16 @@ function buildUpdate (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/update_by_query.js b/api/api/update_by_query.js index 4904cd226..1f06382ff 100644 --- a/api/api/update_by_query.js +++ b/api/api/update_by_query.js @@ -202,16 +202,16 @@ function buildUpdateByQuery (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/update_by_query_rethrottle.js b/api/api/update_by_query_rethrottle.js index 5f90384a5..8fb894f7a 100644 --- a/api/api/update_by_query_rethrottle.js +++ b/api/api/update_by_query_rethrottle.js @@ -105,16 +105,16 @@ function buildUpdateByQueryRethrottle (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.graph.explore.js b/api/api/xpack.graph.explore.js index dd65d8af3..02d33ae1e 100644 --- a/api/api/xpack.graph.explore.js +++ b/api/api/xpack.graph.explore.js @@ -88,16 +88,16 @@ function buildXpackGraphExplore (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.info.js b/api/api/xpack.info.js index a6d2c27e4..eb2fe9c60 100644 --- a/api/api/xpack.info.js +++ b/api/api/xpack.info.js @@ -82,16 +82,16 @@ function buildXpackInfo (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.license.delete.js b/api/api/xpack.license.delete.js index 6bca3d074..281519cf5 100644 --- a/api/api/xpack.license.delete.js +++ b/api/api/xpack.license.delete.js @@ -81,16 +81,16 @@ function buildXpackLicenseDelete (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.license.get.js b/api/api/xpack.license.get.js index 110a5c8a9..e3910bcf0 100644 --- a/api/api/xpack.license.get.js +++ b/api/api/xpack.license.get.js @@ -82,16 +82,16 @@ function buildXpackLicenseGet (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.license.get_basic_status.js b/api/api/xpack.license.get_basic_status.js index 7c0c67e6a..a7e368eb2 100644 --- a/api/api/xpack.license.get_basic_status.js +++ b/api/api/xpack.license.get_basic_status.js @@ -81,16 +81,16 @@ function buildXpackLicenseGetBasicStatus (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.license.get_trial_status.js b/api/api/xpack.license.get_trial_status.js index d9c2927ae..d773b29bd 100644 --- a/api/api/xpack.license.get_trial_status.js +++ b/api/api/xpack.license.get_trial_status.js @@ -81,16 +81,16 @@ function buildXpackLicenseGetTrialStatus (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.license.post.js b/api/api/xpack.license.post.js index 26a31b031..964586b89 100644 --- a/api/api/xpack.license.post.js +++ b/api/api/xpack.license.post.js @@ -75,16 +75,16 @@ function buildXpackLicensePost (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.license.post_start_basic.js b/api/api/xpack.license.post_start_basic.js index 5762ad8a2..ddee829a9 100644 --- a/api/api/xpack.license.post_start_basic.js +++ b/api/api/xpack.license.post_start_basic.js @@ -82,16 +82,16 @@ function buildXpackLicensePostStartBasic (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.license.post_start_trial.js b/api/api/xpack.license.post_start_trial.js index d3b602202..f3a4a85a0 100644 --- a/api/api/xpack.license.post_start_trial.js +++ b/api/api/xpack.license.post_start_trial.js @@ -85,16 +85,16 @@ function buildXpackLicensePostStartTrial (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.migration.deprecations.js b/api/api/xpack.migration.deprecations.js index e9fc7799e..31b984b58 100644 --- a/api/api/xpack.migration.deprecations.js +++ b/api/api/xpack.migration.deprecations.js @@ -82,16 +82,16 @@ function buildXpackMigrationDeprecations (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.migration.get_assistance.js b/api/api/xpack.migration.get_assistance.js index 2b43ef82f..aed1707bd 100644 --- a/api/api/xpack.migration.get_assistance.js +++ b/api/api/xpack.migration.get_assistance.js @@ -81,16 +81,16 @@ function buildXpackMigrationGetAssistance (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.migration.upgrade.js b/api/api/xpack.migration.upgrade.js index 5477f42a7..48a151080 100644 --- a/api/api/xpack.migration.upgrade.js +++ b/api/api/xpack.migration.upgrade.js @@ -83,16 +83,16 @@ function buildXpackMigrationUpgrade (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.close_job.js b/api/api/xpack.ml.close_job.js index 22a2afd14..bee77a2f1 100644 --- a/api/api/xpack.ml.close_job.js +++ b/api/api/xpack.ml.close_job.js @@ -89,16 +89,16 @@ function buildXpackMlCloseJob (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.delete_calendar.js b/api/api/xpack.ml.delete_calendar.js index 07d876fc2..3431be54c 100644 --- a/api/api/xpack.ml.delete_calendar.js +++ b/api/api/xpack.ml.delete_calendar.js @@ -88,16 +88,16 @@ function buildXpackMlDeleteCalendar (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.delete_calendar_event.js b/api/api/xpack.ml.delete_calendar_event.js index 5c30de9eb..a385fcdf0 100644 --- a/api/api/xpack.ml.delete_calendar_event.js +++ b/api/api/xpack.ml.delete_calendar_event.js @@ -103,16 +103,16 @@ function buildXpackMlDeleteCalendarEvent (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.delete_calendar_job.js b/api/api/xpack.ml.delete_calendar_job.js index 669bf6a9e..33a958c88 100644 --- a/api/api/xpack.ml.delete_calendar_job.js +++ b/api/api/xpack.ml.delete_calendar_job.js @@ -103,16 +103,16 @@ function buildXpackMlDeleteCalendarJob (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.delete_datafeed.js b/api/api/xpack.ml.delete_datafeed.js index 52f70eb87..766ac2253 100644 --- a/api/api/xpack.ml.delete_datafeed.js +++ b/api/api/xpack.ml.delete_datafeed.js @@ -89,16 +89,16 @@ function buildXpackMlDeleteDatafeed (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.delete_expired_data.js b/api/api/xpack.ml.delete_expired_data.js index ac0a613b8..bcba02e9a 100644 --- a/api/api/xpack.ml.delete_expired_data.js +++ b/api/api/xpack.ml.delete_expired_data.js @@ -81,16 +81,16 @@ function buildXpackMlDeleteExpiredData (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.delete_filter.js b/api/api/xpack.ml.delete_filter.js index 66cfdf449..c16aa45df 100644 --- a/api/api/xpack.ml.delete_filter.js +++ b/api/api/xpack.ml.delete_filter.js @@ -88,16 +88,16 @@ function buildXpackMlDeleteFilter (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.delete_forecast.js b/api/api/xpack.ml.delete_forecast.js index 9a517fc72..6beb8aac4 100644 --- a/api/api/xpack.ml.delete_forecast.js +++ b/api/api/xpack.ml.delete_forecast.js @@ -101,16 +101,16 @@ function buildXpackMlDeleteForecast (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.delete_job.js b/api/api/xpack.ml.delete_job.js index f2236043e..699f8c75c 100644 --- a/api/api/xpack.ml.delete_job.js +++ b/api/api/xpack.ml.delete_job.js @@ -92,16 +92,16 @@ function buildXpackMlDeleteJob (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.delete_model_snapshot.js b/api/api/xpack.ml.delete_model_snapshot.js index 986782fd8..96e6f9246 100644 --- a/api/api/xpack.ml.delete_model_snapshot.js +++ b/api/api/xpack.ml.delete_model_snapshot.js @@ -103,16 +103,16 @@ function buildXpackMlDeleteModelSnapshot (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.find_file_structure.js b/api/api/xpack.ml.find_file_structure.js index 163a7490a..17d4f0241 100644 --- a/api/api/xpack.ml.find_file_structure.js +++ b/api/api/xpack.ml.find_file_structure.js @@ -119,16 +119,16 @@ function buildXpackMlFindFileStructure (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.flush_job.js b/api/api/xpack.ml.flush_job.js index 623da1fed..8adc2b00f 100644 --- a/api/api/xpack.ml.flush_job.js +++ b/api/api/xpack.ml.flush_job.js @@ -96,16 +96,16 @@ function buildXpackMlFlushJob (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.forecast.js b/api/api/xpack.ml.forecast.js index 531b2106d..80d6b9e7d 100644 --- a/api/api/xpack.ml.forecast.js +++ b/api/api/xpack.ml.forecast.js @@ -92,16 +92,16 @@ function buildXpackMlForecast (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.get_buckets.js b/api/api/xpack.ml.get_buckets.js index 1d8ba2253..d4e6da0e9 100644 --- a/api/api/xpack.ml.get_buckets.js +++ b/api/api/xpack.ml.get_buckets.js @@ -117,16 +117,16 @@ function buildXpackMlGetBuckets (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.get_calendar_events.js b/api/api/xpack.ml.get_calendar_events.js index 40081df89..b01aa18f3 100644 --- a/api/api/xpack.ml.get_calendar_events.js +++ b/api/api/xpack.ml.get_calendar_events.js @@ -101,16 +101,16 @@ function buildXpackMlGetCalendarEvents (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.get_calendars.js b/api/api/xpack.ml.get_calendars.js index 919f21101..04bec5eb2 100644 --- a/api/api/xpack.ml.get_calendars.js +++ b/api/api/xpack.ml.get_calendars.js @@ -86,16 +86,16 @@ function buildXpackMlGetCalendars (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.get_categories.js b/api/api/xpack.ml.get_categories.js index 563cf6a62..749fbb47c 100644 --- a/api/api/xpack.ml.get_categories.js +++ b/api/api/xpack.ml.get_categories.js @@ -90,16 +90,16 @@ function buildXpackMlGetCategories (opts) { path: (params['job_id'] || params['jobId']) != null ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') : '/_xpack/ml/anomaly_detectors/{job_id}/results/categories/{category_id}', - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.get_datafeed_stats.js b/api/api/xpack.ml.get_datafeed_stats.js index 6766bf1ac..496d18b75 100644 --- a/api/api/xpack.ml.get_datafeed_stats.js +++ b/api/api/xpack.ml.get_datafeed_stats.js @@ -83,16 +83,16 @@ function buildXpackMlGetDatafeedStats (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.get_datafeeds.js b/api/api/xpack.ml.get_datafeeds.js index ab5de887b..ede837077 100644 --- a/api/api/xpack.ml.get_datafeeds.js +++ b/api/api/xpack.ml.get_datafeeds.js @@ -83,16 +83,16 @@ function buildXpackMlGetDatafeeds (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.get_filters.js b/api/api/xpack.ml.get_filters.js index 054265fce..83b6d2a77 100644 --- a/api/api/xpack.ml.get_filters.js +++ b/api/api/xpack.ml.get_filters.js @@ -86,16 +86,16 @@ function buildXpackMlGetFilters (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.get_influencers.js b/api/api/xpack.ml.get_influencers.js index 7b769d0db..8c8fed39e 100644 --- a/api/api/xpack.ml.get_influencers.js +++ b/api/api/xpack.ml.get_influencers.js @@ -105,16 +105,16 @@ function buildXpackMlGetInfluencers (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.get_job_stats.js b/api/api/xpack.ml.get_job_stats.js index 62c715b19..26b9fe6a0 100644 --- a/api/api/xpack.ml.get_job_stats.js +++ b/api/api/xpack.ml.get_job_stats.js @@ -83,16 +83,16 @@ function buildXpackMlGetJobStats (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.get_jobs.js b/api/api/xpack.ml.get_jobs.js index d87a86c94..ca5598ab8 100644 --- a/api/api/xpack.ml.get_jobs.js +++ b/api/api/xpack.ml.get_jobs.js @@ -83,16 +83,16 @@ function buildXpackMlGetJobs (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.get_model_snapshots.js b/api/api/xpack.ml.get_model_snapshots.js index b17323927..f3cc57b0b 100644 --- a/api/api/xpack.ml.get_model_snapshots.js +++ b/api/api/xpack.ml.get_model_snapshots.js @@ -108,16 +108,16 @@ function buildXpackMlGetModelSnapshots (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.get_overall_buckets.js b/api/api/xpack.ml.get_overall_buckets.js index 0bc89ff55..9aa67112f 100644 --- a/api/api/xpack.ml.get_overall_buckets.js +++ b/api/api/xpack.ml.get_overall_buckets.js @@ -102,16 +102,16 @@ function buildXpackMlGetOverallBuckets (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.get_records.js b/api/api/xpack.ml.get_records.js index 8aa744819..f5e2a2b88 100644 --- a/api/api/xpack.ml.get_records.js +++ b/api/api/xpack.ml.get_records.js @@ -105,16 +105,16 @@ function buildXpackMlGetRecords (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.info.js b/api/api/xpack.ml.info.js index 444fa7cf5..cab59acec 100644 --- a/api/api/xpack.ml.info.js +++ b/api/api/xpack.ml.info.js @@ -73,16 +73,16 @@ function buildXpackMlInfo (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.open_job.js b/api/api/xpack.ml.open_job.js index db0b8662f..2b1bd7d56 100644 --- a/api/api/xpack.ml.open_job.js +++ b/api/api/xpack.ml.open_job.js @@ -90,16 +90,16 @@ function buildXpackMlOpenJob (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.post_calendar_events.js b/api/api/xpack.ml.post_calendar_events.js index eee4a7fef..742901991 100644 --- a/api/api/xpack.ml.post_calendar_events.js +++ b/api/api/xpack.ml.post_calendar_events.js @@ -89,16 +89,16 @@ function buildXpackMlPostCalendarEvents (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.post_data.js b/api/api/xpack.ml.post_data.js index b6eb4bdec..859c816e7 100644 --- a/api/api/xpack.ml.post_data.js +++ b/api/api/xpack.ml.post_data.js @@ -93,16 +93,16 @@ function buildXpackMlPostData (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.preview_datafeed.js b/api/api/xpack.ml.preview_datafeed.js index 02ad7f38e..4b13d142a 100644 --- a/api/api/xpack.ml.preview_datafeed.js +++ b/api/api/xpack.ml.preview_datafeed.js @@ -88,16 +88,16 @@ function buildXpackMlPreviewDatafeed (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.put_calendar.js b/api/api/xpack.ml.put_calendar.js index 29f97382b..eab6cc376 100644 --- a/api/api/xpack.ml.put_calendar.js +++ b/api/api/xpack.ml.put_calendar.js @@ -83,16 +83,16 @@ function buildXpackMlPutCalendar (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.put_calendar_job.js b/api/api/xpack.ml.put_calendar_job.js index c2926e228..0ea1a089e 100644 --- a/api/api/xpack.ml.put_calendar_job.js +++ b/api/api/xpack.ml.put_calendar_job.js @@ -103,16 +103,16 @@ function buildXpackMlPutCalendarJob (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.put_datafeed.js b/api/api/xpack.ml.put_datafeed.js index 4b038f079..fa011a506 100644 --- a/api/api/xpack.ml.put_datafeed.js +++ b/api/api/xpack.ml.put_datafeed.js @@ -89,16 +89,16 @@ function buildXpackMlPutDatafeed (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.put_filter.js b/api/api/xpack.ml.put_filter.js index 9486f00e8..64baba8d5 100644 --- a/api/api/xpack.ml.put_filter.js +++ b/api/api/xpack.ml.put_filter.js @@ -89,16 +89,16 @@ function buildXpackMlPutFilter (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.put_job.js b/api/api/xpack.ml.put_job.js index b0900ac56..333249a33 100644 --- a/api/api/xpack.ml.put_job.js +++ b/api/api/xpack.ml.put_job.js @@ -89,16 +89,16 @@ function buildXpackMlPutJob (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.revert_model_snapshot.js b/api/api/xpack.ml.revert_model_snapshot.js index 1a8a108d9..b04c713bf 100644 --- a/api/api/xpack.ml.revert_model_snapshot.js +++ b/api/api/xpack.ml.revert_model_snapshot.js @@ -99,16 +99,16 @@ function buildXpackMlRevertModelSnapshot (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.start_datafeed.js b/api/api/xpack.ml.start_datafeed.js index 71e4c456e..57fc53830 100644 --- a/api/api/xpack.ml.start_datafeed.js +++ b/api/api/xpack.ml.start_datafeed.js @@ -90,16 +90,16 @@ function buildXpackMlStartDatafeed (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.stop_datafeed.js b/api/api/xpack.ml.stop_datafeed.js index 49effa5bd..e0a8cd330 100644 --- a/api/api/xpack.ml.stop_datafeed.js +++ b/api/api/xpack.ml.stop_datafeed.js @@ -89,16 +89,16 @@ function buildXpackMlStopDatafeed (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.update_datafeed.js b/api/api/xpack.ml.update_datafeed.js index 217c0a928..15d6881df 100644 --- a/api/api/xpack.ml.update_datafeed.js +++ b/api/api/xpack.ml.update_datafeed.js @@ -89,16 +89,16 @@ function buildXpackMlUpdateDatafeed (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.update_filter.js b/api/api/xpack.ml.update_filter.js index 31aa277f7..21543f6c1 100644 --- a/api/api/xpack.ml.update_filter.js +++ b/api/api/xpack.ml.update_filter.js @@ -89,16 +89,16 @@ function buildXpackMlUpdateFilter (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.update_job.js b/api/api/xpack.ml.update_job.js index bd31ad2ed..d0bd8c310 100644 --- a/api/api/xpack.ml.update_job.js +++ b/api/api/xpack.ml.update_job.js @@ -89,16 +89,16 @@ function buildXpackMlUpdateJob (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.update_model_snapshot.js b/api/api/xpack.ml.update_model_snapshot.js index 7d2bcfc9c..a01271522 100644 --- a/api/api/xpack.ml.update_model_snapshot.js +++ b/api/api/xpack.ml.update_model_snapshot.js @@ -104,16 +104,16 @@ function buildXpackMlUpdateModelSnapshot (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.validate.js b/api/api/xpack.ml.validate.js index f8935900c..fe14682e2 100644 --- a/api/api/xpack.ml.validate.js +++ b/api/api/xpack.ml.validate.js @@ -82,16 +82,16 @@ function buildXpackMlValidate (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ml.validate_detector.js b/api/api/xpack.ml.validate_detector.js index 2d6bbf7b4..9a4215521 100644 --- a/api/api/xpack.ml.validate_detector.js +++ b/api/api/xpack.ml.validate_detector.js @@ -82,16 +82,16 @@ function buildXpackMlValidateDetector (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.monitoring.bulk.js b/api/api/xpack.monitoring.bulk.js index 74ea937e3..35e9dea06 100644 --- a/api/api/xpack.monitoring.bulk.js +++ b/api/api/xpack.monitoring.bulk.js @@ -90,16 +90,16 @@ function buildXpackMonitoringBulk (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.rollup.delete_job.js b/api/api/xpack.rollup.delete_job.js index 9f7a66fd0..42c6f36e1 100644 --- a/api/api/xpack.rollup.delete_job.js +++ b/api/api/xpack.rollup.delete_job.js @@ -82,16 +82,16 @@ function buildXpackRollupDeleteJob (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.rollup.get_jobs.js b/api/api/xpack.rollup.get_jobs.js index 5e9b93d08..980d5a898 100644 --- a/api/api/xpack.rollup.get_jobs.js +++ b/api/api/xpack.rollup.get_jobs.js @@ -74,16 +74,16 @@ function buildXpackRollupGetJobs (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.rollup.get_rollup_caps.js b/api/api/xpack.rollup.get_rollup_caps.js index 33edcf745..fde5b147c 100644 --- a/api/api/xpack.rollup.get_rollup_caps.js +++ b/api/api/xpack.rollup.get_rollup_caps.js @@ -74,16 +74,16 @@ function buildXpackRollupGetRollupCaps (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.rollup.get_rollup_index_caps.js b/api/api/xpack.rollup.get_rollup_index_caps.js index 9364bfd41..b7a0b5c7f 100644 --- a/api/api/xpack.rollup.get_rollup_index_caps.js +++ b/api/api/xpack.rollup.get_rollup_index_caps.js @@ -82,16 +82,16 @@ function buildXpackRollupGetRollupIndexCaps (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.rollup.put_job.js b/api/api/xpack.rollup.put_job.js index 46717e464..dc72b711e 100644 --- a/api/api/xpack.rollup.put_job.js +++ b/api/api/xpack.rollup.put_job.js @@ -89,16 +89,16 @@ function buildXpackRollupPutJob (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.rollup.rollup_search.js b/api/api/xpack.rollup.rollup_search.js index 0ac7c331b..b8667f92b 100644 --- a/api/api/xpack.rollup.rollup_search.js +++ b/api/api/xpack.rollup.rollup_search.js @@ -100,16 +100,16 @@ function buildXpackRollupRollupSearch (opts) { path: params['index'] != null && params['type'] != null ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') : '/{index}/_rollup_search', - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.rollup.start_job.js b/api/api/xpack.rollup.start_job.js index 1b9b33a83..a0b168f98 100644 --- a/api/api/xpack.rollup.start_job.js +++ b/api/api/xpack.rollup.start_job.js @@ -82,16 +82,16 @@ function buildXpackRollupStartJob (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.rollup.stop_job.js b/api/api/xpack.rollup.stop_job.js index 92d2f1b86..cfad8708a 100644 --- a/api/api/xpack.rollup.stop_job.js +++ b/api/api/xpack.rollup.stop_job.js @@ -82,16 +82,16 @@ function buildXpackRollupStopJob (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.authenticate.js b/api/api/xpack.security.authenticate.js index 62e766010..71c4439a7 100644 --- a/api/api/xpack.security.authenticate.js +++ b/api/api/xpack.security.authenticate.js @@ -81,16 +81,16 @@ function buildXpackSecurityAuthenticate (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.change_password.js b/api/api/xpack.security.change_password.js index 0ad182cc8..d67131909 100644 --- a/api/api/xpack.security.change_password.js +++ b/api/api/xpack.security.change_password.js @@ -84,16 +84,16 @@ function buildXpackSecurityChangePassword (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.clear_cached_realms.js b/api/api/xpack.security.clear_cached_realms.js index 44e65460f..b4f81bcfa 100644 --- a/api/api/xpack.security.clear_cached_realms.js +++ b/api/api/xpack.security.clear_cached_realms.js @@ -89,16 +89,16 @@ function buildXpackSecurityClearCachedRealms (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.clear_cached_roles.js b/api/api/xpack.security.clear_cached_roles.js index 05700a5db..eaf91a87d 100644 --- a/api/api/xpack.security.clear_cached_roles.js +++ b/api/api/xpack.security.clear_cached_roles.js @@ -88,16 +88,16 @@ function buildXpackSecurityClearCachedRoles (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.delete_privileges.js b/api/api/xpack.security.delete_privileges.js index ef0944f08..db0e8a974 100644 --- a/api/api/xpack.security.delete_privileges.js +++ b/api/api/xpack.security.delete_privileges.js @@ -104,16 +104,16 @@ function buildXpackSecurityDeletePrivileges (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.delete_role.js b/api/api/xpack.security.delete_role.js index 00a5f1533..b03c57aac 100644 --- a/api/api/xpack.security.delete_role.js +++ b/api/api/xpack.security.delete_role.js @@ -89,16 +89,16 @@ function buildXpackSecurityDeleteRole (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.delete_role_mapping.js b/api/api/xpack.security.delete_role_mapping.js index d1ce3fea7..6c012203b 100644 --- a/api/api/xpack.security.delete_role_mapping.js +++ b/api/api/xpack.security.delete_role_mapping.js @@ -89,16 +89,16 @@ function buildXpackSecurityDeleteRoleMapping (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.delete_user.js b/api/api/xpack.security.delete_user.js index 54960d79f..9368dcfec 100644 --- a/api/api/xpack.security.delete_user.js +++ b/api/api/xpack.security.delete_user.js @@ -89,16 +89,16 @@ function buildXpackSecurityDeleteUser (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.disable_user.js b/api/api/xpack.security.disable_user.js index 5f850ae81..571ec63a8 100644 --- a/api/api/xpack.security.disable_user.js +++ b/api/api/xpack.security.disable_user.js @@ -83,16 +83,16 @@ function buildXpackSecurityDisableUser (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.enable_user.js b/api/api/xpack.security.enable_user.js index a416332a3..a6affe02b 100644 --- a/api/api/xpack.security.enable_user.js +++ b/api/api/xpack.security.enable_user.js @@ -83,16 +83,16 @@ function buildXpackSecurityEnableUser (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.get_privileges.js b/api/api/xpack.security.get_privileges.js index 7a303c24e..683c06458 100644 --- a/api/api/xpack.security.get_privileges.js +++ b/api/api/xpack.security.get_privileges.js @@ -91,16 +91,16 @@ function buildXpackSecurityGetPrivileges (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.get_role.js b/api/api/xpack.security.get_role.js index be44eedc5..9d4ce7d5c 100644 --- a/api/api/xpack.security.get_role.js +++ b/api/api/xpack.security.get_role.js @@ -82,16 +82,16 @@ function buildXpackSecurityGetRole (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.get_role_mapping.js b/api/api/xpack.security.get_role_mapping.js index 227bbc895..101ec8783 100644 --- a/api/api/xpack.security.get_role_mapping.js +++ b/api/api/xpack.security.get_role_mapping.js @@ -82,16 +82,16 @@ function buildXpackSecurityGetRoleMapping (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.get_token.js b/api/api/xpack.security.get_token.js index 8124174c1..0f439b381 100644 --- a/api/api/xpack.security.get_token.js +++ b/api/api/xpack.security.get_token.js @@ -82,16 +82,16 @@ function buildXpackSecurityGetToken (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.get_user.js b/api/api/xpack.security.get_user.js index 264fe16df..8bc1aa65e 100644 --- a/api/api/xpack.security.get_user.js +++ b/api/api/xpack.security.get_user.js @@ -82,16 +82,16 @@ function buildXpackSecurityGetUser (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.get_user_privileges.js b/api/api/xpack.security.get_user_privileges.js index 8a4d0a380..5be01585c 100644 --- a/api/api/xpack.security.get_user_privileges.js +++ b/api/api/xpack.security.get_user_privileges.js @@ -81,16 +81,16 @@ function buildXpackSecurityGetUserPrivileges (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.has_privileges.js b/api/api/xpack.security.has_privileges.js index ec31ac697..2524dd9fe 100644 --- a/api/api/xpack.security.has_privileges.js +++ b/api/api/xpack.security.has_privileges.js @@ -83,16 +83,16 @@ function buildXpackSecurityHasPrivileges (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.invalidate_token.js b/api/api/xpack.security.invalidate_token.js index 587ff3ce3..36155e2b6 100644 --- a/api/api/xpack.security.invalidate_token.js +++ b/api/api/xpack.security.invalidate_token.js @@ -82,16 +82,16 @@ function buildXpackSecurityInvalidateToken (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.put_privileges.js b/api/api/xpack.security.put_privileges.js index abbeb79c9..94ac619b4 100644 --- a/api/api/xpack.security.put_privileges.js +++ b/api/api/xpack.security.put_privileges.js @@ -83,16 +83,16 @@ function buildXpackSecurityPutPrivileges (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.put_role.js b/api/api/xpack.security.put_role.js index 356ebcb34..3b78e8370 100644 --- a/api/api/xpack.security.put_role.js +++ b/api/api/xpack.security.put_role.js @@ -90,16 +90,16 @@ function buildXpackSecurityPutRole (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.put_role_mapping.js b/api/api/xpack.security.put_role_mapping.js index d4429ea8b..d340aaaeb 100644 --- a/api/api/xpack.security.put_role_mapping.js +++ b/api/api/xpack.security.put_role_mapping.js @@ -90,16 +90,16 @@ function buildXpackSecurityPutRoleMapping (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.security.put_user.js b/api/api/xpack.security.put_user.js index 5d219852f..7b45b427e 100644 --- a/api/api/xpack.security.put_user.js +++ b/api/api/xpack.security.put_user.js @@ -90,16 +90,16 @@ function buildXpackSecurityPutUser (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.sql.clear_cursor.js b/api/api/xpack.sql.clear_cursor.js index bb9e30704..9b299bc19 100644 --- a/api/api/xpack.sql.clear_cursor.js +++ b/api/api/xpack.sql.clear_cursor.js @@ -82,16 +82,16 @@ function buildXpackSqlClearCursor (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.sql.query.js b/api/api/xpack.sql.query.js index 2fa2028f4..1e1cb28b3 100644 --- a/api/api/xpack.sql.query.js +++ b/api/api/xpack.sql.query.js @@ -83,16 +83,16 @@ function buildXpackSqlQuery (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.sql.translate.js b/api/api/xpack.sql.translate.js index 3147f6ee9..680f037c8 100644 --- a/api/api/xpack.sql.translate.js +++ b/api/api/xpack.sql.translate.js @@ -82,16 +82,16 @@ function buildXpackSqlTranslate (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.ssl.certificates.js b/api/api/xpack.ssl.certificates.js index 1231db124..142900399 100644 --- a/api/api/xpack.ssl.certificates.js +++ b/api/api/xpack.ssl.certificates.js @@ -81,16 +81,16 @@ function buildXpackSslCertificates (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.usage.js b/api/api/xpack.usage.js index e1b187d2d..2e810ef06 100644 --- a/api/api/xpack.usage.js +++ b/api/api/xpack.usage.js @@ -82,16 +82,16 @@ function buildXpackUsage (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.watcher.ack_watch.js b/api/api/xpack.watcher.ack_watch.js index eed6d5b80..99b781b83 100644 --- a/api/api/xpack.watcher.ack_watch.js +++ b/api/api/xpack.watcher.ack_watch.js @@ -98,16 +98,16 @@ function buildXpackWatcherAckWatch (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.watcher.activate_watch.js b/api/api/xpack.watcher.activate_watch.js index 633406804..96333bdb0 100644 --- a/api/api/xpack.watcher.activate_watch.js +++ b/api/api/xpack.watcher.activate_watch.js @@ -89,16 +89,16 @@ function buildXpackWatcherActivateWatch (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.watcher.deactivate_watch.js b/api/api/xpack.watcher.deactivate_watch.js index 21b96e27e..b9d3cbaf2 100644 --- a/api/api/xpack.watcher.deactivate_watch.js +++ b/api/api/xpack.watcher.deactivate_watch.js @@ -89,16 +89,16 @@ function buildXpackWatcherDeactivateWatch (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.watcher.delete_watch.js b/api/api/xpack.watcher.delete_watch.js index 15fcf0894..92a900d88 100644 --- a/api/api/xpack.watcher.delete_watch.js +++ b/api/api/xpack.watcher.delete_watch.js @@ -89,16 +89,16 @@ function buildXpackWatcherDeleteWatch (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.watcher.execute_watch.js b/api/api/xpack.watcher.execute_watch.js index a98d7e390..10b81222e 100644 --- a/api/api/xpack.watcher.execute_watch.js +++ b/api/api/xpack.watcher.execute_watch.js @@ -76,16 +76,16 @@ function buildXpackWatcherExecuteWatch (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.watcher.get_watch.js b/api/api/xpack.watcher.get_watch.js index 53c0a4a91..dadb61d0c 100644 --- a/api/api/xpack.watcher.get_watch.js +++ b/api/api/xpack.watcher.get_watch.js @@ -88,16 +88,16 @@ function buildXpackWatcherGetWatch (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.watcher.put_watch.js b/api/api/xpack.watcher.put_watch.js index 849110e18..f1bf4956f 100644 --- a/api/api/xpack.watcher.put_watch.js +++ b/api/api/xpack.watcher.put_watch.js @@ -90,16 +90,16 @@ function buildXpackWatcherPutWatch (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: params.body || '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.watcher.restart.js b/api/api/xpack.watcher.restart.js index f8831deb0..12c1337a3 100644 --- a/api/api/xpack.watcher.restart.js +++ b/api/api/xpack.watcher.restart.js @@ -81,16 +81,16 @@ function buildXpackWatcherRestart (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.watcher.start.js b/api/api/xpack.watcher.start.js index 5f6ea3368..0232e3b46 100644 --- a/api/api/xpack.watcher.start.js +++ b/api/api/xpack.watcher.start.js @@ -81,16 +81,16 @@ function buildXpackWatcherStart (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.watcher.stats.js b/api/api/xpack.watcher.stats.js index a6e20d6b4..0b6124eb7 100644 --- a/api/api/xpack.watcher.stats.js +++ b/api/api/xpack.watcher.stats.js @@ -86,16 +86,16 @@ function buildXpackWatcherStats (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: null, - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) diff --git a/api/api/xpack.watcher.stop.js b/api/api/xpack.watcher.stop.js index b7e2a861e..18550bc80 100644 --- a/api/api/xpack.watcher.stop.js +++ b/api/api/xpack.watcher.stop.js @@ -81,16 +81,16 @@ function buildXpackWatcherStop (opts) { const request = { method, path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - querystring, body: '', - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) From 3c667d38e6ef2eed552fd7edafc14285bf508304 Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 13 Dec 2018 16:54:01 +0100 Subject: [PATCH 077/172] Handle headers as request option --- lib/Transport.d.ts | 5 +++++ lib/Transport.js | 13 +++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/Transport.d.ts b/lib/Transport.d.ts index dc935dd1c..1c682d263 100644 --- a/lib/Transport.d.ts +++ b/lib/Transport.d.ts @@ -38,11 +38,16 @@ export interface SniffMeta { reason: string; } +declare type anyObject = { + [key: string]: any; +}; + export interface RequestOptions { ignore?: number | number[]; requestTimeout?: number | string; maxRetries?: number; asStream?: boolean; + headers?: anyObject; } export default class Transport { diff --git a/lib/Transport.js b/lib/Transport.js index eec669d3f..4910654e2 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -74,7 +74,7 @@ class Transport { return callback(new NoLivingConnectionsError('There are not living connections'), result) } - params.headers = params.headers || {} + const headers = options.headers || {} // handle json body if (params.body != null) { if (shouldSerialize(params.body) === true) { @@ -84,9 +84,9 @@ class Transport { return callback(err, result) } } - params.headers['Content-Type'] = 'application/json' + headers['Content-Type'] = 'application/json' if (isStream(params.body) === false) { - params.headers['Content-Length'] = '' + Buffer.byteLength(params.body) + headers['Content-Length'] = '' + Buffer.byteLength(params.body) } // handle ndjson body } else if (params.bulkBody != null) { @@ -99,16 +99,17 @@ class Transport { } else { params.body = params.bulkBody } - params.headers['Content-Type'] = 'application/x-ndjson' + headers['Content-Type'] = 'application/x-ndjson' if (isStream(params.body) === false) { - params.headers['Content-Length'] = '' + Buffer.byteLength(params.body) + headers['Content-Length'] = '' + Buffer.byteLength(params.body) } } if (this.suggestCompression === true) { - params.headers['Accept-Encoding'] = 'gzip,deflate' + headers['Accept-Encoding'] = 'gzip,deflate' } + params.headers = headers // serializes the querystring params.querystring = this.serializer.qserialize(params.querystring) // handles request timeout From 1cda67bcdb2cb634546906f96b48d8907548be7a Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 13 Dec 2018 16:54:10 +0100 Subject: [PATCH 078/172] Updated scripts --- scripts/utils/generate.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/utils/generate.js b/scripts/utils/generate.js index 53895b120..c9be7dce2 100644 --- a/scripts/utils/generate.js +++ b/scripts/utils/generate.js @@ -136,16 +136,16 @@ function generate (spec, common) { const request = { method, ${buildPath(api)} - querystring, ${genBody(api, methods, spec[api].body)} - headers: params.headers || null + querystring } const requestOptions = { ignore, requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, - asStream: options.asStream || false + asStream: options.asStream || false, + headers: options.headers || null } return makeRequest(request, requestOptions, callback) From 7cbc887ea031abf8388c832aa007c33867c3a50b Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 13 Dec 2018 16:54:15 +0100 Subject: [PATCH 079/172] Updated test --- test/integration/test-runner.js | 2 +- test/unit/client.test.js | 65 +++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/test/integration/test-runner.js b/test/integration/test-runner.js index 4c227b366..76d0447cd 100644 --- a/test/integration/test-runner.js +++ b/test/integration/test-runner.js @@ -252,7 +252,7 @@ TestRunner.prototype.set = function (key, name) { TestRunner.prototype.do = function (action, done) { const cmd = this.parseDo(action) const api = delve(this.client, cmd.method).bind(this.client) - const options = { ignore: cmd.params.ignore } + const options = { ignore: cmd.params.ignore, headers: cmd.params.headers } api(cmd.params, options, (err, { body, warnings }) => { if (action.warnings && warnings === null) { this.tap.fail('We should get a warning header', action.warnings) diff --git a/test/unit/client.test.js b/test/unit/client.test.js index 100669d0a..703a5bcf4 100644 --- a/test/unit/client.test.js +++ b/test/unit/client.test.js @@ -191,6 +191,71 @@ test('Node with auth data in the url', t => { }) }) +test('Custom authentication per request', t => { + t.plan(6) + + var first = true + function handler (req, res) { + t.match(req.headers, { + authorization: first ? 'hello' : 'Basic Zm9vOmJhcg==' + }) + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const client = new Client({ + node: `http://foo:bar@localhost:${port}` + }) + + client.info({}, { + headers: { + authorization: 'hello' + } + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + first = false + + client.info((err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + server.stop() + }) + }) + }) +}) + +test('Custom headers per request', t => { + t.plan(3) + + function handler (req, res) { + t.match(req.headers, { + 'x-foo': 'bar', + 'x-baz': 'faz' + }) + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const client = new Client({ + node: `http://foo:bar@localhost:${port}` + }) + + client.info({}, { + headers: { + 'x-foo': 'bar', + 'x-baz': 'faz' + } + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + server.stop() + }) + }) +}) + test('Client close', t => { t.plan(2) From 32e674f26c7a6245c123dbf9d7988b13eda750fa Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 18 Dec 2018 17:28:25 +0100 Subject: [PATCH 080/172] Added protocol validation --- lib/Connection.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Connection.js b/lib/Connection.js index 678e7f1e5..b0327ab44 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -6,7 +6,7 @@ const https = require('https') const debug = require('debug')('elasticsearch') const decompressResponse = require('decompress-response') const pump = require('pump') -const { TimeoutError } = require('./errors') +const { TimeoutError, ConfigurationError } = require('./errors') class Connection { constructor (opts = {}) { @@ -21,6 +21,10 @@ class Connection { this._status = opts.status || Connection.statuses.ALIVE this.roles = opts.roles || defaultRoles + if (!['http:', 'https:'].includes(this.url.protocol)) { + throw new ConfigurationError(`Invalid protocol: '${this.url.protocol}'`) + } + const agentOptions = Object.assign({}, { keepAlive: true, keepAliveMsecs: 1000, From 7a181ff9acf5579a4ec108c50e1239bf1bb40bff Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 18 Dec 2018 17:29:06 +0100 Subject: [PATCH 081/172] Updated test --- test/integration/test-runner.js | 2 +- test/unit/connection.test.js | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/test/integration/test-runner.js b/test/integration/test-runner.js index 76d0447cd..144310659 100644 --- a/test/integration/test-runner.js +++ b/test/integration/test-runner.js @@ -252,7 +252,7 @@ TestRunner.prototype.set = function (key, name) { TestRunner.prototype.do = function (action, done) { const cmd = this.parseDo(action) const api = delve(this.client, cmd.method).bind(this.client) - const options = { ignore: cmd.params.ignore, headers: cmd.params.headers } + const options = { ignore: cmd.params.ignore, headers: action.headers } api(cmd.params, options, (err, { body, warnings }) => { if (action.warnings && warnings === null) { this.tap.fail('We should get a warning header', action.warnings) diff --git a/test/unit/connection.test.js b/test/unit/connection.test.js index 07eccf053..98a3fe940 100644 --- a/test/unit/connection.test.js +++ b/test/unit/connection.test.js @@ -6,7 +6,7 @@ const { URL } = require('url') const intoStream = require('into-stream') const { buildServer } = require('../utils') const Connection = require('../../lib/Connection') -const { TimeoutError } = require('../../lib/errors') +const { TimeoutError, ConfigurationError } = require('../../lib/errors') test('Basic (http)', t => { t.plan(4) @@ -560,3 +560,16 @@ test('Connection id should not contain credentials', t => { t.strictEqual(connection.id, 'http://localhost:9200/') t.end() }) + +test('Should throw if the protocol is not http or https', t => { + try { + new Connection({ // eslint-disable-line + url: new URL('nope://nope') + }) + t.fail('Should throw') + } catch (err) { + t.ok(err instanceof ConfigurationError) + t.is(err.message, 'Invalid protocol: \'nope:\'') + } + t.end() +}) From fc6d12ad3ecabed0eaed701a28f81fe42315b14e Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 19 Dec 2018 19:49:29 +0100 Subject: [PATCH 082/172] Updated closing logic --- index.js | 5 +++-- lib/Connection.js | 5 +++-- lib/ConnectionPool.js | 16 ++++++++++------ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index a889aa2f6..8e0946566 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,7 @@ 'use strict' const { EventEmitter } = require('events') +const debug = require('debug')('elasticsearch') const Transport = require('./lib/Transport') const Connection = require('./lib/Connection') const ConnectionPool = require('./lib/ConnectionPool') @@ -92,8 +93,8 @@ class Client extends EventEmitter { this.close(resolve) }) } - this.connectionPool.empty() - callback() + debug('Closing the client') + this.connectionPool.empty(callback) } } diff --git a/lib/Connection.js b/lib/Connection.js index b0327ab44..11b6e1577 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -110,12 +110,13 @@ class Connection { } // TODO: write a better closing logic - close () { + close (callback = () => {}) { debug('Closing connection', this.id) if (this._openRequests > 0) { - setTimeout(() => this.close(), 1000) + setTimeout(() => this.close(callback), 1000) } else { this._agent.destroy() + callback() } } diff --git a/lib/ConnectionPool.js b/lib/ConnectionPool.js index 40d6f48cf..43c678dda 100644 --- a/lib/ConnectionPool.js +++ b/lib/ConnectionPool.js @@ -220,7 +220,7 @@ class ConnectionPool { */ removeConnection (connection) { debug('Removing connection', connection) - connection.close() + connection.close(noop) const { id } = connection this.connections.delete(id) var index = this.dead.indexOf(id) @@ -233,14 +233,18 @@ class ConnectionPool { * * @returns {ConnectionPool} */ - empty () { + empty (callback) { debug('Emptying the connection pool') + var openConnections = this.connections.size this.connections.forEach(connection => { - connection.close() + connection.close(() => { + if (--openConnections === 0) { + this.connections = new Map() + this.dead = [] + callback() + } + }) }) - this.connections = new Map() - this.dead = [] - return this } /** From dd9ce3407953c02c7b356bb2139295119e697662 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 19 Dec 2018 19:49:40 +0100 Subject: [PATCH 083/172] Updated test --- test/unit/client.test.js | 8 ++++---- test/unit/connection-pool.test.js | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/test/unit/client.test.js b/test/unit/client.test.js index 703a5bcf4..49a71e3fe 100644 --- a/test/unit/client.test.js +++ b/test/unit/client.test.js @@ -260,9 +260,9 @@ test('Client close', t => { t.plan(2) class MyConnectionPool extends ConnectionPool { - empty () { + empty (callback) { t.ok('called') - super.empty() + super.empty(callback) } } @@ -278,9 +278,9 @@ test('Client close (promise)', t => { t.plan(2) class MyConnectionPool extends ConnectionPool { - empty () { + empty (callback) { t.ok('called') - super.empty() + super.empty(callback) } } diff --git a/test/unit/connection-pool.test.js b/test/unit/connection-pool.test.js index 69cd3da00..37a9d3af2 100644 --- a/test/unit/connection-pool.test.js +++ b/test/unit/connection-pool.test.js @@ -240,10 +240,11 @@ test('API', t => { const pool = new ConnectionPool({ Connection }) pool.addConnection('http://localhost:9200/') pool.addConnection('http://localhost:9201/') - pool.empty() - t.strictEqual(pool.connections.size, 0) - t.deepEqual(pool.dead, []) - t.end() + pool.empty(() => { + t.strictEqual(pool.connections.size, 0) + t.deepEqual(pool.dead, []) + t.end() + }) }) t.test('urlToHost', t => { From 41109f0bc06d66880ef572903e750d8b16d0d4bb Mon Sep 17 00:00:00 2001 From: Jonah Bull Date: Fri, 21 Dec 2018 12:14:41 -0600 Subject: [PATCH 084/172] Add JJBB jobs to .ci (#749) This adds the Jenkins jobs definitions to the repo so they can be managed and updated here. --- .ci/jobs/defaults.yml | 64 +++++++++++++++++++ .ci/jobs/elastic+elasticsearch-js+master.yml | 14 ++++ .ci/jobs/elastic+elasticsearch-js+next.yml | 11 ++++ .../elastic+elasticsearch-js+pull-request.yml | 19 ++++++ 4 files changed, 108 insertions(+) create mode 100644 .ci/jobs/defaults.yml create mode 100644 .ci/jobs/elastic+elasticsearch-js+master.yml create mode 100644 .ci/jobs/elastic+elasticsearch-js+next.yml create mode 100644 .ci/jobs/elastic+elasticsearch-js+pull-request.yml diff --git a/.ci/jobs/defaults.yml b/.ci/jobs/defaults.yml new file mode 100644 index 000000000..3df606402 --- /dev/null +++ b/.ci/jobs/defaults.yml @@ -0,0 +1,64 @@ +--- + +##### GLOBAL METADATA + +- meta: + cluster: clients-ci + +##### JOB DEFAULTS + +- job: + project-type: matrix + logrotate: + daysToKeep: 30 + numToKeep: 100 + properties: + - github: + url: https://github.com/elastic/elasticsearch-js/ + - inject: + properties-content: HOME=$JENKINS_HOME + concurrent: true + node: flyweight + scm: + - git: + name: origin + credentials-id: f6c7695a-671e-4f4f-a331-acdce44ff9ba + reference-repo: /var/lib/jenkins/.git-references/elasticsearch-js.git + branches: + - ${branch_specifier} + url: https://github.com/elastic/elasticsearch-js.git + wipe-workspace: 'True' + triggers: + - github + axes: + - axis: + type: slave + name: label + values: + - linux + - axis: + type: yaml + filename: .ci/test-matrix.yml + name: ELASTICSEARCH_VERSION + - axis: + type: yaml + filename: .ci/test-matrix.yml + name: NODE_JS_VERSION + yaml-strategy: + exclude-key: exclude + filename: .ci/test-matrix.yml + wrappers: + - ansicolor + - timeout: + type: absolute + timeout: 120 + fail: true + - timestamps + - workspace-cleanup + builders: + - shell: |- + #!/usr/local/bin/runbld + .ci/run-tests + publishers: + - email: + recipients: infra-root+build@elastic.co diff --git a/.ci/jobs/elastic+elasticsearch-js+master.yml b/.ci/jobs/elastic+elasticsearch-js+master.yml new file mode 100644 index 000000000..284d30f55 --- /dev/null +++ b/.ci/jobs/elastic+elasticsearch-js+master.yml @@ -0,0 +1,14 @@ +--- +- job: + name: elastic+elasticsearch-js+master + display-name: 'elastic / elasticsearch-js # master' + description: Testing the elasticsearch-js master branch. + parameters: + - string: + name: branch_specifier + default: refs/heads/master + description: the Git branch specifier to build (<branchName>, <tagName>, + <commitId>, etc.) + triggers: + - github + - timed: '@daily' diff --git a/.ci/jobs/elastic+elasticsearch-js+next.yml b/.ci/jobs/elastic+elasticsearch-js+next.yml new file mode 100644 index 000000000..333102322 --- /dev/null +++ b/.ci/jobs/elastic+elasticsearch-js+next.yml @@ -0,0 +1,11 @@ +--- +- job: + name: elastic+elasticsearch-js+next + display-name: 'elastic / elasticsearch-js # next' + description: Testing the elasticsearch-js next branch. + parameters: + - string: + name: branch_specifier + default: refs/heads/next + description: the Git branch specifier to build (<branchName>, <tagName>, + <commitId>, etc.) diff --git a/.ci/jobs/elastic+elasticsearch-js+pull-request.yml b/.ci/jobs/elastic+elasticsearch-js+pull-request.yml new file mode 100644 index 000000000..78cde9ecc --- /dev/null +++ b/.ci/jobs/elastic+elasticsearch-js+pull-request.yml @@ -0,0 +1,19 @@ +--- +- job: + name: elastic+elasticsearch-js+pull-request + display-name: 'elastic / elasticsearch-js # pull-request' + description: Testing of elasticsearch-js pull requests. + scm: + - git: + branches: + - ${ghprbActualCommit} + refspec: +refs/pull/*:refs/remotes/origin/pr/* + triggers: + - github-pull-request: + org-list: + - elastic + allow-whitelist-orgs-as-admins: true + github-hooks: true + status-context: clients-ci + cancel-builds-on-update: true + publishers: [] From f56ae1a70d682844e5c1a372bb8928e1b7463ebf Mon Sep 17 00:00:00 2001 From: Tomas Della Vedova Date: Fri, 11 Jan 2019 14:08:49 +0100 Subject: [PATCH 085/172] Request parameters typings (#748) --- api/requestParams.d.ts | 1895 +++++++++++++++++++++++++ index.d.ts | 850 +++++------ scripts/run.js | 11 +- scripts/utils/genMain.js | 9 +- scripts/utils/generateRequestTypes.js | 71 + scripts/utils/index.js | 3 +- 6 files changed, 2411 insertions(+), 428 deletions(-) create mode 100644 api/requestParams.d.ts create mode 100644 scripts/utils/generateRequestTypes.js diff --git a/api/requestParams.d.ts b/api/requestParams.d.ts new file mode 100644 index 000000000..8277562fe --- /dev/null +++ b/api/requestParams.d.ts @@ -0,0 +1,1895 @@ +export interface Generic { + method?: string; + ignore?: number | number[]; + filter_path?: string | string[]; + pretty?: boolean; + human?: boolean; + error_trace?: boolean; + source?: string; +} + +export interface Bulk extends Generic { + index?: string; + type?: string; + wait_for_active_shards?: string; + refresh?: 'true' | 'false' | 'wait_for'; + routing?: string; + timeout?: string; + fields?: string | string[]; + _source?: string | string[]; + _source_exclude?: string | string[]; + _source_include?: string | string[]; + pipeline?: string; + body: any; +} + +export interface CatAliases extends Generic { + name?: string | string[]; + format?: string; + local?: boolean; + master_timeout?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + v?: boolean; +} + +export interface CatAllocation extends Generic { + node_id?: string | string[]; + format?: string; + bytes?: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb'; + local?: boolean; + master_timeout?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + v?: boolean; +} + +export interface CatCount extends Generic { + index?: string | string[]; + format?: string; + local?: boolean; + master_timeout?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + v?: boolean; +} + +export interface CatFielddata extends Generic { + fields?: string | string[]; + format?: string; + bytes?: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb'; + local?: boolean; + master_timeout?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + v?: boolean; +} + +export interface CatHealth extends Generic { + format?: string; + local?: boolean; + master_timeout?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + ts?: boolean; + v?: boolean; +} + +export interface CatHelp extends Generic { + help?: boolean; + s?: string | string[]; +} + +export interface CatIndices extends Generic { + index?: string | string[]; + format?: string; + bytes?: 'b' | 'k' | 'm' | 'g'; + local?: boolean; + master_timeout?: string; + h?: string | string[]; + health?: 'green' | 'yellow' | 'red'; + help?: boolean; + pri?: boolean; + s?: string | string[]; + v?: boolean; +} + +export interface CatMaster extends Generic { + format?: string; + local?: boolean; + master_timeout?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + v?: boolean; +} + +export interface CatNodeattrs extends Generic { + format?: string; + local?: boolean; + master_timeout?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + v?: boolean; +} + +export interface CatNodes extends Generic { + format?: string; + full_id?: boolean; + local?: boolean; + master_timeout?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + v?: boolean; +} + +export interface CatPendingTasks extends Generic { + format?: string; + local?: boolean; + master_timeout?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + v?: boolean; +} + +export interface CatPlugins extends Generic { + format?: string; + local?: boolean; + master_timeout?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + v?: boolean; +} + +export interface CatRecovery extends Generic { + index?: string | string[]; + format?: string; + bytes?: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb'; + master_timeout?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + v?: boolean; +} + +export interface CatRepositories extends Generic { + format?: string; + local?: boolean; + master_timeout?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + v?: boolean; +} + +export interface CatSegments extends Generic { + index?: string | string[]; + format?: string; + bytes?: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb'; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + v?: boolean; +} + +export interface CatShards extends Generic { + index?: string | string[]; + format?: string; + bytes?: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb'; + local?: boolean; + master_timeout?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + v?: boolean; +} + +export interface CatSnapshots extends Generic { + repository?: string | string[]; + format?: string; + ignore_unavailable?: boolean; + master_timeout?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + v?: boolean; +} + +export interface CatTasks extends Generic { + format?: string; + node_id?: string | string[]; + actions?: string | string[]; + detailed?: boolean; + parent_task?: number; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + v?: boolean; +} + +export interface CatTemplates extends Generic { + name?: string; + format?: string; + local?: boolean; + master_timeout?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + v?: boolean; +} + +export interface CatThreadPool extends Generic { + thread_pool_patterns?: string | string[]; + format?: string; + size?: '' | 'k' | 'm' | 'g' | 't' | 'p'; + local?: boolean; + master_timeout?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + v?: boolean; +} + +export interface ClearScroll extends Generic { + scroll_id?: string | string[]; + body?: any; +} + +export interface ClusterAllocationExplain extends Generic { + include_yes_decisions?: boolean; + include_disk_info?: boolean; + body?: any; +} + +export interface ClusterGetSettings extends Generic { + flat_settings?: boolean; + master_timeout?: string; + timeout?: string; + include_defaults?: boolean; +} + +export interface ClusterHealth extends Generic { + index?: string | string[]; + level?: 'cluster' | 'indices' | 'shards'; + local?: boolean; + master_timeout?: string; + timeout?: string; + wait_for_active_shards?: string; + wait_for_nodes?: string; + wait_for_events?: 'immediate' | 'urgent' | 'high' | 'normal' | 'low' | 'languid'; + wait_for_no_relocating_shards?: boolean; + wait_for_no_initializing_shards?: boolean; + wait_for_status?: 'green' | 'yellow' | 'red'; +} + +export interface ClusterPendingTasks extends Generic { + local?: boolean; + master_timeout?: string; +} + +export interface ClusterPutSettings extends Generic { + flat_settings?: boolean; + master_timeout?: string; + timeout?: string; + body: any; +} + +export interface ClusterRemoteInfo extends Generic { +} + +export interface ClusterReroute extends Generic { + dry_run?: boolean; + explain?: boolean; + retry_failed?: boolean; + metric?: string | string[]; + master_timeout?: string; + timeout?: string; + body?: any; +} + +export interface ClusterState extends Generic { + index?: string | string[]; + metric?: string | string[]; + local?: boolean; + master_timeout?: string; + flat_settings?: boolean; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; +} + +export interface ClusterStats extends Generic { + node_id?: string | string[]; + flat_settings?: boolean; + timeout?: string; +} + +export interface Count extends Generic { + index?: string | string[]; + type?: string | string[]; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + min_score?: number; + preference?: string; + routing?: string | string[]; + q?: string; + analyzer?: string; + analyze_wildcard?: boolean; + default_operator?: 'AND' | 'OR'; + df?: string; + lenient?: boolean; + terminate_after?: number; + body?: any; +} + +export interface Create extends Generic { + id: string; + index: string; + type: string; + wait_for_active_shards?: string; + parent?: string; + refresh?: 'true' | 'false' | 'wait_for'; + routing?: string; + timeout?: string; + version?: number; + version_type?: 'internal' | 'external' | 'external_gte' | 'force'; + pipeline?: string; + body: any; +} + +export interface Delete extends Generic { + id: string; + index: string; + type: string; + wait_for_active_shards?: string; + parent?: string; + refresh?: 'true' | 'false' | 'wait_for'; + routing?: string; + timeout?: string; + version?: number; + version_type?: 'internal' | 'external' | 'external_gte' | 'force'; +} + +export interface DeleteByQuery extends Generic { + index: string | string[]; + type?: string | string[]; + analyzer?: string; + analyze_wildcard?: boolean; + default_operator?: 'AND' | 'OR'; + df?: string; + from?: number; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + conflicts?: 'abort' | 'proceed'; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + lenient?: boolean; + preference?: string; + q?: string; + routing?: string | string[]; + scroll?: string; + search_type?: 'query_then_fetch' | 'dfs_query_then_fetch'; + search_timeout?: string; + size?: number; + sort?: string | string[]; + _source?: string | string[]; + _source_exclude?: string | string[]; + _source_include?: string | string[]; + terminate_after?: number; + stats?: string | string[]; + version?: boolean; + request_cache?: boolean; + refresh?: boolean; + timeout?: string; + wait_for_active_shards?: string; + scroll_size?: number; + wait_for_completion?: boolean; + requests_per_second?: number; + slices?: number; + body: any; +} + +export interface DeleteByQueryRethrottle extends Generic { + task_id: string; + requests_per_second: number; +} + +export interface DeleteScript extends Generic { + id: string; + timeout?: string; + master_timeout?: string; +} + +export interface Exists extends Generic { + id: string; + index: string; + type: string; + stored_fields?: string | string[]; + parent?: string; + preference?: string; + realtime?: boolean; + refresh?: boolean; + routing?: string; + _source?: string | string[]; + _source_exclude?: string | string[]; + _source_include?: string | string[]; + version?: number; + version_type?: 'internal' | 'external' | 'external_gte' | 'force'; +} + +export interface ExistsSource extends Generic { + id: string; + index: string; + type: string; + parent?: string; + preference?: string; + realtime?: boolean; + refresh?: boolean; + routing?: string; + _source?: string | string[]; + _source_exclude?: string | string[]; + _source_include?: string | string[]; + version?: number; + version_type?: 'internal' | 'external' | 'external_gte' | 'force'; +} + +export interface Explain extends Generic { + id: string; + index: string; + type: string; + analyze_wildcard?: boolean; + analyzer?: string; + default_operator?: 'AND' | 'OR'; + df?: string; + stored_fields?: string | string[]; + lenient?: boolean; + parent?: string; + preference?: string; + q?: string; + routing?: string; + _source?: string | string[]; + _source_exclude?: string | string[]; + _source_include?: string | string[]; + body?: any; +} + +export interface FieldCaps extends Generic { + index?: string | string[]; + fields?: string | string[]; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + body?: any; +} + +export interface Get extends Generic { + id: string; + index: string; + type: string; + stored_fields?: string | string[]; + parent?: string; + preference?: string; + realtime?: boolean; + refresh?: boolean; + routing?: string; + _source?: string | string[]; + _source_exclude?: string | string[]; + _source_include?: string | string[]; + version?: number; + version_type?: 'internal' | 'external' | 'external_gte' | 'force'; +} + +export interface GetScript extends Generic { + id: string; + master_timeout?: string; +} + +export interface GetSource extends Generic { + id: string; + index: string; + type: string; + parent?: string; + preference?: string; + realtime?: boolean; + refresh?: boolean; + routing?: string; + _source?: string | string[]; + _source_exclude?: string | string[]; + _source_include?: string | string[]; + version?: number; + version_type?: 'internal' | 'external' | 'external_gte' | 'force'; +} + +export interface Index extends Generic { + id?: string; + index: string; + type: string; + wait_for_active_shards?: string; + op_type?: 'index' | 'create'; + parent?: string; + refresh?: 'true' | 'false' | 'wait_for'; + routing?: string; + timeout?: string; + version?: number; + version_type?: 'internal' | 'external' | 'external_gte' | 'force'; + pipeline?: string; + body: any; +} + +export interface IndicesAnalyze extends Generic { + index?: string; + body?: any; +} + +export interface IndicesClearCache extends Generic { + index?: string | string[]; + field_data?: boolean; + fielddata?: boolean; + fields?: string | string[]; + query?: boolean; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + request_cache?: boolean; + request?: boolean; +} + +export interface IndicesClose extends Generic { + index: string | string[]; + timeout?: string; + master_timeout?: string; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; +} + +export interface IndicesCreate extends Generic { + index: string; + wait_for_active_shards?: string; + timeout?: string; + master_timeout?: string; + update_all_types?: boolean; + body?: any; +} + +export interface IndicesDelete extends Generic { + index: string | string[]; + timeout?: string; + master_timeout?: string; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; +} + +export interface IndicesDeleteAlias extends Generic { + index: string | string[]; + name: string | string[]; + timeout?: string; + master_timeout?: string; +} + +export interface IndicesDeleteTemplate extends Generic { + name: string; + timeout?: string; + master_timeout?: string; +} + +export interface IndicesExists extends Generic { + index: string | string[]; + local?: boolean; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + flat_settings?: boolean; + include_defaults?: boolean; +} + +export interface IndicesExistsAlias extends Generic { + index?: string | string[]; + name: string | string[]; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + local?: boolean; +} + +export interface IndicesExistsTemplate extends Generic { + name: string | string[]; + flat_settings?: boolean; + master_timeout?: string; + local?: boolean; +} + +export interface IndicesExistsType extends Generic { + index: string | string[]; + type: string | string[]; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + local?: boolean; +} + +export interface IndicesFlush extends Generic { + index?: string | string[]; + force?: boolean; + wait_if_ongoing?: boolean; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; +} + +export interface IndicesFlushSynced extends Generic { + index?: string | string[]; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; +} + +export interface IndicesForcemerge extends Generic { + index?: string | string[]; + flush?: boolean; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + max_num_segments?: number; + only_expunge_deletes?: boolean; +} + +export interface IndicesGet extends Generic { + index: string | string[]; + local?: boolean; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + flat_settings?: boolean; + include_defaults?: boolean; + master_timeout?: string; +} + +export interface IndicesGetAlias extends Generic { + index?: string | string[]; + name?: string | string[]; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + local?: boolean; +} + +export interface IndicesGetFieldMapping extends Generic { + index?: string | string[]; + type?: string | string[]; + fields: string | string[]; + include_defaults?: boolean; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + local?: boolean; +} + +export interface IndicesGetMapping extends Generic { + index?: string | string[]; + type?: string | string[]; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + master_timeout?: string; + local?: boolean; +} + +export interface IndicesGetSettings extends Generic { + index?: string | string[]; + name?: string | string[]; + master_timeout?: string; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + flat_settings?: boolean; + local?: boolean; + include_defaults?: boolean; +} + +export interface IndicesGetTemplate extends Generic { + name?: string | string[]; + flat_settings?: boolean; + master_timeout?: string; + local?: boolean; +} + +export interface IndicesGetUpgrade extends Generic { + index?: string | string[]; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; +} + +export interface IndicesOpen extends Generic { + index: string | string[]; + timeout?: string; + master_timeout?: string; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + wait_for_active_shards?: string; +} + +export interface IndicesPutAlias extends Generic { + index: string | string[]; + name: string; + timeout?: string; + master_timeout?: string; + body?: any; +} + +export interface IndicesPutMapping extends Generic { + index?: string | string[]; + type: string; + timeout?: string; + master_timeout?: string; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + update_all_types?: boolean; + body: any; +} + +export interface IndicesPutSettings extends Generic { + index?: string | string[]; + master_timeout?: string; + timeout?: string; + preserve_existing?: boolean; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + flat_settings?: boolean; + body: any; +} + +export interface IndicesPutTemplate extends Generic { + name: string; + order?: number; + create?: boolean; + timeout?: string; + master_timeout?: string; + flat_settings?: boolean; + body: any; +} + +export interface IndicesRecovery extends Generic { + index?: string | string[]; + detailed?: boolean; + active_only?: boolean; +} + +export interface IndicesRefresh extends Generic { + index?: string | string[]; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; +} + +export interface IndicesRollover extends Generic { + alias: string; + new_index?: string; + timeout?: string; + dry_run?: boolean; + master_timeout?: string; + wait_for_active_shards?: string; + body?: any; +} + +export interface IndicesSegments extends Generic { + index?: string | string[]; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + verbose?: boolean; +} + +export interface IndicesShardStores extends Generic { + index?: string | string[]; + status?: string | string[]; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; +} + +export interface IndicesShrink extends Generic { + index: string; + target: string; + copy_settings?: boolean; + timeout?: string; + master_timeout?: string; + wait_for_active_shards?: string; + body?: any; +} + +export interface IndicesSplit extends Generic { + index: string; + target: string; + copy_settings?: boolean; + timeout?: string; + master_timeout?: string; + wait_for_active_shards?: string; + body?: any; +} + +export interface IndicesStats extends Generic { + index?: string | string[]; + metric?: string | string[]; + completion_fields?: string | string[]; + fielddata_fields?: string | string[]; + fields?: string | string[]; + groups?: string | string[]; + level?: 'cluster' | 'indices' | 'shards'; + types?: string | string[]; + include_segment_file_sizes?: boolean; +} + +export interface IndicesUpdateAliases extends Generic { + timeout?: string; + master_timeout?: string; + body: any; +} + +export interface IndicesUpgrade extends Generic { + index?: string | string[]; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + ignore_unavailable?: boolean; + wait_for_completion?: boolean; + only_ancient_segments?: boolean; +} + +export interface IndicesValidateQuery extends Generic { + index?: string | string[]; + type?: string | string[]; + explain?: boolean; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + q?: string; + analyzer?: string; + analyze_wildcard?: boolean; + default_operator?: 'AND' | 'OR'; + df?: string; + lenient?: boolean; + rewrite?: boolean; + all_shards?: boolean; + body?: any; +} + +export interface Info extends Generic { +} + +export interface IngestDeletePipeline extends Generic { + id: string; + master_timeout?: string; + timeout?: string; +} + +export interface IngestGetPipeline extends Generic { + id?: string; + master_timeout?: string; +} + +export interface IngestProcessorGrok extends Generic { +} + +export interface IngestPutPipeline extends Generic { + id: string; + master_timeout?: string; + timeout?: string; + body: any; +} + +export interface IngestSimulate extends Generic { + id?: string; + verbose?: boolean; + body: any; +} + +export interface Mget extends Generic { + index?: string; + type?: string; + stored_fields?: string | string[]; + preference?: string; + realtime?: boolean; + refresh?: boolean; + routing?: string; + _source?: string | string[]; + _source_exclude?: string | string[]; + _source_include?: string | string[]; + body: any; +} + +export interface Msearch extends Generic { + index?: string | string[]; + type?: string | string[]; + search_type?: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch'; + max_concurrent_searches?: number; + typed_keys?: boolean; + pre_filter_shard_size?: number; + max_concurrent_shard_requests?: number; + body: any; +} + +export interface MsearchTemplate extends Generic { + index?: string | string[]; + type?: string | string[]; + search_type?: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch'; + typed_keys?: boolean; + max_concurrent_searches?: number; + body: any; +} + +export interface Mtermvectors extends Generic { + index?: string; + type?: string; + ids?: string | string[]; + term_statistics?: boolean; + field_statistics?: boolean; + fields?: string | string[]; + offsets?: boolean; + positions?: boolean; + payloads?: boolean; + preference?: string; + routing?: string; + parent?: string; + realtime?: boolean; + version?: number; + version_type?: 'internal' | 'external' | 'external_gte' | 'force'; + body?: any; +} + +export interface NodesHotThreads extends Generic { + node_id?: string | string[]; + interval?: string; + snapshots?: number; + threads?: number; + ignore_idle_threads?: boolean; + type?: 'cpu' | 'wait' | 'block'; + timeout?: string; +} + +export interface NodesInfo extends Generic { + node_id?: string | string[]; + metric?: string | string[]; + flat_settings?: boolean; + timeout?: string; +} + +export interface NodesReloadSecureSettings extends Generic { + node_id?: string | string[]; + timeout?: string; +} + +export interface NodesStats extends Generic { + metric?: string | string[]; + index_metric?: string | string[]; + node_id?: string | string[]; + completion_fields?: string | string[]; + fielddata_fields?: string | string[]; + fields?: string | string[]; + groups?: boolean; + level?: 'indices' | 'node' | 'shards'; + types?: string | string[]; + timeout?: string; + include_segment_file_sizes?: boolean; +} + +export interface NodesUsage extends Generic { + metric?: string | string[]; + node_id?: string | string[]; + timeout?: string; +} + +export interface Ping extends Generic { +} + +export interface PutScript extends Generic { + id: string; + context?: string; + timeout?: string; + master_timeout?: string; + body: any; +} + +export interface RankEval extends Generic { + index?: string | string[]; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + body: any; +} + +export interface Reindex extends Generic { + refresh?: boolean; + timeout?: string; + wait_for_active_shards?: string; + wait_for_completion?: boolean; + requests_per_second?: number; + slices?: number; + body: any; +} + +export interface ReindexRethrottle extends Generic { + task_id: string; + requests_per_second: number; +} + +export interface RenderSearchTemplate extends Generic { + id?: string; + body?: any; +} + +export interface ScriptsPainlessExecute extends Generic { + body?: any; +} + +export interface Scroll extends Generic { + scroll_id?: string; + scroll?: string; + body?: any; +} + +export interface Search extends Generic { + index?: string | string[]; + type?: string | string[]; + analyzer?: string; + analyze_wildcard?: boolean; + default_operator?: 'AND' | 'OR'; + df?: string; + explain?: boolean; + stored_fields?: string | string[]; + docvalue_fields?: string | string[]; + from?: number; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + lenient?: boolean; + preference?: string; + q?: string; + routing?: string | string[]; + scroll?: string; + search_type?: 'query_then_fetch' | 'dfs_query_then_fetch'; + size?: number; + sort?: string | string[]; + _source?: string | string[]; + _source_exclude?: string | string[]; + _source_include?: string | string[]; + terminate_after?: number; + stats?: string | string[]; + suggest_field?: string; + suggest_mode?: 'missing' | 'popular' | 'always'; + suggest_size?: number; + suggest_text?: string; + timeout?: string; + track_scores?: boolean; + track_total_hits?: boolean; + allow_partial_search_results?: boolean; + typed_keys?: boolean; + version?: boolean; + request_cache?: boolean; + batched_reduce_size?: number; + max_concurrent_shard_requests?: number; + pre_filter_shard_size?: number; + body?: any; +} + +export interface SearchShards extends Generic { + index?: string | string[]; + preference?: string; + routing?: string; + local?: boolean; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; +} + +export interface SearchTemplate extends Generic { + index?: string | string[]; + type?: string | string[]; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + preference?: string; + routing?: string | string[]; + scroll?: string; + search_type?: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch'; + explain?: boolean; + profile?: boolean; + typed_keys?: boolean; + body: any; +} + +export interface SnapshotCreate extends Generic { + repository: string; + snapshot: string; + master_timeout?: string; + wait_for_completion?: boolean; + body?: any; +} + +export interface SnapshotCreateRepository extends Generic { + repository: string; + master_timeout?: string; + timeout?: string; + verify?: boolean; + body: any; +} + +export interface SnapshotDelete extends Generic { + repository: string; + snapshot: string; + master_timeout?: string; +} + +export interface SnapshotDeleteRepository extends Generic { + repository: string | string[]; + master_timeout?: string; + timeout?: string; +} + +export interface SnapshotGet extends Generic { + repository: string; + snapshot: string | string[]; + master_timeout?: string; + ignore_unavailable?: boolean; + verbose?: boolean; +} + +export interface SnapshotGetRepository extends Generic { + repository?: string | string[]; + master_timeout?: string; + local?: boolean; +} + +export interface SnapshotRestore extends Generic { + repository: string; + snapshot: string; + master_timeout?: string; + wait_for_completion?: boolean; + body?: any; +} + +export interface SnapshotStatus extends Generic { + repository?: string; + snapshot?: string | string[]; + master_timeout?: string; + ignore_unavailable?: boolean; +} + +export interface SnapshotVerifyRepository extends Generic { + repository: string; + master_timeout?: string; + timeout?: string; +} + +export interface TasksCancel extends Generic { + task_id?: string; + nodes?: string | string[]; + actions?: string | string[]; + parent_task_id?: string; +} + +export interface TasksGet extends Generic { + task_id: string; + wait_for_completion?: boolean; + timeout?: string; +} + +export interface TasksList extends Generic { + nodes?: string | string[]; + actions?: string | string[]; + detailed?: boolean; + parent_task_id?: string; + wait_for_completion?: boolean; + group_by?: 'nodes' | 'parents' | 'none'; + timeout?: string; +} + +export interface Termvectors extends Generic { + index: string; + type: string; + id?: string; + term_statistics?: boolean; + field_statistics?: boolean; + fields?: string | string[]; + offsets?: boolean; + positions?: boolean; + payloads?: boolean; + preference?: string; + routing?: string; + parent?: string; + realtime?: boolean; + version?: number; + version_type?: 'internal' | 'external' | 'external_gte' | 'force'; + body?: any; +} + +export interface Update extends Generic { + id: string; + index: string; + type: string; + wait_for_active_shards?: string; + fields?: string | string[]; + _source?: string | string[]; + _source_exclude?: string | string[]; + _source_include?: string | string[]; + lang?: string; + parent?: string; + refresh?: 'true' | 'false' | 'wait_for'; + retry_on_conflict?: number; + routing?: string; + timeout?: string; + version?: number; + version_type?: 'internal' | 'force'; + body: any; +} + +export interface UpdateByQuery extends Generic { + index: string | string[]; + type?: string | string[]; + analyzer?: string; + analyze_wildcard?: boolean; + default_operator?: 'AND' | 'OR'; + df?: string; + from?: number; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + conflicts?: 'abort' | 'proceed'; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + lenient?: boolean; + pipeline?: string; + preference?: string; + q?: string; + routing?: string | string[]; + scroll?: string; + search_type?: 'query_then_fetch' | 'dfs_query_then_fetch'; + search_timeout?: string; + size?: number; + sort?: string | string[]; + _source?: string | string[]; + _source_exclude?: string | string[]; + _source_include?: string | string[]; + terminate_after?: number; + stats?: string | string[]; + version?: boolean; + version_type?: boolean; + request_cache?: boolean; + refresh?: boolean; + timeout?: string; + wait_for_active_shards?: string; + scroll_size?: number; + wait_for_completion?: boolean; + requests_per_second?: number; + slices?: number; + body?: any; +} + +export interface UpdateByQueryRethrottle extends Generic { + task_id: string; + requests_per_second: number; +} + +export interface CcrDeleteAutoFollowPattern extends Generic { + name: string; +} + +export interface CcrFollow extends Generic { + index: string; + body: any; +} + +export interface CcrFollowStats extends Generic { + index?: string | string[]; +} + +export interface CcrGetAutoFollowPattern extends Generic { + name?: string; +} + +export interface CcrPauseFollow extends Generic { + index: string; +} + +export interface CcrPutAutoFollowPattern extends Generic { + name: string; + body: any; +} + +export interface CcrResumeFollow extends Generic { + index: string; + body: any; +} + +export interface CcrStats extends Generic { +} + +export interface CcrUnfollow extends Generic { + index: string; +} + +export interface XpackGraphExplore extends Generic { + index?: string | string[]; + type?: string | string[]; + routing?: string; + timeout?: string; + body?: any; +} + +export interface XpackInfo extends Generic { + categories?: string | string[]; +} + +export interface XpackLicenseDelete extends Generic { +} + +export interface XpackLicenseGet extends Generic { + local?: boolean; +} + +export interface XpackLicenseGetBasicStatus extends Generic { +} + +export interface XpackLicenseGetTrialStatus extends Generic { +} + +export interface XpackLicensePost extends Generic { + acknowledge?: boolean; + body?: any; +} + +export interface XpackLicensePostStartBasic extends Generic { + acknowledge?: boolean; +} + +export interface XpackLicensePostStartTrial extends Generic { + type?: string; + acknowledge?: boolean; +} + +export interface XpackMigrationDeprecations extends Generic { + index?: string; +} + +export interface XpackMigrationGetAssistance extends Generic { + index?: string | string[]; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + ignore_unavailable?: boolean; +} + +export interface XpackMigrationUpgrade extends Generic { + index: string; + wait_for_completion?: boolean; +} + +export interface XpackMlCloseJob extends Generic { + job_id: string; + allow_no_jobs?: boolean; + force?: boolean; + timeout?: string; +} + +export interface XpackMlDeleteCalendar extends Generic { + calendar_id: string; +} + +export interface XpackMlDeleteCalendarEvent extends Generic { + calendar_id: string; + event_id: string; +} + +export interface XpackMlDeleteCalendarJob extends Generic { + calendar_id: string; + job_id: string; +} + +export interface XpackMlDeleteDatafeed extends Generic { + datafeed_id: string; + force?: boolean; +} + +export interface XpackMlDeleteExpiredData extends Generic { +} + +export interface XpackMlDeleteFilter extends Generic { + filter_id: string; +} + +export interface XpackMlDeleteForecast extends Generic { + job_id: string; + forecast_id?: string; + allow_no_forecasts?: boolean; + timeout?: string; +} + +export interface XpackMlDeleteJob extends Generic { + job_id: string; + force?: boolean; + wait_for_completion?: boolean; +} + +export interface XpackMlDeleteModelSnapshot extends Generic { + job_id: string; + snapshot_id: string; +} + +export interface XpackMlFindFileStructure extends Generic { + lines_to_sample?: number; + timeout?: string; + charset?: string; + format?: 'ndjson' | 'xml' | 'delimited' | 'semi_structured_text'; + has_header_row?: boolean; + column_names?: string | string[]; + delimiter?: string; + quote?: string; + should_trim_fields?: boolean; + grok_pattern?: string; + timestamp_field?: string; + timestamp_format?: string; + explain?: boolean; + body: any; +} + +export interface XpackMlFlushJob extends Generic { + job_id: string; + calc_interim?: boolean; + start?: string; + end?: string; + advance_time?: string; + skip_time?: string; + body?: any; +} + +export interface XpackMlForecast extends Generic { + job_id: string; + duration?: string; + expires_in?: string; +} + +export interface XpackMlGetBuckets extends Generic { + job_id: string; + timestamp?: string; + expand?: boolean; + exclude_interim?: boolean; + from?: number; + size?: number; + start?: string; + end?: string; + anomaly_score?: number; + sort?: string; + desc?: boolean; + body?: any; +} + +export interface XpackMlGetCalendarEvents extends Generic { + calendar_id: string; + job_id?: string; + start?: string; + end?: string; + from?: number; + size?: number; +} + +export interface XpackMlGetCalendars extends Generic { + calendar_id?: string; + from?: number; + size?: number; +} + +export interface XpackMlGetCategories extends Generic { + job_id: string; + category_id?: number; + from?: number; + size?: number; + body?: any; +} + +export interface XpackMlGetDatafeedStats extends Generic { + datafeed_id?: string; + allow_no_datafeeds?: boolean; +} + +export interface XpackMlGetDatafeeds extends Generic { + datafeed_id?: string; + allow_no_datafeeds?: boolean; +} + +export interface XpackMlGetFilters extends Generic { + filter_id?: string; + from?: number; + size?: number; +} + +export interface XpackMlGetInfluencers extends Generic { + job_id: string; + exclude_interim?: boolean; + from?: number; + size?: number; + start?: string; + end?: string; + influencer_score?: number; + sort?: string; + desc?: boolean; + body?: any; +} + +export interface XpackMlGetJobStats extends Generic { + job_id?: string; + allow_no_jobs?: boolean; +} + +export interface XpackMlGetJobs extends Generic { + job_id?: string; + allow_no_jobs?: boolean; +} + +export interface XpackMlGetModelSnapshots extends Generic { + job_id: string; + snapshot_id?: string; + from?: number; + size?: number; + start?: string; + end?: string; + sort?: string; + desc?: boolean; + body?: any; +} + +export interface XpackMlGetOverallBuckets extends Generic { + job_id: string; + top_n?: number; + bucket_span?: string; + overall_score?: number; + exclude_interim?: boolean; + start?: string; + end?: string; + allow_no_jobs?: boolean; + body?: any; +} + +export interface XpackMlGetRecords extends Generic { + job_id: string; + exclude_interim?: boolean; + from?: number; + size?: number; + start?: string; + end?: string; + record_score?: number; + sort?: string; + desc?: boolean; + body?: any; +} + +export interface XpackMlInfo extends Generic { +} + +export interface XpackMlOpenJob extends Generic { + job_id: string; + ignore_downtime?: boolean; + timeout?: string; +} + +export interface XpackMlPostCalendarEvents extends Generic { + calendar_id: string; + body: any; +} + +export interface XpackMlPostData extends Generic { + job_id: string; + reset_start?: string; + reset_end?: string; + body: any; +} + +export interface XpackMlPreviewDatafeed extends Generic { + datafeed_id: string; +} + +export interface XpackMlPutCalendar extends Generic { + calendar_id: string; + body?: any; +} + +export interface XpackMlPutCalendarJob extends Generic { + calendar_id: string; + job_id: string; +} + +export interface XpackMlPutDatafeed extends Generic { + datafeed_id: string; + body: any; +} + +export interface XpackMlPutFilter extends Generic { + filter_id: string; + body: any; +} + +export interface XpackMlPutJob extends Generic { + job_id: string; + body: any; +} + +export interface XpackMlRevertModelSnapshot extends Generic { + job_id: string; + snapshot_id: string; + delete_intervening_results?: boolean; + body?: any; +} + +export interface XpackMlStartDatafeed extends Generic { + datafeed_id: string; + start?: string; + end?: string; + timeout?: string; + body?: any; +} + +export interface XpackMlStopDatafeed extends Generic { + datafeed_id: string; + allow_no_datafeeds?: boolean; + force?: boolean; + timeout?: string; +} + +export interface XpackMlUpdateDatafeed extends Generic { + datafeed_id: string; + body: any; +} + +export interface XpackMlUpdateFilter extends Generic { + filter_id: string; + body: any; +} + +export interface XpackMlUpdateJob extends Generic { + job_id: string; + body: any; +} + +export interface XpackMlUpdateModelSnapshot extends Generic { + job_id: string; + snapshot_id: string; + body: any; +} + +export interface XpackMlValidate extends Generic { + body: any; +} + +export interface XpackMlValidateDetector extends Generic { + body: any; +} + +export interface XpackMonitoringBulk extends Generic { + type?: string; + system_id?: string; + system_api_version?: string; + interval?: string; + body: any; +} + +export interface XpackRollupDeleteJob extends Generic { + id: string; +} + +export interface XpackRollupGetJobs extends Generic { + id?: string; +} + +export interface XpackRollupGetRollupCaps extends Generic { + id?: string; +} + +export interface XpackRollupGetRollupIndexCaps extends Generic { + index: string; +} + +export interface XpackRollupPutJob extends Generic { + id: string; + body: any; +} + +export interface XpackRollupRollupSearch extends Generic { + index: string; + type?: string; + body: any; +} + +export interface XpackRollupStartJob extends Generic { + id: string; +} + +export interface XpackRollupStopJob extends Generic { + id: string; +} + +export interface XpackSecurityAuthenticate extends Generic { +} + +export interface XpackSecurityChangePassword extends Generic { + username?: string; + refresh?: 'true' | 'false' | 'wait_for'; + body: any; +} + +export interface XpackSecurityClearCachedRealms extends Generic { + realms: string | string[]; + usernames?: string | string[]; +} + +export interface XpackSecurityClearCachedRoles extends Generic { + name: string | string[]; +} + +export interface XpackSecurityDeletePrivileges extends Generic { + application: string; + name: string; + refresh?: 'true' | 'false' | 'wait_for'; +} + +export interface XpackSecurityDeleteRole extends Generic { + name: string; + refresh?: 'true' | 'false' | 'wait_for'; +} + +export interface XpackSecurityDeleteRoleMapping extends Generic { + name: string; + refresh?: 'true' | 'false' | 'wait_for'; +} + +export interface XpackSecurityDeleteUser extends Generic { + username: string; + refresh?: 'true' | 'false' | 'wait_for'; +} + +export interface XpackSecurityDisableUser extends Generic { + username?: string; + refresh?: 'true' | 'false' | 'wait_for'; +} + +export interface XpackSecurityEnableUser extends Generic { + username?: string; + refresh?: 'true' | 'false' | 'wait_for'; +} + +export interface XpackSecurityGetPrivileges extends Generic { + application?: string; + name?: string; +} + +export interface XpackSecurityGetRole extends Generic { + name?: string; +} + +export interface XpackSecurityGetRoleMapping extends Generic { + name?: string; +} + +export interface XpackSecurityGetToken extends Generic { + body: any; +} + +export interface XpackSecurityGetUser extends Generic { + username?: string | string[]; +} + +export interface XpackSecurityGetUserPrivileges extends Generic { +} + +export interface XpackSecurityHasPrivileges extends Generic { + user?: string; + body: any; +} + +export interface XpackSecurityInvalidateToken extends Generic { + body: any; +} + +export interface XpackSecurityPutPrivileges extends Generic { + refresh?: 'true' | 'false' | 'wait_for'; + body: any; +} + +export interface XpackSecurityPutRole extends Generic { + name: string; + refresh?: 'true' | 'false' | 'wait_for'; + body: any; +} + +export interface XpackSecurityPutRoleMapping extends Generic { + name: string; + refresh?: 'true' | 'false' | 'wait_for'; + body: any; +} + +export interface XpackSecurityPutUser extends Generic { + username: string; + refresh?: 'true' | 'false' | 'wait_for'; + body: any; +} + +export interface XpackSqlClearCursor extends Generic { + body: any; +} + +export interface XpackSqlQuery extends Generic { + format?: string; + body: any; +} + +export interface XpackSqlTranslate extends Generic { + body: any; +} + +export interface XpackSslCertificates extends Generic { +} + +export interface XpackUsage extends Generic { + master_timeout?: string; +} + +export interface XpackWatcherAckWatch extends Generic { + watch_id: string; + action_id?: string | string[]; + master_timeout?: string; +} + +export interface XpackWatcherActivateWatch extends Generic { + watch_id: string; + master_timeout?: string; +} + +export interface XpackWatcherDeactivateWatch extends Generic { + watch_id: string; + master_timeout?: string; +} + +export interface XpackWatcherDeleteWatch extends Generic { + id: string; + master_timeout?: string; +} + +export interface XpackWatcherExecuteWatch extends Generic { + id?: string; + debug?: boolean; + body?: any; +} + +export interface XpackWatcherGetWatch extends Generic { + id: string; +} + +export interface XpackWatcherPutWatch extends Generic { + id: string; + master_timeout?: string; + active?: boolean; + version?: number; + body?: any; +} + +export interface XpackWatcherRestart extends Generic { +} + +export interface XpackWatcherStart extends Generic { +} + +export interface XpackWatcherStats extends Generic { + metric?: '_all' | 'queued_watches' | 'pending_watches'; + emit_stacktraces?: boolean; +} + +export interface XpackWatcherStop extends Generic { +} diff --git a/index.d.ts b/index.d.ts index 2455073e5..76c140c35 100644 --- a/index.d.ts +++ b/index.d.ts @@ -6,16 +6,17 @@ import Transport, { ApiResponse, EventMeta, SniffMeta, RequestOptions } from './ import Connection, { AgentOptions } from './lib/Connection'; import ConnectionPool, { nodeSelectorFn, nodeFilterFn, ResurrectMeta } from './lib/ConnectionPool'; import Serializer from './lib/Serializer'; +import * as RequestParams from './api/requestParams' declare type anyObject = { [key: string]: any; }; declare type callbackFn = (err: Error | null, result: ApiResponse) => void; -interface ApiMethod { +interface ApiMethod { (callback?: callbackFn): any; - (params: anyObject, callback?: callbackFn): any; - (params: anyObject, options: RequestOptions, callback?: callbackFn): any; + (params: T, callback?: callbackFn): any; + (params: T, options: RequestOptions, callback?: callbackFn): any; } interface ClientOptions { @@ -45,428 +46,428 @@ declare class Client extends EventEmitter { connectionPool: ConnectionPool; transport: Transport; serializer: Serializer - bulk: ApiMethod - cat: { - aliases: ApiMethod - allocation: ApiMethod - count: ApiMethod - fielddata: ApiMethod - health: ApiMethod - help: ApiMethod - indices: ApiMethod - master: ApiMethod - nodeattrs: ApiMethod - nodes: ApiMethod - pending_tasks: ApiMethod - pendingTasks: ApiMethod - plugins: ApiMethod - recovery: ApiMethod - repositories: ApiMethod - segments: ApiMethod - shards: ApiMethod - snapshots: ApiMethod - tasks: ApiMethod - templates: ApiMethod - thread_pool: ApiMethod - threadPool: ApiMethod - } - ccr: { - delete_auto_follow_pattern: ApiMethod - deleteAutoFollowPattern: ApiMethod - follow: ApiMethod - follow_stats: ApiMethod - followStats: ApiMethod - get_auto_follow_pattern: ApiMethod - getAutoFollowPattern: ApiMethod - pause_follow: ApiMethod - pauseFollow: ApiMethod - put_auto_follow_pattern: ApiMethod - putAutoFollowPattern: ApiMethod - resume_follow: ApiMethod - resumeFollow: ApiMethod - stats: ApiMethod - unfollow: ApiMethod - } - clear_scroll: ApiMethod - clearScroll: ApiMethod - cluster: { - allocation_explain: ApiMethod - allocationExplain: ApiMethod - get_settings: ApiMethod - getSettings: ApiMethod - health: ApiMethod - pending_tasks: ApiMethod - pendingTasks: ApiMethod - put_settings: ApiMethod - putSettings: ApiMethod - remote_info: ApiMethod - remoteInfo: ApiMethod - reroute: ApiMethod - state: ApiMethod - stats: ApiMethod - } - count: ApiMethod - create: ApiMethod - delete: ApiMethod - delete_by_query: ApiMethod - deleteByQuery: ApiMethod - delete_by_query_rethrottle: ApiMethod - deleteByQueryRethrottle: ApiMethod - delete_script: ApiMethod - deleteScript: ApiMethod - exists: ApiMethod - exists_source: ApiMethod - existsSource: ApiMethod - explain: ApiMethod - field_caps: ApiMethod - fieldCaps: ApiMethod - get: ApiMethod - get_script: ApiMethod - getScript: ApiMethod - get_source: ApiMethod - getSource: ApiMethod - index: ApiMethod - indices: { - analyze: ApiMethod - clear_cache: ApiMethod - clearCache: ApiMethod - close: ApiMethod - create: ApiMethod - delete: ApiMethod - delete_alias: ApiMethod - deleteAlias: ApiMethod - delete_template: ApiMethod - deleteTemplate: ApiMethod - exists: ApiMethod - exists_alias: ApiMethod - existsAlias: ApiMethod - exists_template: ApiMethod - existsTemplate: ApiMethod - exists_type: ApiMethod - existsType: ApiMethod - flush: ApiMethod - flush_synced: ApiMethod - flushSynced: ApiMethod - forcemerge: ApiMethod - get: ApiMethod - get_alias: ApiMethod - getAlias: ApiMethod - get_field_mapping: ApiMethod - getFieldMapping: ApiMethod - get_mapping: ApiMethod - getMapping: ApiMethod - get_settings: ApiMethod - getSettings: ApiMethod - get_template: ApiMethod - getTemplate: ApiMethod - get_upgrade: ApiMethod - getUpgrade: ApiMethod - open: ApiMethod - put_alias: ApiMethod - putAlias: ApiMethod - put_mapping: ApiMethod - putMapping: ApiMethod - put_settings: ApiMethod - putSettings: ApiMethod - put_template: ApiMethod - putTemplate: ApiMethod - recovery: ApiMethod - refresh: ApiMethod - rollover: ApiMethod - segments: ApiMethod - shard_stores: ApiMethod - shardStores: ApiMethod - shrink: ApiMethod - split: ApiMethod - stats: ApiMethod - update_aliases: ApiMethod - updateAliases: ApiMethod - upgrade: ApiMethod - validate_query: ApiMethod - validateQuery: ApiMethod - } - info: ApiMethod - ingest: { - delete_pipeline: ApiMethod - deletePipeline: ApiMethod - get_pipeline: ApiMethod - getPipeline: ApiMethod - processor_grok: ApiMethod - processorGrok: ApiMethod - put_pipeline: ApiMethod - putPipeline: ApiMethod - simulate: ApiMethod - } - mget: ApiMethod - msearch: ApiMethod - msearch_template: ApiMethod - msearchTemplate: ApiMethod - mtermvectors: ApiMethod - nodes: { - hot_threads: ApiMethod - hotThreads: ApiMethod - info: ApiMethod - reload_secure_settings: ApiMethod - reloadSecureSettings: ApiMethod - stats: ApiMethod - usage: ApiMethod - } - ping: ApiMethod - put_script: ApiMethod - putScript: ApiMethod - rank_eval: ApiMethod - rankEval: ApiMethod - reindex: ApiMethod - reindex_rethrottle: ApiMethod - reindexRethrottle: ApiMethod - render_search_template: ApiMethod - renderSearchTemplate: ApiMethod - scripts_painless_execute: ApiMethod - scriptsPainlessExecute: ApiMethod - scroll: ApiMethod - search: ApiMethod - search_shards: ApiMethod - searchShards: ApiMethod - search_template: ApiMethod - searchTemplate: ApiMethod - snapshot: { - create: ApiMethod - create_repository: ApiMethod - createRepository: ApiMethod - delete: ApiMethod - delete_repository: ApiMethod - deleteRepository: ApiMethod - get: ApiMethod - get_repository: ApiMethod - getRepository: ApiMethod - restore: ApiMethod - status: ApiMethod - verify_repository: ApiMethod - verifyRepository: ApiMethod - } - tasks: { - cancel: ApiMethod - get: ApiMethod - list: ApiMethod - } - termvectors: ApiMethod - update: ApiMethod - update_by_query: ApiMethod - updateByQuery: ApiMethod - update_by_query_rethrottle: ApiMethod - updateByQueryRethrottle: ApiMethod - xpack: { - graph: { - explore: ApiMethod - } - info: ApiMethod - license: { - delete: ApiMethod - get: ApiMethod - get_basic_status: ApiMethod - getBasicStatus: ApiMethod - get_trial_status: ApiMethod - getTrialStatus: ApiMethod - post: ApiMethod - post_start_basic: ApiMethod - postStartBasic: ApiMethod - post_start_trial: ApiMethod - postStartTrial: ApiMethod - } - migration: { - deprecations: ApiMethod - get_assistance: ApiMethod - getAssistance: ApiMethod - upgrade: ApiMethod - } - ml: { - close_job: ApiMethod - closeJob: ApiMethod - delete_calendar: ApiMethod - deleteCalendar: ApiMethod - delete_calendar_event: ApiMethod - deleteCalendarEvent: ApiMethod - delete_calendar_job: ApiMethod - deleteCalendarJob: ApiMethod - delete_datafeed: ApiMethod - deleteDatafeed: ApiMethod - delete_expired_data: ApiMethod - deleteExpiredData: ApiMethod - delete_filter: ApiMethod - deleteFilter: ApiMethod - delete_forecast: ApiMethod - deleteForecast: ApiMethod - delete_job: ApiMethod - deleteJob: ApiMethod - delete_model_snapshot: ApiMethod - deleteModelSnapshot: ApiMethod - find_file_structure: ApiMethod - findFileStructure: ApiMethod - flush_job: ApiMethod - flushJob: ApiMethod - forecast: ApiMethod - get_buckets: ApiMethod - getBuckets: ApiMethod - get_calendar_events: ApiMethod - getCalendarEvents: ApiMethod - get_calendars: ApiMethod - getCalendars: ApiMethod - get_categories: ApiMethod - getCategories: ApiMethod - get_datafeed_stats: ApiMethod - getDatafeedStats: ApiMethod - get_datafeeds: ApiMethod - getDatafeeds: ApiMethod - get_filters: ApiMethod - getFilters: ApiMethod - get_influencers: ApiMethod - getInfluencers: ApiMethod - get_job_stats: ApiMethod - getJobStats: ApiMethod - get_jobs: ApiMethod - getJobs: ApiMethod - get_model_snapshots: ApiMethod - getModelSnapshots: ApiMethod - get_overall_buckets: ApiMethod - getOverallBuckets: ApiMethod - get_records: ApiMethod - getRecords: ApiMethod - info: ApiMethod - open_job: ApiMethod - openJob: ApiMethod - post_calendar_events: ApiMethod - postCalendarEvents: ApiMethod - post_data: ApiMethod - postData: ApiMethod - preview_datafeed: ApiMethod - previewDatafeed: ApiMethod - put_calendar: ApiMethod - putCalendar: ApiMethod - put_calendar_job: ApiMethod - putCalendarJob: ApiMethod - put_datafeed: ApiMethod - putDatafeed: ApiMethod - put_filter: ApiMethod - putFilter: ApiMethod - put_job: ApiMethod - putJob: ApiMethod - revert_model_snapshot: ApiMethod - revertModelSnapshot: ApiMethod - start_datafeed: ApiMethod - startDatafeed: ApiMethod - stop_datafeed: ApiMethod - stopDatafeed: ApiMethod - update_datafeed: ApiMethod - updateDatafeed: ApiMethod - update_filter: ApiMethod - updateFilter: ApiMethod - update_job: ApiMethod - updateJob: ApiMethod - update_model_snapshot: ApiMethod - updateModelSnapshot: ApiMethod - validate: ApiMethod - validate_detector: ApiMethod - validateDetector: ApiMethod - } - monitoring: { - bulk: ApiMethod - } - rollup: { - delete_job: ApiMethod - deleteJob: ApiMethod - get_jobs: ApiMethod - getJobs: ApiMethod - get_rollup_caps: ApiMethod - getRollupCaps: ApiMethod - get_rollup_index_caps: ApiMethod - getRollupIndexCaps: ApiMethod - put_job: ApiMethod - putJob: ApiMethod - rollup_search: ApiMethod - rollupSearch: ApiMethod - start_job: ApiMethod - startJob: ApiMethod - stop_job: ApiMethod - stopJob: ApiMethod - } - security: { - authenticate: ApiMethod - change_password: ApiMethod - changePassword: ApiMethod - clear_cached_realms: ApiMethod - clearCachedRealms: ApiMethod - clear_cached_roles: ApiMethod - clearCachedRoles: ApiMethod - delete_privileges: ApiMethod - deletePrivileges: ApiMethod - delete_role: ApiMethod - deleteRole: ApiMethod - delete_role_mapping: ApiMethod - deleteRoleMapping: ApiMethod - delete_user: ApiMethod - deleteUser: ApiMethod - disable_user: ApiMethod - disableUser: ApiMethod - enable_user: ApiMethod - enableUser: ApiMethod - get_privileges: ApiMethod - getPrivileges: ApiMethod - get_role: ApiMethod - getRole: ApiMethod - get_role_mapping: ApiMethod - getRoleMapping: ApiMethod - get_token: ApiMethod - getToken: ApiMethod - get_user: ApiMethod - getUser: ApiMethod - get_user_privileges: ApiMethod - getUserPrivileges: ApiMethod - has_privileges: ApiMethod - hasPrivileges: ApiMethod - invalidate_token: ApiMethod - invalidateToken: ApiMethod - put_privileges: ApiMethod - putPrivileges: ApiMethod - put_role: ApiMethod - putRole: ApiMethod - put_role_mapping: ApiMethod - putRoleMapping: ApiMethod - put_user: ApiMethod - putUser: ApiMethod - } - sql: { - clear_cursor: ApiMethod - clearCursor: ApiMethod - query: ApiMethod - translate: ApiMethod - } - ssl: { - certificates: ApiMethod - } - usage: ApiMethod - watcher: { - ack_watch: ApiMethod - ackWatch: ApiMethod - activate_watch: ApiMethod - activateWatch: ApiMethod - deactivate_watch: ApiMethod - deactivateWatch: ApiMethod - delete_watch: ApiMethod - deleteWatch: ApiMethod - execute_watch: ApiMethod - executeWatch: ApiMethod - get_watch: ApiMethod - getWatch: ApiMethod - put_watch: ApiMethod - putWatch: ApiMethod - restart: ApiMethod - start: ApiMethod - stats: ApiMethod - stop: ApiMethod - } - } constructor(opts?: ClientOptions); close(callback?: Function): Promise | void; + bulk: ApiMethod + cat: { + aliases: ApiMethod + allocation: ApiMethod + count: ApiMethod + fielddata: ApiMethod + health: ApiMethod + help: ApiMethod + indices: ApiMethod + master: ApiMethod + nodeattrs: ApiMethod + nodes: ApiMethod + pending_tasks: ApiMethod + pendingTasks: ApiMethod + plugins: ApiMethod + recovery: ApiMethod + repositories: ApiMethod + segments: ApiMethod + shards: ApiMethod + snapshots: ApiMethod + tasks: ApiMethod + templates: ApiMethod + thread_pool: ApiMethod + threadPool: ApiMethod + } + ccr: { + delete_auto_follow_pattern: ApiMethod + deleteAutoFollowPattern: ApiMethod + follow: ApiMethod + follow_stats: ApiMethod + followStats: ApiMethod + get_auto_follow_pattern: ApiMethod + getAutoFollowPattern: ApiMethod + pause_follow: ApiMethod + pauseFollow: ApiMethod + put_auto_follow_pattern: ApiMethod + putAutoFollowPattern: ApiMethod + resume_follow: ApiMethod + resumeFollow: ApiMethod + stats: ApiMethod + unfollow: ApiMethod + } + clear_scroll: ApiMethod + clearScroll: ApiMethod + cluster: { + allocation_explain: ApiMethod + allocationExplain: ApiMethod + get_settings: ApiMethod + getSettings: ApiMethod + health: ApiMethod + pending_tasks: ApiMethod + pendingTasks: ApiMethod + put_settings: ApiMethod + putSettings: ApiMethod + remote_info: ApiMethod + remoteInfo: ApiMethod + reroute: ApiMethod + state: ApiMethod + stats: ApiMethod + } + count: ApiMethod + create: ApiMethod + delete: ApiMethod + delete_by_query: ApiMethod + deleteByQuery: ApiMethod + delete_by_query_rethrottle: ApiMethod + deleteByQueryRethrottle: ApiMethod + delete_script: ApiMethod + deleteScript: ApiMethod + exists: ApiMethod + exists_source: ApiMethod + existsSource: ApiMethod + explain: ApiMethod + field_caps: ApiMethod + fieldCaps: ApiMethod + get: ApiMethod + get_script: ApiMethod + getScript: ApiMethod + get_source: ApiMethod + getSource: ApiMethod + index: ApiMethod + indices: { + analyze: ApiMethod + clear_cache: ApiMethod + clearCache: ApiMethod + close: ApiMethod + create: ApiMethod + delete: ApiMethod + delete_alias: ApiMethod + deleteAlias: ApiMethod + delete_template: ApiMethod + deleteTemplate: ApiMethod + exists: ApiMethod + exists_alias: ApiMethod + existsAlias: ApiMethod + exists_template: ApiMethod + existsTemplate: ApiMethod + exists_type: ApiMethod + existsType: ApiMethod + flush: ApiMethod + flush_synced: ApiMethod + flushSynced: ApiMethod + forcemerge: ApiMethod + get: ApiMethod + get_alias: ApiMethod + getAlias: ApiMethod + get_field_mapping: ApiMethod + getFieldMapping: ApiMethod + get_mapping: ApiMethod + getMapping: ApiMethod + get_settings: ApiMethod + getSettings: ApiMethod + get_template: ApiMethod + getTemplate: ApiMethod + get_upgrade: ApiMethod + getUpgrade: ApiMethod + open: ApiMethod + put_alias: ApiMethod + putAlias: ApiMethod + put_mapping: ApiMethod + putMapping: ApiMethod + put_settings: ApiMethod + putSettings: ApiMethod + put_template: ApiMethod + putTemplate: ApiMethod + recovery: ApiMethod + refresh: ApiMethod + rollover: ApiMethod + segments: ApiMethod + shard_stores: ApiMethod + shardStores: ApiMethod + shrink: ApiMethod + split: ApiMethod + stats: ApiMethod + update_aliases: ApiMethod + updateAliases: ApiMethod + upgrade: ApiMethod + validate_query: ApiMethod + validateQuery: ApiMethod + } + info: ApiMethod + ingest: { + delete_pipeline: ApiMethod + deletePipeline: ApiMethod + get_pipeline: ApiMethod + getPipeline: ApiMethod + processor_grok: ApiMethod + processorGrok: ApiMethod + put_pipeline: ApiMethod + putPipeline: ApiMethod + simulate: ApiMethod + } + mget: ApiMethod + msearch: ApiMethod + msearch_template: ApiMethod + msearchTemplate: ApiMethod + mtermvectors: ApiMethod + nodes: { + hot_threads: ApiMethod + hotThreads: ApiMethod + info: ApiMethod + reload_secure_settings: ApiMethod + reloadSecureSettings: ApiMethod + stats: ApiMethod + usage: ApiMethod + } + ping: ApiMethod + put_script: ApiMethod + putScript: ApiMethod + rank_eval: ApiMethod + rankEval: ApiMethod + reindex: ApiMethod + reindex_rethrottle: ApiMethod + reindexRethrottle: ApiMethod + render_search_template: ApiMethod + renderSearchTemplate: ApiMethod + scripts_painless_execute: ApiMethod + scriptsPainlessExecute: ApiMethod + scroll: ApiMethod + search: ApiMethod + search_shards: ApiMethod + searchShards: ApiMethod + search_template: ApiMethod + searchTemplate: ApiMethod + snapshot: { + create: ApiMethod + create_repository: ApiMethod + createRepository: ApiMethod + delete: ApiMethod + delete_repository: ApiMethod + deleteRepository: ApiMethod + get: ApiMethod + get_repository: ApiMethod + getRepository: ApiMethod + restore: ApiMethod + status: ApiMethod + verify_repository: ApiMethod + verifyRepository: ApiMethod + } + tasks: { + cancel: ApiMethod + get: ApiMethod + list: ApiMethod + } + termvectors: ApiMethod + update: ApiMethod + update_by_query: ApiMethod + updateByQuery: ApiMethod + update_by_query_rethrottle: ApiMethod + updateByQueryRethrottle: ApiMethod + xpack: { + graph: { + explore: ApiMethod + } + info: ApiMethod + license: { + delete: ApiMethod + get: ApiMethod + get_basic_status: ApiMethod + getBasicStatus: ApiMethod + get_trial_status: ApiMethod + getTrialStatus: ApiMethod + post: ApiMethod + post_start_basic: ApiMethod + postStartBasic: ApiMethod + post_start_trial: ApiMethod + postStartTrial: ApiMethod + } + migration: { + deprecations: ApiMethod + get_assistance: ApiMethod + getAssistance: ApiMethod + upgrade: ApiMethod + } + ml: { + close_job: ApiMethod + closeJob: ApiMethod + delete_calendar: ApiMethod + deleteCalendar: ApiMethod + delete_calendar_event: ApiMethod + deleteCalendarEvent: ApiMethod + delete_calendar_job: ApiMethod + deleteCalendarJob: ApiMethod + delete_datafeed: ApiMethod + deleteDatafeed: ApiMethod + delete_expired_data: ApiMethod + deleteExpiredData: ApiMethod + delete_filter: ApiMethod + deleteFilter: ApiMethod + delete_forecast: ApiMethod + deleteForecast: ApiMethod + delete_job: ApiMethod + deleteJob: ApiMethod + delete_model_snapshot: ApiMethod + deleteModelSnapshot: ApiMethod + find_file_structure: ApiMethod + findFileStructure: ApiMethod + flush_job: ApiMethod + flushJob: ApiMethod + forecast: ApiMethod + get_buckets: ApiMethod + getBuckets: ApiMethod + get_calendar_events: ApiMethod + getCalendarEvents: ApiMethod + get_calendars: ApiMethod + getCalendars: ApiMethod + get_categories: ApiMethod + getCategories: ApiMethod + get_datafeed_stats: ApiMethod + getDatafeedStats: ApiMethod + get_datafeeds: ApiMethod + getDatafeeds: ApiMethod + get_filters: ApiMethod + getFilters: ApiMethod + get_influencers: ApiMethod + getInfluencers: ApiMethod + get_job_stats: ApiMethod + getJobStats: ApiMethod + get_jobs: ApiMethod + getJobs: ApiMethod + get_model_snapshots: ApiMethod + getModelSnapshots: ApiMethod + get_overall_buckets: ApiMethod + getOverallBuckets: ApiMethod + get_records: ApiMethod + getRecords: ApiMethod + info: ApiMethod + open_job: ApiMethod + openJob: ApiMethod + post_calendar_events: ApiMethod + postCalendarEvents: ApiMethod + post_data: ApiMethod + postData: ApiMethod + preview_datafeed: ApiMethod + previewDatafeed: ApiMethod + put_calendar: ApiMethod + putCalendar: ApiMethod + put_calendar_job: ApiMethod + putCalendarJob: ApiMethod + put_datafeed: ApiMethod + putDatafeed: ApiMethod + put_filter: ApiMethod + putFilter: ApiMethod + put_job: ApiMethod + putJob: ApiMethod + revert_model_snapshot: ApiMethod + revertModelSnapshot: ApiMethod + start_datafeed: ApiMethod + startDatafeed: ApiMethod + stop_datafeed: ApiMethod + stopDatafeed: ApiMethod + update_datafeed: ApiMethod + updateDatafeed: ApiMethod + update_filter: ApiMethod + updateFilter: ApiMethod + update_job: ApiMethod + updateJob: ApiMethod + update_model_snapshot: ApiMethod + updateModelSnapshot: ApiMethod + validate: ApiMethod + validate_detector: ApiMethod + validateDetector: ApiMethod + } + monitoring: { + bulk: ApiMethod + } + rollup: { + delete_job: ApiMethod + deleteJob: ApiMethod + get_jobs: ApiMethod + getJobs: ApiMethod + get_rollup_caps: ApiMethod + getRollupCaps: ApiMethod + get_rollup_index_caps: ApiMethod + getRollupIndexCaps: ApiMethod + put_job: ApiMethod + putJob: ApiMethod + rollup_search: ApiMethod + rollupSearch: ApiMethod + start_job: ApiMethod + startJob: ApiMethod + stop_job: ApiMethod + stopJob: ApiMethod + } + security: { + authenticate: ApiMethod + change_password: ApiMethod + changePassword: ApiMethod + clear_cached_realms: ApiMethod + clearCachedRealms: ApiMethod + clear_cached_roles: ApiMethod + clearCachedRoles: ApiMethod + delete_privileges: ApiMethod + deletePrivileges: ApiMethod + delete_role: ApiMethod + deleteRole: ApiMethod + delete_role_mapping: ApiMethod + deleteRoleMapping: ApiMethod + delete_user: ApiMethod + deleteUser: ApiMethod + disable_user: ApiMethod + disableUser: ApiMethod + enable_user: ApiMethod + enableUser: ApiMethod + get_privileges: ApiMethod + getPrivileges: ApiMethod + get_role: ApiMethod + getRole: ApiMethod + get_role_mapping: ApiMethod + getRoleMapping: ApiMethod + get_token: ApiMethod + getToken: ApiMethod + get_user: ApiMethod + getUser: ApiMethod + get_user_privileges: ApiMethod + getUserPrivileges: ApiMethod + has_privileges: ApiMethod + hasPrivileges: ApiMethod + invalidate_token: ApiMethod + invalidateToken: ApiMethod + put_privileges: ApiMethod + putPrivileges: ApiMethod + put_role: ApiMethod + putRole: ApiMethod + put_role_mapping: ApiMethod + putRoleMapping: ApiMethod + put_user: ApiMethod + putUser: ApiMethod + } + sql: { + clear_cursor: ApiMethod + clearCursor: ApiMethod + query: ApiMethod + translate: ApiMethod + } + ssl: { + certificates: ApiMethod + } + usage: ApiMethod + watcher: { + ack_watch: ApiMethod + ackWatch: ApiMethod + activate_watch: ApiMethod + activateWatch: ApiMethod + deactivate_watch: ApiMethod + deactivateWatch: ApiMethod + delete_watch: ApiMethod + deleteWatch: ApiMethod + execute_watch: ApiMethod + executeWatch: ApiMethod + get_watch: ApiMethod + getWatch: ApiMethod + put_watch: ApiMethod + putWatch: ApiMethod + restart: ApiMethod + start: ApiMethod + stats: ApiMethod + stop: ApiMethod + } + } } declare const events: { @@ -486,5 +487,6 @@ export { ApiResponse, EventMeta, SniffMeta, - ResurrectMeta + ResurrectMeta, + RequestParams }; diff --git a/scripts/run.js b/scripts/run.js index 7776efba5..92b63fb8b 100644 --- a/scripts/run.js +++ b/scripts/run.js @@ -7,7 +7,7 @@ const semver = require('semver') const ora = require('ora') const rimraf = require('rimraf') const standard = require('standard') -const { generate, cloneAndCheckout, genFactory } = require('./utils') +const { generate, cloneAndCheckout, genFactory, generateRequestTypes } = require('./utils') start(minimist(process.argv.slice(2), { string: ['tag'] @@ -23,6 +23,8 @@ function start (opts) { const apiOutputFolder = join(packageFolder, 'api') const mainOutputFile = join(packageFolder, 'index.js') const typesOutputFile = join(packageFolder, 'generated.d.ts') + const requestParamsOutputFile = join(packageFolder, 'requestParams.d.ts') + const allSpec = [] log.text = 'Cleaning API folder...' rimraf.sync(join(apiOutputFolder, '*.js')) @@ -36,6 +38,12 @@ function start (opts) { readdirSync(apiFolder).forEach(generateApiFile(apiFolder, log)) readdirSync(xPackFolder).forEach(generateApiFile(xPackFolder, log)) + writeFileSync( + requestParamsOutputFile, + generateRequestTypes(allSpec), + { encoding: 'utf8' } + ) + const { fn: factory, types } = genFactory(apiOutputFolder) writeFileSync( mainOutputFile, @@ -61,6 +69,7 @@ function start (opts) { log.text = `Processing ${file}` const spec = require(join(apiFolder, file)) + allSpec.push(spec) const code = generate(spec, common) const filePath = join(apiOutputFolder, `${file.slice(0, file.lastIndexOf('.'))}.js`) diff --git a/scripts/utils/genMain.js b/scripts/utils/genMain.js index ed36ceaa9..f7bc2358b 100644 --- a/scripts/utils/genMain.js +++ b/scripts/utils/genMain.js @@ -9,6 +9,11 @@ function genFactory (folder) { const apiFiles = readdirSync(folder) const types = apiFiles .map(file => { + const name = file + .slice(0, -3) + .replace(/\.([a-z])/g, k => k[1].toUpperCase()) + .replace(/_([a-z])/g, k => k[1].toUpperCase()) + return file .slice(0, -3) // remove `.js` extension .split('.') @@ -16,12 +21,12 @@ function genFactory (folder) { .reduce((acc, val) => { const obj = { [val]: acc === null - ? 'ApiMethod' + ? `ApiMethod` : acc } if (isSnakeCased(val)) { obj[camelify(val)] = acc === null - ? 'ApiMethod' + ? `ApiMethod` : acc } return obj diff --git a/scripts/utils/generateRequestTypes.js b/scripts/utils/generateRequestTypes.js new file mode 100644 index 000000000..092bdf99d --- /dev/null +++ b/scripts/utils/generateRequestTypes.js @@ -0,0 +1,71 @@ +'use strict' + +function generate (api) { + var types = `export interface Generic { + method?: string; + ignore?: number | number[]; + filter_path?: string | string[]; + pretty?: boolean; + human?: boolean; + error_trace?: boolean; + source?: string; +} +` + + api.forEach(generateRequestType) + return types + + function generateRequestType (spec) { + const api = Object.keys(spec)[0] + const name = api + .replace(/\.([a-z])/g, k => k[1].toUpperCase()) + .replace(/_([a-z])/g, k => k[1].toUpperCase()) + + const { parts = {}, params = {} } = spec[api].url + const { body } = spec[api] + + const partsArr = Object.keys(parts) + .map(k => ({ key: k, value: parts[k] })) + const paramsArr = Object.keys(params) + .filter(k => !Object.keys(parts).includes(k)) + .map(k => ({ key: k, value: params[k] })) + + const genLine = e => { + const optional = e.value.required ? '' : '?' + return `${e.key}${optional}: ${getType(e.value.type, e.value.options)};` + } + + const code = ` +export interface ${name[0].toUpperCase() + name.slice(1)} extends Generic { + ${partsArr.map(genLine).join('\n ')} + ${paramsArr.map(genLine).join('\n ')} + ${body ? `body${body.required ? '' : '?'}: any;` : ''} +} +` + + types += '\n' + // remove empty lines + types += code.replace(/^\s*\n/gm, '') + } + + function getType (type, options) { + switch (type) { + case 'list': + return 'string | string[]' + case 'date': + case 'time': + case 'timeout': + return 'string' + case 'enum': + return options.map(k => `'${k}'`).join(' | ') + case 'int': + case 'double': + case 'long': + return 'number' + default: + return type + } + } +} + +module.exports = generate diff --git a/scripts/utils/index.js b/scripts/utils/index.js index 8f781cef7..6993895f7 100644 --- a/scripts/utils/index.js +++ b/scripts/utils/index.js @@ -1,7 +1,8 @@ 'use strict' const generate = require('./generate') +const generateRequestTypes = require('./generateRequestTypes') const cloneAndCheckout = require('./clone-es') const genFactory = require('./genMain') -module.exports = { generate, cloneAndCheckout, genFactory } +module.exports = { generate, cloneAndCheckout, genFactory, generateRequestTypes } From 32b13bcdfe9344792112a5b92a5d5ec2e91bcb64 Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 11 Jan 2019 18:14:59 +0100 Subject: [PATCH 086/172] Bumped v0.1.0-alpha.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 79ba1eb66..bd0ca4677 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "The official Elasticsearch client for Node.js", "main": "index.js", "homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html", - "version": "0.1.0-alpha.3", + "version": "0.1.0-alpha.4", "keywords": [ "elasticsearch", "elastic", From ea3e54b255e7a21bee128ec5821881c2853c7347 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 14 Jan 2019 16:08:20 +0100 Subject: [PATCH 087/172] Updated Connection Pool - Merge nodes with same url but different id during update - Cache auth data if provided when adding a connection --- lib/ConnectionPool.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/lib/ConnectionPool.js b/lib/ConnectionPool.js index 43c678dda..b70f7675d 100644 --- a/lib/ConnectionPool.js +++ b/lib/ConnectionPool.js @@ -11,6 +11,7 @@ class ConnectionPool { this.connections = new Map() this.dead = [] this.selector = opts.selector + this._auth = null this._ssl = opts.ssl this._agent = opts.agent // the resurrect timeout is 60s @@ -200,10 +201,26 @@ class ConnectionPool { if (typeof opts === 'string') { opts = this.urlToHost(opts) } + // if a given node has auth data we store it in the connection pool, + // so if we add new nodes without auth data (after a sniff for example) + // we can add it to them once the connection instance has been created + if (opts.url.username !== '' && opts.url.password !== '') { + this._auth = { + username: opts.url.username, + password: opts.url.password + } + } if (opts.ssl == null) opts.ssl = this._ssl if (opts.agent == null) opts.agent = this._agent const connection = new this.Connection(opts) + if (connection.url.username === '' && + connection.url.password === '' && + this._auth != null) { + connection.url.username = this._auth.username + connection.url.password = this._auth.password + } + debug('Adding a new connection', connection) if (this.connections.has(connection.id)) { throw new Error(`Connection with id '${connection.id}' is already present`) @@ -267,6 +284,18 @@ class ConnectionPool { if (oldConnection.status === Connection.statuses.DEAD) { this.markAlive(oldConnection) } + // in case the user has passed a single url (or an array of urls), + // the connection id will be the full href; to avoid closing valid connections + // because are not present in the pool, we check also the node url, + // and if is already present we update its id with the ES provided one. + } else if (this.connections.has(connection.url.href) === true) { + const oldConnection = this.connections.get(connection.url.href) + this.connections.delete(connection.url.href) + oldConnection.id = connection.id + this.connections.set(connection.id, oldConnection) + if (oldConnection.status === Connection.statuses.DEAD) { + this.markAlive(oldConnection) + } } else { this.addConnection(connection) } From f12424272fb408937fe7f803c2c3e0d09d3aa250 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 14 Jan 2019 16:09:47 +0100 Subject: [PATCH 088/172] Updated test --- test/behavior/sniff.test.js | 35 +++++++++++++++------- test/unit/connection-pool.test.js | 50 +++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 11 deletions(-) diff --git a/test/behavior/sniff.test.js b/test/behavior/sniff.test.js index c6ec1334f..22b84e2e2 100644 --- a/test/behavior/sniff.test.js +++ b/test/behavior/sniff.test.js @@ -37,17 +37,30 @@ test('Should update the connection pool', t => { const ids = Object.keys(nodes) for (var i = 0; i < hosts.length; i++) { const id = ids[i] - t.deepEqual(hosts[i], { - url: new URL(nodes[id].url), - id: id, - roles: { - master: true, - data: true, - ingest: true - }, - ssl: null, - agent: null - }) + // the first node will be an update of the existing one + if (id === 'node0') { + t.deepEqual(hosts[i], { + url: new URL(nodes[id].url), + id: id, + roles: { + master: true, + data: true, + ingest: true + } + }) + } else { + t.deepEqual(hosts[i], { + url: new URL(nodes[id].url), + id: id, + roles: { + master: true, + data: true, + ingest: true + }, + ssl: null, + agent: null + }) + } } t.strictEqual(client.connectionPool.connections.size, 4) diff --git a/test/unit/connection-pool.test.js b/test/unit/connection-pool.test.js index 37a9d3af2..5ca572ffe 100644 --- a/test/unit/connection-pool.test.js +++ b/test/unit/connection-pool.test.js @@ -30,6 +30,22 @@ test('API', t => { t.end() }) + t.test('addConnection (should store the auth data)', t => { + const pool = new ConnectionPool({ Connection }) + const href = 'http://localhost:9200/' + pool.addConnection('http://foo:bar@localhost:9200') + + t.ok(pool.connections.get(href) instanceof Connection) + t.strictEqual(pool.connections.get(href).status, Connection.statuses.ALIVE) + t.deepEqual(pool.dead, []) + t.deepEqual(pool._auth, { username: 'foo', password: 'bar' }) + + pool.addConnection('http://localhost:9201') + t.strictEqual(pool.connections.get('http://localhost:9201/').url.username, 'foo') + t.strictEqual(pool.connections.get('http://localhost:9201/').url.password, 'bar') + t.end() + }) + t.test('markDead', t => { const pool = new ConnectionPool({ Connection }) const href = 'http://localhost:9200/' @@ -381,6 +397,40 @@ test('API', t => { t.ok(pool.connections.get('a2').roles !== null) }) + t.test('Should not update existing connections (same url, different id)', t => { + t.plan(2) + class CustomConnectionPool extends ConnectionPool { + markAlive () { + t.fail('Should not be called') + } + } + const pool = new CustomConnectionPool({ Connection }) + pool.addConnection([{ + url: new URL('http://127.0.0.1:9200'), + id: 'http://127.0.0.1:9200/', + roles: { + master: true, + data: true, + ingest: true + } + }]) + + pool.update([{ + url: new URL('http://127.0.0.1:9200'), + id: 'a1', + roles: true + }]) + + // roles will never be updated, we only use it to do + // a dummy check to see if the connection has been updated + t.deepEqual(pool.connections.get('a1').roles, { + master: true, + data: true, + ingest: true + }) + t.strictEqual(pool.connections.get('http://127.0.0.1:9200/'), undefined) + }) + t.test('Add a new connection', t => { t.plan(2) const pool = new ConnectionPool({ Connection }) From 88c9fa85463ac6633fd80ab05b77818d25f46205 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 21 Jan 2019 16:49:08 +0100 Subject: [PATCH 089/172] Consistent roles handling --- lib/Connection.d.ts | 3 +-- lib/Connection.js | 8 +++----- lib/ConnectionPool.js | 22 ++++++++++++++-------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/Connection.d.ts b/lib/Connection.d.ts index 6cfda0ed2..469bb473b 100644 --- a/lib/Connection.d.ts +++ b/lib/Connection.d.ts @@ -34,8 +34,7 @@ export default class Connection { MASTER: string; DATA: string; INGEST: string; - COORDINATING: string; - MACHINE_LEARNING: string; + ML: string; }; url: URL; ssl: SecureContextOptions | null; diff --git a/lib/Connection.js b/lib/Connection.js index 11b6e1577..35e982a70 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -19,7 +19,7 @@ class Connection { this._openRequests = 0 this._status = opts.status || Connection.statuses.ALIVE - this.roles = opts.roles || defaultRoles + this.roles = Object.assign({}, defaultRoles, opts.roles) || Object.assign({}, defaultRoles) if (!['http:', 'https:'].includes(this.url.protocol)) { throw new ConfigurationError(`Invalid protocol: '${this.url.protocol}'`) @@ -199,16 +199,14 @@ Connection.roles = { MASTER: 'master', DATA: 'data', INGEST: 'ingest', - COORDINATING: 'coordinating', - MACHINE_LEARNING: 'machine_learning' + ML: 'ml' } const defaultRoles = { [Connection.roles.MASTER]: true, [Connection.roles.DATA]: true, [Connection.roles.INGEST]: true, - [Connection.roles.COORDINATING]: true, - [Connection.roles.MACHINE_LEARNING]: true + [Connection.roles.ML]: false } const validStatuses = Object.keys(Connection.statuses) diff --git a/lib/ConnectionPool.js b/lib/ConnectionPool.js index b70f7675d..fd9104390 100644 --- a/lib/ConnectionPool.js +++ b/lib/ConnectionPool.js @@ -314,7 +314,6 @@ class ConnectionPool { /** * Transforms the nodes objects to a host object. - * TODO: handle ssl and agent options * * @param {object} nodes * @returns {array} hosts @@ -331,13 +330,20 @@ class ConnectionPool { address = address.slice(0, 4) === 'http' ? address : 'http://' + address + const roles = node.roles.reduce((acc, role) => { + acc[role] = true + return acc + }, {}) + hosts.push({ url: new URL(address), id: ids[i], - roles: node.roles.reduce((acc, role) => { - acc[role] = true - return acc - }, {}) + roles: Object.assign({ + [Connection.roles.MASTER]: true, + [Connection.roles.DATA]: true, + [Connection.roles.INGEST]: true, + [Connection.roles.ML]: false + }, roles) }) } @@ -371,9 +377,9 @@ ConnectionPool.resurrectStrategies = { function defaultNodeFilter (node) { // avoid master only nodes - if (!!node.roles.master === true && - !!node.roles.data === false && - !!node.roles.ingest === false) { + if (node.roles.master === true && + node.roles.data === false && + node.roles.ingest === false) { return false } return true From 9936c0622a0515314df16d5399b1749a7cd627b5 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 21 Jan 2019 16:49:18 +0100 Subject: [PATCH 090/172] Updated test --- test/behavior/sniff.test.js | 6 ++-- test/unit/client.test.js | 60 ++++++++++++++++++------------- test/unit/connection-pool.test.js | 9 +++-- 3 files changed, 46 insertions(+), 29 deletions(-) diff --git a/test/behavior/sniff.test.js b/test/behavior/sniff.test.js index 22b84e2e2..bf0a7b386 100644 --- a/test/behavior/sniff.test.js +++ b/test/behavior/sniff.test.js @@ -45,7 +45,8 @@ test('Should update the connection pool', t => { roles: { master: true, data: true, - ingest: true + ingest: true, + ml: false } }) } else { @@ -55,7 +56,8 @@ test('Should update the connection pool', t => { roles: { master: true, data: true, - ingest: true + ingest: true, + ml: false }, ssl: null, agent: null diff --git a/test/unit/client.test.js b/test/unit/client.test.js index 49a71e3fe..53510ba6a 100644 --- a/test/unit/client.test.js +++ b/test/unit/client.test.js @@ -21,8 +21,7 @@ test('Configure host', t => { master: true, data: true, ingest: true, - coordinating: true, - machine_learning: true + ml: false } }) t.end() @@ -43,8 +42,7 @@ test('Configure host', t => { master: true, data: true, ingest: true, - coordinating: true, - machine_learning: true + ml: false } }) t.match(pool.connections.get('http://localhost:9201/'), { @@ -57,8 +55,7 @@ test('Configure host', t => { master: true, data: true, ingest: true, - coordinating: true, - machine_learning: true + ml: false } }) @@ -72,7 +69,8 @@ test('Configure host', t => { id: 'node', roles: { master: true, - data: false + data: false, + ingest: false }, ssl: 'ssl' } @@ -83,12 +81,16 @@ test('Configure host', t => { id: 'node', ssl: 'ssl', deadCount: 0, - resurrectTimeout: 0, - roles: { - master: true, - data: false - } + resurrectTimeout: 0 }) + + t.deepEqual(pool.connections.get('node').roles, { + master: true, + data: false, + ingest: false, + ml: false + }) + t.end() }) @@ -99,7 +101,8 @@ test('Configure host', t => { id: 'node1', roles: { master: true, - data: false + data: false, + ingest: false }, ssl: 'ssl' }, { @@ -107,7 +110,8 @@ test('Configure host', t => { id: 'node2', roles: { master: false, - data: true + data: true, + ingest: false }, ssl: 'ssl' }] @@ -118,23 +122,31 @@ test('Configure host', t => { id: 'node1', ssl: 'ssl', deadCount: 0, - resurrectTimeout: 0, - roles: { - master: true, - data: false - } + resurrectTimeout: 0 }) + + t.deepEqual(pool.connections.get('node1').roles, { + master: true, + data: false, + ingest: false, + ml: false + }) + t.match(pool.connections.get('node2'), { url: new URL('http://localhost:9200'), id: 'node2', ssl: 'ssl', deadCount: 0, - resurrectTimeout: 0, - roles: { - master: false, - data: true - } + resurrectTimeout: 0 }) + + t.deepEqual(pool.connections.get('node2').roles, { + master: false, + data: true, + ingest: false, + ml: false + }) + t.end() }) diff --git a/test/unit/connection-pool.test.js b/test/unit/connection-pool.test.js index 5ca572ffe..cf054aade 100644 --- a/test/unit/connection-pool.test.js +++ b/test/unit/connection-pool.test.js @@ -296,7 +296,8 @@ test('API', t => { roles: { master: true, data: true, - ingest: true + ingest: true, + ml: false } }, { url: new URL('http://127.0.0.1:9201'), @@ -304,7 +305,8 @@ test('API', t => { roles: { master: true, data: true, - ingest: true + ingest: true, + ml: false } }]) t.end() @@ -426,7 +428,8 @@ test('API', t => { t.deepEqual(pool.connections.get('a1').roles, { master: true, data: true, - ingest: true + ingest: true, + ml: false }) t.strictEqual(pool.connections.get('http://127.0.0.1:9200/'), undefined) }) From 8e26dc874f51f1e1a3b39b363948fc3366023260 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 22 Jan 2019 18:17:17 +0100 Subject: [PATCH 091/172] Added types field --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index bd0ca4677..e348e2689 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "@elastic/elasticsearch", "description": "The official Elasticsearch client for Node.js", "main": "index.js", + "types": "index.d.ts", "homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html", "version": "0.1.0-alpha.4", "keywords": [ From 55fc8d7388a735eec48c82439cb867ddd40bb3ba Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 28 Jan 2019 11:27:21 +0100 Subject: [PATCH 092/172] Handle unescaped characters --- lib/Connection.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Connection.js b/lib/Connection.js index 35e982a70..e5187ce78 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -6,6 +6,7 @@ const https = require('https') const debug = require('debug')('elasticsearch') const decompressResponse = require('decompress-response') const pump = require('pump') +const INVALID_PATH_REGEX = /[^\u0021-\u00ff]/ const { TimeoutError, ConfigurationError } = require('./errors') class Connection { @@ -44,8 +45,15 @@ class Connection { this._openRequests++ var ended = false + const requestParams = this.buildRequestObject(params) + // https://github.com/nodejs/node/commit/b961d9fd83 + if (INVALID_PATH_REGEX.test(requestParams.path) === true) { + callback(new TypeError(`ERR_UNESCAPED_CHARACTERS: ${requestParams.path}`), null) + return { abort: () => {} } + } + debug('Starting a new request', params) - const request = this.makeRequest(this.buildRequestObject(params)) + const request = this.makeRequest(requestParams) // listen for the response event // TODO: handle redirects? From bd2755a302fea417eb124fe1995d5ed709b53cd4 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 28 Jan 2019 11:27:36 +0100 Subject: [PATCH 093/172] Updated test --- test/unit/connection.test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/unit/connection.test.js b/test/unit/connection.test.js index 98a3fe940..b2e8d92d6 100644 --- a/test/unit/connection.test.js +++ b/test/unit/connection.test.js @@ -573,3 +573,21 @@ test('Should throw if the protocol is not http or https', t => { } t.end() }) + +// https://github.com/nodejs/node/commit/b961d9fd83 +test('Should disallow two-byte characters in URL path', t => { + t.plan(1) + + const connection = new Connection({ + url: new URL('http://localhost:9200') + }) + connection.request({ + path: '/thisisinvalid' + encodeURIComponent('\uffe2'), + method: 'GET' + }, (err, res) => { + t.strictEqual( + err.message, + 'ERR_UNESCAPED_CHARACTERS: /thisisinvalid\uffe2' + ) + }) +}) From 7acd2e3b07285fa8b74672de0a0c0c5fb518aa71 Mon Sep 17 00:00:00 2001 From: Tomas Della Vedova Date: Tue, 29 Jan 2019 12:10:20 +0100 Subject: [PATCH 094/172] =?UTF-8?q?Elasticsearch=207=20support=20?= =?UTF-8?q?=F0=9F=9A=80=20(#760)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * API generation * Updated typings * Updated code generation * Updated test * Updated ci configuration * Fixed test --- .ci/docker-compose.yml | 5 +- .ci/test-matrix.yml | 2 +- .travis.yml | 2 +- api/api/bulk.js | 28 +- api/api/cat.aliases.js | 11 +- api/api/cat.allocation.js | 11 +- api/api/cat.count.js | 11 +- api/api/cat.fielddata.js | 11 +- api/api/cat.health.js | 7 +- api/api/cat.help.js | 7 +- api/api/cat.indices.js | 11 +- api/api/cat.master.js | 7 +- api/api/cat.nodeattrs.js | 7 +- api/api/cat.nodes.js | 7 +- api/api/cat.pending_tasks.js | 7 +- api/api/cat.plugins.js | 7 +- api/api/cat.recovery.js | 11 +- api/api/cat.repositories.js | 7 +- api/api/cat.segments.js | 11 +- api/api/cat.shards.js | 11 +- api/api/cat.snapshots.js | 11 +- api/api/cat.tasks.js | 7 +- api/api/cat.templates.js | 11 +- api/api/cat.thread_pool.js | 11 +- api/api/ccr.delete_auto_follow_pattern.js | 7 +- api/api/ccr.follow.js | 7 +- api/api/ccr.follow_stats.js | 7 +- api/api/ccr.get_auto_follow_pattern.js | 11 +- api/api/ccr.pause_follow.js | 7 +- api/api/ccr.put_auto_follow_pattern.js | 7 +- api/api/ccr.resume_follow.js | 7 +- api/api/ccr.stats.js | 7 +- api/api/ccr.unfollow.js | 7 +- api/api/clear_scroll.js | 11 +- api/api/cluster.allocation_explain.js | 7 +- api/api/cluster.get_settings.js | 7 +- api/api/cluster.health.js | 11 +- api/api/cluster.pending_tasks.js | 7 +- api/api/cluster.put_settings.js | 7 +- api/api/cluster.remote_info.js | 7 +- api/api/cluster.reroute.js | 7 +- api/api/cluster.state.js | 19 +- api/api/cluster.stats.js | 13 +- api/api/count.js | 16 +- api/api/create.js | 7 +- api/api/delete.js | 24 +- api/api/delete_by_query.js | 23 +- api/api/delete_by_query_rethrottle.js | 7 +- api/api/delete_script.js | 7 +- api/api/exists.js | 42 +- api/api/exists_source.js | 19 +- api/api/explain.js | 42 +- api/api/field_caps.js | 22 +- api/api/get.js | 36 +- api/api/get_script.js | 7 +- api/api/get_source.js | 19 +- api/api/ilm.delete_lifecycle.js | 104 ++ api/api/ilm.explain_lifecycle.js | 105 ++ api/api/ilm.get_lifecycle.js | 108 ++ api/api/ilm.get_status.js | 103 ++ api/api/ilm.move_to_step.js | 97 ++ api/api/ilm.put_lifecycle.js | 97 ++ api/api/ilm.remove_policy.js | 104 ++ api/api/ilm.retry.js | 104 ++ ...{xpack.watcher.restart.js => ilm.start.js} | 17 +- api/api/ilm.stop.js | 103 ++ api/api/index.js | 28 +- api/api/indices.analyze.js | 11 +- api/api/indices.clear_cache.js | 19 +- api/api/indices.close.js | 7 +- api/api/indices.create.js | 13 +- api/api/indices.delete.js | 7 +- api/api/indices.delete_alias.js | 13 +- api/api/indices.delete_template.js | 7 +- api/api/indices.exists.js | 7 +- api/api/indices.exists_alias.js | 11 +- api/api/indices.exists_template.js | 7 +- api/api/indices.exists_type.js | 7 +- api/api/indices.flush.js | 11 +- api/api/indices.flush_synced.js | 11 +- api/api/indices.forcemerge.js | 11 +- api/api/indices.freeze.js | 126 +++ api/api/indices.get.js | 7 +- api/api/indices.get_alias.js | 15 +- api/api/indices.get_field_mapping.js | 15 +- api/api/indices.get_mapping.js | 18 +- api/api/indices.get_settings.js | 15 +- api/api/indices.get_template.js | 11 +- api/api/indices.get_upgrade.js | 11 +- api/api/indices.open.js | 7 +- api/api/indices.put_alias.js | 13 +- api/api/indices.put_mapping.js | 35 +- api/api/indices.put_settings.js | 11 +- api/api/indices.put_template.js | 7 +- api/api/indices.recovery.js | 11 +- api/api/indices.refresh.js | 11 +- api/api/indices.rollover.js | 11 +- api/api/indices.segments.js | 11 +- api/api/indices.shard_stores.js | 11 +- api/api/indices.shrink.js | 7 +- api/api/indices.split.js | 7 +- api/api/indices.stats.js | 15 +- api/api/indices.unfreeze.js | 126 +++ api/api/indices.update_aliases.js | 7 +- api/api/indices.upgrade.js | 11 +- api/api/indices.validate_query.js | 13 +- api/api/info.js | 7 +- api/api/ingest.delete_pipeline.js | 7 +- api/api/ingest.get_pipeline.js | 11 +- api/api/ingest.processor_grok.js | 7 +- api/api/ingest.put_pipeline.js | 7 +- api/api/ingest.simulate.js | 11 +- api/api/mget.js | 25 +- ...{xpack.ml.close_job.js => ml.close_job.js} | 17 +- ...lete_calendar.js => ml.delete_calendar.js} | 17 +- ...r_event.js => ml.delete_calendar_event.js} | 17 +- ...endar_job.js => ml.delete_calendar_job.js} | 17 +- ...lete_datafeed.js => ml.delete_datafeed.js} | 17 +- ...ired_data.js => ml.delete_expired_data.js} | 17 +- ...l.delete_filter.js => ml.delete_filter.js} | 17 +- ...lete_forecast.js => ml.delete_forecast.js} | 21 +- ...pack.ml.delete_job.js => ml.delete_job.js} | 17 +- ...napshot.js => ml.delete_model_snapshot.js} | 17 +- ...structure.js => ml.find_file_structure.js} | 17 +- ...{xpack.ml.flush_job.js => ml.flush_job.js} | 17 +- .../{xpack.ml.forecast.js => ml.forecast.js} | 17 +- ...ck.ml.get_buckets.js => ml.get_buckets.js} | 21 +- ...ar_events.js => ml.get_calendar_events.js} | 17 +- ...l.get_calendars.js => ml.get_calendars.js} | 21 +- ...get_categories.js => ml.get_categories.js} | 23 +- ...feed_stats.js => ml.get_datafeed_stats.js} | 21 +- ...l.get_datafeeds.js => ml.get_datafeeds.js} | 21 +- ...ck.ml.get_filters.js => ml.get_filters.js} | 21 +- ...t_influencers.js => ml.get_influencers.js} | 17 +- ...l.get_job_stats.js => ml.get_job_stats.js} | 21 +- .../{xpack.ml.get_jobs.js => ml.get_jobs.js} | 21 +- ...snapshots.js => ml.get_model_snapshots.js} | 21 +- ...l_buckets.js => ml.get_overall_buckets.js} | 17 +- ...ck.ml.get_records.js => ml.get_records.js} | 17 +- api/api/{xpack.ml.info.js => ml.info.js} | 17 +- .../{xpack.ml.open_job.js => ml.open_job.js} | 17 +- ...r_events.js => ml.post_calendar_events.js} | 17 +- ...{xpack.ml.post_data.js => ml.post_data.js} | 17 +- ...iew_datafeed.js => ml.preview_datafeed.js} | 17 +- ....ml.put_calendar.js => ml.put_calendar.js} | 17 +- ...calendar_job.js => ml.put_calendar_job.js} | 17 +- ....ml.put_datafeed.js => ml.put_datafeed.js} | 17 +- ...pack.ml.put_filter.js => ml.put_filter.js} | 17 +- .../{xpack.ml.put_job.js => ml.put_job.js} | 17 +- ...napshot.js => ml.revert_model_snapshot.js} | 17 +- ...start_datafeed.js => ml.start_datafeed.js} | 17 +- ...l.stop_datafeed.js => ml.stop_datafeed.js} | 17 +- ...date_datafeed.js => ml.update_datafeed.js} | 17 +- ...l.update_filter.js => ml.update_filter.js} | 17 +- ...pack.ml.update_job.js => ml.update_job.js} | 17 +- ...napshot.js => ml.update_model_snapshot.js} | 17 +- .../{xpack.ml.validate.js => ml.validate.js} | 17 +- ...te_detector.js => ml.validate_detector.js} | 17 +- ....monitoring.bulk.js => monitoring.bulk.js} | 21 +- api/api/msearch.js | 16 +- api/api/msearch_template.js | 16 +- api/api/mtermvectors.js | 13 +- api/api/nodes.hot_threads.js | 19 +- api/api/nodes.info.js | 15 +- api/api/nodes.reload_secure_settings.js | 13 +- api/api/nodes.stats.js | 19 +- api/api/nodes.usage.js | 15 +- api/api/ping.js | 7 +- api/api/put_script.js | 11 +- api/api/rank_eval.js | 11 +- api/api/reindex.js | 7 +- api/api/reindex_rethrottle.js | 7 +- api/api/render_search_template.js | 11 +- api/api/scripts_painless_execute.js | 7 +- api/api/scroll.js | 14 +- api/api/search.js | 33 +- api/api/search_shards.js | 11 +- api/api/search_template.js | 19 +- ...rtificates.js => security.authenticate.js} | 17 +- ...assword.js => security.change_password.js} | 21 +- ...lms.js => security.clear_cached_realms.js} | 17 +- ...oles.js => security.clear_cached_roles.js} | 17 +- ...leges.js => security.delete_privileges.js} | 17 +- ...delete_role.js => security.delete_role.js} | 17 +- ...ing.js => security.delete_role_mapping.js} | 17 +- ...delete_user.js => security.delete_user.js} | 17 +- ...sable_user.js => security.disable_user.js} | 17 +- ...enable_user.js => security.enable_user.js} | 17 +- ...ivileges.js => security.get_privileges.js} | 17 +- ...urity.get_role.js => security.get_role.js} | 21 +- ...apping.js => security.get_role_mapping.js} | 21 +- ...ity.get_token.js => security.get_token.js} | 17 +- ...urity.get_user.js => security.get_user.js} | 21 +- ...ate.js => security.get_user_privileges.js} | 17 +- ...ivileges.js => security.has_privileges.js} | 21 +- ..._token.js => security.invalidate_token.js} | 17 +- ...ivileges.js => security.put_privileges.js} | 17 +- ...urity.put_role.js => security.put_role.js} | 17 +- ...apping.js => security.put_role_mapping.js} | 17 +- ...urity.put_user.js => security.put_user.js} | 17 +- api/api/snapshot.create.js | 7 +- api/api/snapshot.create_repository.js | 7 +- api/api/snapshot.delete.js | 7 +- api/api/snapshot.delete_repository.js | 7 +- api/api/snapshot.get.js | 7 +- api/api/snapshot.get_repository.js | 11 +- api/api/snapshot.restore.js | 7 +- api/api/snapshot.status.js | 13 +- api/api/snapshot.verify_repository.js | 7 +- api/api/ssl.certificates.js | 103 ++ api/api/tasks.cancel.js | 11 +- api/api/tasks.get.js | 7 +- api/api/tasks.list.js | 7 +- api/api/termvectors.js | 34 +- api/api/update.js | 45 +- api/api/update_by_query.js | 23 +- api/api/update_by_query_rethrottle.js | 7 +- api/api/xpack.graph.explore.js | 11 +- api/api/xpack.info.js | 7 +- api/api/xpack.license.delete.js | 7 +- api/api/xpack.license.get.js | 7 +- api/api/xpack.license.get_basic_status.js | 7 +- api/api/xpack.license.get_trial_status.js | 7 +- api/api/xpack.license.post.js | 7 +- api/api/xpack.license.post_start_basic.js | 7 +- api/api/xpack.license.post_start_trial.js | 7 +- api/api/xpack.migration.deprecations.js | 11 +- api/api/xpack.migration.get_assistance.js | 11 +- api/api/xpack.migration.upgrade.js | 7 +- api/api/xpack.rollup.delete_job.js | 7 +- api/api/xpack.rollup.get_jobs.js | 11 +- api/api/xpack.rollup.get_rollup_caps.js | 11 +- api/api/xpack.rollup.get_rollup_index_caps.js | 7 +- api/api/xpack.rollup.put_job.js | 7 +- api/api/xpack.rollup.rollup_search.js | 21 +- api/api/xpack.rollup.start_job.js | 7 +- api/api/xpack.rollup.stop_job.js | 15 +- api/api/xpack.security.get_user_privileges.js | 100 -- api/api/xpack.sql.clear_cursor.js | 7 +- api/api/xpack.sql.query.js | 7 +- api/api/xpack.sql.translate.js | 7 +- api/api/xpack.usage.js | 7 +- api/api/xpack.watcher.ack_watch.js | 16 +- api/api/xpack.watcher.activate_watch.js | 12 +- api/api/xpack.watcher.deactivate_watch.js | 12 +- api/api/xpack.watcher.delete_watch.js | 12 +- api/api/xpack.watcher.execute_watch.js | 11 +- api/api/xpack.watcher.get_watch.js | 7 +- api/api/xpack.watcher.put_watch.js | 10 +- api/api/xpack.watcher.start.js | 7 +- api/api/xpack.watcher.stats.js | 11 +- api/api/xpack.watcher.stop.js | 7 +- api/index.js | 302 +++--- api/requestParams.d.ts | 982 ++++++++++-------- index.d.ts | 302 +++--- scripts/es-docker.sh | 4 +- scripts/utils/generate.js | 155 ++- test/integration/index.js | 26 +- test/unit/connection.test.js | 2 +- 259 files changed, 4368 insertions(+), 1990 deletions(-) create mode 100644 api/api/ilm.delete_lifecycle.js create mode 100644 api/api/ilm.explain_lifecycle.js create mode 100644 api/api/ilm.get_lifecycle.js create mode 100644 api/api/ilm.get_status.js create mode 100644 api/api/ilm.move_to_step.js create mode 100644 api/api/ilm.put_lifecycle.js create mode 100644 api/api/ilm.remove_policy.js create mode 100644 api/api/ilm.retry.js rename api/api/{xpack.watcher.restart.js => ilm.start.js} (82%) create mode 100644 api/api/ilm.stop.js create mode 100644 api/api/indices.freeze.js create mode 100644 api/api/indices.unfreeze.js rename api/api/{xpack.ml.close_job.js => ml.close_job.js} (84%) rename api/api/{xpack.ml.delete_calendar.js => ml.delete_calendar.js} (84%) rename api/api/{xpack.ml.delete_calendar_event.js => ml.delete_calendar_event.js} (85%) rename api/api/{xpack.ml.delete_calendar_job.js => ml.delete_calendar_job.js} (85%) rename api/api/{xpack.ml.delete_datafeed.js => ml.delete_datafeed.js} (82%) rename api/api/{xpack.ml.delete_expired_data.js => ml.delete_expired_data.js} (83%) rename api/api/{xpack.ml.delete_filter.js => ml.delete_filter.js} (84%) rename api/api/{xpack.ml.delete_forecast.js => ml.delete_forecast.js} (78%) rename api/api/{xpack.ml.delete_job.js => ml.delete_job.js} (84%) rename api/api/{xpack.ml.delete_model_snapshot.js => ml.delete_model_snapshot.js} (82%) rename api/api/{xpack.ml.find_file_structure.js => ml.find_file_structure.js} (89%) rename api/api/{xpack.ml.flush_job.js => ml.flush_job.js} (86%) rename api/api/{xpack.ml.forecast.js => ml.forecast.js} (86%) rename api/api/{xpack.ml.get_buckets.js => ml.get_buckets.js} (81%) rename api/api/{xpack.ml.get_calendar_events.js => ml.get_calendar_events.js} (86%) rename api/api/{xpack.ml.get_calendars.js => ml.get_calendars.js} (82%) rename api/api/{xpack.ml.get_categories.js => ml.get_categories.js} (75%) rename api/api/{xpack.ml.get_datafeed_stats.js => ml.get_datafeed_stats.js} (78%) rename api/api/{xpack.ml.get_datafeeds.js => ml.get_datafeeds.js} (80%) rename api/api/{xpack.ml.get_filters.js => ml.get_filters.js} (82%) rename api/api/{xpack.ml.get_influencers.js => ml.get_influencers.js} (85%) rename api/api/{xpack.ml.get_job_stats.js => ml.get_job_stats.js} (79%) rename api/api/{xpack.ml.get_jobs.js => ml.get_jobs.js} (81%) rename api/api/{xpack.ml.get_model_snapshots.js => ml.get_model_snapshots.js} (79%) rename api/api/{xpack.ml.get_overall_buckets.js => ml.get_overall_buckets.js} (85%) rename api/api/{xpack.ml.get_records.js => ml.get_records.js} (85%) rename api/api/{xpack.ml.info.js => ml.info.js} (85%) rename api/api/{xpack.ml.open_job.js => ml.open_job.js} (84%) rename api/api/{xpack.ml.post_calendar_events.js => ml.post_calendar_events.js} (83%) rename api/api/{xpack.ml.post_data.js => ml.post_data.js} (84%) rename api/api/{xpack.ml.preview_datafeed.js => ml.preview_datafeed.js} (81%) rename api/api/{xpack.ml.put_calendar.js => ml.put_calendar.js} (84%) rename api/api/{xpack.ml.put_calendar_job.js => ml.put_calendar_job.js} (85%) rename api/api/{xpack.ml.put_datafeed.js => ml.put_datafeed.js} (83%) rename api/api/{xpack.ml.put_filter.js => ml.put_filter.js} (85%) rename api/api/{xpack.ml.put_job.js => ml.put_job.js} (83%) rename api/api/{xpack.ml.revert_model_snapshot.js => ml.revert_model_snapshot.js} (83%) rename api/api/{xpack.ml.start_datafeed.js => ml.start_datafeed.js} (83%) rename api/api/{xpack.ml.stop_datafeed.js => ml.stop_datafeed.js} (84%) rename api/api/{xpack.ml.update_datafeed.js => ml.update_datafeed.js} (82%) rename api/api/{xpack.ml.update_filter.js => ml.update_filter.js} (84%) rename api/api/{xpack.ml.update_job.js => ml.update_job.js} (83%) rename api/api/{xpack.ml.update_model_snapshot.js => ml.update_model_snapshot.js} (83%) rename api/api/{xpack.ml.validate.js => ml.validate.js} (85%) rename api/api/{xpack.ml.validate_detector.js => ml.validate_detector.js} (83%) rename api/api/{xpack.monitoring.bulk.js => monitoring.bulk.js} (83%) rename api/api/{xpack.ssl.certificates.js => security.authenticate.js} (82%) rename api/api/{xpack.security.change_password.js => security.change_password.js} (80%) rename api/api/{xpack.security.clear_cached_realms.js => security.clear_cached_realms.js} (81%) rename api/api/{xpack.security.clear_cached_roles.js => security.clear_cached_roles.js} (80%) rename api/api/{xpack.security.delete_privileges.js => security.delete_privileges.js} (86%) rename api/api/{xpack.security.delete_role.js => security.delete_role.js} (83%) rename api/api/{xpack.security.delete_role_mapping.js => security.delete_role_mapping.js} (82%) rename api/api/{xpack.security.delete_user.js => security.delete_user.js} (83%) rename api/api/{xpack.security.disable_user.js => security.disable_user.js} (82%) rename api/api/{xpack.security.enable_user.js => security.enable_user.js} (82%) rename api/api/{xpack.security.get_privileges.js => security.get_privileges.js} (84%) rename api/api/{xpack.security.get_role.js => security.get_role.js} (80%) rename api/api/{xpack.security.get_role_mapping.js => security.get_role_mapping.js} (78%) rename api/api/{xpack.security.get_token.js => security.get_token.js} (81%) rename api/api/{xpack.security.get_user.js => security.get_user.js} (80%) rename api/api/{xpack.security.authenticate.js => security.get_user_privileges.js} (81%) rename api/api/{xpack.security.has_privileges.js => security.has_privileges.js} (78%) rename api/api/{xpack.security.invalidate_token.js => security.invalidate_token.js} (80%) rename api/api/{xpack.security.put_privileges.js => security.put_privileges.js} (85%) rename api/api/{xpack.security.put_role.js => security.put_role.js} (84%) rename api/api/{xpack.security.put_role_mapping.js => security.put_role_mapping.js} (83%) rename api/api/{xpack.security.put_user.js => security.put_user.js} (84%) create mode 100644 api/api/ssl.certificates.js delete mode 100644 api/api/xpack.security.get_user_privileges.js diff --git a/.ci/docker-compose.yml b/.ci/docker-compose.yml index 5176c6440..17b4a4797 100644 --- a/.ci/docker-compose.yml +++ b/.ci/docker-compose.yml @@ -20,7 +20,7 @@ services: depends_on: - elasticsearch elasticsearch: - image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-6.5.0} + image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-7.0.0-alpha2} volumes: - esvol:/tmp networks: @@ -30,7 +30,8 @@ services: - "repositories.url.allowed_urls=http://*" - node.attr.testattr=test - bootstrap.memory_lock=false - - "discovery.zen.ping.unicast.hosts=elasticsearch" + # - "discovery.zen.ping.unicast.hosts=elasticsearch" + - "discovery.type=single-node" - "http.max_content_length=5mb" networks: esnet: diff --git a/.ci/test-matrix.yml b/.ci/test-matrix.yml index 6625ffaac..78f9ccd21 100644 --- a/.ci/test-matrix.yml +++ b/.ci/test-matrix.yml @@ -1,6 +1,6 @@ --- ELASTICSEARCH_VERSION: -- 6.5.0 +- 7.0.0-alpha2 NODE_JS_VERSION: - 10 diff --git a/.travis.yml b/.travis.yml index 743820f04..a37514d99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ node_js: env: global: - - ELASTICSEARCH_VERSION=6.5.0 + - ELASTICSEARCH_VERSION=7.0.0-alpha2 - QUIET=true before_install: diff --git a/api/api/bulk.js b/api/api/bulk.js index 45165b1c2..9a310438a 100644 --- a/api/api/bulk.js +++ b/api/api/bulk.js @@ -13,10 +13,9 @@ function buildBulk (opts) { * @param {string} routing - Specific routing value * @param {time} timeout - Explicit operation timeout * @param {string} type - Default document type for items which don't provide one - * @param {list} fields - Default comma-separated list of fields to return in the response for updates, can be overridden on each sub-request * @param {list} _source - True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request - * @param {list} _source_exclude - Default list of fields to exclude from the returned _source field, can be overridden on each sub-request - * @param {list} _source_include - Default list of fields to extract and return from the _source field, can be overridden on each sub-request + * @param {list} _source_excludes - Default list of fields to exclude from the returned _source field, can be overridden on each sub-request + * @param {list} _source_includes - Default list of fields to extract and return from the _source field, can be overridden on each sub-request * @param {string} pipeline - The pipeline id to preprocess incoming documents with * @param {object} body - The operation definition and data (action-data pairs), separated by newlines */ @@ -65,10 +64,9 @@ function buildBulk (opts) { 'routing', 'timeout', 'type', - 'fields', '_source', - '_source_exclude', - '_source_include', + '_source_excludes', + '_source_includes', 'pipeline', 'pretty', 'human', @@ -82,10 +80,9 @@ function buildBulk (opts) { 'routing', 'timeout', 'type', - 'fields', '_source', - '_sourceExclude', - '_sourceInclude', + '_sourceExcludes', + '_sourceIncludes', 'pipeline', 'pretty', 'human', @@ -125,11 +122,20 @@ function buildBulk (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_bulk' + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_bulk' + } else { + path = '/' + '_bulk' + } + // build request object - const parts = [params['index'], params['type'], '_bulk'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, bulkBody: params.body, querystring } diff --git a/api/api/cat.aliases.js b/api/api/cat.aliases.js index 5a55df2a2..44a925878 100644 --- a/api/api/cat.aliases.js +++ b/api/api/cat.aliases.js @@ -106,11 +106,18 @@ function buildCatAliases (opts) { ignore = [ignore] } + var path = '' + + if ((params['name']) != null) { + path = '/' + '_cat' + '/' + 'aliases' + '/' + encodeURIComponent(params['name']) + } else { + path = '/' + '_cat' + '/' + 'aliases' + } + // build request object - const parts = ['_cat', 'aliases', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.allocation.js b/api/api/cat.allocation.js index 71e73aa9c..483da3e42 100644 --- a/api/api/cat.allocation.js +++ b/api/api/cat.allocation.js @@ -109,11 +109,18 @@ function buildCatAllocation (opts) { ignore = [ignore] } + var path = '' + + if ((params['node_id'] || params['nodeId']) != null) { + path = '/' + '_cat' + '/' + 'allocation' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + } else { + path = '/' + '_cat' + '/' + 'allocation' + } + // build request object - const parts = ['_cat', 'allocation', params['node_id'] || params['nodeId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.count.js b/api/api/cat.count.js index 31d497340..351f119d2 100644 --- a/api/api/cat.count.js +++ b/api/api/cat.count.js @@ -106,11 +106,18 @@ function buildCatCount (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + '_cat' + '/' + 'count' + '/' + encodeURIComponent(params['index']) + } else { + path = '/' + '_cat' + '/' + 'count' + } + // build request object - const parts = ['_cat', 'count', params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.fielddata.js b/api/api/cat.fielddata.js index 0a6cc1d59..484467085 100644 --- a/api/api/cat.fielddata.js +++ b/api/api/cat.fielddata.js @@ -112,11 +112,18 @@ function buildCatFielddata (opts) { ignore = [ignore] } + var path = '' + + if ((params['fields']) != null) { + path = '/' + '_cat' + '/' + 'fielddata' + '/' + encodeURIComponent(params['fields']) + } else { + path = '/' + '_cat' + '/' + 'fielddata' + } + // build request object - const parts = ['_cat', 'fielddata', params['fields']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.health.js b/api/api/cat.health.js index fbb4c5946..a22eeef1b 100644 --- a/api/api/cat.health.js +++ b/api/api/cat.health.js @@ -108,11 +108,14 @@ function buildCatHealth (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cat' + '/' + 'health' + // build request object - const parts = ['_cat', 'health'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.help.js b/api/api/cat.help.js index 6b671f2b2..55838067e 100644 --- a/api/api/cat.help.js +++ b/api/api/cat.help.js @@ -90,11 +90,14 @@ function buildCatHelp (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cat' + // build request object - const parts = ['_cat'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.indices.js b/api/api/cat.indices.js index 0b0370fbb..7f4231376 100644 --- a/api/api/cat.indices.js +++ b/api/api/cat.indices.js @@ -115,11 +115,18 @@ function buildCatIndices (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + '_cat' + '/' + 'indices' + '/' + encodeURIComponent(params['index']) + } else { + path = '/' + '_cat' + '/' + 'indices' + } + // build request object - const parts = ['_cat', 'indices', params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.master.js b/api/api/cat.master.js index a313a0c6e..c7474c209 100644 --- a/api/api/cat.master.js +++ b/api/api/cat.master.js @@ -105,11 +105,14 @@ function buildCatMaster (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cat' + '/' + 'master' + // build request object - const parts = ['_cat', 'master'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.nodeattrs.js b/api/api/cat.nodeattrs.js index 31234406e..1b491a9b6 100644 --- a/api/api/cat.nodeattrs.js +++ b/api/api/cat.nodeattrs.js @@ -105,11 +105,14 @@ function buildCatNodeattrs (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cat' + '/' + 'nodeattrs' + // build request object - const parts = ['_cat', 'nodeattrs'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.nodes.js b/api/api/cat.nodes.js index 4785a9e93..8191197c6 100644 --- a/api/api/cat.nodes.js +++ b/api/api/cat.nodes.js @@ -108,11 +108,14 @@ function buildCatNodes (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cat' + '/' + 'nodes' + // build request object - const parts = ['_cat', 'nodes'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.pending_tasks.js b/api/api/cat.pending_tasks.js index bd355ebef..755c78feb 100644 --- a/api/api/cat.pending_tasks.js +++ b/api/api/cat.pending_tasks.js @@ -105,11 +105,14 @@ function buildCatPendingTasks (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cat' + '/' + 'pending_tasks' + // build request object - const parts = ['_cat', 'pending_tasks'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.plugins.js b/api/api/cat.plugins.js index eaf9874a1..2cfd47dd5 100644 --- a/api/api/cat.plugins.js +++ b/api/api/cat.plugins.js @@ -105,11 +105,14 @@ function buildCatPlugins (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cat' + '/' + 'plugins' + // build request object - const parts = ['_cat', 'plugins'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.recovery.js b/api/api/cat.recovery.js index c453e4703..204bffe54 100644 --- a/api/api/cat.recovery.js +++ b/api/api/cat.recovery.js @@ -106,11 +106,18 @@ function buildCatRecovery (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + '_cat' + '/' + 'recovery' + '/' + encodeURIComponent(params['index']) + } else { + path = '/' + '_cat' + '/' + 'recovery' + } + // build request object - const parts = ['_cat', 'recovery', params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.repositories.js b/api/api/cat.repositories.js index f022ca815..6b2f01746 100644 --- a/api/api/cat.repositories.js +++ b/api/api/cat.repositories.js @@ -105,11 +105,14 @@ function buildCatRepositories (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cat' + '/' + 'repositories' + // build request object - const parts = ['_cat', 'repositories'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.segments.js b/api/api/cat.segments.js index 6075d045e..2a502db05 100644 --- a/api/api/cat.segments.js +++ b/api/api/cat.segments.js @@ -103,11 +103,18 @@ function buildCatSegments (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + '_cat' + '/' + 'segments' + '/' + encodeURIComponent(params['index']) + } else { + path = '/' + '_cat' + '/' + 'segments' + } + // build request object - const parts = ['_cat', 'segments', params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.shards.js b/api/api/cat.shards.js index dc2cd6cb8..c9cecbdee 100644 --- a/api/api/cat.shards.js +++ b/api/api/cat.shards.js @@ -109,11 +109,18 @@ function buildCatShards (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + '_cat' + '/' + 'shards' + '/' + encodeURIComponent(params['index']) + } else { + path = '/' + '_cat' + '/' + 'shards' + } + // build request object - const parts = ['_cat', 'shards', params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.snapshots.js b/api/api/cat.snapshots.js index 4d192d79c..1a36c6994 100644 --- a/api/api/cat.snapshots.js +++ b/api/api/cat.snapshots.js @@ -106,11 +106,18 @@ function buildCatSnapshots (opts) { ignore = [ignore] } + var path = '' + + if ((params['repository']) != null) { + path = '/' + '_cat' + '/' + 'snapshots' + '/' + encodeURIComponent(params['repository']) + } else { + path = '/' + '_cat' + '/' + 'snapshots' + } + // build request object - const parts = ['_cat', 'snapshots', params['repository']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.tasks.js b/api/api/cat.tasks.js index 9546b0166..b51c5d0e5 100644 --- a/api/api/cat.tasks.js +++ b/api/api/cat.tasks.js @@ -111,11 +111,14 @@ function buildCatTasks (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cat' + '/' + 'tasks' + // build request object - const parts = ['_cat', 'tasks'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.templates.js b/api/api/cat.templates.js index ce2ffbd18..1fbcf3549 100644 --- a/api/api/cat.templates.js +++ b/api/api/cat.templates.js @@ -106,11 +106,18 @@ function buildCatTemplates (opts) { ignore = [ignore] } + var path = '' + + if ((params['name']) != null) { + path = '/' + '_cat' + '/' + 'templates' + '/' + encodeURIComponent(params['name']) + } else { + path = '/' + '_cat' + '/' + 'templates' + } + // build request object - const parts = ['_cat', 'templates', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.thread_pool.js b/api/api/cat.thread_pool.js index edba83157..c32c15d5e 100644 --- a/api/api/cat.thread_pool.js +++ b/api/api/cat.thread_pool.js @@ -109,11 +109,18 @@ function buildCatThreadPool (opts) { ignore = [ignore] } + var path = '' + + if ((params['thread_pool_patterns'] || params['threadPoolPatterns']) != null) { + path = '/' + '_cat' + '/' + 'thread_pool' + '/' + encodeURIComponent(params['thread_pool_patterns'] || params['threadPoolPatterns']) + } else { + path = '/' + '_cat' + '/' + 'thread_pool' + } + // build request object - const parts = ['_cat', 'thread_pool', params['thread_pool_patterns'] || params['threadPoolPatterns']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/ccr.delete_auto_follow_pattern.js b/api/api/ccr.delete_auto_follow_pattern.js index d676aa96a..83f4f279b 100644 --- a/api/api/ccr.delete_auto_follow_pattern.js +++ b/api/api/ccr.delete_auto_follow_pattern.js @@ -77,11 +77,14 @@ function buildCcrDeleteAutoFollowPattern (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_ccr', 'auto_follow', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/ccr.follow.js b/api/api/ccr.follow.js index 344e12a83..2ac210f45 100644 --- a/api/api/ccr.follow.js +++ b/api/api/ccr.follow.js @@ -84,11 +84,14 @@ function buildCcrFollow (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_ccr' + '/' + 'follow' + // build request object - const parts = [params['index'], '_ccr', 'follow'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/ccr.follow_stats.js b/api/api/ccr.follow_stats.js index a073af9fc..f095eb271 100644 --- a/api/api/ccr.follow_stats.js +++ b/api/api/ccr.follow_stats.js @@ -69,11 +69,14 @@ function buildCcrFollowStats (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_ccr' + '/' + 'stats' + // build request object - const parts = [params['index'], '_ccr', 'stats'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/ccr.get_auto_follow_pattern.js b/api/api/ccr.get_auto_follow_pattern.js index e0b15f89e..ee2f82606 100644 --- a/api/api/ccr.get_auto_follow_pattern.js +++ b/api/api/ccr.get_auto_follow_pattern.js @@ -69,11 +69,18 @@ function buildCcrGetAutoFollowPattern (opts) { ignore = [ignore] } + var path = '' + + if ((params['name']) != null) { + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(params['name']) + } else { + path = '/' + '_ccr' + '/' + 'auto_follow' + } + // build request object - const parts = ['_ccr', 'auto_follow', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/ccr.pause_follow.js b/api/api/ccr.pause_follow.js index e0f646809..2b79f162e 100644 --- a/api/api/ccr.pause_follow.js +++ b/api/api/ccr.pause_follow.js @@ -77,11 +77,14 @@ function buildCcrPauseFollow (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_ccr' + '/' + 'pause_follow' + // build request object - const parts = [params['index'], '_ccr', 'pause_follow'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/ccr.put_auto_follow_pattern.js b/api/api/ccr.put_auto_follow_pattern.js index 766a24d9e..49ae7ff06 100644 --- a/api/api/ccr.put_auto_follow_pattern.js +++ b/api/api/ccr.put_auto_follow_pattern.js @@ -84,11 +84,14 @@ function buildCcrPutAutoFollowPattern (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_ccr', 'auto_follow', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/ccr.resume_follow.js b/api/api/ccr.resume_follow.js index 989e04e1a..7ee6ba6c5 100644 --- a/api/api/ccr.resume_follow.js +++ b/api/api/ccr.resume_follow.js @@ -84,11 +84,14 @@ function buildCcrResumeFollow (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_ccr' + '/' + 'resume_follow' + // build request object - const parts = [params['index'], '_ccr', 'resume_follow'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/ccr.stats.js b/api/api/ccr.stats.js index 786a130cb..00e94ea6d 100644 --- a/api/api/ccr.stats.js +++ b/api/api/ccr.stats.js @@ -68,11 +68,14 @@ function buildCcrStats (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ccr' + '/' + 'stats' + // build request object - const parts = ['_ccr', 'stats'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/ccr.unfollow.js b/api/api/ccr.unfollow.js index 92f192de4..bd810eaa9 100644 --- a/api/api/ccr.unfollow.js +++ b/api/api/ccr.unfollow.js @@ -77,11 +77,14 @@ function buildCcrUnfollow (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_ccr' + '/' + 'unfollow' + // build request object - const parts = [params['index'], '_ccr', 'unfollow'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/clear_scroll.js b/api/api/clear_scroll.js index 439a07481..229df18d6 100644 --- a/api/api/clear_scroll.js +++ b/api/api/clear_scroll.js @@ -78,11 +78,18 @@ function buildClearScroll (opts) { ignore = [ignore] } + var path = '' + + if ((params['scroll_id'] || params['scrollId']) != null) { + path = '/' + '_search' + '/' + 'scroll' + '/' + encodeURIComponent(params['scroll_id'] || params['scrollId']) + } else { + path = '/' + '_search' + '/' + 'scroll' + } + // build request object - const parts = ['_search', 'scroll', params['scroll_id'] || params['scrollId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/cluster.allocation_explain.js b/api/api/cluster.allocation_explain.js index 799658e2a..c7cecff23 100644 --- a/api/api/cluster.allocation_explain.js +++ b/api/api/cluster.allocation_explain.js @@ -83,11 +83,14 @@ function buildClusterAllocationExplain (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cluster' + '/' + 'allocation' + '/' + 'explain' + // build request object - const parts = ['_cluster', 'allocation', 'explain'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/cluster.get_settings.js b/api/api/cluster.get_settings.js index 8897c47c7..dd35c7343 100644 --- a/api/api/cluster.get_settings.js +++ b/api/api/cluster.get_settings.js @@ -96,11 +96,14 @@ function buildClusterGetSettings (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cluster' + '/' + 'settings' + // build request object - const parts = ['_cluster', 'settings'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cluster.health.js b/api/api/cluster.health.js index 018a91159..9fce75525 100644 --- a/api/api/cluster.health.js +++ b/api/api/cluster.health.js @@ -115,11 +115,18 @@ function buildClusterHealth (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + '_cluster' + '/' + 'health' + '/' + encodeURIComponent(params['index']) + } else { + path = '/' + '_cluster' + '/' + 'health' + } + // build request object - const parts = ['_cluster', 'health', params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cluster.pending_tasks.js b/api/api/cluster.pending_tasks.js index 2310d4313..afcaafe78 100644 --- a/api/api/cluster.pending_tasks.js +++ b/api/api/cluster.pending_tasks.js @@ -90,11 +90,14 @@ function buildClusterPendingTasks (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cluster' + '/' + 'pending_tasks' + // build request object - const parts = ['_cluster', 'pending_tasks'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cluster.put_settings.js b/api/api/cluster.put_settings.js index a5b5edc1b..74edae830 100644 --- a/api/api/cluster.put_settings.js +++ b/api/api/cluster.put_settings.js @@ -94,11 +94,14 @@ function buildClusterPutSettings (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cluster' + '/' + 'settings' + // build request object - const parts = ['_cluster', 'settings'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/cluster.remote_info.js b/api/api/cluster.remote_info.js index 89eb5a8c2..97ba00e6b 100644 --- a/api/api/cluster.remote_info.js +++ b/api/api/cluster.remote_info.js @@ -84,11 +84,14 @@ function buildClusterRemoteInfo (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_remote' + '/' + 'info' + // build request object - const parts = ['_remote', 'info'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cluster.reroute.js b/api/api/cluster.reroute.js index 3749abcde..f4f114305 100644 --- a/api/api/cluster.reroute.js +++ b/api/api/cluster.reroute.js @@ -95,11 +95,14 @@ function buildClusterReroute (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cluster' + '/' + 'reroute' + // build request object - const parts = ['_cluster', 'reroute'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/cluster.state.js b/api/api/cluster.state.js index e749f4a17..70e1307ec 100644 --- a/api/api/cluster.state.js +++ b/api/api/cluster.state.js @@ -11,6 +11,8 @@ function buildClusterState (opts) { * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) * @param {time} master_timeout - Specify timeout for connection to master * @param {boolean} flat_settings - Return settings in flat format (default: false) + * @param {number} wait_for_metadata_version - Wait for the metadata version to be equal or greater than the specified metadata version + * @param {time} wait_for_timeout - The maximum time to wait for wait_for_metadata_version before timing out * @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. @@ -58,6 +60,8 @@ function buildClusterState (opts) { 'local', 'master_timeout', 'flat_settings', + 'wait_for_metadata_version', + 'wait_for_timeout', 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', @@ -71,6 +75,8 @@ function buildClusterState (opts) { 'local', 'masterTimeout', 'flatSettings', + 'waitForMetadataVersion', + 'waitForTimeout', 'ignoreUnavailable', 'allowNoIndices', 'expandWildcards', @@ -112,11 +118,20 @@ function buildClusterState (opts) { ignore = [ignore] } + var path = '' + + if ((params['metric']) != null && (params['index']) != null) { + path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(params['metric']) + '/' + encodeURIComponent(params['index']) + } else if ((params['metric']) != null) { + path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(params['metric']) + } else { + path = '/' + '_cluster' + '/' + 'state' + } + // build request object - const parts = ['_cluster', 'state', params['metric'], params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cluster.stats.js b/api/api/cluster.stats.js index 8c37aba10..50a797066 100644 --- a/api/api/cluster.stats.js +++ b/api/api/cluster.stats.js @@ -91,13 +91,18 @@ function buildClusterStats (opts) { ignore = [ignore] } + var path = '' + + if ((params['node_id'] || params['nodeId']) != null) { + path = '/' + '_cluster' + '/' + 'stats' + '/' + 'nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + } else { + path = '/' + '_cluster' + '/' + 'stats' + } + // build request object - const parts = ['_cluster', 'stats', 'nodes', params['node_id'] || params['nodeId']] const request = { method, - path: (params['node_id'] || params['nodeId']) != null - ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') - : '/_cluster/stats', + path, body: null, querystring } diff --git a/api/api/count.js b/api/api/count.js index 568a403b6..74e261b14 100644 --- a/api/api/count.js +++ b/api/api/count.js @@ -9,6 +9,7 @@ function buildCount (opts) { * @param {list} index - A comma-separated list of indices to restrict the results * @param {list} type - A comma-separated list of types to restrict the results * @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {boolean} ignore_throttled - Whether specified concrete, expanded or aliased indices should be ignored when throttled * @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 {number} min_score - Include only documents with a specific `_score` value in the result @@ -56,6 +57,7 @@ function buildCount (opts) { const keys = Object.keys(params) const acceptedQuerystring = [ 'ignore_unavailable', + 'ignore_throttled', 'allow_no_indices', 'expand_wildcards', 'min_score', @@ -76,6 +78,7 @@ function buildCount (opts) { ] const acceptedQuerystringCamelCased = [ 'ignoreUnavailable', + 'ignoreThrottled', 'allowNoIndices', 'expandWildcards', 'minScore', @@ -126,11 +129,20 @@ function buildCount (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_count' + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_count' + } else { + path = '/' + '_count' + } + // build request object - const parts = [params['index'], params['type'], '_count'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/create.js b/api/api/create.js index 38c40df49..b20a5269a 100644 --- a/api/api/create.js +++ b/api/api/create.js @@ -143,11 +143,14 @@ function buildCreate (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_create' + // build request object - const parts = [params['index'], params['type'], params['id'], '_create'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/delete.js b/api/api/delete.js index a6545c05c..d4b227a4f 100644 --- a/api/api/delete.js +++ b/api/api/delete.js @@ -50,12 +50,6 @@ function buildDelete (opts) { result ) } - if (params['type'] == null) { - return callback( - new ConfigurationError('Missing required parameter: type'), - result - ) - } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), @@ -64,12 +58,7 @@ function buildDelete (opts) { } // check required url components - if (params['id'] != null && (params['type'] == null || params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: type, index'), - result - ) - } else if (params['type'] != null && (params['index'] == null)) { + if (params['id'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), result @@ -139,11 +128,18 @@ function buildDelete (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null && (params['id']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_doc' + '/' + encodeURIComponent(params['id']) + } + // build request object - const parts = [params['index'], params['type'], params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/delete_by_query.js b/api/api/delete_by_query.js index e0b984a53..91302e500 100644 --- a/api/api/delete_by_query.js +++ b/api/api/delete_by_query.js @@ -27,8 +27,8 @@ function buildDeleteByQuery (opts) { * @param {number} size - Number of hits to return (default: 10) * @param {list} sort - A comma-separated list of : pairs * @param {list} _source - True or false to return the _source field or not, or a list of fields to return - * @param {list} _source_exclude - A list of fields to exclude from the returned _source field - * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {list} _source_excludes - A list of fields to exclude from the returned _source field + * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {number} terminate_after - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. * @param {list} stats - Specific 'tag' of the request for logging and statistical purposes * @param {boolean} version - Specify whether to return document version as part of a hit @@ -107,8 +107,8 @@ function buildDeleteByQuery (opts) { 'size', 'sort', '_source', - '_source_exclude', - '_source_include', + '_source_excludes', + '_source_includes', 'terminate_after', 'stats', 'version', @@ -146,8 +146,8 @@ function buildDeleteByQuery (opts) { 'size', 'sort', '_source', - '_sourceExclude', - '_sourceInclude', + '_sourceExcludes', + '_sourceIncludes', 'terminateAfter', 'stats', 'version', @@ -197,11 +197,18 @@ function buildDeleteByQuery (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_delete_by_query' + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_delete_by_query' + } + // build request object - const parts = [params['index'], params['type'], '_delete_by_query'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/delete_by_query_rethrottle.js b/api/api/delete_by_query_rethrottle.js index 423144942..ef307c463 100644 --- a/api/api/delete_by_query_rethrottle.js +++ b/api/api/delete_by_query_rethrottle.js @@ -100,11 +100,14 @@ function buildDeleteByQueryRethrottle (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_delete_by_query' + '/' + encodeURIComponent(params['task_id'] || params['taskId']) + '/' + '_rethrottle' + // build request object - const parts = ['_delete_by_query', params['task_id'] || params['taskId'], '_rethrottle'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/delete_script.js b/api/api/delete_script.js index 0459738b7..280b73d46 100644 --- a/api/api/delete_script.js +++ b/api/api/delete_script.js @@ -97,11 +97,14 @@ function buildDeleteScript (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_scripts' + '/' + encodeURIComponent(params['id']) + // build request object - const parts = ['_scripts', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/exists.js b/api/api/exists.js index b2b27dcb5..d2be719f3 100644 --- a/api/api/exists.js +++ b/api/api/exists.js @@ -16,8 +16,8 @@ function buildExists (opts) { * @param {boolean} refresh - Refresh the shard containing the document before performing the operation * @param {string} routing - Specific routing value * @param {list} _source - True or false to return the _source field or not, or a list of fields to return - * @param {list} _source_exclude - A list of fields to exclude from the returned _source field - * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {list} _source_excludes - A list of fields to exclude from the returned _source field + * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {number} version - Explicit version number for concurrency control * @param {enum} version_type - Specific version type */ @@ -54,12 +54,6 @@ function buildExists (opts) { result ) } - if (params['type'] == null) { - return callback( - new ConfigurationError('Missing required parameter: type'), - result - ) - } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), @@ -67,19 +61,6 @@ function buildExists (opts) { ) } - // check required url components - if (params['id'] != null && (params['type'] == null || params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: type, index'), - result - ) - } else if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) - } - // build querystring object const querystring = {} const keys = Object.keys(params) @@ -91,8 +72,8 @@ function buildExists (opts) { 'refresh', 'routing', '_source', - '_source_exclude', - '_source_include', + '_source_excludes', + '_source_includes', 'version', 'version_type', 'pretty', @@ -109,8 +90,8 @@ function buildExists (opts) { 'refresh', 'routing', '_source', - '_sourceExclude', - '_sourceInclude', + '_sourceExcludes', + '_sourceIncludes', 'version', 'versionType', 'pretty', @@ -151,11 +132,18 @@ function buildExists (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null && (params['id']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_doc' + '/' + encodeURIComponent(params['id']) + } + // build request object - const parts = [params['index'], params['type'], params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/exists_source.js b/api/api/exists_source.js index 188d53ed4..47d5cd451 100644 --- a/api/api/exists_source.js +++ b/api/api/exists_source.js @@ -15,8 +15,8 @@ function buildExistsSource (opts) { * @param {boolean} refresh - Refresh the shard containing the document before performing the operation * @param {string} routing - Specific routing value * @param {list} _source - True or false to return the _source field or not, or a list of fields to return - * @param {list} _source_exclude - A list of fields to exclude from the returned _source field - * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {list} _source_excludes - A list of fields to exclude from the returned _source field + * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {number} version - Explicit version number for concurrency control * @param {enum} version_type - Specific version type */ @@ -89,8 +89,8 @@ function buildExistsSource (opts) { 'refresh', 'routing', '_source', - '_source_exclude', - '_source_include', + '_source_excludes', + '_source_includes', 'version', 'version_type', 'pretty', @@ -106,8 +106,8 @@ function buildExistsSource (opts) { 'refresh', 'routing', '_source', - '_sourceExclude', - '_sourceInclude', + '_sourceExcludes', + '_sourceIncludes', 'version', 'versionType', 'pretty', @@ -148,11 +148,14 @@ function buildExistsSource (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_source' + // build request object - const parts = [params['index'], params['type'], params['id'], '_source'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/explain.js b/api/api/explain.js index a0ffea3e3..aa3c60c12 100644 --- a/api/api/explain.js +++ b/api/api/explain.js @@ -20,8 +20,8 @@ function buildExplain (opts) { * @param {string} q - Query in the Lucene query string syntax * @param {string} routing - Specific routing value * @param {list} _source - True or false to return the _source field or not, or a list of fields to return - * @param {list} _source_exclude - A list of fields to exclude from the returned _source field - * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {list} _source_excludes - A list of fields to exclude from the returned _source field + * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {object} body - The query definition using the Query DSL */ return function explain (params, options, callback) { @@ -57,25 +57,6 @@ function buildExplain (opts) { result ) } - if (params['type'] == null) { - return callback( - new ConfigurationError('Missing required parameter: type'), - result - ) - } - - // check required url components - if (params['id'] != null && (params['type'] == null || params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: type, index'), - result - ) - } else if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) - } // build querystring object const querystring = {} @@ -92,8 +73,8 @@ function buildExplain (opts) { 'q', 'routing', '_source', - '_source_exclude', - '_source_include', + '_source_excludes', + '_source_includes', 'pretty', 'human', 'error_trace', @@ -112,8 +93,8 @@ function buildExplain (opts) { 'q', 'routing', '_source', - '_sourceExclude', - '_sourceInclude', + '_sourceExcludes', + '_sourceIncludes', 'pretty', 'human', 'errorTrace', @@ -152,11 +133,18 @@ function buildExplain (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null && (params['id']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_explain' + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_explain' + '/' + encodeURIComponent(params['id']) + } + // build request object - const parts = [params['index'], params['type'], params['id'], '_explain'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/field_caps.js b/api/api/field_caps.js index b69b053e2..836651834 100644 --- a/api/api/field_caps.js +++ b/api/api/field_caps.js @@ -11,7 +11,6 @@ function buildFieldCaps (opts) { * @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 {object} body - Field json objects containing an array of field names */ return function fieldCaps (params, options, callback) { options = options || {} @@ -33,6 +32,14 @@ function buildFieldCaps (opts) { }) } + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + // build querystring object const querystring = {} const keys = Object.keys(params) @@ -90,12 +97,19 @@ function buildFieldCaps (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_field_caps' + } else { + path = '/' + '_field_caps' + } + // build request object - const parts = [params['index'], '_field_caps'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - body: params.body || '', + path, + body: '', querystring } diff --git a/api/api/get.js b/api/api/get.js index da4e07579..861bf49bc 100644 --- a/api/api/get.js +++ b/api/api/get.js @@ -16,6 +16,8 @@ function buildGet (opts) { * @param {boolean} refresh - Refresh the shard containing the document before performing the operation * @param {string} routing - Specific routing value * @param {list} _source - True or false to return the _source field or not, or a list of fields to return + * @param {list} _source_excludes - A list of fields to exclude from the returned _source field + * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {list} _source_exclude - A list of fields to exclude from the returned _source field * @param {list} _source_include - A list of fields to extract and return from the _source field * @param {number} version - Explicit version number for concurrency control @@ -54,12 +56,6 @@ function buildGet (opts) { result ) } - if (params['type'] == null) { - return callback( - new ConfigurationError('Missing required parameter: type'), - result - ) - } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), @@ -67,19 +63,6 @@ function buildGet (opts) { ) } - // check required url components - if (params['id'] != null && (params['type'] == null || params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: type, index'), - result - ) - } else if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) - } - // build querystring object const querystring = {} const keys = Object.keys(params) @@ -91,6 +74,8 @@ function buildGet (opts) { 'refresh', 'routing', '_source', + '_source_excludes', + '_source_includes', '_source_exclude', '_source_include', 'version', @@ -109,6 +94,8 @@ function buildGet (opts) { 'refresh', 'routing', '_source', + '_sourceExcludes', + '_sourceIncludes', '_sourceExclude', '_sourceInclude', 'version', @@ -151,11 +138,18 @@ function buildGet (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null && (params['id']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_doc' + '/' + encodeURIComponent(params['id']) + } + // build request object - const parts = [params['index'], params['type'], params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/get_script.js b/api/api/get_script.js index 852df3d5c..37b6c09ca 100644 --- a/api/api/get_script.js +++ b/api/api/get_script.js @@ -94,11 +94,14 @@ function buildGetScript (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_scripts' + '/' + encodeURIComponent(params['id']) + // build request object - const parts = ['_scripts', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/get_source.js b/api/api/get_source.js index 37300e8b5..700b58940 100644 --- a/api/api/get_source.js +++ b/api/api/get_source.js @@ -15,8 +15,8 @@ function buildGetSource (opts) { * @param {boolean} refresh - Refresh the shard containing the document before performing the operation * @param {string} routing - Specific routing value * @param {list} _source - True or false to return the _source field or not, or a list of fields to return - * @param {list} _source_exclude - A list of fields to exclude from the returned _source field - * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {list} _source_excludes - A list of fields to exclude from the returned _source field + * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {number} version - Explicit version number for concurrency control * @param {enum} version_type - Specific version type */ @@ -89,8 +89,8 @@ function buildGetSource (opts) { 'refresh', 'routing', '_source', - '_source_exclude', - '_source_include', + '_source_excludes', + '_source_includes', 'version', 'version_type', 'pretty', @@ -106,8 +106,8 @@ function buildGetSource (opts) { 'refresh', 'routing', '_source', - '_sourceExclude', - '_sourceInclude', + '_sourceExcludes', + '_sourceIncludes', 'version', 'versionType', 'pretty', @@ -148,11 +148,14 @@ function buildGetSource (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_source' + // build request object - const parts = [params['index'], params['type'], params['id'], '_source'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/ilm.delete_lifecycle.js b/api/api/ilm.delete_lifecycle.js new file mode 100644 index 000000000..69968d7d3 --- /dev/null +++ b/api/api/ilm.delete_lifecycle.js @@ -0,0 +1,104 @@ +'use strict' + +function buildIlmDeleteLifecycle (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ilm.delete_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-delete-lifecycle.html) request + * + * @param {string} policy - The name of the index lifecycle policy + */ + return function ilmDeleteLifecycle (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmDeleteLifecycle(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(params['policy']) + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIlmDeleteLifecycle diff --git a/api/api/ilm.explain_lifecycle.js b/api/api/ilm.explain_lifecycle.js new file mode 100644 index 000000000..56ddafcfd --- /dev/null +++ b/api/api/ilm.explain_lifecycle.js @@ -0,0 +1,105 @@ +'use strict' + +function buildIlmExplainLifecycle (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ilm.explain_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-explain-lifecycle.html) request + * + * @param {string} index - The name of the index to explain + * @param {boolean} human - Return data such as dates in a human readable format + */ + return function ilmExplainLifecycle (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmExplainLifecycle(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'human' + ] + const acceptedQuerystringCamelCased = [ + 'human' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_ilm' + '/' + 'explain' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIlmExplainLifecycle diff --git a/api/api/ilm.get_lifecycle.js b/api/api/ilm.get_lifecycle.js new file mode 100644 index 000000000..93869ca64 --- /dev/null +++ b/api/api/ilm.get_lifecycle.js @@ -0,0 +1,108 @@ +'use strict' + +function buildIlmGetLifecycle (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ilm.get_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-lifecycle.html) request + * + * @param {string} policy - The name of the index lifecycle policy + */ + return function ilmGetLifecycle (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmGetLifecycle(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((params['policy']) != null) { + path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(params['policy']) + } else { + path = '/' + '_ilm' + '/' + 'policy' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIlmGetLifecycle diff --git a/api/api/ilm.get_status.js b/api/api/ilm.get_status.js new file mode 100644 index 000000000..7d4bfaed5 --- /dev/null +++ b/api/api/ilm.get_status.js @@ -0,0 +1,103 @@ +'use strict' + +function buildIlmGetStatus (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ilm.get_status](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-status.html) request + * + */ + return function ilmGetStatus (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmGetStatus(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ilm' + '/' + 'status' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIlmGetStatus diff --git a/api/api/ilm.move_to_step.js b/api/api/ilm.move_to_step.js new file mode 100644 index 000000000..e1562289d --- /dev/null +++ b/api/api/ilm.move_to_step.js @@ -0,0 +1,97 @@ +'use strict' + +function buildIlmMoveToStep (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ilm.move_to_step](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-move-to-step.html) request + * + * @param {string} index - The name of the index whose lifecycle step is to change + * @param {object} body - The new lifecycle step to move to + */ + return function ilmMoveToStep (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmMoveToStep(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ilm' + '/' + 'move' + '/' + encodeURIComponent(params['index']) + + // build request object + const request = { + method, + path, + body: params.body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIlmMoveToStep diff --git a/api/api/ilm.put_lifecycle.js b/api/api/ilm.put_lifecycle.js new file mode 100644 index 000000000..7f2c7d447 --- /dev/null +++ b/api/api/ilm.put_lifecycle.js @@ -0,0 +1,97 @@ +'use strict' + +function buildIlmPutLifecycle (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ilm.put_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-put-lifecycle.html) request + * + * @param {string} policy - The name of the index lifecycle policy + * @param {object} body - The lifecycle policy definition to register + */ + return function ilmPutLifecycle (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmPutLifecycle(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(params['policy']) + + // build request object + const request = { + method, + path, + body: params.body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIlmPutLifecycle diff --git a/api/api/ilm.remove_policy.js b/api/api/ilm.remove_policy.js new file mode 100644 index 000000000..09e429ebc --- /dev/null +++ b/api/api/ilm.remove_policy.js @@ -0,0 +1,104 @@ +'use strict' + +function buildIlmRemovePolicy (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ilm.remove_policy](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-remove-policy.html) request + * + * @param {string} index - The name of the index to remove policy on + */ + return function ilmRemovePolicy (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmRemovePolicy(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_ilm' + '/' + 'remove' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIlmRemovePolicy diff --git a/api/api/ilm.retry.js b/api/api/ilm.retry.js new file mode 100644 index 000000000..0e3f7dc2c --- /dev/null +++ b/api/api/ilm.retry.js @@ -0,0 +1,104 @@ +'use strict' + +function buildIlmRetry (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ilm.retry](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-retry-policy.html) request + * + * @param {string} index - The name of the indices (comma-separated) whose failed lifecycle step is to be retry + */ + return function ilmRetry (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmRetry(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_ilm' + '/' + 'retry' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIlmRetry diff --git a/api/api/xpack.watcher.restart.js b/api/api/ilm.start.js similarity index 82% rename from api/api/xpack.watcher.restart.js rename to api/api/ilm.start.js index 12c1337a3..f0b9a77ca 100644 --- a/api/api/xpack.watcher.restart.js +++ b/api/api/ilm.start.js @@ -1,13 +1,13 @@ 'use strict' -function buildXpackWatcherRestart (opts) { +function buildIlmStart (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.watcher.restart](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-restart.html) request + * Perform a [ilm.start](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-start.html) request * */ - return function xpackWatcherRestart (params, options, callback) { + return function ilmStart (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -21,7 +21,7 @@ function buildXpackWatcherRestart (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackWatcherRestart(params, options, (err, body) => { + ilmStart(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -76,11 +76,14 @@ function buildXpackWatcherRestart (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ilm' + '/' + 'start' + // build request object - const parts = ['_xpack', 'watcher', '_restart'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -97,4 +100,4 @@ function buildXpackWatcherRestart (opts) { } } -module.exports = buildXpackWatcherRestart +module.exports = buildIlmStart diff --git a/api/api/ilm.stop.js b/api/api/ilm.stop.js new file mode 100644 index 000000000..500e10a3e --- /dev/null +++ b/api/api/ilm.stop.js @@ -0,0 +1,103 @@ +'use strict' + +function buildIlmStop (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ilm.stop](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-stop.html) request + * + */ + return function ilmStop (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmStop(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ilm' + '/' + 'stop' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIlmStop diff --git a/api/api/index.js b/api/api/index.js index ab0c1a920..db8aa2648 100644 --- a/api/api/index.js +++ b/api/api/index.js @@ -47,12 +47,6 @@ function buildIndex (opts) { result ) } - if (params['type'] == null) { - return callback( - new ConfigurationError('Missing required parameter: type'), - result - ) - } if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), @@ -61,12 +55,7 @@ function buildIndex (opts) { } // check required url components - if (params['id'] != null && (params['type'] == null || params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: type, index'), - result - ) - } else if (params['type'] != null && (params['index'] == null)) { + if (params['id'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), result @@ -140,11 +129,22 @@ function buildIndex (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null && (params['id']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + } else if ((params['index']) != null && (params['id']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_doc' + '/' + encodeURIComponent(params['id']) + } else if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_doc' + } + // build request object - const parts = [params['index'], params['type'], params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/indices.analyze.js b/api/api/indices.analyze.js index 37fd178ce..87ef4e735 100644 --- a/api/api/indices.analyze.js +++ b/api/api/indices.analyze.js @@ -81,11 +81,18 @@ function buildIndicesAnalyze (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_analyze' + } else { + path = '/' + '_analyze' + } + // build request object - const parts = [params['index'], '_analyze'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/indices.clear_cache.js b/api/api/indices.clear_cache.js index 6e0ed7555..8b5b78219 100644 --- a/api/api/indices.clear_cache.js +++ b/api/api/indices.clear_cache.js @@ -7,7 +7,6 @@ function buildIndicesClearCache (opts) { * Perform a [indices.clear_cache](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clearcache.html) request * * @param {list} index - A comma-separated list of index name to limit the operation - * @param {boolean} field_data - Clear field data. This is deprecated. Prefer `fielddata`. * @param {boolean} fielddata - Clear field data * @param {list} fields - A comma-separated list of fields to clear when using the `fielddata` parameter (default: all) * @param {boolean} query - Clear query caches @@ -15,7 +14,6 @@ function buildIndicesClearCache (opts) { * @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 {list} index - A comma-separated list of index name to limit the operation - * @param {boolean} request_cache - Clear request cache * @param {boolean} request - Clear request cache */ return function indicesClearCache (params, options, callback) { @@ -50,7 +48,6 @@ function buildIndicesClearCache (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ - 'field_data', 'fielddata', 'fields', 'query', @@ -58,7 +55,6 @@ function buildIndicesClearCache (opts) { 'allow_no_indices', 'expand_wildcards', 'index', - 'request_cache', 'request', 'pretty', 'human', @@ -67,7 +63,6 @@ function buildIndicesClearCache (opts) { 'filter_path' ] const acceptedQuerystringCamelCased = [ - 'fieldData', 'fielddata', 'fields', 'query', @@ -75,7 +70,6 @@ function buildIndicesClearCache (opts) { 'allowNoIndices', 'expandWildcards', 'index', - 'requestCache', 'request', 'pretty', 'human', @@ -99,7 +93,7 @@ function buildIndicesClearCache (opts) { // configure http method var method = params.method if (method == null) { - method = params.body == null ? 'GET' : 'POST' + method = 'POST' } // validate headers object @@ -115,11 +109,18 @@ function buildIndicesClearCache (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_cache' + '/' + 'clear' + } else { + path = '/' + '_cache' + '/' + 'clear' + } + // build request object - const parts = [params['index'], '_cache', 'clear'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/indices.close.js b/api/api/indices.close.js index 3d8c33f86..22eec8674 100644 --- a/api/api/indices.close.js +++ b/api/api/indices.close.js @@ -106,11 +106,14 @@ function buildIndicesClose (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_close' + // build request object - const parts = [params['index'], '_close'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/indices.create.js b/api/api/indices.create.js index a855bafec..97e913b91 100644 --- a/api/api/indices.create.js +++ b/api/api/indices.create.js @@ -7,10 +7,10 @@ function buildIndicesCreate (opts) { * Perform a [indices.create](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-index.html) request * * @param {string} index - The name of the index + * @param {string} include_type_name - Whether a type should be expected in the body of the mappings. * @param {string} wait_for_active_shards - Set the number of active shards to wait for before the operation returns. * @param {time} timeout - Explicit operation timeout * @param {time} master_timeout - Specify timeout for connection to master - * @param {boolean} update_all_types - Whether to update the mapping for all fields with the same name across all types or not * @param {object} body - The configuration for the index (`settings` and `mappings`) */ return function indicesCreate (params, options, callback) { @@ -45,10 +45,10 @@ function buildIndicesCreate (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ + 'include_type_name', 'wait_for_active_shards', 'timeout', 'master_timeout', - 'update_all_types', 'pretty', 'human', 'error_trace', @@ -56,10 +56,10 @@ function buildIndicesCreate (opts) { 'filter_path' ] const acceptedQuerystringCamelCased = [ + 'includeTypeName', 'waitForActiveShards', 'timeout', 'masterTimeout', - 'updateAllTypes', 'pretty', 'human', 'errorTrace', @@ -98,11 +98,14 @@ function buildIndicesCreate (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + // build request object - const parts = [params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/indices.delete.js b/api/api/indices.delete.js index 06b649926..a0c9c2f70 100644 --- a/api/api/indices.delete.js +++ b/api/api/indices.delete.js @@ -106,11 +106,14 @@ function buildIndicesDelete (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + // build request object - const parts = [params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/indices.delete_alias.js b/api/api/indices.delete_alias.js index 43447d915..d4725eb62 100644 --- a/api/api/indices.delete_alias.js +++ b/api/api/indices.delete_alias.js @@ -112,13 +112,18 @@ function buildIndicesDeleteAlias (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['name']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_alias' + '/' + encodeURIComponent(params['name']) + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_aliases' + '/' + encodeURIComponent(params['name']) + } + // build request object - const parts = [params['index'], '_aliases', params['name']] const request = { method, - path: params['index'] != null && params['name'] != null - ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') - : '/{index}/_alias/{name}', + path, body: '', querystring } diff --git a/api/api/indices.delete_template.js b/api/api/indices.delete_template.js index 3c4dd12ea..9cbd307c8 100644 --- a/api/api/indices.delete_template.js +++ b/api/api/indices.delete_template.js @@ -97,11 +97,14 @@ function buildIndicesDeleteTemplate (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_template' + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_template', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/indices.exists.js b/api/api/indices.exists.js index dc2fe554a..145e754d0 100644 --- a/api/api/indices.exists.js +++ b/api/api/indices.exists.js @@ -109,11 +109,14 @@ function buildIndicesExists (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + // build request object - const parts = [params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.exists_alias.js b/api/api/indices.exists_alias.js index d827db77c..61e218698 100644 --- a/api/api/indices.exists_alias.js +++ b/api/api/indices.exists_alias.js @@ -104,11 +104,18 @@ function buildIndicesExistsAlias (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['name']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_alias' + '/' + encodeURIComponent(params['name']) + } else { + path = '/' + '_alias' + '/' + encodeURIComponent(params['name']) + } + // build request object - const parts = [params['index'], '_alias', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.exists_template.js b/api/api/indices.exists_template.js index 78d5056ba..1902bd5c2 100644 --- a/api/api/indices.exists_template.js +++ b/api/api/indices.exists_template.js @@ -100,11 +100,14 @@ function buildIndicesExistsTemplate (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_template' + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_template', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.exists_type.js b/api/api/indices.exists_type.js index 00c2f3036..4e9305263 100644 --- a/api/api/indices.exists_type.js +++ b/api/api/indices.exists_type.js @@ -118,11 +118,14 @@ function buildIndicesExistsType (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + '/' + encodeURIComponent(params['type']) + // build request object - const parts = [params['index'], '_mapping', params['type']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.flush.js b/api/api/indices.flush.js index df05b411b..87a8d76f9 100644 --- a/api/api/indices.flush.js +++ b/api/api/indices.flush.js @@ -100,11 +100,18 @@ function buildIndicesFlush (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_flush' + } else { + path = '/' + '_flush' + } + // build request object - const parts = [params['index'], '_flush'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/indices.flush_synced.js b/api/api/indices.flush_synced.js index aa5a65bdc..857670661 100644 --- a/api/api/indices.flush_synced.js +++ b/api/api/indices.flush_synced.js @@ -94,11 +94,18 @@ function buildIndicesFlushSynced (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_flush' + '/' + 'synced' + } else { + path = '/' + '_flush' + '/' + 'synced' + } + // build request object - const parts = [params['index'], '_flush', 'synced'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/indices.forcemerge.js b/api/api/indices.forcemerge.js index 3631441d6..ea8633ae8 100644 --- a/api/api/indices.forcemerge.js +++ b/api/api/indices.forcemerge.js @@ -103,11 +103,18 @@ function buildIndicesForcemerge (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_forcemerge' + } else { + path = '/' + '_forcemerge' + } + // build request object - const parts = [params['index'], '_forcemerge'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/indices.freeze.js b/api/api/indices.freeze.js new file mode 100644 index 000000000..5226f6064 --- /dev/null +++ b/api/api/indices.freeze.js @@ -0,0 +1,126 @@ +'use strict' + +function buildIndicesFreeze (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [indices.freeze](https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.html) request + * + * @param {string} index - The name of the index to freeze + * @param {time} timeout - Explicit operation timeout + * @param {time} master_timeout - Specify timeout for connection to master + * @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 {string} wait_for_active_shards - Sets the number of active shards to wait for before the operation returns. + */ + return function indicesFreeze (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesFreeze(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'wait_for_active_shards' + ] + const acceptedQuerystringCamelCased = [ + 'timeout', + 'masterTimeout', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'waitForActiveShards' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_freeze' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIndicesFreeze diff --git a/api/api/indices.get.js b/api/api/indices.get.js index 0322a28d7..b0a9b8dad 100644 --- a/api/api/indices.get.js +++ b/api/api/indices.get.js @@ -112,11 +112,14 @@ function buildIndicesGet (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + // build request object - const parts = [params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.get_alias.js b/api/api/indices.get_alias.js index e7904cc2c..b5401a1bd 100644 --- a/api/api/indices.get_alias.js +++ b/api/api/indices.get_alias.js @@ -98,11 +98,22 @@ function buildIndicesGetAlias (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['name']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_alias' + '/' + encodeURIComponent(params['name']) + } else if ((params['name']) != null) { + path = '/' + '_alias' + '/' + encodeURIComponent(params['name']) + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_alias' + } else { + path = '/' + '_alias' + } + // build request object - const parts = [params['index'], '_alias', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.get_field_mapping.js b/api/api/indices.get_field_mapping.js index 003ac8f3c..63fa23006 100644 --- a/api/api/indices.get_field_mapping.js +++ b/api/api/indices.get_field_mapping.js @@ -108,11 +108,22 @@ function buildIndicesGetFieldMapping (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null && (params['fields']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + '/' + encodeURIComponent(params['type']) + '/' + 'field' + '/' + encodeURIComponent(params['fields']) + } else if ((params['index']) != null && (params['fields']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + '/' + 'field' + '/' + encodeURIComponent(params['fields']) + } else if ((params['type']) != null && (params['fields']) != null) { + path = '/' + '_mapping' + '/' + encodeURIComponent(params['type']) + '/' + 'field' + '/' + encodeURIComponent(params['fields']) + } else { + path = '/' + '_mapping' + '/' + 'field' + '/' + encodeURIComponent(params['fields']) + } + // build request object - const parts = [params['index'], '_mapping', params['type'], 'field', params['fields']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.get_mapping.js b/api/api/indices.get_mapping.js index 0a6870540..84c8f249c 100644 --- a/api/api/indices.get_mapping.js +++ b/api/api/indices.get_mapping.js @@ -8,6 +8,7 @@ function buildIndicesGetMapping (opts) { * * @param {list} index - A comma-separated list of index names * @param {list} type - A comma-separated list of document types + * @param {string} include_type_name - Whether to add the type name to the response * @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. @@ -46,6 +47,7 @@ function buildIndicesGetMapping (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ + 'include_type_name', 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', @@ -58,6 +60,7 @@ function buildIndicesGetMapping (opts) { 'filter_path' ] const acceptedQuerystringCamelCased = [ + 'includeTypeName', 'ignoreUnavailable', 'allowNoIndices', 'expandWildcards', @@ -101,11 +104,22 @@ function buildIndicesGetMapping (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + '/' + encodeURIComponent(params['type']) + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + } else if ((params['type']) != null) { + path = '/' + '_mapping' + '/' + encodeURIComponent(params['type']) + } else { + path = '/' + '_mapping' + } + // build request object - const parts = [params['index'], '_mapping', params['type']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.get_settings.js b/api/api/indices.get_settings.js index 76d8a13a9..22a8639a9 100644 --- a/api/api/indices.get_settings.js +++ b/api/api/indices.get_settings.js @@ -107,11 +107,22 @@ function buildIndicesGetSettings (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['name']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_settings' + '/' + encodeURIComponent(params['name']) + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_settings' + } else if ((params['name']) != null) { + path = '/' + '_settings' + '/' + encodeURIComponent(params['name']) + } else { + path = '/' + '_settings' + } + // build request object - const parts = [params['index'], '_settings', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.get_template.js b/api/api/indices.get_template.js index d392de288..f22726bf2 100644 --- a/api/api/indices.get_template.js +++ b/api/api/indices.get_template.js @@ -94,11 +94,18 @@ function buildIndicesGetTemplate (opts) { ignore = [ignore] } + var path = '' + + if ((params['name']) != null) { + path = '/' + '_template' + '/' + encodeURIComponent(params['name']) + } else { + path = '/' + '_template' + } + // build request object - const parts = ['_template', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.get_upgrade.js b/api/api/indices.get_upgrade.js index 1a8b2a1a5..02e1a01bf 100644 --- a/api/api/indices.get_upgrade.js +++ b/api/api/indices.get_upgrade.js @@ -94,11 +94,18 @@ function buildIndicesGetUpgrade (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_upgrade' + } else { + path = '/' + '_upgrade' + } + // build request object - const parts = [params['index'], '_upgrade'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.open.js b/api/api/indices.open.js index addc18a50..76a014b5d 100644 --- a/api/api/indices.open.js +++ b/api/api/indices.open.js @@ -109,11 +109,14 @@ function buildIndicesOpen (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_open' + // build request object - const parts = [params['index'], '_open'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/indices.put_alias.js b/api/api/indices.put_alias.js index 48cb6d31e..200e833e6 100644 --- a/api/api/indices.put_alias.js +++ b/api/api/indices.put_alias.js @@ -107,13 +107,18 @@ function buildIndicesPutAlias (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['name']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_alias' + '/' + encodeURIComponent(params['name']) + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_aliases' + '/' + encodeURIComponent(params['name']) + } + // build request object - const parts = [params['index'], '_aliases', params['name']] const request = { method, - path: params['index'] != null && params['name'] != null - ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') - : '/{index}/_alias/{name}', + path, body: params.body || '', querystring } diff --git a/api/api/indices.put_mapping.js b/api/api/indices.put_mapping.js index e2c12da00..8a04ed0c9 100644 --- a/api/api/indices.put_mapping.js +++ b/api/api/indices.put_mapping.js @@ -8,12 +8,12 @@ function buildIndicesPutMapping (opts) { * * @param {list} index - A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. * @param {string} type - The name of the document type + * @param {string} include_type_name - Whether a type should be expected in the body of the mappings. * @param {time} timeout - Explicit operation timeout * @param {time} master_timeout - Specify timeout for connection to master * @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} update_all_types - Whether to update the mapping for all fields with the same name across all types or not * @param {object} body - The mapping definition */ return function indicesPutMapping (params, options, callback) { @@ -37,12 +37,6 @@ function buildIndicesPutMapping (opts) { } // check required parameters - if (params['type'] == null) { - return callback( - new ConfigurationError('Missing required parameter: type'), - result - ) - } if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), @@ -54,12 +48,12 @@ function buildIndicesPutMapping (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ + 'include_type_name', 'timeout', 'master_timeout', 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', - 'update_all_types', 'pretty', 'human', 'error_trace', @@ -67,12 +61,12 @@ function buildIndicesPutMapping (opts) { 'filter_path' ] const acceptedQuerystringCamelCased = [ + 'includeTypeName', 'timeout', 'masterTimeout', 'ignoreUnavailable', 'allowNoIndices', 'expandWildcards', - 'updateAllTypes', 'pretty', 'human', 'errorTrace', @@ -111,11 +105,30 @@ function buildIndicesPutMapping (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_mapping' + } else if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + '/' + encodeURIComponent(params['type']) + } else if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_mappings' + } else if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_mappings' + '/' + encodeURIComponent(params['type']) + } else if ((params['type']) != null) { + path = '/' + '_mapping' + '/' + encodeURIComponent(params['type']) + } else if ((params['type']) != null) { + path = '/' + '_mappings' + '/' + encodeURIComponent(params['type']) + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_mappings' + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + } + // build request object - const parts = [params['index'], '_mappings', params['type']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/indices.put_settings.js b/api/api/indices.put_settings.js index dc4c28656..0c2532df3 100644 --- a/api/api/indices.put_settings.js +++ b/api/api/indices.put_settings.js @@ -107,11 +107,18 @@ function buildIndicesPutSettings (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_settings' + } else { + path = '/' + '_settings' + } + // build request object - const parts = [params['index'], '_settings'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/indices.put_template.js b/api/api/indices.put_template.js index 962c3814a..97b317e0f 100644 --- a/api/api/indices.put_template.js +++ b/api/api/indices.put_template.js @@ -107,11 +107,14 @@ function buildIndicesPutTemplate (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_template' + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_template', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/indices.recovery.js b/api/api/indices.recovery.js index efa854df6..f36f31d01 100644 --- a/api/api/indices.recovery.js +++ b/api/api/indices.recovery.js @@ -91,11 +91,18 @@ function buildIndicesRecovery (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_recovery' + } else { + path = '/' + '_recovery' + } + // build request object - const parts = [params['index'], '_recovery'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.refresh.js b/api/api/indices.refresh.js index 90bb65a31..0e264b781 100644 --- a/api/api/indices.refresh.js +++ b/api/api/indices.refresh.js @@ -94,11 +94,18 @@ function buildIndicesRefresh (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_refresh' + } else { + path = '/' + '_refresh' + } + // build request object - const parts = [params['index'], '_refresh'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/indices.rollover.js b/api/api/indices.rollover.js index 9a50a7543..166c41856 100644 --- a/api/api/indices.rollover.js +++ b/api/api/indices.rollover.js @@ -107,11 +107,18 @@ function buildIndicesRollover (opts) { ignore = [ignore] } + var path = '' + + if ((params['alias']) != null && (params['new_index'] || params['newIndex']) != null) { + path = '/' + encodeURIComponent(params['alias']) + '/' + '_rollover' + '/' + encodeURIComponent(params['new_index'] || params['newIndex']) + } else { + path = '/' + encodeURIComponent(params['alias']) + '/' + '_rollover' + } + // build request object - const parts = [params['alias'], '_rollover', params['new_index'] || params['newIndex']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/indices.segments.js b/api/api/indices.segments.js index 18a80b030..e8f044e1a 100644 --- a/api/api/indices.segments.js +++ b/api/api/indices.segments.js @@ -97,11 +97,18 @@ function buildIndicesSegments (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_segments' + } else { + path = '/' + '_segments' + } + // build request object - const parts = [params['index'], '_segments'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.shard_stores.js b/api/api/indices.shard_stores.js index bfc958c1e..663841e74 100644 --- a/api/api/indices.shard_stores.js +++ b/api/api/indices.shard_stores.js @@ -97,11 +97,18 @@ function buildIndicesShardStores (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_shard_stores' + } else { + path = '/' + '_shard_stores' + } + // build request object - const parts = [params['index'], '_shard_stores'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.shrink.js b/api/api/indices.shrink.js index 670806137..db423b13f 100644 --- a/api/api/indices.shrink.js +++ b/api/api/indices.shrink.js @@ -113,11 +113,14 @@ function buildIndicesShrink (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_shrink' + '/' + encodeURIComponent(params['target']) + // build request object - const parts = [params['index'], '_shrink', params['target']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/indices.split.js b/api/api/indices.split.js index 831d3ed08..b2ce07cf7 100644 --- a/api/api/indices.split.js +++ b/api/api/indices.split.js @@ -113,11 +113,14 @@ function buildIndicesSplit (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_split' + '/' + encodeURIComponent(params['target']) + // build request object - const parts = [params['index'], '_split', params['target']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/indices.stats.js b/api/api/indices.stats.js index d7a4d0f0d..63bb90ab4 100644 --- a/api/api/indices.stats.js +++ b/api/api/indices.stats.js @@ -107,11 +107,22 @@ function buildIndicesStats (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['metric']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_stats' + '/' + encodeURIComponent(params['metric']) + } else if ((params['metric']) != null) { + path = '/' + '_stats' + '/' + encodeURIComponent(params['metric']) + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_stats' + } else { + path = '/' + '_stats' + } + // build request object - const parts = [params['index'], '_stats', params['metric']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.unfreeze.js b/api/api/indices.unfreeze.js new file mode 100644 index 000000000..3f6ade686 --- /dev/null +++ b/api/api/indices.unfreeze.js @@ -0,0 +1,126 @@ +'use strict' + +function buildIndicesUnfreeze (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [indices.unfreeze](https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.html) request + * + * @param {string} index - The name of the index to unfreeze + * @param {time} timeout - Explicit operation timeout + * @param {time} master_timeout - Specify timeout for connection to master + * @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 {string} wait_for_active_shards - Sets the number of active shards to wait for before the operation returns. + */ + return function indicesUnfreeze (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesUnfreeze(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'wait_for_active_shards' + ] + const acceptedQuerystringCamelCased = [ + 'timeout', + 'masterTimeout', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'waitForActiveShards' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_unfreeze' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIndicesUnfreeze diff --git a/api/api/indices.update_aliases.js b/api/api/indices.update_aliases.js index f507ae604..cb2b8f91b 100644 --- a/api/api/indices.update_aliases.js +++ b/api/api/indices.update_aliases.js @@ -91,11 +91,14 @@ function buildIndicesUpdateAliases (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_aliases' + // build request object - const parts = ['_aliases'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/indices.upgrade.js b/api/api/indices.upgrade.js index 9741684d5..bfa521d65 100644 --- a/api/api/indices.upgrade.js +++ b/api/api/indices.upgrade.js @@ -100,11 +100,18 @@ function buildIndicesUpgrade (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_upgrade' + } else { + path = '/' + '_upgrade' + } + // build request object - const parts = [params['index'], '_upgrade'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/indices.validate_query.js b/api/api/indices.validate_query.js index cbd783b86..2c3d76aae 100644 --- a/api/api/indices.validate_query.js +++ b/api/api/indices.validate_query.js @@ -123,11 +123,20 @@ function buildIndicesValidateQuery (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_validate' + '/' + 'query' + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_validate' + '/' + 'query' + } else { + path = '/' + '_validate' + '/' + 'query' + } + // build request object - const parts = [params['index'], params['type'], '_validate', 'query'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/info.js b/api/api/info.js index 6e6c58746..280d74b2b 100644 --- a/api/api/info.js +++ b/api/api/info.js @@ -84,11 +84,14 @@ function buildInfo (opts) { ignore = [ignore] } + var path = '' + + path = '/' + // build request object - const parts = [] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/ingest.delete_pipeline.js b/api/api/ingest.delete_pipeline.js index 78b6cbc33..48ed5832a 100644 --- a/api/api/ingest.delete_pipeline.js +++ b/api/api/ingest.delete_pipeline.js @@ -97,11 +97,14 @@ function buildIngestDeletePipeline (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(params['id']) + // build request object - const parts = ['_ingest', 'pipeline', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/ingest.get_pipeline.js b/api/api/ingest.get_pipeline.js index 2f15be8f9..b275e6283 100644 --- a/api/api/ingest.get_pipeline.js +++ b/api/api/ingest.get_pipeline.js @@ -88,11 +88,18 @@ function buildIngestGetPipeline (opts) { ignore = [ignore] } + var path = '' + + if ((params['id']) != null) { + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(params['id']) + } else { + path = '/' + '_ingest' + '/' + 'pipeline' + } + // build request object - const parts = ['_ingest', 'pipeline', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/ingest.processor_grok.js b/api/api/ingest.processor_grok.js index c9c40f32c..c64b7c6b2 100644 --- a/api/api/ingest.processor_grok.js +++ b/api/api/ingest.processor_grok.js @@ -84,11 +84,14 @@ function buildIngestProcessorGrok (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ingest' + '/' + 'processor' + '/' + 'grok' + // build request object - const parts = ['_ingest', 'processor', 'grok'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/ingest.put_pipeline.js b/api/api/ingest.put_pipeline.js index 6a14d4637..2a50f23b2 100644 --- a/api/api/ingest.put_pipeline.js +++ b/api/api/ingest.put_pipeline.js @@ -98,11 +98,14 @@ function buildIngestPutPipeline (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(params['id']) + // build request object - const parts = ['_ingest', 'pipeline', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/ingest.simulate.js b/api/api/ingest.simulate.js index fb0c0a1a6..d5e961359 100644 --- a/api/api/ingest.simulate.js +++ b/api/api/ingest.simulate.js @@ -89,11 +89,18 @@ function buildIngestSimulate (opts) { ignore = [ignore] } + var path = '' + + if ((params['id']) != null) { + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(params['id']) + '/' + '_simulate' + } else { + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + '_simulate' + } + // build request object - const parts = ['_ingest', 'pipeline', params['id'], '_simulate'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/mget.js b/api/api/mget.js index 1327af217..2213dff78 100644 --- a/api/api/mget.js +++ b/api/api/mget.js @@ -14,8 +14,8 @@ function buildMget (opts) { * @param {boolean} refresh - Refresh the shard containing the document before performing the operation * @param {string} routing - Specific routing value * @param {list} _source - True or false to return the _source field or not, or a list of fields to return - * @param {list} _source_exclude - A list of fields to exclude from the returned _source field - * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {list} _source_excludes - A list of fields to exclude from the returned _source field + * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {object} body - Document identifiers; can be either `docs` (containing full document information) or `ids` (when index and type is provided in the URL. */ return function mget (params, options, callback) { @@ -64,8 +64,8 @@ function buildMget (opts) { 'refresh', 'routing', '_source', - '_source_exclude', - '_source_include', + '_source_excludes', + '_source_includes', 'pretty', 'human', 'error_trace', @@ -79,8 +79,8 @@ function buildMget (opts) { 'refresh', 'routing', '_source', - '_sourceExclude', - '_sourceInclude', + '_sourceExcludes', + '_sourceIncludes', 'pretty', 'human', 'errorTrace', @@ -119,11 +119,20 @@ function buildMget (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_mget' + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_mget' + } else { + path = '/' + '_mget' + } + // build request object - const parts = [params['index'], params['type'], '_mget'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.ml.close_job.js b/api/api/ml.close_job.js similarity index 84% rename from api/api/xpack.ml.close_job.js rename to api/api/ml.close_job.js index bee77a2f1..b69411c12 100644 --- a/api/api/xpack.ml.close_job.js +++ b/api/api/ml.close_job.js @@ -1,17 +1,17 @@ 'use strict' -function buildXpackMlCloseJob (opts) { +function buildMlCloseJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.close_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-close-job.html) request + * Perform a [ml.close_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-close-job.html) request * * @param {string} job_id - The name of the job to close * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) * @param {boolean} force - True if the job should be forcefully closed * @param {time} timeout - Controls the time to wait until a job has closed. Default to 30 minutes */ - return function xpackMlCloseJob (params, options, callback) { + return function mlCloseJob (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -25,7 +25,7 @@ function buildXpackMlCloseJob (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlCloseJob(params, options, (err, body) => { + mlCloseJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackMlCloseJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_close' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_close'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -105,4 +108,4 @@ function buildXpackMlCloseJob (opts) { } } -module.exports = buildXpackMlCloseJob +module.exports = buildMlCloseJob diff --git a/api/api/xpack.ml.delete_calendar.js b/api/api/ml.delete_calendar.js similarity index 84% rename from api/api/xpack.ml.delete_calendar.js rename to api/api/ml.delete_calendar.js index 3431be54c..e287d0a81 100644 --- a/api/api/xpack.ml.delete_calendar.js +++ b/api/api/ml.delete_calendar.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackMlDeleteCalendar (opts) { +function buildMlDeleteCalendar (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.delete_calendar](undefined) request + * Perform a [ml.delete_calendar](undefined) request * * @param {string} calendar_id - The ID of the calendar to delete */ - return function xpackMlDeleteCalendar (params, options, callback) { + return function mlDeleteCalendar (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackMlDeleteCalendar (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteCalendar(params, options, (err, body) => { + mlDeleteCalendar(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -83,11 +83,14 @@ function buildXpackMlDeleteCalendar (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + // build request object - const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -104,4 +107,4 @@ function buildXpackMlDeleteCalendar (opts) { } } -module.exports = buildXpackMlDeleteCalendar +module.exports = buildMlDeleteCalendar diff --git a/api/api/xpack.ml.delete_calendar_event.js b/api/api/ml.delete_calendar_event.js similarity index 85% rename from api/api/xpack.ml.delete_calendar_event.js rename to api/api/ml.delete_calendar_event.js index a385fcdf0..9a8e67ed5 100644 --- a/api/api/xpack.ml.delete_calendar_event.js +++ b/api/api/ml.delete_calendar_event.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlDeleteCalendarEvent (opts) { +function buildMlDeleteCalendarEvent (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.delete_calendar_event](undefined) request + * Perform a [ml.delete_calendar_event](undefined) request * * @param {string} calendar_id - The ID of the calendar to modify * @param {string} event_id - The ID of the event to remove from the calendar */ - return function xpackMlDeleteCalendarEvent (params, options, callback) { + return function mlDeleteCalendarEvent (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlDeleteCalendarEvent (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteCalendarEvent(params, options, (err, body) => { + mlDeleteCalendarEvent(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -98,11 +98,14 @@ function buildXpackMlDeleteCalendarEvent (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + '/' + 'events' + '/' + encodeURIComponent(params['event_id'] || params['eventId']) + // build request object - const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId'], 'events', params['event_id'] || params['eventId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -119,4 +122,4 @@ function buildXpackMlDeleteCalendarEvent (opts) { } } -module.exports = buildXpackMlDeleteCalendarEvent +module.exports = buildMlDeleteCalendarEvent diff --git a/api/api/xpack.ml.delete_calendar_job.js b/api/api/ml.delete_calendar_job.js similarity index 85% rename from api/api/xpack.ml.delete_calendar_job.js rename to api/api/ml.delete_calendar_job.js index 33a958c88..17dcac080 100644 --- a/api/api/xpack.ml.delete_calendar_job.js +++ b/api/api/ml.delete_calendar_job.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlDeleteCalendarJob (opts) { +function buildMlDeleteCalendarJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.delete_calendar_job](undefined) request + * Perform a [ml.delete_calendar_job](undefined) request * * @param {string} calendar_id - The ID of the calendar to modify * @param {string} job_id - The ID of the job to remove from the calendar */ - return function xpackMlDeleteCalendarJob (params, options, callback) { + return function mlDeleteCalendarJob (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlDeleteCalendarJob (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteCalendarJob(params, options, (err, body) => { + mlDeleteCalendarJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -98,11 +98,14 @@ function buildXpackMlDeleteCalendarJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + '/' + 'jobs' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + // build request object - const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId'], 'jobs', params['job_id'] || params['jobId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -119,4 +122,4 @@ function buildXpackMlDeleteCalendarJob (opts) { } } -module.exports = buildXpackMlDeleteCalendarJob +module.exports = buildMlDeleteCalendarJob diff --git a/api/api/xpack.ml.delete_datafeed.js b/api/api/ml.delete_datafeed.js similarity index 82% rename from api/api/xpack.ml.delete_datafeed.js rename to api/api/ml.delete_datafeed.js index 766ac2253..ff4b9e3f3 100644 --- a/api/api/xpack.ml.delete_datafeed.js +++ b/api/api/ml.delete_datafeed.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlDeleteDatafeed (opts) { +function buildMlDeleteDatafeed (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.delete_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html) request + * Perform a [ml.delete_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html) request * * @param {string} datafeed_id - The ID of the datafeed to delete * @param {boolean} force - True if the datafeed should be forcefully deleted */ - return function xpackMlDeleteDatafeed (params, options, callback) { + return function mlDeleteDatafeed (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlDeleteDatafeed (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteDatafeed(params, options, (err, body) => { + mlDeleteDatafeed(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackMlDeleteDatafeed (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + // build request object - const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -105,4 +108,4 @@ function buildXpackMlDeleteDatafeed (opts) { } } -module.exports = buildXpackMlDeleteDatafeed +module.exports = buildMlDeleteDatafeed diff --git a/api/api/xpack.ml.delete_expired_data.js b/api/api/ml.delete_expired_data.js similarity index 83% rename from api/api/xpack.ml.delete_expired_data.js rename to api/api/ml.delete_expired_data.js index bcba02e9a..95bd3781c 100644 --- a/api/api/xpack.ml.delete_expired_data.js +++ b/api/api/ml.delete_expired_data.js @@ -1,13 +1,13 @@ 'use strict' -function buildXpackMlDeleteExpiredData (opts) { +function buildMlDeleteExpiredData (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.delete_expired_data](undefined) request + * Perform a [ml.delete_expired_data](undefined) request * */ - return function xpackMlDeleteExpiredData (params, options, callback) { + return function mlDeleteExpiredData (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -21,7 +21,7 @@ function buildXpackMlDeleteExpiredData (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteExpiredData(params, options, (err, body) => { + mlDeleteExpiredData(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -76,11 +76,14 @@ function buildXpackMlDeleteExpiredData (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + '_delete_expired_data' + // build request object - const parts = ['_xpack', 'ml', '_delete_expired_data'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -97,4 +100,4 @@ function buildXpackMlDeleteExpiredData (opts) { } } -module.exports = buildXpackMlDeleteExpiredData +module.exports = buildMlDeleteExpiredData diff --git a/api/api/xpack.ml.delete_filter.js b/api/api/ml.delete_filter.js similarity index 84% rename from api/api/xpack.ml.delete_filter.js rename to api/api/ml.delete_filter.js index c16aa45df..d8306bbda 100644 --- a/api/api/xpack.ml.delete_filter.js +++ b/api/api/ml.delete_filter.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackMlDeleteFilter (opts) { +function buildMlDeleteFilter (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.delete_filter](undefined) request + * Perform a [ml.delete_filter](undefined) request * * @param {string} filter_id - The ID of the filter to delete */ - return function xpackMlDeleteFilter (params, options, callback) { + return function mlDeleteFilter (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackMlDeleteFilter (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteFilter(params, options, (err, body) => { + mlDeleteFilter(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -83,11 +83,14 @@ function buildXpackMlDeleteFilter (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(params['filter_id'] || params['filterId']) + // build request object - const parts = ['_xpack', 'ml', 'filters', params['filter_id'] || params['filterId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -104,4 +107,4 @@ function buildXpackMlDeleteFilter (opts) { } } -module.exports = buildXpackMlDeleteFilter +module.exports = buildMlDeleteFilter diff --git a/api/api/xpack.ml.delete_forecast.js b/api/api/ml.delete_forecast.js similarity index 78% rename from api/api/xpack.ml.delete_forecast.js rename to api/api/ml.delete_forecast.js index 6beb8aac4..e235dcb55 100644 --- a/api/api/xpack.ml.delete_forecast.js +++ b/api/api/ml.delete_forecast.js @@ -1,17 +1,17 @@ 'use strict' -function buildXpackMlDeleteForecast (opts) { +function buildMlDeleteForecast (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.delete_forecast](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html) request + * Perform a [ml.delete_forecast](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html) request * * @param {string} job_id - The ID of the job from which to delete forecasts * @param {string} forecast_id - The ID of the forecast to delete, can be comma delimited list. Leaving blank implies `_all` * @param {boolean} allow_no_forecasts - Whether to ignore if `_all` matches no forecasts * @param {time} timeout - Controls the time to wait until the forecast(s) are deleted. Default to 30 seconds */ - return function xpackMlDeleteForecast (params, options, callback) { + return function mlDeleteForecast (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -25,7 +25,7 @@ function buildXpackMlDeleteForecast (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteForecast(params, options, (err, body) => { + mlDeleteForecast(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -96,11 +96,18 @@ function buildXpackMlDeleteForecast (opts) { ignore = [ignore] } + var path = '' + + if ((params['job_id'] || params['jobId']) != null && (params['forecast_id'] || params['forecastId']) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_forecast' + '/' + encodeURIComponent(params['forecast_id'] || params['forecastId']) + } else { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_forecast' + } + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_forecast', params['forecast_id'] || params['forecastId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -117,4 +124,4 @@ function buildXpackMlDeleteForecast (opts) { } } -module.exports = buildXpackMlDeleteForecast +module.exports = buildMlDeleteForecast diff --git a/api/api/xpack.ml.delete_job.js b/api/api/ml.delete_job.js similarity index 84% rename from api/api/xpack.ml.delete_job.js rename to api/api/ml.delete_job.js index 699f8c75c..dfa895748 100644 --- a/api/api/xpack.ml.delete_job.js +++ b/api/api/ml.delete_job.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackMlDeleteJob (opts) { +function buildMlDeleteJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.delete_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html) request + * Perform a [ml.delete_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html) request * * @param {string} job_id - The ID of the job to delete * @param {boolean} force - True if the job should be forcefully deleted * @param {boolean} wait_for_completion - Should this request wait until the operation has completed before returning */ - return function xpackMlDeleteJob (params, options, callback) { + return function mlDeleteJob (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackMlDeleteJob (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteJob(params, options, (err, body) => { + mlDeleteJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -87,11 +87,14 @@ function buildXpackMlDeleteJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -108,4 +111,4 @@ function buildXpackMlDeleteJob (opts) { } } -module.exports = buildXpackMlDeleteJob +module.exports = buildMlDeleteJob diff --git a/api/api/xpack.ml.delete_model_snapshot.js b/api/api/ml.delete_model_snapshot.js similarity index 82% rename from api/api/xpack.ml.delete_model_snapshot.js rename to api/api/ml.delete_model_snapshot.js index 96e6f9246..61c1b8737 100644 --- a/api/api/xpack.ml.delete_model_snapshot.js +++ b/api/api/ml.delete_model_snapshot.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlDeleteModelSnapshot (opts) { +function buildMlDeleteModelSnapshot (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.delete_model_snapshot](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-snapshot.html) request + * Perform a [ml.delete_model_snapshot](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-snapshot.html) request * * @param {string} job_id - The ID of the job to fetch * @param {string} snapshot_id - The ID of the snapshot to delete */ - return function xpackMlDeleteModelSnapshot (params, options, callback) { + return function mlDeleteModelSnapshot (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlDeleteModelSnapshot (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteModelSnapshot(params, options, (err, body) => { + mlDeleteModelSnapshot(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -98,11 +98,14 @@ function buildXpackMlDeleteModelSnapshot (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'model_snapshots' + '/' + encodeURIComponent(params['snapshot_id'] || params['snapshotId']) + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'model_snapshots', params['snapshot_id'] || params['snapshotId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -119,4 +122,4 @@ function buildXpackMlDeleteModelSnapshot (opts) { } } -module.exports = buildXpackMlDeleteModelSnapshot +module.exports = buildMlDeleteModelSnapshot diff --git a/api/api/xpack.ml.find_file_structure.js b/api/api/ml.find_file_structure.js similarity index 89% rename from api/api/xpack.ml.find_file_structure.js rename to api/api/ml.find_file_structure.js index 17d4f0241..cc22f0c0d 100644 --- a/api/api/xpack.ml.find_file_structure.js +++ b/api/api/ml.find_file_structure.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMlFindFileStructure (opts) { +function buildMlFindFileStructure (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.find_file_structure](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-file-structure.html) request + * Perform a [ml.find_file_structure](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-file-structure.html) request * * @param {int} lines_to_sample - How many lines of the file should be included in the analysis * @param {time} timeout - Timeout after which the analysis will be aborted @@ -21,7 +21,7 @@ function buildXpackMlFindFileStructure (opts) { * @param {boolean} explain - Whether to include a commentary on how the structure was derived * @param {object} body - The contents of the file to be analyzed */ - return function xpackMlFindFileStructure (params, options, callback) { + return function mlFindFileStructure (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -35,7 +35,7 @@ function buildXpackMlFindFileStructure (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlFindFileStructure(params, options, (err, body) => { + mlFindFileStructure(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -114,11 +114,14 @@ function buildXpackMlFindFileStructure (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'find_file_structure' + // build request object - const parts = ['_xpack', 'ml', 'find_file_structure'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -135,4 +138,4 @@ function buildXpackMlFindFileStructure (opts) { } } -module.exports = buildXpackMlFindFileStructure +module.exports = buildMlFindFileStructure diff --git a/api/api/xpack.ml.flush_job.js b/api/api/ml.flush_job.js similarity index 86% rename from api/api/xpack.ml.flush_job.js rename to api/api/ml.flush_job.js index 8adc2b00f..8f47ecdb2 100644 --- a/api/api/xpack.ml.flush_job.js +++ b/api/api/ml.flush_job.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMlFlushJob (opts) { +function buildMlFlushJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.flush_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-flush-job.html) request + * Perform a [ml.flush_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-flush-job.html) request * * @param {string} job_id - The name of the job to flush * @param {boolean} calc_interim - Calculates interim results for the most recent bucket or all buckets within the latency period @@ -14,7 +14,7 @@ function buildXpackMlFlushJob (opts) { * @param {string} skip_time - Skips time to the given value without generating results or updating the model for the skipped interval * @param {object} body - Flush parameters */ - return function xpackMlFlushJob (params, options, callback) { + return function mlFlushJob (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -28,7 +28,7 @@ function buildXpackMlFlushJob (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlFlushJob(params, options, (err, body) => { + mlFlushJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -91,11 +91,14 @@ function buildXpackMlFlushJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_flush' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_flush'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -112,4 +115,4 @@ function buildXpackMlFlushJob (opts) { } } -module.exports = buildXpackMlFlushJob +module.exports = buildMlFlushJob diff --git a/api/api/xpack.ml.forecast.js b/api/api/ml.forecast.js similarity index 86% rename from api/api/xpack.ml.forecast.js rename to api/api/ml.forecast.js index 80d6b9e7d..f6c0119b9 100644 --- a/api/api/xpack.ml.forecast.js +++ b/api/api/ml.forecast.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackMlForecast (opts) { +function buildMlForecast (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.forecast](undefined) request + * Perform a [ml.forecast](undefined) request * * @param {string} job_id - The ID of the job to forecast for * @param {time} duration - The duration of the forecast * @param {time} expires_in - The time interval after which the forecast expires. Expired forecasts will be deleted at the first opportunity. */ - return function xpackMlForecast (params, options, callback) { + return function mlForecast (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackMlForecast (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlForecast(params, options, (err, body) => { + mlForecast(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -87,11 +87,14 @@ function buildXpackMlForecast (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_forecast' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_forecast'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -108,4 +111,4 @@ function buildXpackMlForecast (opts) { } } -module.exports = buildXpackMlForecast +module.exports = buildMlForecast diff --git a/api/api/xpack.ml.get_buckets.js b/api/api/ml.get_buckets.js similarity index 81% rename from api/api/xpack.ml.get_buckets.js rename to api/api/ml.get_buckets.js index d4e6da0e9..bda3bdbaa 100644 --- a/api/api/xpack.ml.get_buckets.js +++ b/api/api/ml.get_buckets.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMlGetBuckets (opts) { +function buildMlGetBuckets (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_buckets](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-bucket.html) request + * Perform a [ml.get_buckets](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-bucket.html) request * * @param {string} job_id - ID of the job to get bucket results from * @param {string} timestamp - The timestamp of the desired single bucket result @@ -19,7 +19,7 @@ function buildXpackMlGetBuckets (opts) { * @param {boolean} desc - Set the sort direction * @param {object} body - Bucket selection details if not provided in URI */ - return function xpackMlGetBuckets (params, options, callback) { + return function mlGetBuckets (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -33,7 +33,7 @@ function buildXpackMlGetBuckets (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetBuckets(params, options, (err, body) => { + mlGetBuckets(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -112,11 +112,18 @@ function buildXpackMlGetBuckets (opts) { ignore = [ignore] } + var path = '' + + if ((params['job_id'] || params['jobId']) != null && (params['timestamp']) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'results' + '/' + 'buckets' + '/' + encodeURIComponent(params['timestamp']) + } else { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'results' + '/' + 'buckets' + } + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'results', 'buckets', params['timestamp']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -133,4 +140,4 @@ function buildXpackMlGetBuckets (opts) { } } -module.exports = buildXpackMlGetBuckets +module.exports = buildMlGetBuckets diff --git a/api/api/xpack.ml.get_calendar_events.js b/api/api/ml.get_calendar_events.js similarity index 86% rename from api/api/xpack.ml.get_calendar_events.js rename to api/api/ml.get_calendar_events.js index b01aa18f3..4a9f9872e 100644 --- a/api/api/xpack.ml.get_calendar_events.js +++ b/api/api/ml.get_calendar_events.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMlGetCalendarEvents (opts) { +function buildMlGetCalendarEvents (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_calendar_events](undefined) request + * Perform a [ml.get_calendar_events](undefined) request * * @param {string} calendar_id - The ID of the calendar containing the events * @param {string} job_id - Get events for the job. When this option is used calendar_id must be '_all' @@ -13,7 +13,7 @@ function buildXpackMlGetCalendarEvents (opts) { * @param {int} from - Skips a number of events * @param {int} size - Specifies a max number of events to get */ - return function xpackMlGetCalendarEvents (params, options, callback) { + return function mlGetCalendarEvents (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -27,7 +27,7 @@ function buildXpackMlGetCalendarEvents (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetCalendarEvents(params, options, (err, body) => { + mlGetCalendarEvents(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -96,11 +96,14 @@ function buildXpackMlGetCalendarEvents (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + '/' + 'events' + // build request object - const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId'], 'events'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -117,4 +120,4 @@ function buildXpackMlGetCalendarEvents (opts) { } } -module.exports = buildXpackMlGetCalendarEvents +module.exports = buildMlGetCalendarEvents diff --git a/api/api/xpack.ml.get_calendars.js b/api/api/ml.get_calendars.js similarity index 82% rename from api/api/xpack.ml.get_calendars.js rename to api/api/ml.get_calendars.js index 04bec5eb2..1ff78b88e 100644 --- a/api/api/xpack.ml.get_calendars.js +++ b/api/api/ml.get_calendars.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackMlGetCalendars (opts) { +function buildMlGetCalendars (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_calendars](undefined) request + * Perform a [ml.get_calendars](undefined) request * * @param {string} calendar_id - The ID of the calendar to fetch * @param {int} from - skips a number of calendars * @param {int} size - specifies a max number of calendars to get */ - return function xpackMlGetCalendars (params, options, callback) { + return function mlGetCalendars (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackMlGetCalendars (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetCalendars(params, options, (err, body) => { + mlGetCalendars(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -81,11 +81,18 @@ function buildXpackMlGetCalendars (opts) { ignore = [ignore] } + var path = '' + + if ((params['calendar_id'] || params['calendarId']) != null) { + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + } else { + path = '/' + '_ml' + '/' + 'calendars' + } + // build request object - const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -102,4 +109,4 @@ function buildXpackMlGetCalendars (opts) { } } -module.exports = buildXpackMlGetCalendars +module.exports = buildMlGetCalendars diff --git a/api/api/xpack.ml.get_categories.js b/api/api/ml.get_categories.js similarity index 75% rename from api/api/xpack.ml.get_categories.js rename to api/api/ml.get_categories.js index 749fbb47c..268a64846 100644 --- a/api/api/xpack.ml.get_categories.js +++ b/api/api/ml.get_categories.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMlGetCategories (opts) { +function buildMlGetCategories (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_categories](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-category.html) request + * Perform a [ml.get_categories](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-category.html) request * * @param {string} job_id - The name of the job * @param {long} category_id - The identifier of the category definition of interest @@ -12,7 +12,7 @@ function buildXpackMlGetCategories (opts) { * @param {int} size - specifies a max number of categories to get * @param {object} body - Category selection details if not provided in URI */ - return function xpackMlGetCategories (params, options, callback) { + return function mlGetCategories (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -26,7 +26,7 @@ function buildXpackMlGetCategories (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetCategories(params, options, (err, body) => { + mlGetCategories(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -83,13 +83,18 @@ function buildXpackMlGetCategories (opts) { ignore = [ignore] } + var path = '' + + if ((params['job_id'] || params['jobId']) != null && (params['category_id'] || params['categoryId']) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'results' + '/' + 'categories' + '/' + encodeURIComponent(params['category_id'] || params['categoryId']) + } else { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'results' + '/' + 'categories' + } + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'results', 'categories'] const request = { method, - path: (params['job_id'] || params['jobId']) != null - ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') - : '/_xpack/ml/anomaly_detectors/{job_id}/results/categories/{category_id}', + path, body: params.body || '', querystring } @@ -106,4 +111,4 @@ function buildXpackMlGetCategories (opts) { } } -module.exports = buildXpackMlGetCategories +module.exports = buildMlGetCategories diff --git a/api/api/xpack.ml.get_datafeed_stats.js b/api/api/ml.get_datafeed_stats.js similarity index 78% rename from api/api/xpack.ml.get_datafeed_stats.js rename to api/api/ml.get_datafeed_stats.js index 496d18b75..6d84d3f61 100644 --- a/api/api/xpack.ml.get_datafeed_stats.js +++ b/api/api/ml.get_datafeed_stats.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlGetDatafeedStats (opts) { +function buildMlGetDatafeedStats (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_datafeed_stats](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed-stats.html) request + * Perform a [ml.get_datafeed_stats](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed-stats.html) request * * @param {string} datafeed_id - The ID of the datafeeds stats to fetch * @param {boolean} allow_no_datafeeds - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) */ - return function xpackMlGetDatafeedStats (params, options, callback) { + return function mlGetDatafeedStats (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlGetDatafeedStats (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetDatafeedStats(params, options, (err, body) => { + mlGetDatafeedStats(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -78,11 +78,18 @@ function buildXpackMlGetDatafeedStats (opts) { ignore = [ignore] } + var path = '' + + if ((params['datafeed_id'] || params['datafeedId']) != null) { + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + '/' + '_stats' + } else { + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + '_stats' + } + // build request object - const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId'], '_stats'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -99,4 +106,4 @@ function buildXpackMlGetDatafeedStats (opts) { } } -module.exports = buildXpackMlGetDatafeedStats +module.exports = buildMlGetDatafeedStats diff --git a/api/api/xpack.ml.get_datafeeds.js b/api/api/ml.get_datafeeds.js similarity index 80% rename from api/api/xpack.ml.get_datafeeds.js rename to api/api/ml.get_datafeeds.js index ede837077..98a90d8db 100644 --- a/api/api/xpack.ml.get_datafeeds.js +++ b/api/api/ml.get_datafeeds.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlGetDatafeeds (opts) { +function buildMlGetDatafeeds (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_datafeeds](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed.html) request + * Perform a [ml.get_datafeeds](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed.html) request * * @param {string} datafeed_id - The ID of the datafeeds to fetch * @param {boolean} allow_no_datafeeds - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) */ - return function xpackMlGetDatafeeds (params, options, callback) { + return function mlGetDatafeeds (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlGetDatafeeds (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetDatafeeds(params, options, (err, body) => { + mlGetDatafeeds(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -78,11 +78,18 @@ function buildXpackMlGetDatafeeds (opts) { ignore = [ignore] } + var path = '' + + if ((params['datafeed_id'] || params['datafeedId']) != null) { + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + } else { + path = '/' + '_ml' + '/' + 'datafeeds' + } + // build request object - const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -99,4 +106,4 @@ function buildXpackMlGetDatafeeds (opts) { } } -module.exports = buildXpackMlGetDatafeeds +module.exports = buildMlGetDatafeeds diff --git a/api/api/xpack.ml.get_filters.js b/api/api/ml.get_filters.js similarity index 82% rename from api/api/xpack.ml.get_filters.js rename to api/api/ml.get_filters.js index 83b6d2a77..952af25a9 100644 --- a/api/api/xpack.ml.get_filters.js +++ b/api/api/ml.get_filters.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackMlGetFilters (opts) { +function buildMlGetFilters (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_filters](undefined) request + * Perform a [ml.get_filters](undefined) request * * @param {string} filter_id - The ID of the filter to fetch * @param {int} from - skips a number of filters * @param {int} size - specifies a max number of filters to get */ - return function xpackMlGetFilters (params, options, callback) { + return function mlGetFilters (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackMlGetFilters (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetFilters(params, options, (err, body) => { + mlGetFilters(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -81,11 +81,18 @@ function buildXpackMlGetFilters (opts) { ignore = [ignore] } + var path = '' + + if ((params['filter_id'] || params['filterId']) != null) { + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(params['filter_id'] || params['filterId']) + } else { + path = '/' + '_ml' + '/' + 'filters' + } + // build request object - const parts = ['_xpack', 'ml', 'filters', params['filter_id'] || params['filterId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -102,4 +109,4 @@ function buildXpackMlGetFilters (opts) { } } -module.exports = buildXpackMlGetFilters +module.exports = buildMlGetFilters diff --git a/api/api/xpack.ml.get_influencers.js b/api/api/ml.get_influencers.js similarity index 85% rename from api/api/xpack.ml.get_influencers.js rename to api/api/ml.get_influencers.js index 8c8fed39e..d7629cb08 100644 --- a/api/api/xpack.ml.get_influencers.js +++ b/api/api/ml.get_influencers.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMlGetInfluencers (opts) { +function buildMlGetInfluencers (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_influencers](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-influencer.html) request + * Perform a [ml.get_influencers](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-influencer.html) request * * @param {string} job_id - * @param {boolean} exclude_interim - Exclude interim results @@ -17,7 +17,7 @@ function buildXpackMlGetInfluencers (opts) { * @param {boolean} desc - whether the results should be sorted in decending order * @param {object} body - Influencer selection criteria */ - return function xpackMlGetInfluencers (params, options, callback) { + return function mlGetInfluencers (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -31,7 +31,7 @@ function buildXpackMlGetInfluencers (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetInfluencers(params, options, (err, body) => { + mlGetInfluencers(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -100,11 +100,14 @@ function buildXpackMlGetInfluencers (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'results' + '/' + 'influencers' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'results', 'influencers'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -121,4 +124,4 @@ function buildXpackMlGetInfluencers (opts) { } } -module.exports = buildXpackMlGetInfluencers +module.exports = buildMlGetInfluencers diff --git a/api/api/xpack.ml.get_job_stats.js b/api/api/ml.get_job_stats.js similarity index 79% rename from api/api/xpack.ml.get_job_stats.js rename to api/api/ml.get_job_stats.js index 26b9fe6a0..0b96ccb0f 100644 --- a/api/api/xpack.ml.get_job_stats.js +++ b/api/api/ml.get_job_stats.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlGetJobStats (opts) { +function buildMlGetJobStats (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_job_stats](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-stats.html) request + * Perform a [ml.get_job_stats](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-stats.html) request * * @param {string} job_id - The ID of the jobs stats to fetch * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) */ - return function xpackMlGetJobStats (params, options, callback) { + return function mlGetJobStats (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlGetJobStats (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetJobStats(params, options, (err, body) => { + mlGetJobStats(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -78,11 +78,18 @@ function buildXpackMlGetJobStats (opts) { ignore = [ignore] } + var path = '' + + if ((params['job_id'] || params['jobId']) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_stats' + } else { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_stats' + } + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_stats'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -99,4 +106,4 @@ function buildXpackMlGetJobStats (opts) { } } -module.exports = buildXpackMlGetJobStats +module.exports = buildMlGetJobStats diff --git a/api/api/xpack.ml.get_jobs.js b/api/api/ml.get_jobs.js similarity index 81% rename from api/api/xpack.ml.get_jobs.js rename to api/api/ml.get_jobs.js index ca5598ab8..5d471a4af 100644 --- a/api/api/xpack.ml.get_jobs.js +++ b/api/api/ml.get_jobs.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlGetJobs (opts) { +function buildMlGetJobs (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_jobs](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job.html) request + * Perform a [ml.get_jobs](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job.html) request * * @param {string} job_id - The ID of the jobs to fetch * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) */ - return function xpackMlGetJobs (params, options, callback) { + return function mlGetJobs (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlGetJobs (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetJobs(params, options, (err, body) => { + mlGetJobs(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -78,11 +78,18 @@ function buildXpackMlGetJobs (opts) { ignore = [ignore] } + var path = '' + + if ((params['job_id'] || params['jobId']) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + } else { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + } + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -99,4 +106,4 @@ function buildXpackMlGetJobs (opts) { } } -module.exports = buildXpackMlGetJobs +module.exports = buildMlGetJobs diff --git a/api/api/xpack.ml.get_model_snapshots.js b/api/api/ml.get_model_snapshots.js similarity index 79% rename from api/api/xpack.ml.get_model_snapshots.js rename to api/api/ml.get_model_snapshots.js index f3cc57b0b..49511b048 100644 --- a/api/api/xpack.ml.get_model_snapshots.js +++ b/api/api/ml.get_model_snapshots.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMlGetModelSnapshots (opts) { +function buildMlGetModelSnapshots (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_model_snapshots](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-snapshot.html) request + * Perform a [ml.get_model_snapshots](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-snapshot.html) request * * @param {string} job_id - The ID of the job to fetch * @param {string} snapshot_id - The ID of the snapshot to fetch @@ -16,7 +16,7 @@ function buildXpackMlGetModelSnapshots (opts) { * @param {boolean} desc - True if the results should be sorted in descending order * @param {object} body - Model snapshot selection criteria */ - return function xpackMlGetModelSnapshots (params, options, callback) { + return function mlGetModelSnapshots (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -30,7 +30,7 @@ function buildXpackMlGetModelSnapshots (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetModelSnapshots(params, options, (err, body) => { + mlGetModelSnapshots(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -103,11 +103,18 @@ function buildXpackMlGetModelSnapshots (opts) { ignore = [ignore] } + var path = '' + + if ((params['job_id'] || params['jobId']) != null && (params['snapshot_id'] || params['snapshotId']) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'model_snapshots' + '/' + encodeURIComponent(params['snapshot_id'] || params['snapshotId']) + } else { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'model_snapshots' + } + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'model_snapshots', params['snapshot_id'] || params['snapshotId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -124,4 +131,4 @@ function buildXpackMlGetModelSnapshots (opts) { } } -module.exports = buildXpackMlGetModelSnapshots +module.exports = buildMlGetModelSnapshots diff --git a/api/api/xpack.ml.get_overall_buckets.js b/api/api/ml.get_overall_buckets.js similarity index 85% rename from api/api/xpack.ml.get_overall_buckets.js rename to api/api/ml.get_overall_buckets.js index 9aa67112f..a9db109a2 100644 --- a/api/api/xpack.ml.get_overall_buckets.js +++ b/api/api/ml.get_overall_buckets.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMlGetOverallBuckets (opts) { +function buildMlGetOverallBuckets (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_overall_buckets](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-overall-buckets.html) request + * Perform a [ml.get_overall_buckets](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-overall-buckets.html) request * * @param {string} job_id - The job IDs for which to calculate overall bucket results * @param {int} top_n - The number of top job bucket scores to be used in the overall_score calculation @@ -16,7 +16,7 @@ function buildXpackMlGetOverallBuckets (opts) { * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) * @param {object} body - Overall bucket selection details if not provided in URI */ - return function xpackMlGetOverallBuckets (params, options, callback) { + return function mlGetOverallBuckets (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -30,7 +30,7 @@ function buildXpackMlGetOverallBuckets (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetOverallBuckets(params, options, (err, body) => { + mlGetOverallBuckets(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -97,11 +97,14 @@ function buildXpackMlGetOverallBuckets (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'results' + '/' + 'overall_buckets' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'results', 'overall_buckets'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -118,4 +121,4 @@ function buildXpackMlGetOverallBuckets (opts) { } } -module.exports = buildXpackMlGetOverallBuckets +module.exports = buildMlGetOverallBuckets diff --git a/api/api/xpack.ml.get_records.js b/api/api/ml.get_records.js similarity index 85% rename from api/api/xpack.ml.get_records.js rename to api/api/ml.get_records.js index f5e2a2b88..5f8b35aba 100644 --- a/api/api/xpack.ml.get_records.js +++ b/api/api/ml.get_records.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMlGetRecords (opts) { +function buildMlGetRecords (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_records](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-record.html) request + * Perform a [ml.get_records](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-record.html) request * * @param {string} job_id - * @param {boolean} exclude_interim - Exclude interim results @@ -17,7 +17,7 @@ function buildXpackMlGetRecords (opts) { * @param {boolean} desc - Set the sort direction * @param {object} body - Record selection criteria */ - return function xpackMlGetRecords (params, options, callback) { + return function mlGetRecords (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -31,7 +31,7 @@ function buildXpackMlGetRecords (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetRecords(params, options, (err, body) => { + mlGetRecords(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -100,11 +100,14 @@ function buildXpackMlGetRecords (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'results' + '/' + 'records' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'results', 'records'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -121,4 +124,4 @@ function buildXpackMlGetRecords (opts) { } } -module.exports = buildXpackMlGetRecords +module.exports = buildMlGetRecords diff --git a/api/api/xpack.ml.info.js b/api/api/ml.info.js similarity index 85% rename from api/api/xpack.ml.info.js rename to api/api/ml.info.js index cab59acec..3885261f9 100644 --- a/api/api/xpack.ml.info.js +++ b/api/api/ml.info.js @@ -1,13 +1,13 @@ 'use strict' -function buildXpackMlInfo (opts) { +function buildMlInfo (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.info](undefined) request + * Perform a [ml.info](undefined) request * */ - return function xpackMlInfo (params, options, callback) { + return function mlInfo (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -21,7 +21,7 @@ function buildXpackMlInfo (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlInfo(params, options, (err, body) => { + mlInfo(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -68,11 +68,14 @@ function buildXpackMlInfo (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'info' + // build request object - const parts = ['_xpack', 'ml', 'info'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -89,4 +92,4 @@ function buildXpackMlInfo (opts) { } } -module.exports = buildXpackMlInfo +module.exports = buildMlInfo diff --git a/api/api/xpack.ml.open_job.js b/api/api/ml.open_job.js similarity index 84% rename from api/api/xpack.ml.open_job.js rename to api/api/ml.open_job.js index 2b1bd7d56..47df12f64 100644 --- a/api/api/xpack.ml.open_job.js +++ b/api/api/ml.open_job.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackMlOpenJob (opts) { +function buildMlOpenJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.open_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html) request + * Perform a [ml.open_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html) request * * @param {string} job_id - The ID of the job to open * @param {boolean} ignore_downtime - Controls if gaps in data are treated as anomalous or as a maintenance window after a job re-start * @param {time} timeout - Controls the time to wait until a job has opened. Default to 30 minutes */ - return function xpackMlOpenJob (params, options, callback) { + return function mlOpenJob (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackMlOpenJob (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlOpenJob(params, options, (err, body) => { + mlOpenJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -85,11 +85,14 @@ function buildXpackMlOpenJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_open' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_open'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -106,4 +109,4 @@ function buildXpackMlOpenJob (opts) { } } -module.exports = buildXpackMlOpenJob +module.exports = buildMlOpenJob diff --git a/api/api/xpack.ml.post_calendar_events.js b/api/api/ml.post_calendar_events.js similarity index 83% rename from api/api/xpack.ml.post_calendar_events.js rename to api/api/ml.post_calendar_events.js index 742901991..565807442 100644 --- a/api/api/xpack.ml.post_calendar_events.js +++ b/api/api/ml.post_calendar_events.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlPostCalendarEvents (opts) { +function buildMlPostCalendarEvents (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.post_calendar_events](undefined) request + * Perform a [ml.post_calendar_events](undefined) request * * @param {string} calendar_id - The ID of the calendar to modify * @param {object} body - A list of events */ - return function xpackMlPostCalendarEvents (params, options, callback) { + return function mlPostCalendarEvents (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlPostCalendarEvents (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPostCalendarEvents(params, options, (err, body) => { + mlPostCalendarEvents(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackMlPostCalendarEvents (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + '/' + 'events' + // build request object - const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId'], 'events'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -105,4 +108,4 @@ function buildXpackMlPostCalendarEvents (opts) { } } -module.exports = buildXpackMlPostCalendarEvents +module.exports = buildMlPostCalendarEvents diff --git a/api/api/xpack.ml.post_data.js b/api/api/ml.post_data.js similarity index 84% rename from api/api/xpack.ml.post_data.js rename to api/api/ml.post_data.js index 859c816e7..708b4fdf8 100644 --- a/api/api/xpack.ml.post_data.js +++ b/api/api/ml.post_data.js @@ -1,17 +1,17 @@ 'use strict' -function buildXpackMlPostData (opts) { +function buildMlPostData (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.post_data](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-data.html) request + * Perform a [ml.post_data](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-data.html) request * * @param {string} job_id - The name of the job receiving the data * @param {string} reset_start - Optional parameter to specify the start of the bucket resetting range * @param {string} reset_end - Optional parameter to specify the end of the bucket resetting range * @param {object} body - The data to process */ - return function xpackMlPostData (params, options, callback) { + return function mlPostData (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -25,7 +25,7 @@ function buildXpackMlPostData (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPostData(params, options, (err, body) => { + mlPostData(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -88,11 +88,14 @@ function buildXpackMlPostData (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_data' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_data'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -109,4 +112,4 @@ function buildXpackMlPostData (opts) { } } -module.exports = buildXpackMlPostData +module.exports = buildMlPostData diff --git a/api/api/xpack.ml.preview_datafeed.js b/api/api/ml.preview_datafeed.js similarity index 81% rename from api/api/xpack.ml.preview_datafeed.js rename to api/api/ml.preview_datafeed.js index 4b13d142a..6d0c27191 100644 --- a/api/api/xpack.ml.preview_datafeed.js +++ b/api/api/ml.preview_datafeed.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackMlPreviewDatafeed (opts) { +function buildMlPreviewDatafeed (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.preview_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html) request + * Perform a [ml.preview_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html) request * * @param {string} datafeed_id - The ID of the datafeed to preview */ - return function xpackMlPreviewDatafeed (params, options, callback) { + return function mlPreviewDatafeed (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackMlPreviewDatafeed (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPreviewDatafeed(params, options, (err, body) => { + mlPreviewDatafeed(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -83,11 +83,14 @@ function buildXpackMlPreviewDatafeed (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + '/' + '_preview' + // build request object - const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId'], '_preview'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -104,4 +107,4 @@ function buildXpackMlPreviewDatafeed (opts) { } } -module.exports = buildXpackMlPreviewDatafeed +module.exports = buildMlPreviewDatafeed diff --git a/api/api/xpack.ml.put_calendar.js b/api/api/ml.put_calendar.js similarity index 84% rename from api/api/xpack.ml.put_calendar.js rename to api/api/ml.put_calendar.js index eab6cc376..16220fea7 100644 --- a/api/api/xpack.ml.put_calendar.js +++ b/api/api/ml.put_calendar.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlPutCalendar (opts) { +function buildMlPutCalendar (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.put_calendar](undefined) request + * Perform a [ml.put_calendar](undefined) request * * @param {string} calendar_id - The ID of the calendar to create * @param {object} body - The calendar details */ - return function xpackMlPutCalendar (params, options, callback) { + return function mlPutCalendar (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlPutCalendar (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPutCalendar(params, options, (err, body) => { + mlPutCalendar(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -78,11 +78,14 @@ function buildXpackMlPutCalendar (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + // build request object - const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -99,4 +102,4 @@ function buildXpackMlPutCalendar (opts) { } } -module.exports = buildXpackMlPutCalendar +module.exports = buildMlPutCalendar diff --git a/api/api/xpack.ml.put_calendar_job.js b/api/api/ml.put_calendar_job.js similarity index 85% rename from api/api/xpack.ml.put_calendar_job.js rename to api/api/ml.put_calendar_job.js index 0ea1a089e..d61cdce3f 100644 --- a/api/api/xpack.ml.put_calendar_job.js +++ b/api/api/ml.put_calendar_job.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlPutCalendarJob (opts) { +function buildMlPutCalendarJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.put_calendar_job](undefined) request + * Perform a [ml.put_calendar_job](undefined) request * * @param {string} calendar_id - The ID of the calendar to modify * @param {string} job_id - The ID of the job to add to the calendar */ - return function xpackMlPutCalendarJob (params, options, callback) { + return function mlPutCalendarJob (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlPutCalendarJob (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPutCalendarJob(params, options, (err, body) => { + mlPutCalendarJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -98,11 +98,14 @@ function buildXpackMlPutCalendarJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + '/' + 'jobs' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + // build request object - const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId'], 'jobs', params['job_id'] || params['jobId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -119,4 +122,4 @@ function buildXpackMlPutCalendarJob (opts) { } } -module.exports = buildXpackMlPutCalendarJob +module.exports = buildMlPutCalendarJob diff --git a/api/api/xpack.ml.put_datafeed.js b/api/api/ml.put_datafeed.js similarity index 83% rename from api/api/xpack.ml.put_datafeed.js rename to api/api/ml.put_datafeed.js index fa011a506..3cc416c86 100644 --- a/api/api/xpack.ml.put_datafeed.js +++ b/api/api/ml.put_datafeed.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlPutDatafeed (opts) { +function buildMlPutDatafeed (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.put_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-datafeed.html) request + * Perform a [ml.put_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-datafeed.html) request * * @param {string} datafeed_id - The ID of the datafeed to create * @param {object} body - The datafeed config */ - return function xpackMlPutDatafeed (params, options, callback) { + return function mlPutDatafeed (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlPutDatafeed (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPutDatafeed(params, options, (err, body) => { + mlPutDatafeed(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackMlPutDatafeed (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + // build request object - const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -105,4 +108,4 @@ function buildXpackMlPutDatafeed (opts) { } } -module.exports = buildXpackMlPutDatafeed +module.exports = buildMlPutDatafeed diff --git a/api/api/xpack.ml.put_filter.js b/api/api/ml.put_filter.js similarity index 85% rename from api/api/xpack.ml.put_filter.js rename to api/api/ml.put_filter.js index 64baba8d5..2f2645f05 100644 --- a/api/api/xpack.ml.put_filter.js +++ b/api/api/ml.put_filter.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlPutFilter (opts) { +function buildMlPutFilter (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.put_filter](undefined) request + * Perform a [ml.put_filter](undefined) request * * @param {string} filter_id - The ID of the filter to create * @param {object} body - The filter details */ - return function xpackMlPutFilter (params, options, callback) { + return function mlPutFilter (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlPutFilter (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPutFilter(params, options, (err, body) => { + mlPutFilter(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackMlPutFilter (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(params['filter_id'] || params['filterId']) + // build request object - const parts = ['_xpack', 'ml', 'filters', params['filter_id'] || params['filterId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -105,4 +108,4 @@ function buildXpackMlPutFilter (opts) { } } -module.exports = buildXpackMlPutFilter +module.exports = buildMlPutFilter diff --git a/api/api/xpack.ml.put_job.js b/api/api/ml.put_job.js similarity index 83% rename from api/api/xpack.ml.put_job.js rename to api/api/ml.put_job.js index 333249a33..b9abe9a4e 100644 --- a/api/api/xpack.ml.put_job.js +++ b/api/api/ml.put_job.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlPutJob (opts) { +function buildMlPutJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.put_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html) request + * Perform a [ml.put_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html) request * * @param {string} job_id - The ID of the job to create * @param {object} body - The job */ - return function xpackMlPutJob (params, options, callback) { + return function mlPutJob (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlPutJob (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPutJob(params, options, (err, body) => { + mlPutJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackMlPutJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -105,4 +108,4 @@ function buildXpackMlPutJob (opts) { } } -module.exports = buildXpackMlPutJob +module.exports = buildMlPutJob diff --git a/api/api/xpack.ml.revert_model_snapshot.js b/api/api/ml.revert_model_snapshot.js similarity index 83% rename from api/api/xpack.ml.revert_model_snapshot.js rename to api/api/ml.revert_model_snapshot.js index b04c713bf..dd4446ada 100644 --- a/api/api/xpack.ml.revert_model_snapshot.js +++ b/api/api/ml.revert_model_snapshot.js @@ -1,17 +1,17 @@ 'use strict' -function buildXpackMlRevertModelSnapshot (opts) { +function buildMlRevertModelSnapshot (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.revert_model_snapshot](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-revert-snapshot.html) request + * Perform a [ml.revert_model_snapshot](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-revert-snapshot.html) request * * @param {string} job_id - The ID of the job to fetch * @param {string} snapshot_id - The ID of the snapshot to revert to * @param {boolean} delete_intervening_results - Should we reset the results back to the time of the snapshot? * @param {object} body - Reversion options */ - return function xpackMlRevertModelSnapshot (params, options, callback) { + return function mlRevertModelSnapshot (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -25,7 +25,7 @@ function buildXpackMlRevertModelSnapshot (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlRevertModelSnapshot(params, options, (err, body) => { + mlRevertModelSnapshot(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -94,11 +94,14 @@ function buildXpackMlRevertModelSnapshot (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'model_snapshots' + '/' + encodeURIComponent(params['snapshot_id'] || params['snapshotId']) + '/' + '_revert' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'model_snapshots', params['snapshot_id'] || params['snapshotId'], '_revert'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -115,4 +118,4 @@ function buildXpackMlRevertModelSnapshot (opts) { } } -module.exports = buildXpackMlRevertModelSnapshot +module.exports = buildMlRevertModelSnapshot diff --git a/api/api/xpack.ml.start_datafeed.js b/api/api/ml.start_datafeed.js similarity index 83% rename from api/api/xpack.ml.start_datafeed.js rename to api/api/ml.start_datafeed.js index 57fc53830..789b906f8 100644 --- a/api/api/xpack.ml.start_datafeed.js +++ b/api/api/ml.start_datafeed.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMlStartDatafeed (opts) { +function buildMlStartDatafeed (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.start_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-start-datafeed.html) request + * Perform a [ml.start_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-start-datafeed.html) request * * @param {string} datafeed_id - The ID of the datafeed to start * @param {string} start - The start time from where the datafeed should begin @@ -12,7 +12,7 @@ function buildXpackMlStartDatafeed (opts) { * @param {time} timeout - Controls the time to wait until a datafeed has started. Default to 20 seconds * @param {object} body - The start datafeed parameters */ - return function xpackMlStartDatafeed (params, options, callback) { + return function mlStartDatafeed (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -26,7 +26,7 @@ function buildXpackMlStartDatafeed (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlStartDatafeed(params, options, (err, body) => { + mlStartDatafeed(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -85,11 +85,14 @@ function buildXpackMlStartDatafeed (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + '/' + '_start' + // build request object - const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId'], '_start'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -106,4 +109,4 @@ function buildXpackMlStartDatafeed (opts) { } } -module.exports = buildXpackMlStartDatafeed +module.exports = buildMlStartDatafeed diff --git a/api/api/xpack.ml.stop_datafeed.js b/api/api/ml.stop_datafeed.js similarity index 84% rename from api/api/xpack.ml.stop_datafeed.js rename to api/api/ml.stop_datafeed.js index e0a8cd330..59ec92d8e 100644 --- a/api/api/xpack.ml.stop_datafeed.js +++ b/api/api/ml.stop_datafeed.js @@ -1,17 +1,17 @@ 'use strict' -function buildXpackMlStopDatafeed (opts) { +function buildMlStopDatafeed (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.stop_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-stop-datafeed.html) request + * Perform a [ml.stop_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-stop-datafeed.html) request * * @param {string} datafeed_id - The ID of the datafeed to stop * @param {boolean} allow_no_datafeeds - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) * @param {boolean} force - True if the datafeed should be forcefully stopped. * @param {time} timeout - Controls the time to wait until a datafeed has stopped. Default to 20 seconds */ - return function xpackMlStopDatafeed (params, options, callback) { + return function mlStopDatafeed (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -25,7 +25,7 @@ function buildXpackMlStopDatafeed (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlStopDatafeed(params, options, (err, body) => { + mlStopDatafeed(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackMlStopDatafeed (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + '/' + '_stop' + // build request object - const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId'], '_stop'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -105,4 +108,4 @@ function buildXpackMlStopDatafeed (opts) { } } -module.exports = buildXpackMlStopDatafeed +module.exports = buildMlStopDatafeed diff --git a/api/api/xpack.ml.update_datafeed.js b/api/api/ml.update_datafeed.js similarity index 82% rename from api/api/xpack.ml.update_datafeed.js rename to api/api/ml.update_datafeed.js index 15d6881df..e2742e273 100644 --- a/api/api/xpack.ml.update_datafeed.js +++ b/api/api/ml.update_datafeed.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlUpdateDatafeed (opts) { +function buildMlUpdateDatafeed (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.update_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-datafeed.html) request + * Perform a [ml.update_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-datafeed.html) request * * @param {string} datafeed_id - The ID of the datafeed to update * @param {object} body - The datafeed update settings */ - return function xpackMlUpdateDatafeed (params, options, callback) { + return function mlUpdateDatafeed (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlUpdateDatafeed (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlUpdateDatafeed(params, options, (err, body) => { + mlUpdateDatafeed(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackMlUpdateDatafeed (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + '/' + '_update' + // build request object - const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId'], '_update'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -105,4 +108,4 @@ function buildXpackMlUpdateDatafeed (opts) { } } -module.exports = buildXpackMlUpdateDatafeed +module.exports = buildMlUpdateDatafeed diff --git a/api/api/xpack.ml.update_filter.js b/api/api/ml.update_filter.js similarity index 84% rename from api/api/xpack.ml.update_filter.js rename to api/api/ml.update_filter.js index 21543f6c1..1f5e094c7 100644 --- a/api/api/xpack.ml.update_filter.js +++ b/api/api/ml.update_filter.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlUpdateFilter (opts) { +function buildMlUpdateFilter (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.update_filter](undefined) request + * Perform a [ml.update_filter](undefined) request * * @param {string} filter_id - The ID of the filter to update * @param {object} body - The filter update */ - return function xpackMlUpdateFilter (params, options, callback) { + return function mlUpdateFilter (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlUpdateFilter (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlUpdateFilter(params, options, (err, body) => { + mlUpdateFilter(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackMlUpdateFilter (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(params['filter_id'] || params['filterId']) + '/' + '_update' + // build request object - const parts = ['_xpack', 'ml', 'filters', params['filter_id'] || params['filterId'], '_update'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -105,4 +108,4 @@ function buildXpackMlUpdateFilter (opts) { } } -module.exports = buildXpackMlUpdateFilter +module.exports = buildMlUpdateFilter diff --git a/api/api/xpack.ml.update_job.js b/api/api/ml.update_job.js similarity index 83% rename from api/api/xpack.ml.update_job.js rename to api/api/ml.update_job.js index d0bd8c310..5d4ee264e 100644 --- a/api/api/xpack.ml.update_job.js +++ b/api/api/ml.update_job.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlUpdateJob (opts) { +function buildMlUpdateJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.update_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-job.html) request + * Perform a [ml.update_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-job.html) request * * @param {string} job_id - The ID of the job to create * @param {object} body - The job update settings */ - return function xpackMlUpdateJob (params, options, callback) { + return function mlUpdateJob (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlUpdateJob (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlUpdateJob(params, options, (err, body) => { + mlUpdateJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackMlUpdateJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_update' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_update'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -105,4 +108,4 @@ function buildXpackMlUpdateJob (opts) { } } -module.exports = buildXpackMlUpdateJob +module.exports = buildMlUpdateJob diff --git a/api/api/xpack.ml.update_model_snapshot.js b/api/api/ml.update_model_snapshot.js similarity index 83% rename from api/api/xpack.ml.update_model_snapshot.js rename to api/api/ml.update_model_snapshot.js index a01271522..e2fe7ec1b 100644 --- a/api/api/xpack.ml.update_model_snapshot.js +++ b/api/api/ml.update_model_snapshot.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackMlUpdateModelSnapshot (opts) { +function buildMlUpdateModelSnapshot (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.update_model_snapshot](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-snapshot.html) request + * Perform a [ml.update_model_snapshot](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-snapshot.html) request * * @param {string} job_id - The ID of the job to fetch * @param {string} snapshot_id - The ID of the snapshot to update * @param {object} body - The model snapshot properties to update */ - return function xpackMlUpdateModelSnapshot (params, options, callback) { + return function mlUpdateModelSnapshot (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackMlUpdateModelSnapshot (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlUpdateModelSnapshot(params, options, (err, body) => { + mlUpdateModelSnapshot(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -99,11 +99,14 @@ function buildXpackMlUpdateModelSnapshot (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'model_snapshots' + '/' + encodeURIComponent(params['snapshot_id'] || params['snapshotId']) + '/' + '_update' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'model_snapshots', params['snapshot_id'] || params['snapshotId'], '_update'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -120,4 +123,4 @@ function buildXpackMlUpdateModelSnapshot (opts) { } } -module.exports = buildXpackMlUpdateModelSnapshot +module.exports = buildMlUpdateModelSnapshot diff --git a/api/api/xpack.ml.validate.js b/api/api/ml.validate.js similarity index 85% rename from api/api/xpack.ml.validate.js rename to api/api/ml.validate.js index fe14682e2..2f9dd9e22 100644 --- a/api/api/xpack.ml.validate.js +++ b/api/api/ml.validate.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackMlValidate (opts) { +function buildMlValidate (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.validate](undefined) request + * Perform a [ml.validate](undefined) request * * @param {object} body - The job config */ - return function xpackMlValidate (params, options, callback) { + return function mlValidate (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackMlValidate (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlValidate(params, options, (err, body) => { + mlValidate(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -77,11 +77,14 @@ function buildXpackMlValidate (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_validate' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', '_validate'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -98,4 +101,4 @@ function buildXpackMlValidate (opts) { } } -module.exports = buildXpackMlValidate +module.exports = buildMlValidate diff --git a/api/api/xpack.ml.validate_detector.js b/api/api/ml.validate_detector.js similarity index 83% rename from api/api/xpack.ml.validate_detector.js rename to api/api/ml.validate_detector.js index 9a4215521..93cceaf23 100644 --- a/api/api/xpack.ml.validate_detector.js +++ b/api/api/ml.validate_detector.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackMlValidateDetector (opts) { +function buildMlValidateDetector (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.validate_detector](undefined) request + * Perform a [ml.validate_detector](undefined) request * * @param {object} body - The detector */ - return function xpackMlValidateDetector (params, options, callback) { + return function mlValidateDetector (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackMlValidateDetector (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlValidateDetector(params, options, (err, body) => { + mlValidateDetector(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -77,11 +77,14 @@ function buildXpackMlValidateDetector (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_validate' + '/' + 'detector' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', '_validate', 'detector'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -98,4 +101,4 @@ function buildXpackMlValidateDetector (opts) { } } -module.exports = buildXpackMlValidateDetector +module.exports = buildMlValidateDetector diff --git a/api/api/xpack.monitoring.bulk.js b/api/api/monitoring.bulk.js similarity index 83% rename from api/api/xpack.monitoring.bulk.js rename to api/api/monitoring.bulk.js index 35e9dea06..aa71f8154 100644 --- a/api/api/xpack.monitoring.bulk.js +++ b/api/api/monitoring.bulk.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMonitoringBulk (opts) { +function buildMonitoringBulk (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.monitoring.bulk](http://www.elastic.co/guide/en/monitoring/current/appendix-api-bulk.html) request + * Perform a [monitoring.bulk](http://www.elastic.co/guide/en/monitoring/current/appendix-api-bulk.html) request * * @param {string} type - Default document type for items which don't provide one * @param {string} system_id - Identifier of the monitored system @@ -12,7 +12,7 @@ function buildXpackMonitoringBulk (opts) { * @param {string} interval - Collection interval (e.g., '10s' or '10000ms') of the payload * @param {object} body - The operation definition and data (action-data pairs), separated by newlines */ - return function xpackMonitoringBulk (params, options, callback) { + return function monitoringBulk (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -26,7 +26,7 @@ function buildXpackMonitoringBulk (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMonitoringBulk(params, options, (err, body) => { + monitoringBulk(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -85,11 +85,18 @@ function buildXpackMonitoringBulk (opts) { ignore = [ignore] } + var path = '' + + if ((params['type']) != null) { + path = '/' + '_monitoring' + '/' + encodeURIComponent(params['type']) + '/' + 'bulk' + } else { + path = '/' + '_monitoring' + '/' + 'bulk' + } + // build request object - const parts = ['_xpack', 'monitoring', params['type'], '_bulk'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -106,4 +113,4 @@ function buildXpackMonitoringBulk (opts) { } } -module.exports = buildXpackMonitoringBulk +module.exports = buildMonitoringBulk diff --git a/api/api/msearch.js b/api/api/msearch.js index b4aa9faea..8cc3c750d 100644 --- a/api/api/msearch.js +++ b/api/api/msearch.js @@ -13,6 +13,7 @@ function buildMsearch (opts) { * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response * @param {number} pre_filter_shard_size - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on it's rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. * @param {number} max_concurrent_shard_requests - The number of concurrent shard requests each sub search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response * @param {object} body - The request definitions (metadata-search request definition pairs), separated by newlines */ return function msearch (params, options, callback) { @@ -60,6 +61,7 @@ function buildMsearch (opts) { 'typed_keys', 'pre_filter_shard_size', 'max_concurrent_shard_requests', + 'rest_total_hits_as_int', 'pretty', 'human', 'error_trace', @@ -72,6 +74,7 @@ function buildMsearch (opts) { 'typedKeys', 'preFilterShardSize', 'maxConcurrentShardRequests', + 'restTotalHitsAsInt', 'pretty', 'human', 'errorTrace', @@ -110,11 +113,20 @@ function buildMsearch (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_msearch' + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_msearch' + } else { + path = '/' + '_msearch' + } + // build request object - const parts = [params['index'], params['type'], '_msearch'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, bulkBody: params.body, querystring } diff --git a/api/api/msearch_template.js b/api/api/msearch_template.js index 2d7331260..d0b6ed126 100644 --- a/api/api/msearch_template.js +++ b/api/api/msearch_template.js @@ -11,6 +11,7 @@ function buildMsearchTemplate (opts) { * @param {enum} search_type - Search operation type * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response * @param {number} max_concurrent_searches - Controls the maximum number of concurrent searches the multi search api will execute + * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response * @param {object} body - The request definitions (metadata-search request definition pairs), separated by newlines */ return function msearchTemplate (params, options, callback) { @@ -56,6 +57,7 @@ function buildMsearchTemplate (opts) { 'search_type', 'typed_keys', 'max_concurrent_searches', + 'rest_total_hits_as_int', 'pretty', 'human', 'error_trace', @@ -66,6 +68,7 @@ function buildMsearchTemplate (opts) { 'searchType', 'typedKeys', 'maxConcurrentSearches', + 'restTotalHitsAsInt', 'pretty', 'human', 'errorTrace', @@ -104,11 +107,20 @@ function buildMsearchTemplate (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_msearch' + '/' + 'template' + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_msearch' + '/' + 'template' + } else { + path = '/' + '_msearch' + '/' + 'template' + } + // build request object - const parts = [params['index'], params['type'], '_msearch', 'template'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, bulkBody: params.body, querystring } diff --git a/api/api/mtermvectors.js b/api/api/mtermvectors.js index a2628e6a0..eb743c9fd 100644 --- a/api/api/mtermvectors.js +++ b/api/api/mtermvectors.js @@ -126,11 +126,20 @@ function buildMtermvectors (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_mtermvectors' + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_mtermvectors' + } else { + path = '/' + '_mtermvectors' + } + // build request object - const parts = [params['index'], params['type'], '_mtermvectors'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/nodes.hot_threads.js b/api/api/nodes.hot_threads.js index b19169efe..9eb77104d 100644 --- a/api/api/nodes.hot_threads.js +++ b/api/api/nodes.hot_threads.js @@ -103,13 +103,24 @@ function buildNodesHotThreads (opts) { ignore = [ignore] } + var path = '' + + if ((params['node_id'] || params['nodeId']) != null) { + path = '/' + '_cluster' + '/' + 'nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'hotthreads' + } else if ((params['node_id'] || params['nodeId']) != null) { + path = '/' + '_cluster' + '/' + 'nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'hot_threads' + } else if ((params['node_id'] || params['nodeId']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'hotthreads' + } else if ((params['node_id'] || params['nodeId']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'hot_threads' + } else { + path = '/' + '_cluster' + '/' + 'nodes' + '/' + 'hotthreads' + } + // build request object - const parts = ['_cluster', 'nodes', params['node_id'] || params['nodeId'], 'hot_threads'] const request = { method, - path: (params['node_id'] || params['nodeId']) != null - ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') - : '/_nodes/hot_threads', + path, body: null, querystring } diff --git a/api/api/nodes.info.js b/api/api/nodes.info.js index c2ef92c6d..0fe37efdd 100644 --- a/api/api/nodes.info.js +++ b/api/api/nodes.info.js @@ -92,11 +92,22 @@ function buildNodesInfo (opts) { ignore = [ignore] } + var path = '' + + if ((params['node_id'] || params['nodeId']) != null && (params['metric']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + encodeURIComponent(params['metric']) + } else if ((params['node_id'] || params['nodeId']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + } else if ((params['metric']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['metric']) + } else { + path = '/' + '_nodes' + } + // build request object - const parts = ['_nodes', params['node_id'] || params['nodeId'], params['metric']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/nodes.reload_secure_settings.js b/api/api/nodes.reload_secure_settings.js index 98d3f5c3a..0f04f3c0a 100644 --- a/api/api/nodes.reload_secure_settings.js +++ b/api/api/nodes.reload_secure_settings.js @@ -4,7 +4,7 @@ function buildNodesReloadSecureSettings (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [nodes.reload_secure_settings](https://www.elastic.co/guide/en/elasticsearch/reference/6.5/secure-settings.html#reloadable-secure-settings) request + * Perform a [nodes.reload_secure_settings](https://www.elastic.co/guide/en/elasticsearch/reference/master/secure-settings.html#reloadable-secure-settings) request * * @param {list} node_id - A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes. * @param {time} timeout - Explicit operation timeout @@ -88,11 +88,18 @@ function buildNodesReloadSecureSettings (opts) { ignore = [ignore] } + var path = '' + + if ((params['node_id'] || params['nodeId']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'reload_secure_settings' + } else { + path = '/' + '_nodes' + '/' + 'reload_secure_settings' + } + // build request object - const parts = ['_nodes', params['node_id'] || params['nodeId'], 'reload_secure_settings'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/nodes.stats.js b/api/api/nodes.stats.js index b4faa6ba4..dc80a9363 100644 --- a/api/api/nodes.stats.js +++ b/api/api/nodes.stats.js @@ -111,11 +111,26 @@ function buildNodesStats (opts) { ignore = [ignore] } + var path = '' + + if ((params['node_id'] || params['nodeId']) != null && (params['metric']) != null && (params['index_metric'] || params['indexMetric']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'stats' + '/' + encodeURIComponent(params['metric']) + '/' + encodeURIComponent(params['index_metric'] || params['indexMetric']) + } else if ((params['node_id'] || params['nodeId']) != null && (params['metric']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'stats' + '/' + encodeURIComponent(params['metric']) + } else if ((params['metric']) != null && (params['index_metric'] || params['indexMetric']) != null) { + path = '/' + '_nodes' + '/' + 'stats' + '/' + encodeURIComponent(params['metric']) + '/' + encodeURIComponent(params['index_metric'] || params['indexMetric']) + } else if ((params['node_id'] || params['nodeId']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'stats' + } else if ((params['metric']) != null) { + path = '/' + '_nodes' + '/' + 'stats' + '/' + encodeURIComponent(params['metric']) + } else { + path = '/' + '_nodes' + '/' + 'stats' + } + // build request object - const parts = ['_nodes', params['node_id'] || params['nodeId'], 'stats', params['metric'], params['index_metric'] || params['indexMetric']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/nodes.usage.js b/api/api/nodes.usage.js index 37b7244de..13a1010e1 100644 --- a/api/api/nodes.usage.js +++ b/api/api/nodes.usage.js @@ -89,11 +89,22 @@ function buildNodesUsage (opts) { ignore = [ignore] } + var path = '' + + if ((params['node_id'] || params['nodeId']) != null && (params['metric']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'usage' + '/' + encodeURIComponent(params['metric']) + } else if ((params['node_id'] || params['nodeId']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'usage' + } else if ((params['metric']) != null) { + path = '/' + '_nodes' + '/' + 'usage' + '/' + encodeURIComponent(params['metric']) + } else { + path = '/' + '_nodes' + '/' + 'usage' + } + // build request object - const parts = ['_nodes', params['node_id'] || params['nodeId'], 'usage', params['metric']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/ping.js b/api/api/ping.js index 98af2d2d4..ea12fc318 100644 --- a/api/api/ping.js +++ b/api/api/ping.js @@ -84,11 +84,14 @@ function buildPing (opts) { ignore = [ignore] } + var path = '' + + path = '/' + // build request object - const parts = [] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/put_script.js b/api/api/put_script.js index be52f8e01..a1597dbc1 100644 --- a/api/api/put_script.js +++ b/api/api/put_script.js @@ -110,11 +110,18 @@ function buildPutScript (opts) { ignore = [ignore] } + var path = '' + + if ((params['id']) != null && (params['context']) != null) { + path = '/' + '_scripts' + '/' + encodeURIComponent(params['id']) + '/' + encodeURIComponent(params['context']) + } else { + path = '/' + '_scripts' + '/' + encodeURIComponent(params['id']) + } + // build request object - const parts = ['_scripts', params['id'], params['context']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/rank_eval.js b/api/api/rank_eval.js index 3b693eaf4..26590c7d2 100644 --- a/api/api/rank_eval.js +++ b/api/api/rank_eval.js @@ -95,11 +95,18 @@ function buildRankEval (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_rank_eval' + } else { + path = '/' + '_rank_eval' + } + // build request object - const parts = [params['index'], '_rank_eval'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/reindex.js b/api/api/reindex.js index c61ca9587..6a5a1f43d 100644 --- a/api/api/reindex.js +++ b/api/api/reindex.js @@ -103,11 +103,14 @@ function buildReindex (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_reindex' + // build request object - const parts = ['_reindex'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/reindex_rethrottle.js b/api/api/reindex_rethrottle.js index 1d80eeddf..35961aa79 100644 --- a/api/api/reindex_rethrottle.js +++ b/api/api/reindex_rethrottle.js @@ -100,11 +100,14 @@ function buildReindexRethrottle (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_reindex' + '/' + encodeURIComponent(params['task_id'] || params['taskId']) + '/' + '_rethrottle' + // build request object - const parts = ['_reindex', params['task_id'] || params['taskId'], '_rethrottle'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/render_search_template.js b/api/api/render_search_template.js index a6c50ec8b..e4a8e742c 100644 --- a/api/api/render_search_template.js +++ b/api/api/render_search_template.js @@ -78,11 +78,18 @@ function buildRenderSearchTemplate (opts) { ignore = [ignore] } + var path = '' + + if ((params['id']) != null) { + path = '/' + '_render' + '/' + 'template' + '/' + encodeURIComponent(params['id']) + } else { + path = '/' + '_render' + '/' + 'template' + } + // build request object - const parts = ['_render', 'template', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/scripts_painless_execute.js b/api/api/scripts_painless_execute.js index 028e3e479..1093a6333 100644 --- a/api/api/scripts_painless_execute.js +++ b/api/api/scripts_painless_execute.js @@ -77,11 +77,14 @@ function buildScriptsPainlessExecute (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_scripts' + '/' + 'painless' + '/' + '_execute' + // build request object - const parts = ['_scripts', 'painless', '_execute'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/scroll.js b/api/api/scroll.js index 0f09babcd..f1b7063b8 100644 --- a/api/api/scroll.js +++ b/api/api/scroll.js @@ -9,6 +9,7 @@ function buildScroll (opts) { * @param {string} scroll_id - The scroll ID * @param {time} scroll - Specify how long a consistent view of the index should be maintained for scrolled search * @param {string} scroll_id - The scroll ID for scrolled search + * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response * @param {object} body - The scroll ID if not passed by URL or query parameter. */ return function scroll (params, options, callback) { @@ -37,6 +38,7 @@ function buildScroll (opts) { const acceptedQuerystring = [ 'scroll', 'scroll_id', + 'rest_total_hits_as_int', 'pretty', 'human', 'error_trace', @@ -46,6 +48,7 @@ function buildScroll (opts) { const acceptedQuerystringCamelCased = [ 'scroll', 'scrollId', + 'restTotalHitsAsInt', 'pretty', 'human', 'errorTrace', @@ -84,11 +87,18 @@ function buildScroll (opts) { ignore = [ignore] } + var path = '' + + if ((params['scroll_id'] || params['scrollId']) != null) { + path = '/' + '_search' + '/' + 'scroll' + '/' + encodeURIComponent(params['scroll_id'] || params['scrollId']) + } else { + path = '/' + '_search' + '/' + 'scroll' + } + // build request object - const parts = ['_search', 'scroll', params['scroll_id'] || params['scrollId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/search.js b/api/api/search.js index 48bc3702a..2b49563a7 100644 --- a/api/api/search.js +++ b/api/api/search.js @@ -17,6 +17,7 @@ function buildSearch (opts) { * @param {list} docvalue_fields - A comma-separated list of fields to return as the docvalue representation of a field for each hit * @param {number} from - Starting offset (default: 0) * @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {boolean} ignore_throttled - Whether specified concrete, expanded or aliased indices should be ignored when throttled * @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} lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored @@ -28,8 +29,8 @@ function buildSearch (opts) { * @param {number} size - Number of hits to return (default: 10) * @param {list} sort - A comma-separated list of : pairs * @param {list} _source - True or false to return the _source field or not, or a list of fields to return - * @param {list} _source_exclude - A list of fields to exclude from the returned _source field - * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {list} _source_excludes - A list of fields to exclude from the returned _source field + * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {number} terminate_after - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. * @param {list} stats - Specific 'tag' of the request for logging and statistical purposes * @param {string} suggest_field - Specify which field to use for suggestions @@ -44,8 +45,9 @@ function buildSearch (opts) { * @param {boolean} version - Specify whether to return document version as part of a hit * @param {boolean} request_cache - Specify if request cache should be used for this request or not, defaults to index level setting * @param {number} batched_reduce_size - The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. - * @param {number} max_concurrent_shard_requests - The number of concurrent shard requests this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + * @param {number} max_concurrent_shard_requests - The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests * @param {number} pre_filter_shard_size - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on it's rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. + * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response * @param {object} body - The search definition using the Query DSL */ return function search (params, options, callback) { @@ -89,6 +91,7 @@ function buildSearch (opts) { 'docvalue_fields', 'from', 'ignore_unavailable', + 'ignore_throttled', 'allow_no_indices', 'expand_wildcards', 'lenient', @@ -100,8 +103,8 @@ function buildSearch (opts) { 'size', 'sort', '_source', - '_source_exclude', - '_source_include', + '_source_excludes', + '_source_includes', 'terminate_after', 'stats', 'suggest_field', @@ -118,6 +121,7 @@ function buildSearch (opts) { 'batched_reduce_size', 'max_concurrent_shard_requests', 'pre_filter_shard_size', + 'rest_total_hits_as_int', 'pretty', 'human', 'error_trace', @@ -134,6 +138,7 @@ function buildSearch (opts) { 'docvalueFields', 'from', 'ignoreUnavailable', + 'ignoreThrottled', 'allowNoIndices', 'expandWildcards', 'lenient', @@ -145,8 +150,8 @@ function buildSearch (opts) { 'size', 'sort', '_source', - '_sourceExclude', - '_sourceInclude', + '_sourceExcludes', + '_sourceIncludes', 'terminateAfter', 'stats', 'suggestField', @@ -163,6 +168,7 @@ function buildSearch (opts) { 'batchedReduceSize', 'maxConcurrentShardRequests', 'preFilterShardSize', + 'restTotalHitsAsInt', 'pretty', 'human', 'errorTrace', @@ -201,11 +207,20 @@ function buildSearch (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_search' + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_search' + } else { + path = '/' + '_search' + } + // build request object - const parts = [params['index'], params['type'], '_search'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/search_shards.js b/api/api/search_shards.js index cc1ec72ff..95ade603e 100644 --- a/api/api/search_shards.js +++ b/api/api/search_shards.js @@ -103,11 +103,18 @@ function buildSearchShards (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_search_shards' + } else { + path = '/' + '_search_shards' + } + // build request object - const parts = [params['index'], '_search_shards'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/search_template.js b/api/api/search_template.js index 66af6e928..63cdbb441 100644 --- a/api/api/search_template.js +++ b/api/api/search_template.js @@ -9,6 +9,7 @@ function buildSearchTemplate (opts) { * @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices * @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types * @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {boolean} ignore_throttled - Whether specified concrete, expanded or aliased indices should be ignored when throttled * @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 {string} preference - Specify the node or shard the operation should be performed on (default: random) @@ -18,6 +19,7 @@ function buildSearchTemplate (opts) { * @param {boolean} explain - Specify whether to return detailed information about score computation as part of a hit * @param {boolean} profile - Specify whether to profile the query execution * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response * @param {object} body - The search definition template and its params */ return function searchTemplate (params, options, callback) { @@ -61,6 +63,7 @@ function buildSearchTemplate (opts) { const keys = Object.keys(params) const acceptedQuerystring = [ 'ignore_unavailable', + 'ignore_throttled', 'allow_no_indices', 'expand_wildcards', 'preference', @@ -70,6 +73,7 @@ function buildSearchTemplate (opts) { 'explain', 'profile', 'typed_keys', + 'rest_total_hits_as_int', 'pretty', 'human', 'error_trace', @@ -78,6 +82,7 @@ function buildSearchTemplate (opts) { ] const acceptedQuerystringCamelCased = [ 'ignoreUnavailable', + 'ignoreThrottled', 'allowNoIndices', 'expandWildcards', 'preference', @@ -87,6 +92,7 @@ function buildSearchTemplate (opts) { 'explain', 'profile', 'typedKeys', + 'restTotalHitsAsInt', 'pretty', 'human', 'errorTrace', @@ -125,11 +131,20 @@ function buildSearchTemplate (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_search' + '/' + 'template' + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_search' + '/' + 'template' + } else { + path = '/' + '_search' + '/' + 'template' + } + // build request object - const parts = [params['index'], params['type'], '_search', 'template'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.ssl.certificates.js b/api/api/security.authenticate.js similarity index 82% rename from api/api/xpack.ssl.certificates.js rename to api/api/security.authenticate.js index 142900399..d1bd8a815 100644 --- a/api/api/xpack.ssl.certificates.js +++ b/api/api/security.authenticate.js @@ -1,13 +1,13 @@ 'use strict' -function buildXpackSslCertificates (opts) { +function buildSecurityAuthenticate (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ssl.certificates](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-ssl.html) request + * Perform a [security.authenticate](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-authenticate.html) request * */ - return function xpackSslCertificates (params, options, callback) { + return function securityAuthenticate (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -21,7 +21,7 @@ function buildXpackSslCertificates (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSslCertificates(params, options, (err, body) => { + securityAuthenticate(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -76,11 +76,14 @@ function buildXpackSslCertificates (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + '_authenticate' + // build request object - const parts = ['_xpack', 'ssl', 'certificates'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -97,4 +100,4 @@ function buildXpackSslCertificates (opts) { } } -module.exports = buildXpackSslCertificates +module.exports = buildSecurityAuthenticate diff --git a/api/api/xpack.security.change_password.js b/api/api/security.change_password.js similarity index 80% rename from api/api/xpack.security.change_password.js rename to api/api/security.change_password.js index d67131909..fc07667d7 100644 --- a/api/api/xpack.security.change_password.js +++ b/api/api/security.change_password.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackSecurityChangePassword (opts) { +function buildSecurityChangePassword (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.change_password](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-change-password.html) request + * Perform a [security.change_password](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-change-password.html) request * * @param {string} username - The username of the user to change the password for * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. * @param {object} body - the new password for the user */ - return function xpackSecurityChangePassword (params, options, callback) { + return function securityChangePassword (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackSecurityChangePassword (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityChangePassword(params, options, (err, body) => { + securityChangePassword(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -79,11 +79,18 @@ function buildXpackSecurityChangePassword (opts) { ignore = [ignore] } + var path = '' + + if ((params['username']) != null) { + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(params['username']) + '/' + '_password' + } else { + path = '/' + '_security' + '/' + 'user' + '/' + '_password' + } + // build request object - const parts = ['_xpack', 'security', 'user', params['username'], '_password'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -100,4 +107,4 @@ function buildXpackSecurityChangePassword (opts) { } } -module.exports = buildXpackSecurityChangePassword +module.exports = buildSecurityChangePassword diff --git a/api/api/xpack.security.clear_cached_realms.js b/api/api/security.clear_cached_realms.js similarity index 81% rename from api/api/xpack.security.clear_cached_realms.js rename to api/api/security.clear_cached_realms.js index b4f81bcfa..0d89991dd 100644 --- a/api/api/xpack.security.clear_cached_realms.js +++ b/api/api/security.clear_cached_realms.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackSecurityClearCachedRealms (opts) { +function buildSecurityClearCachedRealms (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.clear_cached_realms](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-cache.html) request + * Perform a [security.clear_cached_realms](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-cache.html) request * * @param {list} realms - Comma-separated list of realms to clear * @param {list} usernames - Comma-separated list of usernames to clear from the cache */ - return function xpackSecurityClearCachedRealms (params, options, callback) { + return function securityClearCachedRealms (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackSecurityClearCachedRealms (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityClearCachedRealms(params, options, (err, body) => { + securityClearCachedRealms(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackSecurityClearCachedRealms (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'realm' + '/' + encodeURIComponent(params['realms']) + '/' + '_clear_cache' + // build request object - const parts = ['_xpack', 'security', 'realm', params['realms'], '_clear_cache'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -105,4 +108,4 @@ function buildXpackSecurityClearCachedRealms (opts) { } } -module.exports = buildXpackSecurityClearCachedRealms +module.exports = buildSecurityClearCachedRealms diff --git a/api/api/xpack.security.clear_cached_roles.js b/api/api/security.clear_cached_roles.js similarity index 80% rename from api/api/xpack.security.clear_cached_roles.js rename to api/api/security.clear_cached_roles.js index eaf91a87d..d4f658bcd 100644 --- a/api/api/xpack.security.clear_cached_roles.js +++ b/api/api/security.clear_cached_roles.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackSecurityClearCachedRoles (opts) { +function buildSecurityClearCachedRoles (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.clear_cached_roles](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-role-cache.html) request + * Perform a [security.clear_cached_roles](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-role-cache.html) request * * @param {list} name - Role name */ - return function xpackSecurityClearCachedRoles (params, options, callback) { + return function securityClearCachedRoles (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackSecurityClearCachedRoles (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityClearCachedRoles(params, options, (err, body) => { + securityClearCachedRoles(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -83,11 +83,14 @@ function buildXpackSecurityClearCachedRoles (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(params['name']) + '/' + '_clear_cache' + // build request object - const parts = ['_xpack', 'security', 'role', params['name'], '_clear_cache'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -104,4 +107,4 @@ function buildXpackSecurityClearCachedRoles (opts) { } } -module.exports = buildXpackSecurityClearCachedRoles +module.exports = buildSecurityClearCachedRoles diff --git a/api/api/xpack.security.delete_privileges.js b/api/api/security.delete_privileges.js similarity index 86% rename from api/api/xpack.security.delete_privileges.js rename to api/api/security.delete_privileges.js index db0e8a974..0a0f6492b 100644 --- a/api/api/xpack.security.delete_privileges.js +++ b/api/api/security.delete_privileges.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackSecurityDeletePrivileges (opts) { +function buildSecurityDeletePrivileges (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.delete_privileges](TODO) request + * Perform a [security.delete_privileges](TODO) request * * @param {string} application - Application name * @param {string} name - Privilege name * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ - return function xpackSecurityDeletePrivileges (params, options, callback) { + return function securityDeletePrivileges (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackSecurityDeletePrivileges (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityDeletePrivileges(params, options, (err, body) => { + securityDeletePrivileges(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -99,11 +99,14 @@ function buildXpackSecurityDeletePrivileges (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(params['application']) + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_xpack', 'security', 'privilege', params['application'], params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -120,4 +123,4 @@ function buildXpackSecurityDeletePrivileges (opts) { } } -module.exports = buildXpackSecurityDeletePrivileges +module.exports = buildSecurityDeletePrivileges diff --git a/api/api/xpack.security.delete_role.js b/api/api/security.delete_role.js similarity index 83% rename from api/api/xpack.security.delete_role.js rename to api/api/security.delete_role.js index b03c57aac..c7d2ccb83 100644 --- a/api/api/xpack.security.delete_role.js +++ b/api/api/security.delete_role.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackSecurityDeleteRole (opts) { +function buildSecurityDeleteRole (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.delete_role](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role.html) request + * Perform a [security.delete_role](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role.html) request * * @param {string} name - Role name * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ - return function xpackSecurityDeleteRole (params, options, callback) { + return function securityDeleteRole (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackSecurityDeleteRole (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityDeleteRole(params, options, (err, body) => { + securityDeleteRole(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackSecurityDeleteRole (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_xpack', 'security', 'role', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -105,4 +108,4 @@ function buildXpackSecurityDeleteRole (opts) { } } -module.exports = buildXpackSecurityDeleteRole +module.exports = buildSecurityDeleteRole diff --git a/api/api/xpack.security.delete_role_mapping.js b/api/api/security.delete_role_mapping.js similarity index 82% rename from api/api/xpack.security.delete_role_mapping.js rename to api/api/security.delete_role_mapping.js index 6c012203b..0ddde9ce2 100644 --- a/api/api/xpack.security.delete_role_mapping.js +++ b/api/api/security.delete_role_mapping.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackSecurityDeleteRoleMapping (opts) { +function buildSecurityDeleteRoleMapping (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.delete_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role-mapping.html) request + * Perform a [security.delete_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role-mapping.html) request * * @param {string} name - Role-mapping name * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ - return function xpackSecurityDeleteRoleMapping (params, options, callback) { + return function securityDeleteRoleMapping (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackSecurityDeleteRoleMapping (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityDeleteRoleMapping(params, options, (err, body) => { + securityDeleteRoleMapping(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackSecurityDeleteRoleMapping (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_xpack', 'security', 'role_mapping', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -105,4 +108,4 @@ function buildXpackSecurityDeleteRoleMapping (opts) { } } -module.exports = buildXpackSecurityDeleteRoleMapping +module.exports = buildSecurityDeleteRoleMapping diff --git a/api/api/xpack.security.delete_user.js b/api/api/security.delete_user.js similarity index 83% rename from api/api/xpack.security.delete_user.js rename to api/api/security.delete_user.js index 9368dcfec..b5418ad91 100644 --- a/api/api/xpack.security.delete_user.js +++ b/api/api/security.delete_user.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackSecurityDeleteUser (opts) { +function buildSecurityDeleteUser (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.delete_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-user.html) request + * Perform a [security.delete_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-user.html) request * * @param {string} username - username * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ - return function xpackSecurityDeleteUser (params, options, callback) { + return function securityDeleteUser (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackSecurityDeleteUser (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityDeleteUser(params, options, (err, body) => { + securityDeleteUser(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackSecurityDeleteUser (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(params['username']) + // build request object - const parts = ['_xpack', 'security', 'user', params['username']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -105,4 +108,4 @@ function buildXpackSecurityDeleteUser (opts) { } } -module.exports = buildXpackSecurityDeleteUser +module.exports = buildSecurityDeleteUser diff --git a/api/api/xpack.security.disable_user.js b/api/api/security.disable_user.js similarity index 82% rename from api/api/xpack.security.disable_user.js rename to api/api/security.disable_user.js index 571ec63a8..095724886 100644 --- a/api/api/xpack.security.disable_user.js +++ b/api/api/security.disable_user.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackSecurityDisableUser (opts) { +function buildSecurityDisableUser (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.disable_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-disable-user.html) request + * Perform a [security.disable_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-disable-user.html) request * * @param {string} username - The username of the user to disable * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ - return function xpackSecurityDisableUser (params, options, callback) { + return function securityDisableUser (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackSecurityDisableUser (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityDisableUser(params, options, (err, body) => { + securityDisableUser(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -78,11 +78,14 @@ function buildXpackSecurityDisableUser (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(params['username']) + '/' + '_disable' + // build request object - const parts = ['_xpack', 'security', 'user', params['username'], '_disable'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -99,4 +102,4 @@ function buildXpackSecurityDisableUser (opts) { } } -module.exports = buildXpackSecurityDisableUser +module.exports = buildSecurityDisableUser diff --git a/api/api/xpack.security.enable_user.js b/api/api/security.enable_user.js similarity index 82% rename from api/api/xpack.security.enable_user.js rename to api/api/security.enable_user.js index a6affe02b..24509b689 100644 --- a/api/api/xpack.security.enable_user.js +++ b/api/api/security.enable_user.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackSecurityEnableUser (opts) { +function buildSecurityEnableUser (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.enable_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-enable-user.html) request + * Perform a [security.enable_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-enable-user.html) request * * @param {string} username - The username of the user to enable * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ - return function xpackSecurityEnableUser (params, options, callback) { + return function securityEnableUser (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackSecurityEnableUser (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityEnableUser(params, options, (err, body) => { + securityEnableUser(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -78,11 +78,14 @@ function buildXpackSecurityEnableUser (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(params['username']) + '/' + '_enable' + // build request object - const parts = ['_xpack', 'security', 'user', params['username'], '_enable'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -99,4 +102,4 @@ function buildXpackSecurityEnableUser (opts) { } } -module.exports = buildXpackSecurityEnableUser +module.exports = buildSecurityEnableUser diff --git a/api/api/xpack.security.get_privileges.js b/api/api/security.get_privileges.js similarity index 84% rename from api/api/xpack.security.get_privileges.js rename to api/api/security.get_privileges.js index 683c06458..816d288e6 100644 --- a/api/api/xpack.security.get_privileges.js +++ b/api/api/security.get_privileges.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackSecurityGetPrivileges (opts) { +function buildSecurityGetPrivileges (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.get_privileges](TODO) request + * Perform a [security.get_privileges](TODO) request * * @param {string} application - Application name * @param {string} name - Privilege name */ - return function xpackSecurityGetPrivileges (params, options, callback) { + return function securityGetPrivileges (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackSecurityGetPrivileges (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityGetPrivileges(params, options, (err, body) => { + securityGetPrivileges(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -86,11 +86,14 @@ function buildXpackSecurityGetPrivileges (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(params['application']) + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_xpack', 'security', 'privilege', params['application'], params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -107,4 +110,4 @@ function buildXpackSecurityGetPrivileges (opts) { } } -module.exports = buildXpackSecurityGetPrivileges +module.exports = buildSecurityGetPrivileges diff --git a/api/api/xpack.security.get_role.js b/api/api/security.get_role.js similarity index 80% rename from api/api/xpack.security.get_role.js rename to api/api/security.get_role.js index 9d4ce7d5c..6937deaab 100644 --- a/api/api/xpack.security.get_role.js +++ b/api/api/security.get_role.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackSecurityGetRole (opts) { +function buildSecurityGetRole (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.get_role](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html) request + * Perform a [security.get_role](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html) request * * @param {string} name - Role name */ - return function xpackSecurityGetRole (params, options, callback) { + return function securityGetRole (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackSecurityGetRole (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityGetRole(params, options, (err, body) => { + securityGetRole(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -77,11 +77,18 @@ function buildXpackSecurityGetRole (opts) { ignore = [ignore] } + var path = '' + + if ((params['name']) != null) { + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(params['name']) + } else { + path = '/' + '_security' + '/' + 'role' + } + // build request object - const parts = ['_xpack', 'security', 'role', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -98,4 +105,4 @@ function buildXpackSecurityGetRole (opts) { } } -module.exports = buildXpackSecurityGetRole +module.exports = buildSecurityGetRole diff --git a/api/api/xpack.security.get_role_mapping.js b/api/api/security.get_role_mapping.js similarity index 78% rename from api/api/xpack.security.get_role_mapping.js rename to api/api/security.get_role_mapping.js index 101ec8783..6730f8e25 100644 --- a/api/api/xpack.security.get_role_mapping.js +++ b/api/api/security.get_role_mapping.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackSecurityGetRoleMapping (opts) { +function buildSecurityGetRoleMapping (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.get_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role-mapping.html) request + * Perform a [security.get_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role-mapping.html) request * * @param {string} name - Role-Mapping name */ - return function xpackSecurityGetRoleMapping (params, options, callback) { + return function securityGetRoleMapping (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackSecurityGetRoleMapping (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityGetRoleMapping(params, options, (err, body) => { + securityGetRoleMapping(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -77,11 +77,18 @@ function buildXpackSecurityGetRoleMapping (opts) { ignore = [ignore] } + var path = '' + + if ((params['name']) != null) { + path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(params['name']) + } else { + path = '/' + '_security' + '/' + 'role_mapping' + } + // build request object - const parts = ['_xpack', 'security', 'role_mapping', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -98,4 +105,4 @@ function buildXpackSecurityGetRoleMapping (opts) { } } -module.exports = buildXpackSecurityGetRoleMapping +module.exports = buildSecurityGetRoleMapping diff --git a/api/api/xpack.security.get_token.js b/api/api/security.get_token.js similarity index 81% rename from api/api/xpack.security.get_token.js rename to api/api/security.get_token.js index 0f439b381..7dcfc72cd 100644 --- a/api/api/xpack.security.get_token.js +++ b/api/api/security.get_token.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackSecurityGetToken (opts) { +function buildSecurityGetToken (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.get_token](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html) request + * Perform a [security.get_token](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html) request * * @param {object} body - The token request to get */ - return function xpackSecurityGetToken (params, options, callback) { + return function securityGetToken (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackSecurityGetToken (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityGetToken(params, options, (err, body) => { + securityGetToken(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -77,11 +77,14 @@ function buildXpackSecurityGetToken (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'oauth2' + '/' + 'token' + // build request object - const parts = ['_xpack', 'security', 'oauth2', 'token'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -98,4 +101,4 @@ function buildXpackSecurityGetToken (opts) { } } -module.exports = buildXpackSecurityGetToken +module.exports = buildSecurityGetToken diff --git a/api/api/xpack.security.get_user.js b/api/api/security.get_user.js similarity index 80% rename from api/api/xpack.security.get_user.js rename to api/api/security.get_user.js index 8bc1aa65e..13fb8e9fe 100644 --- a/api/api/xpack.security.get_user.js +++ b/api/api/security.get_user.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackSecurityGetUser (opts) { +function buildSecurityGetUser (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.get_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user.html) request + * Perform a [security.get_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user.html) request * * @param {list} username - A comma-separated list of usernames */ - return function xpackSecurityGetUser (params, options, callback) { + return function securityGetUser (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackSecurityGetUser (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityGetUser(params, options, (err, body) => { + securityGetUser(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -77,11 +77,18 @@ function buildXpackSecurityGetUser (opts) { ignore = [ignore] } + var path = '' + + if ((params['username']) != null) { + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(params['username']) + } else { + path = '/' + '_security' + '/' + 'user' + } + // build request object - const parts = ['_xpack', 'security', 'user', params['username']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -98,4 +105,4 @@ function buildXpackSecurityGetUser (opts) { } } -module.exports = buildXpackSecurityGetUser +module.exports = buildSecurityGetUser diff --git a/api/api/xpack.security.authenticate.js b/api/api/security.get_user_privileges.js similarity index 81% rename from api/api/xpack.security.authenticate.js rename to api/api/security.get_user_privileges.js index 71c4439a7..5403767bd 100644 --- a/api/api/xpack.security.authenticate.js +++ b/api/api/security.get_user_privileges.js @@ -1,13 +1,13 @@ 'use strict' -function buildXpackSecurityAuthenticate (opts) { +function buildSecurityGetUserPrivileges (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.authenticate](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-authenticate.html) request + * Perform a [security.get_user_privileges](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-privileges.html) request * */ - return function xpackSecurityAuthenticate (params, options, callback) { + return function securityGetUserPrivileges (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -21,7 +21,7 @@ function buildXpackSecurityAuthenticate (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityAuthenticate(params, options, (err, body) => { + securityGetUserPrivileges(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -76,11 +76,14 @@ function buildXpackSecurityAuthenticate (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'user' + '/' + '_privileges' + // build request object - const parts = ['_xpack', 'security', '_authenticate'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -97,4 +100,4 @@ function buildXpackSecurityAuthenticate (opts) { } } -module.exports = buildXpackSecurityAuthenticate +module.exports = buildSecurityGetUserPrivileges diff --git a/api/api/xpack.security.has_privileges.js b/api/api/security.has_privileges.js similarity index 78% rename from api/api/xpack.security.has_privileges.js rename to api/api/security.has_privileges.js index 2524dd9fe..7fa1f3e5c 100644 --- a/api/api/xpack.security.has_privileges.js +++ b/api/api/security.has_privileges.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackSecurityHasPrivileges (opts) { +function buildSecurityHasPrivileges (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.has_privileges](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html) request + * Perform a [security.has_privileges](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html) request * * @param {string} user - Username * @param {object} body - The privileges to test */ - return function xpackSecurityHasPrivileges (params, options, callback) { + return function securityHasPrivileges (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackSecurityHasPrivileges (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityHasPrivileges(params, options, (err, body) => { + securityHasPrivileges(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -78,11 +78,18 @@ function buildXpackSecurityHasPrivileges (opts) { ignore = [ignore] } + var path = '' + + if ((params['user']) != null) { + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(params['user']) + '/' + '_has_privileges' + } else { + path = '/' + '_security' + '/' + 'user' + '/' + '_has_privileges' + } + // build request object - const parts = ['_xpack', 'security', 'user', params['user'], '_has_privileges'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -99,4 +106,4 @@ function buildXpackSecurityHasPrivileges (opts) { } } -module.exports = buildXpackSecurityHasPrivileges +module.exports = buildSecurityHasPrivileges diff --git a/api/api/xpack.security.invalidate_token.js b/api/api/security.invalidate_token.js similarity index 80% rename from api/api/xpack.security.invalidate_token.js rename to api/api/security.invalidate_token.js index 36155e2b6..45ec5bd9b 100644 --- a/api/api/xpack.security.invalidate_token.js +++ b/api/api/security.invalidate_token.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackSecurityInvalidateToken (opts) { +function buildSecurityInvalidateToken (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.invalidate_token](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html) request + * Perform a [security.invalidate_token](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html) request * * @param {object} body - The token to invalidate */ - return function xpackSecurityInvalidateToken (params, options, callback) { + return function securityInvalidateToken (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackSecurityInvalidateToken (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityInvalidateToken(params, options, (err, body) => { + securityInvalidateToken(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -77,11 +77,14 @@ function buildXpackSecurityInvalidateToken (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'oauth2' + '/' + 'token' + // build request object - const parts = ['_xpack', 'security', 'oauth2', 'token'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -98,4 +101,4 @@ function buildXpackSecurityInvalidateToken (opts) { } } -module.exports = buildXpackSecurityInvalidateToken +module.exports = buildSecurityInvalidateToken diff --git a/api/api/xpack.security.put_privileges.js b/api/api/security.put_privileges.js similarity index 85% rename from api/api/xpack.security.put_privileges.js rename to api/api/security.put_privileges.js index 94ac619b4..6f18c7f68 100644 --- a/api/api/xpack.security.put_privileges.js +++ b/api/api/security.put_privileges.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackSecurityPutPrivileges (opts) { +function buildSecurityPutPrivileges (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.put_privileges](TODO) request + * Perform a [security.put_privileges](TODO) request * * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. * @param {object} body - The privilege(s) to add */ - return function xpackSecurityPutPrivileges (params, options, callback) { + return function securityPutPrivileges (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackSecurityPutPrivileges (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityPutPrivileges(params, options, (err, body) => { + securityPutPrivileges(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -78,11 +78,14 @@ function buildXpackSecurityPutPrivileges (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'privilege' + // build request object - const parts = ['_xpack', 'security', 'privilege'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -99,4 +102,4 @@ function buildXpackSecurityPutPrivileges (opts) { } } -module.exports = buildXpackSecurityPutPrivileges +module.exports = buildSecurityPutPrivileges diff --git a/api/api/xpack.security.put_role.js b/api/api/security.put_role.js similarity index 84% rename from api/api/xpack.security.put_role.js rename to api/api/security.put_role.js index 3b78e8370..259ad1b0e 100644 --- a/api/api/xpack.security.put_role.js +++ b/api/api/security.put_role.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackSecurityPutRole (opts) { +function buildSecurityPutRole (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.put_role](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html) request + * Perform a [security.put_role](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html) request * * @param {string} name - Role name * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. * @param {object} body - The role to add */ - return function xpackSecurityPutRole (params, options, callback) { + return function securityPutRole (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackSecurityPutRole (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityPutRole(params, options, (err, body) => { + securityPutRole(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -85,11 +85,14 @@ function buildXpackSecurityPutRole (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_xpack', 'security', 'role', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -106,4 +109,4 @@ function buildXpackSecurityPutRole (opts) { } } -module.exports = buildXpackSecurityPutRole +module.exports = buildSecurityPutRole diff --git a/api/api/xpack.security.put_role_mapping.js b/api/api/security.put_role_mapping.js similarity index 83% rename from api/api/xpack.security.put_role_mapping.js rename to api/api/security.put_role_mapping.js index d340aaaeb..03b74a65f 100644 --- a/api/api/xpack.security.put_role_mapping.js +++ b/api/api/security.put_role_mapping.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackSecurityPutRoleMapping (opts) { +function buildSecurityPutRoleMapping (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.put_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role-mapping.html) request + * Perform a [security.put_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role-mapping.html) request * * @param {string} name - Role-mapping name * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. * @param {object} body - The role to add */ - return function xpackSecurityPutRoleMapping (params, options, callback) { + return function securityPutRoleMapping (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackSecurityPutRoleMapping (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityPutRoleMapping(params, options, (err, body) => { + securityPutRoleMapping(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -85,11 +85,14 @@ function buildXpackSecurityPutRoleMapping (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_xpack', 'security', 'role_mapping', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -106,4 +109,4 @@ function buildXpackSecurityPutRoleMapping (opts) { } } -module.exports = buildXpackSecurityPutRoleMapping +module.exports = buildSecurityPutRoleMapping diff --git a/api/api/xpack.security.put_user.js b/api/api/security.put_user.js similarity index 84% rename from api/api/xpack.security.put_user.js rename to api/api/security.put_user.js index 7b45b427e..ddc512d15 100644 --- a/api/api/xpack.security.put_user.js +++ b/api/api/security.put_user.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackSecurityPutUser (opts) { +function buildSecurityPutUser (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.put_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html) request + * Perform a [security.put_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html) request * * @param {string} username - The username of the User * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. * @param {object} body - The user to add */ - return function xpackSecurityPutUser (params, options, callback) { + return function securityPutUser (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackSecurityPutUser (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityPutUser(params, options, (err, body) => { + securityPutUser(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -85,11 +85,14 @@ function buildXpackSecurityPutUser (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(params['username']) + // build request object - const parts = ['_xpack', 'security', 'user', params['username']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -106,4 +109,4 @@ function buildXpackSecurityPutUser (opts) { } } -module.exports = buildXpackSecurityPutUser +module.exports = buildSecurityPutUser diff --git a/api/api/snapshot.create.js b/api/api/snapshot.create.js index 873982d68..3b4f9a239 100644 --- a/api/api/snapshot.create.js +++ b/api/api/snapshot.create.js @@ -107,11 +107,14 @@ function buildSnapshotCreate (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + '/' + encodeURIComponent(params['snapshot']) + // build request object - const parts = ['_snapshot', params['repository'], params['snapshot']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/snapshot.create_repository.js b/api/api/snapshot.create_repository.js index 9a6aefde6..a8845077f 100644 --- a/api/api/snapshot.create_repository.js +++ b/api/api/snapshot.create_repository.js @@ -101,11 +101,14 @@ function buildSnapshotCreateRepository (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + // build request object - const parts = ['_snapshot', params['repository']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/snapshot.delete.js b/api/api/snapshot.delete.js index 22a5c691d..1e3753ae0 100644 --- a/api/api/snapshot.delete.js +++ b/api/api/snapshot.delete.js @@ -109,11 +109,14 @@ function buildSnapshotDelete (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + '/' + encodeURIComponent(params['snapshot']) + // build request object - const parts = ['_snapshot', params['repository'], params['snapshot']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/snapshot.delete_repository.js b/api/api/snapshot.delete_repository.js index fa26f7174..01b30678d 100644 --- a/api/api/snapshot.delete_repository.js +++ b/api/api/snapshot.delete_repository.js @@ -97,11 +97,14 @@ function buildSnapshotDeleteRepository (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + // build request object - const parts = ['_snapshot', params['repository']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/snapshot.get.js b/api/api/snapshot.get.js index 5fbded88b..e3e74caf1 100644 --- a/api/api/snapshot.get.js +++ b/api/api/snapshot.get.js @@ -115,11 +115,14 @@ function buildSnapshotGet (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + '/' + encodeURIComponent(params['snapshot']) + // build request object - const parts = ['_snapshot', params['repository'], params['snapshot']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/snapshot.get_repository.js b/api/api/snapshot.get_repository.js index 4eb197991..02dc64e37 100644 --- a/api/api/snapshot.get_repository.js +++ b/api/api/snapshot.get_repository.js @@ -91,11 +91,18 @@ function buildSnapshotGetRepository (opts) { ignore = [ignore] } + var path = '' + + if ((params['repository']) != null) { + path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + } else { + path = '/' + '_snapshot' + } + // build request object - const parts = ['_snapshot', params['repository']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/snapshot.restore.js b/api/api/snapshot.restore.js index d0577e954..da587e286 100644 --- a/api/api/snapshot.restore.js +++ b/api/api/snapshot.restore.js @@ -107,11 +107,14 @@ function buildSnapshotRestore (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + '/' + encodeURIComponent(params['snapshot']) + '/' + '_restore' + // build request object - const parts = ['_snapshot', params['repository'], params['snapshot'], '_restore'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/snapshot.status.js b/api/api/snapshot.status.js index 8c618f622..a80f9aed2 100644 --- a/api/api/snapshot.status.js +++ b/api/api/snapshot.status.js @@ -100,11 +100,20 @@ function buildSnapshotStatus (opts) { ignore = [ignore] } + var path = '' + + if ((params['repository']) != null && (params['snapshot']) != null) { + path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + '/' + encodeURIComponent(params['snapshot']) + '/' + '_status' + } else if ((params['repository']) != null) { + path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + '/' + '_status' + } else { + path = '/' + '_snapshot' + '/' + '_status' + } + // build request object - const parts = ['_snapshot', params['repository'], params['snapshot'], '_status'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/snapshot.verify_repository.js b/api/api/snapshot.verify_repository.js index b93250b38..ab26069cc 100644 --- a/api/api/snapshot.verify_repository.js +++ b/api/api/snapshot.verify_repository.js @@ -97,11 +97,14 @@ function buildSnapshotVerifyRepository (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + '/' + '_verify' + // build request object - const parts = ['_snapshot', params['repository'], '_verify'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/ssl.certificates.js b/api/api/ssl.certificates.js new file mode 100644 index 000000000..7e6adc9a1 --- /dev/null +++ b/api/api/ssl.certificates.js @@ -0,0 +1,103 @@ +'use strict' + +function buildSslCertificates (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ssl.certificates](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-ssl.html) request + * + */ + return function sslCertificates (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + sslCertificates(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ssl' + '/' + 'certificates' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildSslCertificates diff --git a/api/api/tasks.cancel.js b/api/api/tasks.cancel.js index d2ed6a011..14eb29793 100644 --- a/api/api/tasks.cancel.js +++ b/api/api/tasks.cancel.js @@ -94,11 +94,18 @@ function buildTasksCancel (opts) { ignore = [ignore] } + var path = '' + + if ((params['task_id'] || params['taskId']) != null) { + path = '/' + '_tasks' + '/' + encodeURIComponent(params['task_id'] || params['taskId']) + '/' + '_cancel' + } else { + path = '/' + '_tasks' + '/' + '_cancel' + } + // build request object - const parts = ['_tasks', params['task_id'] || params['taskId'], '_cancel'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/tasks.get.js b/api/api/tasks.get.js index 0fab38d31..998a14f64 100644 --- a/api/api/tasks.get.js +++ b/api/api/tasks.get.js @@ -97,11 +97,14 @@ function buildTasksGet (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_tasks' + '/' + encodeURIComponent(params['task_id'] || params['taskId']) + // build request object - const parts = ['_tasks', params['task_id'] || params['taskId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/tasks.list.js b/api/api/tasks.list.js index 90cabbcc4..8696defb6 100644 --- a/api/api/tasks.list.js +++ b/api/api/tasks.list.js @@ -105,11 +105,14 @@ function buildTasksList (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_tasks' + // build request object - const parts = ['_tasks'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/termvectors.js b/api/api/termvectors.js index ec2354fc4..3888a41aa 100644 --- a/api/api/termvectors.js +++ b/api/api/termvectors.js @@ -50,25 +50,6 @@ function buildTermvectors (opts) { result ) } - if (params['type'] == null) { - return callback( - new ConfigurationError('Missing required parameter: type'), - result - ) - } - - // check required url components - if (params['id'] != null && (params['type'] == null || params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: type, index'), - result - ) - } else if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) - } // build querystring object const querystring = {} @@ -143,11 +124,22 @@ function buildTermvectors (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null && (params['id']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_termvectors' + } else if ((params['index']) != null && (params['id']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_termvectors' + '/' + encodeURIComponent(params['id']) + } else if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_termvectors' + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_termvectors' + } + // build request object - const parts = [params['index'], params['type'], params['id'], '_termvectors'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/update.js b/api/api/update.js index 13e8539ee..73bcfecf0 100644 --- a/api/api/update.js +++ b/api/api/update.js @@ -10,10 +10,9 @@ function buildUpdate (opts) { * @param {string} index - The name of the index * @param {string} type - The type of the document * @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - * @param {list} fields - A comma-separated list of fields to return in the response * @param {list} _source - True or false to return the _source field or not, or a list of fields to return - * @param {list} _source_exclude - A list of fields to exclude from the returned _source field - * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {list} _source_excludes - A list of fields to exclude from the returned _source field + * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {string} lang - The script language (default: painless) * @param {string} parent - ID of the parent document. Is is only used for routing and when for the upsert request * @param {enum} refresh - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. @@ -57,12 +56,6 @@ function buildUpdate (opts) { result ) } - if (params['type'] == null) { - return callback( - new ConfigurationError('Missing required parameter: type'), - result - ) - } if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), @@ -70,28 +63,14 @@ function buildUpdate (opts) { ) } - // check required url components - if (params['id'] != null && (params['type'] == null || params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: type, index'), - result - ) - } else if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) - } - // build querystring object const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ 'wait_for_active_shards', - 'fields', '_source', - '_source_exclude', - '_source_include', + '_source_excludes', + '_source_includes', 'lang', 'parent', 'refresh', @@ -108,10 +87,9 @@ function buildUpdate (opts) { ] const acceptedQuerystringCamelCased = [ 'waitForActiveShards', - 'fields', '_source', - '_sourceExclude', - '_sourceInclude', + '_sourceExcludes', + '_sourceIncludes', 'lang', 'parent', 'refresh', @@ -158,11 +136,18 @@ function buildUpdate (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null && (params['id']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_update' + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_update' + '/' + encodeURIComponent(params['id']) + } + // build request object - const parts = [params['index'], params['type'], params['id'], '_update'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/update_by_query.js b/api/api/update_by_query.js index 1f06382ff..e7b4c31bd 100644 --- a/api/api/update_by_query.js +++ b/api/api/update_by_query.js @@ -28,8 +28,8 @@ function buildUpdateByQuery (opts) { * @param {number} size - Number of hits to return (default: 10) * @param {list} sort - A comma-separated list of : pairs * @param {list} _source - True or false to return the _source field or not, or a list of fields to return - * @param {list} _source_exclude - A list of fields to exclude from the returned _source field - * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {list} _source_excludes - A list of fields to exclude from the returned _source field + * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {number} terminate_after - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. * @param {list} stats - Specific 'tag' of the request for logging and statistical purposes * @param {boolean} version - Specify whether to return document version as part of a hit @@ -104,8 +104,8 @@ function buildUpdateByQuery (opts) { 'size', 'sort', '_source', - '_source_exclude', - '_source_include', + '_source_excludes', + '_source_includes', 'terminate_after', 'stats', 'version', @@ -145,8 +145,8 @@ function buildUpdateByQuery (opts) { 'size', 'sort', '_source', - '_sourceExclude', - '_sourceInclude', + '_sourceExcludes', + '_sourceIncludes', 'terminateAfter', 'stats', 'version', @@ -197,11 +197,18 @@ function buildUpdateByQuery (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_update_by_query' + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_update_by_query' + } + // build request object - const parts = [params['index'], params['type'], '_update_by_query'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/update_by_query_rethrottle.js b/api/api/update_by_query_rethrottle.js index 8fb894f7a..4e55ab341 100644 --- a/api/api/update_by_query_rethrottle.js +++ b/api/api/update_by_query_rethrottle.js @@ -100,11 +100,14 @@ function buildUpdateByQueryRethrottle (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_update_by_query' + '/' + encodeURIComponent(params['task_id'] || params['taskId']) + '/' + '_rethrottle' + // build request object - const parts = ['_update_by_query', params['task_id'] || params['taskId'], '_rethrottle'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/xpack.graph.explore.js b/api/api/xpack.graph.explore.js index 02d33ae1e..0513c7e8b 100644 --- a/api/api/xpack.graph.explore.js +++ b/api/api/xpack.graph.explore.js @@ -83,11 +83,18 @@ function buildXpackGraphExplore (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_graph' + '/' + 'explore' + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_graph' + '/' + 'explore' + } + // build request object - const parts = [params['index'], params['type'], '_xpack', 'graph', '_explore'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.info.js b/api/api/xpack.info.js index eb2fe9c60..92bd594d8 100644 --- a/api/api/xpack.info.js +++ b/api/api/xpack.info.js @@ -77,11 +77,14 @@ function buildXpackInfo (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_xpack' + // build request object - const parts = ['_xpack'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.license.delete.js b/api/api/xpack.license.delete.js index 281519cf5..f021661f1 100644 --- a/api/api/xpack.license.delete.js +++ b/api/api/xpack.license.delete.js @@ -76,11 +76,14 @@ function buildXpackLicenseDelete (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_license' + // build request object - const parts = ['_xpack', 'license'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/xpack.license.get.js b/api/api/xpack.license.get.js index e3910bcf0..6d2a404a2 100644 --- a/api/api/xpack.license.get.js +++ b/api/api/xpack.license.get.js @@ -77,11 +77,14 @@ function buildXpackLicenseGet (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_license' + // build request object - const parts = ['_xpack', 'license'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.license.get_basic_status.js b/api/api/xpack.license.get_basic_status.js index a7e368eb2..80b700fae 100644 --- a/api/api/xpack.license.get_basic_status.js +++ b/api/api/xpack.license.get_basic_status.js @@ -76,11 +76,14 @@ function buildXpackLicenseGetBasicStatus (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_license' + '/' + 'basic_status' + // build request object - const parts = ['_xpack', 'license', 'basic_status'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.license.get_trial_status.js b/api/api/xpack.license.get_trial_status.js index d773b29bd..b1875fcc3 100644 --- a/api/api/xpack.license.get_trial_status.js +++ b/api/api/xpack.license.get_trial_status.js @@ -76,11 +76,14 @@ function buildXpackLicenseGetTrialStatus (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_license' + '/' + 'trial_status' + // build request object - const parts = ['_xpack', 'license', 'trial_status'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.license.post.js b/api/api/xpack.license.post.js index 964586b89..38cae7f83 100644 --- a/api/api/xpack.license.post.js +++ b/api/api/xpack.license.post.js @@ -70,11 +70,14 @@ function buildXpackLicensePost (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_license' + // build request object - const parts = ['_xpack', 'license'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.license.post_start_basic.js b/api/api/xpack.license.post_start_basic.js index ddee829a9..39e16ebc1 100644 --- a/api/api/xpack.license.post_start_basic.js +++ b/api/api/xpack.license.post_start_basic.js @@ -77,11 +77,14 @@ function buildXpackLicensePostStartBasic (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_license' + '/' + 'start_basic' + // build request object - const parts = ['_xpack', 'license', 'start_basic'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/xpack.license.post_start_trial.js b/api/api/xpack.license.post_start_trial.js index f3a4a85a0..b9c934e9d 100644 --- a/api/api/xpack.license.post_start_trial.js +++ b/api/api/xpack.license.post_start_trial.js @@ -80,11 +80,14 @@ function buildXpackLicensePostStartTrial (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_license' + '/' + 'start_trial' + // build request object - const parts = ['_xpack', 'license', 'start_trial'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/xpack.migration.deprecations.js b/api/api/xpack.migration.deprecations.js index 31b984b58..53cd0f260 100644 --- a/api/api/xpack.migration.deprecations.js +++ b/api/api/xpack.migration.deprecations.js @@ -77,11 +77,18 @@ function buildXpackMigrationDeprecations (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_migration' + '/' + 'deprecations' + } else { + path = '/' + '_migration' + '/' + 'deprecations' + } + // build request object - const parts = [params['index'], '_xpack', 'migration', 'deprecations'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.migration.get_assistance.js b/api/api/xpack.migration.get_assistance.js index aed1707bd..62b98ca71 100644 --- a/api/api/xpack.migration.get_assistance.js +++ b/api/api/xpack.migration.get_assistance.js @@ -76,11 +76,18 @@ function buildXpackMigrationGetAssistance (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + '_migration' + '/' + 'assistance' + '/' + encodeURIComponent(params['index']) + } else { + path = '/' + '_migration' + '/' + 'assistance' + } + // build request object - const parts = ['_xpack', 'migration', 'assistance', params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.migration.upgrade.js b/api/api/xpack.migration.upgrade.js index 48a151080..1c3cb5aa3 100644 --- a/api/api/xpack.migration.upgrade.js +++ b/api/api/xpack.migration.upgrade.js @@ -78,11 +78,14 @@ function buildXpackMigrationUpgrade (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_migration' + '/' + 'upgrade' + '/' + encodeURIComponent(params['index']) + // build request object - const parts = ['_xpack', 'migration', 'upgrade', params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.rollup.delete_job.js b/api/api/xpack.rollup.delete_job.js index 42c6f36e1..d9df1880f 100644 --- a/api/api/xpack.rollup.delete_job.js +++ b/api/api/xpack.rollup.delete_job.js @@ -77,11 +77,14 @@ function buildXpackRollupDeleteJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(params['id']) + // build request object - const parts = ['_xpack', 'rollup', 'job', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.rollup.get_jobs.js b/api/api/xpack.rollup.get_jobs.js index 980d5a898..f9bf7992f 100644 --- a/api/api/xpack.rollup.get_jobs.js +++ b/api/api/xpack.rollup.get_jobs.js @@ -69,11 +69,18 @@ function buildXpackRollupGetJobs (opts) { ignore = [ignore] } + var path = '' + + if ((params['id']) != null) { + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(params['id']) + } else { + path = '/' + '_rollup' + '/' + 'job' + } + // build request object - const parts = ['_xpack', 'rollup', 'job'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.rollup.get_rollup_caps.js b/api/api/xpack.rollup.get_rollup_caps.js index fde5b147c..083e6a905 100644 --- a/api/api/xpack.rollup.get_rollup_caps.js +++ b/api/api/xpack.rollup.get_rollup_caps.js @@ -69,11 +69,18 @@ function buildXpackRollupGetRollupCaps (opts) { ignore = [ignore] } + var path = '' + + if ((params['id']) != null) { + path = '/' + '_rollup' + '/' + 'data' + '/' + encodeURIComponent(params['id']) + } else { + path = '/' + '_rollup' + '/' + 'data' + } + // build request object - const parts = ['_xpack', 'rollup', 'data'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.rollup.get_rollup_index_caps.js b/api/api/xpack.rollup.get_rollup_index_caps.js index b7a0b5c7f..5a62668d6 100644 --- a/api/api/xpack.rollup.get_rollup_index_caps.js +++ b/api/api/xpack.rollup.get_rollup_index_caps.js @@ -77,11 +77,14 @@ function buildXpackRollupGetRollupIndexCaps (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_rollup' + '/' + 'data' + // build request object - const parts = [params['index'], '_xpack', 'rollup', 'data'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.rollup.put_job.js b/api/api/xpack.rollup.put_job.js index dc72b711e..df8f39fbf 100644 --- a/api/api/xpack.rollup.put_job.js +++ b/api/api/xpack.rollup.put_job.js @@ -84,11 +84,14 @@ function buildXpackRollupPutJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(params['id']) + // build request object - const parts = ['_xpack', 'rollup', 'job', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.rollup.rollup_search.js b/api/api/xpack.rollup.rollup_search.js index b8667f92b..68a8d1610 100644 --- a/api/api/xpack.rollup.rollup_search.js +++ b/api/api/xpack.rollup.rollup_search.js @@ -8,6 +8,8 @@ function buildXpackRollupRollupSearch (opts) { * * @param {string} index - The index or index-pattern (containing rollup or regular data) that should be searched * @param {string} type - The doc type inside the index + * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response * @param {object} body - The search request body */ return function xpackRollupRollupSearch (params, options, callback) { @@ -56,10 +58,12 @@ function buildXpackRollupRollupSearch (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ - + 'typed_keys', + 'rest_total_hits_as_int' ] const acceptedQuerystringCamelCased = [ - + 'typedKeys', + 'restTotalHitsAsInt' ] for (var i = 0, len = keys.length; i < len; i++) { @@ -93,13 +97,18 @@ function buildXpackRollupRollupSearch (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_rollup_search' + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_rollup_search' + } + // build request object - const parts = [params['index'], params['type'], '_rollup_search'] const request = { method, - path: params['index'] != null && params['type'] != null - ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') - : '/{index}/_rollup_search', + path, body: params.body || '', querystring } diff --git a/api/api/xpack.rollup.start_job.js b/api/api/xpack.rollup.start_job.js index a0b168f98..7b2314546 100644 --- a/api/api/xpack.rollup.start_job.js +++ b/api/api/xpack.rollup.start_job.js @@ -77,11 +77,14 @@ function buildXpackRollupStartJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(params['id']) + '/' + '_start' + // build request object - const parts = ['_xpack', 'rollup', 'job', params['id'], '_start'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.rollup.stop_job.js b/api/api/xpack.rollup.stop_job.js index cfad8708a..c3215a3a0 100644 --- a/api/api/xpack.rollup.stop_job.js +++ b/api/api/xpack.rollup.stop_job.js @@ -7,6 +7,8 @@ function buildXpackRollupStopJob (opts) { * Perform a [xpack.rollup.stop_job]() request * * @param {string} id - The ID of the job to stop + * @param {boolean} wait_for_completion - True if the API should block until the job has fully stopped, false if should be executed async. Defaults to false. + * @param {time} timeout - Block for (at maximum) the specified duration while waiting for the job to stop. Defaults to 30s. */ return function xpackRollupStopJob (params, options, callback) { options = options || {} @@ -40,10 +42,12 @@ function buildXpackRollupStopJob (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ - + 'wait_for_completion', + 'timeout' ] const acceptedQuerystringCamelCased = [ - + 'waitForCompletion', + 'timeout' ] for (var i = 0, len = keys.length; i < len; i++) { @@ -77,11 +81,14 @@ function buildXpackRollupStopJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(params['id']) + '/' + '_stop' + // build request object - const parts = ['_xpack', 'rollup', 'job', params['id'], '_stop'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.security.get_user_privileges.js b/api/api/xpack.security.get_user_privileges.js deleted file mode 100644 index 5be01585c..000000000 --- a/api/api/xpack.security.get_user_privileges.js +++ /dev/null @@ -1,100 +0,0 @@ -'use strict' - -function buildXpackSecurityGetUserPrivileges (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts - /** - * Perform a [xpack.security.get_user_privileges](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-privileges.html) request - * - */ - return function xpackSecurityGetUserPrivileges (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackSecurityGetUserPrivileges(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - - // check required parameters - if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) - } - - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - result - ) - } - - var ignore = options.ignore || null - if (typeof ignore === 'number') { - ignore = [ignore] - } - - // build request object - const parts = ['_xpack', 'security', 'user', '_privileges'] - const request = { - method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - body: null, - querystring - } - - const requestOptions = { - ignore, - requestTimeout: options.requestTimeout || null, - maxRetries: options.maxRetries || null, - asStream: options.asStream || false, - headers: options.headers || null - } - - return makeRequest(request, requestOptions, callback) - } -} - -module.exports = buildXpackSecurityGetUserPrivileges diff --git a/api/api/xpack.sql.clear_cursor.js b/api/api/xpack.sql.clear_cursor.js index 9b299bc19..0d69796bc 100644 --- a/api/api/xpack.sql.clear_cursor.js +++ b/api/api/xpack.sql.clear_cursor.js @@ -77,11 +77,14 @@ function buildXpackSqlClearCursor (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_sql' + '/' + 'close' + // build request object - const parts = ['_xpack', 'sql', 'close'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.sql.query.js b/api/api/xpack.sql.query.js index 1e1cb28b3..6030181da 100644 --- a/api/api/xpack.sql.query.js +++ b/api/api/xpack.sql.query.js @@ -78,11 +78,14 @@ function buildXpackSqlQuery (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_sql' + // build request object - const parts = ['_xpack', 'sql'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.sql.translate.js b/api/api/xpack.sql.translate.js index 680f037c8..2a3450652 100644 --- a/api/api/xpack.sql.translate.js +++ b/api/api/xpack.sql.translate.js @@ -77,11 +77,14 @@ function buildXpackSqlTranslate (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_sql' + '/' + 'translate' + // build request object - const parts = ['_xpack', 'sql', 'translate'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.usage.js b/api/api/xpack.usage.js index 2e810ef06..09df41f17 100644 --- a/api/api/xpack.usage.js +++ b/api/api/xpack.usage.js @@ -77,11 +77,14 @@ function buildXpackUsage (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_xpack' + '/' + 'usage' + // build request object - const parts = ['_xpack', 'usage'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.watcher.ack_watch.js b/api/api/xpack.watcher.ack_watch.js index 99b781b83..bca2cc0df 100644 --- a/api/api/xpack.watcher.ack_watch.js +++ b/api/api/xpack.watcher.ack_watch.js @@ -8,7 +8,6 @@ function buildXpackWatcherAckWatch (opts) { * * @param {string} watch_id - Watch ID * @param {list} action_id - A comma-separated list of the action ids to be acked - * @param {time} master_timeout - Explicit operation timeout for connection to master node */ return function xpackWatcherAckWatch (params, options, callback) { options = options || {} @@ -56,10 +55,10 @@ function buildXpackWatcherAckWatch (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ - 'master_timeout' + ] const acceptedQuerystringCamelCased = [ - 'masterTimeout' + ] for (var i = 0, len = keys.length; i < len; i++) { @@ -93,11 +92,18 @@ function buildXpackWatcherAckWatch (opts) { ignore = [ignore] } + var path = '' + + if ((params['watch_id'] || params['watchId']) != null && (params['action_id'] || params['actionId']) != null) { + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['watch_id'] || params['watchId']) + '/' + '_ack' + '/' + encodeURIComponent(params['action_id'] || params['actionId']) + } else { + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['watch_id'] || params['watchId']) + '/' + '_ack' + } + // build request object - const parts = ['_xpack', 'watcher', 'watch', params['watch_id'] || params['watchId'], '_ack', params['action_id'] || params['actionId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/xpack.watcher.activate_watch.js b/api/api/xpack.watcher.activate_watch.js index 96333bdb0..cc2e7674b 100644 --- a/api/api/xpack.watcher.activate_watch.js +++ b/api/api/xpack.watcher.activate_watch.js @@ -7,7 +7,6 @@ function buildXpackWatcherActivateWatch (opts) { * Perform a [xpack.watcher.activate_watch](https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-activate-watch.html) request * * @param {string} watch_id - Watch ID - * @param {time} master_timeout - Explicit operation timeout for connection to master node */ return function xpackWatcherActivateWatch (params, options, callback) { options = options || {} @@ -47,10 +46,10 @@ function buildXpackWatcherActivateWatch (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ - 'master_timeout' + ] const acceptedQuerystringCamelCased = [ - 'masterTimeout' + ] for (var i = 0, len = keys.length; i < len; i++) { @@ -84,11 +83,14 @@ function buildXpackWatcherActivateWatch (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['watch_id'] || params['watchId']) + '/' + '_activate' + // build request object - const parts = ['_xpack', 'watcher', 'watch', params['watch_id'] || params['watchId'], '_activate'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/xpack.watcher.deactivate_watch.js b/api/api/xpack.watcher.deactivate_watch.js index b9d3cbaf2..5392ed21d 100644 --- a/api/api/xpack.watcher.deactivate_watch.js +++ b/api/api/xpack.watcher.deactivate_watch.js @@ -7,7 +7,6 @@ function buildXpackWatcherDeactivateWatch (opts) { * Perform a [xpack.watcher.deactivate_watch](https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-deactivate-watch.html) request * * @param {string} watch_id - Watch ID - * @param {time} master_timeout - Explicit operation timeout for connection to master node */ return function xpackWatcherDeactivateWatch (params, options, callback) { options = options || {} @@ -47,10 +46,10 @@ function buildXpackWatcherDeactivateWatch (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ - 'master_timeout' + ] const acceptedQuerystringCamelCased = [ - 'masterTimeout' + ] for (var i = 0, len = keys.length; i < len; i++) { @@ -84,11 +83,14 @@ function buildXpackWatcherDeactivateWatch (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['watch_id'] || params['watchId']) + '/' + '_deactivate' + // build request object - const parts = ['_xpack', 'watcher', 'watch', params['watch_id'] || params['watchId'], '_deactivate'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/xpack.watcher.delete_watch.js b/api/api/xpack.watcher.delete_watch.js index 92a900d88..a0e590960 100644 --- a/api/api/xpack.watcher.delete_watch.js +++ b/api/api/xpack.watcher.delete_watch.js @@ -7,7 +7,6 @@ function buildXpackWatcherDeleteWatch (opts) { * Perform a [xpack.watcher.delete_watch](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-delete-watch.html) request * * @param {string} id - Watch ID - * @param {time} master_timeout - Explicit operation timeout for connection to master node */ return function xpackWatcherDeleteWatch (params, options, callback) { options = options || {} @@ -47,10 +46,10 @@ function buildXpackWatcherDeleteWatch (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ - 'master_timeout' + ] const acceptedQuerystringCamelCased = [ - 'masterTimeout' + ] for (var i = 0, len = keys.length; i < len; i++) { @@ -84,11 +83,14 @@ function buildXpackWatcherDeleteWatch (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['id']) + // build request object - const parts = ['_xpack', 'watcher', 'watch', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/xpack.watcher.execute_watch.js b/api/api/xpack.watcher.execute_watch.js index 10b81222e..45c897650 100644 --- a/api/api/xpack.watcher.execute_watch.js +++ b/api/api/xpack.watcher.execute_watch.js @@ -71,11 +71,18 @@ function buildXpackWatcherExecuteWatch (opts) { ignore = [ignore] } + var path = '' + + if ((params['id']) != null) { + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['id']) + '/' + '_execute' + } else { + path = '/' + '_watcher' + '/' + 'watch' + '/' + '_execute' + } + // build request object - const parts = ['_xpack', 'watcher', 'watch', params['id'], '_execute'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.watcher.get_watch.js b/api/api/xpack.watcher.get_watch.js index dadb61d0c..223cddf13 100644 --- a/api/api/xpack.watcher.get_watch.js +++ b/api/api/xpack.watcher.get_watch.js @@ -83,11 +83,14 @@ function buildXpackWatcherGetWatch (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['id']) + // build request object - const parts = ['_xpack', 'watcher', 'watch', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.watcher.put_watch.js b/api/api/xpack.watcher.put_watch.js index f1bf4956f..59317d9c3 100644 --- a/api/api/xpack.watcher.put_watch.js +++ b/api/api/xpack.watcher.put_watch.js @@ -7,7 +7,6 @@ function buildXpackWatcherPutWatch (opts) { * Perform a [xpack.watcher.put_watch](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html) request * * @param {string} id - Watch ID - * @param {time} master_timeout - Explicit operation timeout for connection to master node * @param {boolean} active - Specify whether the watch is in/active by default * @param {number} version - Explicit version number for concurrency control * @param {object} body - The watch @@ -44,12 +43,10 @@ function buildXpackWatcherPutWatch (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ - 'master_timeout', 'active', 'version' ] const acceptedQuerystringCamelCased = [ - 'masterTimeout', 'active', 'version' ] @@ -85,11 +82,14 @@ function buildXpackWatcherPutWatch (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['id']) + // build request object - const parts = ['_xpack', 'watcher', 'watch', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.watcher.start.js b/api/api/xpack.watcher.start.js index 0232e3b46..0d2eae0e0 100644 --- a/api/api/xpack.watcher.start.js +++ b/api/api/xpack.watcher.start.js @@ -76,11 +76,14 @@ function buildXpackWatcherStart (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_watcher' + '/' + '_start' + // build request object - const parts = ['_xpack', 'watcher', '_start'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/xpack.watcher.stats.js b/api/api/xpack.watcher.stats.js index 0b6124eb7..64417cf55 100644 --- a/api/api/xpack.watcher.stats.js +++ b/api/api/xpack.watcher.stats.js @@ -81,11 +81,18 @@ function buildXpackWatcherStats (opts) { ignore = [ignore] } + var path = '' + + if ((params['metric']) != null) { + path = '/' + '_watcher' + '/' + 'stats' + '/' + encodeURIComponent(params['metric']) + } else { + path = '/' + '_watcher' + '/' + 'stats' + } + // build request object - const parts = ['_xpack', 'watcher', 'stats', params['metric']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.watcher.stop.js b/api/api/xpack.watcher.stop.js index 18550bc80..a414bbb68 100644 --- a/api/api/xpack.watcher.stop.js +++ b/api/api/xpack.watcher.stop.js @@ -76,11 +76,14 @@ function buildXpackWatcherStop (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_watcher' + '/' + '_stop' + // build request object - const parts = ['_xpack', 'watcher', '_stop'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/index.js b/api/index.js index 0f4bb3df9..2993857b2 100644 --- a/api/index.js +++ b/api/index.js @@ -88,6 +88,25 @@ function ESAPI (opts) { getScript: lazyLoad('./api/get_script.js', opts), get_source: lazyLoad('./api/get_source.js', opts), getSource: lazyLoad('./api/get_source.js', opts), + ilm: { + delete_lifecycle: lazyLoad('./api/ilm.delete_lifecycle.js', opts), + deleteLifecycle: lazyLoad('./api/ilm.delete_lifecycle.js', opts), + explain_lifecycle: lazyLoad('./api/ilm.explain_lifecycle.js', opts), + explainLifecycle: lazyLoad('./api/ilm.explain_lifecycle.js', opts), + get_lifecycle: lazyLoad('./api/ilm.get_lifecycle.js', opts), + getLifecycle: lazyLoad('./api/ilm.get_lifecycle.js', opts), + get_status: lazyLoad('./api/ilm.get_status.js', opts), + getStatus: lazyLoad('./api/ilm.get_status.js', opts), + move_to_step: lazyLoad('./api/ilm.move_to_step.js', opts), + moveToStep: lazyLoad('./api/ilm.move_to_step.js', opts), + put_lifecycle: lazyLoad('./api/ilm.put_lifecycle.js', opts), + putLifecycle: lazyLoad('./api/ilm.put_lifecycle.js', opts), + remove_policy: lazyLoad('./api/ilm.remove_policy.js', opts), + removePolicy: lazyLoad('./api/ilm.remove_policy.js', opts), + retry: lazyLoad('./api/ilm.retry.js', opts), + start: lazyLoad('./api/ilm.start.js', opts), + stop: lazyLoad('./api/ilm.stop.js', opts) + }, index: lazyLoad('./api/index.js', opts), indices: { analyze: lazyLoad('./api/indices.analyze.js', opts), @@ -111,6 +130,7 @@ function ESAPI (opts) { flush_synced: lazyLoad('./api/indices.flush_synced.js', opts), flushSynced: lazyLoad('./api/indices.flush_synced.js', opts), forcemerge: lazyLoad('./api/indices.forcemerge.js', opts), + freeze: lazyLoad('./api/indices.freeze.js', opts), get: lazyLoad('./api/indices.get.js', opts), get_alias: lazyLoad('./api/indices.get_alias.js', opts), getAlias: lazyLoad('./api/indices.get_alias.js', opts), @@ -142,6 +162,7 @@ function ESAPI (opts) { shrink: lazyLoad('./api/indices.shrink.js', opts), split: lazyLoad('./api/indices.split.js', opts), stats: lazyLoad('./api/indices.stats.js', opts), + unfreeze: lazyLoad('./api/indices.unfreeze.js', opts), update_aliases: lazyLoad('./api/indices.update_aliases.js', opts), updateAliases: lazyLoad('./api/indices.update_aliases.js', opts), upgrade: lazyLoad('./api/indices.upgrade.js', opts), @@ -161,6 +182,98 @@ function ESAPI (opts) { simulate: lazyLoad('./api/ingest.simulate.js', opts) }, mget: lazyLoad('./api/mget.js', opts), + ml: { + close_job: lazyLoad('./api/ml.close_job.js', opts), + closeJob: lazyLoad('./api/ml.close_job.js', opts), + delete_calendar: lazyLoad('./api/ml.delete_calendar.js', opts), + deleteCalendar: lazyLoad('./api/ml.delete_calendar.js', opts), + delete_calendar_event: lazyLoad('./api/ml.delete_calendar_event.js', opts), + deleteCalendarEvent: lazyLoad('./api/ml.delete_calendar_event.js', opts), + delete_calendar_job: lazyLoad('./api/ml.delete_calendar_job.js', opts), + deleteCalendarJob: lazyLoad('./api/ml.delete_calendar_job.js', opts), + delete_datafeed: lazyLoad('./api/ml.delete_datafeed.js', opts), + deleteDatafeed: lazyLoad('./api/ml.delete_datafeed.js', opts), + delete_expired_data: lazyLoad('./api/ml.delete_expired_data.js', opts), + deleteExpiredData: lazyLoad('./api/ml.delete_expired_data.js', opts), + delete_filter: lazyLoad('./api/ml.delete_filter.js', opts), + deleteFilter: lazyLoad('./api/ml.delete_filter.js', opts), + delete_forecast: lazyLoad('./api/ml.delete_forecast.js', opts), + deleteForecast: lazyLoad('./api/ml.delete_forecast.js', opts), + delete_job: lazyLoad('./api/ml.delete_job.js', opts), + deleteJob: lazyLoad('./api/ml.delete_job.js', opts), + delete_model_snapshot: lazyLoad('./api/ml.delete_model_snapshot.js', opts), + deleteModelSnapshot: lazyLoad('./api/ml.delete_model_snapshot.js', opts), + find_file_structure: lazyLoad('./api/ml.find_file_structure.js', opts), + findFileStructure: lazyLoad('./api/ml.find_file_structure.js', opts), + flush_job: lazyLoad('./api/ml.flush_job.js', opts), + flushJob: lazyLoad('./api/ml.flush_job.js', opts), + forecast: lazyLoad('./api/ml.forecast.js', opts), + get_buckets: lazyLoad('./api/ml.get_buckets.js', opts), + getBuckets: lazyLoad('./api/ml.get_buckets.js', opts), + get_calendar_events: lazyLoad('./api/ml.get_calendar_events.js', opts), + getCalendarEvents: lazyLoad('./api/ml.get_calendar_events.js', opts), + get_calendars: lazyLoad('./api/ml.get_calendars.js', opts), + getCalendars: lazyLoad('./api/ml.get_calendars.js', opts), + get_categories: lazyLoad('./api/ml.get_categories.js', opts), + getCategories: lazyLoad('./api/ml.get_categories.js', opts), + get_datafeed_stats: lazyLoad('./api/ml.get_datafeed_stats.js', opts), + getDatafeedStats: lazyLoad('./api/ml.get_datafeed_stats.js', opts), + get_datafeeds: lazyLoad('./api/ml.get_datafeeds.js', opts), + getDatafeeds: lazyLoad('./api/ml.get_datafeeds.js', opts), + get_filters: lazyLoad('./api/ml.get_filters.js', opts), + getFilters: lazyLoad('./api/ml.get_filters.js', opts), + get_influencers: lazyLoad('./api/ml.get_influencers.js', opts), + getInfluencers: lazyLoad('./api/ml.get_influencers.js', opts), + get_job_stats: lazyLoad('./api/ml.get_job_stats.js', opts), + getJobStats: lazyLoad('./api/ml.get_job_stats.js', opts), + get_jobs: lazyLoad('./api/ml.get_jobs.js', opts), + getJobs: lazyLoad('./api/ml.get_jobs.js', opts), + get_model_snapshots: lazyLoad('./api/ml.get_model_snapshots.js', opts), + getModelSnapshots: lazyLoad('./api/ml.get_model_snapshots.js', opts), + get_overall_buckets: lazyLoad('./api/ml.get_overall_buckets.js', opts), + getOverallBuckets: lazyLoad('./api/ml.get_overall_buckets.js', opts), + get_records: lazyLoad('./api/ml.get_records.js', opts), + getRecords: lazyLoad('./api/ml.get_records.js', opts), + info: lazyLoad('./api/ml.info.js', opts), + open_job: lazyLoad('./api/ml.open_job.js', opts), + openJob: lazyLoad('./api/ml.open_job.js', opts), + post_calendar_events: lazyLoad('./api/ml.post_calendar_events.js', opts), + postCalendarEvents: lazyLoad('./api/ml.post_calendar_events.js', opts), + post_data: lazyLoad('./api/ml.post_data.js', opts), + postData: lazyLoad('./api/ml.post_data.js', opts), + preview_datafeed: lazyLoad('./api/ml.preview_datafeed.js', opts), + previewDatafeed: lazyLoad('./api/ml.preview_datafeed.js', opts), + put_calendar: lazyLoad('./api/ml.put_calendar.js', opts), + putCalendar: lazyLoad('./api/ml.put_calendar.js', opts), + put_calendar_job: lazyLoad('./api/ml.put_calendar_job.js', opts), + putCalendarJob: lazyLoad('./api/ml.put_calendar_job.js', opts), + put_datafeed: lazyLoad('./api/ml.put_datafeed.js', opts), + putDatafeed: lazyLoad('./api/ml.put_datafeed.js', opts), + put_filter: lazyLoad('./api/ml.put_filter.js', opts), + putFilter: lazyLoad('./api/ml.put_filter.js', opts), + put_job: lazyLoad('./api/ml.put_job.js', opts), + putJob: lazyLoad('./api/ml.put_job.js', opts), + revert_model_snapshot: lazyLoad('./api/ml.revert_model_snapshot.js', opts), + revertModelSnapshot: lazyLoad('./api/ml.revert_model_snapshot.js', opts), + start_datafeed: lazyLoad('./api/ml.start_datafeed.js', opts), + startDatafeed: lazyLoad('./api/ml.start_datafeed.js', opts), + stop_datafeed: lazyLoad('./api/ml.stop_datafeed.js', opts), + stopDatafeed: lazyLoad('./api/ml.stop_datafeed.js', opts), + update_datafeed: lazyLoad('./api/ml.update_datafeed.js', opts), + updateDatafeed: lazyLoad('./api/ml.update_datafeed.js', opts), + update_filter: lazyLoad('./api/ml.update_filter.js', opts), + updateFilter: lazyLoad('./api/ml.update_filter.js', opts), + update_job: lazyLoad('./api/ml.update_job.js', opts), + updateJob: lazyLoad('./api/ml.update_job.js', opts), + update_model_snapshot: lazyLoad('./api/ml.update_model_snapshot.js', opts), + updateModelSnapshot: lazyLoad('./api/ml.update_model_snapshot.js', opts), + validate: lazyLoad('./api/ml.validate.js', opts), + validate_detector: lazyLoad('./api/ml.validate_detector.js', opts), + validateDetector: lazyLoad('./api/ml.validate_detector.js', opts) + }, + monitoring: { + bulk: lazyLoad('./api/monitoring.bulk.js', opts) + }, msearch: lazyLoad('./api/msearch.js', opts), msearch_template: lazyLoad('./api/msearch_template.js', opts), msearchTemplate: lazyLoad('./api/msearch_template.js', opts), @@ -192,6 +305,51 @@ function ESAPI (opts) { searchShards: lazyLoad('./api/search_shards.js', opts), search_template: lazyLoad('./api/search_template.js', opts), searchTemplate: lazyLoad('./api/search_template.js', opts), + security: { + authenticate: lazyLoad('./api/security.authenticate.js', opts), + change_password: lazyLoad('./api/security.change_password.js', opts), + changePassword: lazyLoad('./api/security.change_password.js', opts), + clear_cached_realms: lazyLoad('./api/security.clear_cached_realms.js', opts), + clearCachedRealms: lazyLoad('./api/security.clear_cached_realms.js', opts), + clear_cached_roles: lazyLoad('./api/security.clear_cached_roles.js', opts), + clearCachedRoles: lazyLoad('./api/security.clear_cached_roles.js', opts), + delete_privileges: lazyLoad('./api/security.delete_privileges.js', opts), + deletePrivileges: lazyLoad('./api/security.delete_privileges.js', opts), + delete_role: lazyLoad('./api/security.delete_role.js', opts), + deleteRole: lazyLoad('./api/security.delete_role.js', opts), + delete_role_mapping: lazyLoad('./api/security.delete_role_mapping.js', opts), + deleteRoleMapping: lazyLoad('./api/security.delete_role_mapping.js', opts), + delete_user: lazyLoad('./api/security.delete_user.js', opts), + deleteUser: lazyLoad('./api/security.delete_user.js', opts), + disable_user: lazyLoad('./api/security.disable_user.js', opts), + disableUser: lazyLoad('./api/security.disable_user.js', opts), + enable_user: lazyLoad('./api/security.enable_user.js', opts), + enableUser: lazyLoad('./api/security.enable_user.js', opts), + get_privileges: lazyLoad('./api/security.get_privileges.js', opts), + getPrivileges: lazyLoad('./api/security.get_privileges.js', opts), + get_role: lazyLoad('./api/security.get_role.js', opts), + getRole: lazyLoad('./api/security.get_role.js', opts), + get_role_mapping: lazyLoad('./api/security.get_role_mapping.js', opts), + getRoleMapping: lazyLoad('./api/security.get_role_mapping.js', opts), + get_token: lazyLoad('./api/security.get_token.js', opts), + getToken: lazyLoad('./api/security.get_token.js', opts), + get_user: lazyLoad('./api/security.get_user.js', opts), + getUser: lazyLoad('./api/security.get_user.js', opts), + get_user_privileges: lazyLoad('./api/security.get_user_privileges.js', opts), + getUserPrivileges: lazyLoad('./api/security.get_user_privileges.js', opts), + has_privileges: lazyLoad('./api/security.has_privileges.js', opts), + hasPrivileges: lazyLoad('./api/security.has_privileges.js', opts), + invalidate_token: lazyLoad('./api/security.invalidate_token.js', opts), + invalidateToken: lazyLoad('./api/security.invalidate_token.js', opts), + put_privileges: lazyLoad('./api/security.put_privileges.js', opts), + putPrivileges: lazyLoad('./api/security.put_privileges.js', opts), + put_role: lazyLoad('./api/security.put_role.js', opts), + putRole: lazyLoad('./api/security.put_role.js', opts), + put_role_mapping: lazyLoad('./api/security.put_role_mapping.js', opts), + putRoleMapping: lazyLoad('./api/security.put_role_mapping.js', opts), + put_user: lazyLoad('./api/security.put_user.js', opts), + putUser: lazyLoad('./api/security.put_user.js', opts) + }, snapshot: { create: lazyLoad('./api/snapshot.create.js', opts), create_repository: lazyLoad('./api/snapshot.create_repository.js', opts), @@ -207,6 +365,9 @@ function ESAPI (opts) { verify_repository: lazyLoad('./api/snapshot.verify_repository.js', opts), verifyRepository: lazyLoad('./api/snapshot.verify_repository.js', opts) }, + ssl: { + certificates: lazyLoad('./api/ssl.certificates.js', opts) + }, tasks: { cancel: lazyLoad('./api/tasks.cancel.js', opts), get: lazyLoad('./api/tasks.get.js', opts), @@ -242,98 +403,6 @@ function ESAPI (opts) { getAssistance: lazyLoad('./api/xpack.migration.get_assistance.js', opts), upgrade: lazyLoad('./api/xpack.migration.upgrade.js', opts) }, - ml: { - close_job: lazyLoad('./api/xpack.ml.close_job.js', opts), - closeJob: lazyLoad('./api/xpack.ml.close_job.js', opts), - delete_calendar: lazyLoad('./api/xpack.ml.delete_calendar.js', opts), - deleteCalendar: lazyLoad('./api/xpack.ml.delete_calendar.js', opts), - delete_calendar_event: lazyLoad('./api/xpack.ml.delete_calendar_event.js', opts), - deleteCalendarEvent: lazyLoad('./api/xpack.ml.delete_calendar_event.js', opts), - delete_calendar_job: lazyLoad('./api/xpack.ml.delete_calendar_job.js', opts), - deleteCalendarJob: lazyLoad('./api/xpack.ml.delete_calendar_job.js', opts), - delete_datafeed: lazyLoad('./api/xpack.ml.delete_datafeed.js', opts), - deleteDatafeed: lazyLoad('./api/xpack.ml.delete_datafeed.js', opts), - delete_expired_data: lazyLoad('./api/xpack.ml.delete_expired_data.js', opts), - deleteExpiredData: lazyLoad('./api/xpack.ml.delete_expired_data.js', opts), - delete_filter: lazyLoad('./api/xpack.ml.delete_filter.js', opts), - deleteFilter: lazyLoad('./api/xpack.ml.delete_filter.js', opts), - delete_forecast: lazyLoad('./api/xpack.ml.delete_forecast.js', opts), - deleteForecast: lazyLoad('./api/xpack.ml.delete_forecast.js', opts), - delete_job: lazyLoad('./api/xpack.ml.delete_job.js', opts), - deleteJob: lazyLoad('./api/xpack.ml.delete_job.js', opts), - delete_model_snapshot: lazyLoad('./api/xpack.ml.delete_model_snapshot.js', opts), - deleteModelSnapshot: lazyLoad('./api/xpack.ml.delete_model_snapshot.js', opts), - find_file_structure: lazyLoad('./api/xpack.ml.find_file_structure.js', opts), - findFileStructure: lazyLoad('./api/xpack.ml.find_file_structure.js', opts), - flush_job: lazyLoad('./api/xpack.ml.flush_job.js', opts), - flushJob: lazyLoad('./api/xpack.ml.flush_job.js', opts), - forecast: lazyLoad('./api/xpack.ml.forecast.js', opts), - get_buckets: lazyLoad('./api/xpack.ml.get_buckets.js', opts), - getBuckets: lazyLoad('./api/xpack.ml.get_buckets.js', opts), - get_calendar_events: lazyLoad('./api/xpack.ml.get_calendar_events.js', opts), - getCalendarEvents: lazyLoad('./api/xpack.ml.get_calendar_events.js', opts), - get_calendars: lazyLoad('./api/xpack.ml.get_calendars.js', opts), - getCalendars: lazyLoad('./api/xpack.ml.get_calendars.js', opts), - get_categories: lazyLoad('./api/xpack.ml.get_categories.js', opts), - getCategories: lazyLoad('./api/xpack.ml.get_categories.js', opts), - get_datafeed_stats: lazyLoad('./api/xpack.ml.get_datafeed_stats.js', opts), - getDatafeedStats: lazyLoad('./api/xpack.ml.get_datafeed_stats.js', opts), - get_datafeeds: lazyLoad('./api/xpack.ml.get_datafeeds.js', opts), - getDatafeeds: lazyLoad('./api/xpack.ml.get_datafeeds.js', opts), - get_filters: lazyLoad('./api/xpack.ml.get_filters.js', opts), - getFilters: lazyLoad('./api/xpack.ml.get_filters.js', opts), - get_influencers: lazyLoad('./api/xpack.ml.get_influencers.js', opts), - getInfluencers: lazyLoad('./api/xpack.ml.get_influencers.js', opts), - get_job_stats: lazyLoad('./api/xpack.ml.get_job_stats.js', opts), - getJobStats: lazyLoad('./api/xpack.ml.get_job_stats.js', opts), - get_jobs: lazyLoad('./api/xpack.ml.get_jobs.js', opts), - getJobs: lazyLoad('./api/xpack.ml.get_jobs.js', opts), - get_model_snapshots: lazyLoad('./api/xpack.ml.get_model_snapshots.js', opts), - getModelSnapshots: lazyLoad('./api/xpack.ml.get_model_snapshots.js', opts), - get_overall_buckets: lazyLoad('./api/xpack.ml.get_overall_buckets.js', opts), - getOverallBuckets: lazyLoad('./api/xpack.ml.get_overall_buckets.js', opts), - get_records: lazyLoad('./api/xpack.ml.get_records.js', opts), - getRecords: lazyLoad('./api/xpack.ml.get_records.js', opts), - info: lazyLoad('./api/xpack.ml.info.js', opts), - open_job: lazyLoad('./api/xpack.ml.open_job.js', opts), - openJob: lazyLoad('./api/xpack.ml.open_job.js', opts), - post_calendar_events: lazyLoad('./api/xpack.ml.post_calendar_events.js', opts), - postCalendarEvents: lazyLoad('./api/xpack.ml.post_calendar_events.js', opts), - post_data: lazyLoad('./api/xpack.ml.post_data.js', opts), - postData: lazyLoad('./api/xpack.ml.post_data.js', opts), - preview_datafeed: lazyLoad('./api/xpack.ml.preview_datafeed.js', opts), - previewDatafeed: lazyLoad('./api/xpack.ml.preview_datafeed.js', opts), - put_calendar: lazyLoad('./api/xpack.ml.put_calendar.js', opts), - putCalendar: lazyLoad('./api/xpack.ml.put_calendar.js', opts), - put_calendar_job: lazyLoad('./api/xpack.ml.put_calendar_job.js', opts), - putCalendarJob: lazyLoad('./api/xpack.ml.put_calendar_job.js', opts), - put_datafeed: lazyLoad('./api/xpack.ml.put_datafeed.js', opts), - putDatafeed: lazyLoad('./api/xpack.ml.put_datafeed.js', opts), - put_filter: lazyLoad('./api/xpack.ml.put_filter.js', opts), - putFilter: lazyLoad('./api/xpack.ml.put_filter.js', opts), - put_job: lazyLoad('./api/xpack.ml.put_job.js', opts), - putJob: lazyLoad('./api/xpack.ml.put_job.js', opts), - revert_model_snapshot: lazyLoad('./api/xpack.ml.revert_model_snapshot.js', opts), - revertModelSnapshot: lazyLoad('./api/xpack.ml.revert_model_snapshot.js', opts), - start_datafeed: lazyLoad('./api/xpack.ml.start_datafeed.js', opts), - startDatafeed: lazyLoad('./api/xpack.ml.start_datafeed.js', opts), - stop_datafeed: lazyLoad('./api/xpack.ml.stop_datafeed.js', opts), - stopDatafeed: lazyLoad('./api/xpack.ml.stop_datafeed.js', opts), - update_datafeed: lazyLoad('./api/xpack.ml.update_datafeed.js', opts), - updateDatafeed: lazyLoad('./api/xpack.ml.update_datafeed.js', opts), - update_filter: lazyLoad('./api/xpack.ml.update_filter.js', opts), - updateFilter: lazyLoad('./api/xpack.ml.update_filter.js', opts), - update_job: lazyLoad('./api/xpack.ml.update_job.js', opts), - updateJob: lazyLoad('./api/xpack.ml.update_job.js', opts), - update_model_snapshot: lazyLoad('./api/xpack.ml.update_model_snapshot.js', opts), - updateModelSnapshot: lazyLoad('./api/xpack.ml.update_model_snapshot.js', opts), - validate: lazyLoad('./api/xpack.ml.validate.js', opts), - validate_detector: lazyLoad('./api/xpack.ml.validate_detector.js', opts), - validateDetector: lazyLoad('./api/xpack.ml.validate_detector.js', opts) - }, - monitoring: { - bulk: lazyLoad('./api/xpack.monitoring.bulk.js', opts) - }, rollup: { delete_job: lazyLoad('./api/xpack.rollup.delete_job.js', opts), deleteJob: lazyLoad('./api/xpack.rollup.delete_job.js', opts), @@ -352,60 +421,12 @@ function ESAPI (opts) { stop_job: lazyLoad('./api/xpack.rollup.stop_job.js', opts), stopJob: lazyLoad('./api/xpack.rollup.stop_job.js', opts) }, - security: { - authenticate: lazyLoad('./api/xpack.security.authenticate.js', opts), - change_password: lazyLoad('./api/xpack.security.change_password.js', opts), - changePassword: lazyLoad('./api/xpack.security.change_password.js', opts), - clear_cached_realms: lazyLoad('./api/xpack.security.clear_cached_realms.js', opts), - clearCachedRealms: lazyLoad('./api/xpack.security.clear_cached_realms.js', opts), - clear_cached_roles: lazyLoad('./api/xpack.security.clear_cached_roles.js', opts), - clearCachedRoles: lazyLoad('./api/xpack.security.clear_cached_roles.js', opts), - delete_privileges: lazyLoad('./api/xpack.security.delete_privileges.js', opts), - deletePrivileges: lazyLoad('./api/xpack.security.delete_privileges.js', opts), - delete_role: lazyLoad('./api/xpack.security.delete_role.js', opts), - deleteRole: lazyLoad('./api/xpack.security.delete_role.js', opts), - delete_role_mapping: lazyLoad('./api/xpack.security.delete_role_mapping.js', opts), - deleteRoleMapping: lazyLoad('./api/xpack.security.delete_role_mapping.js', opts), - delete_user: lazyLoad('./api/xpack.security.delete_user.js', opts), - deleteUser: lazyLoad('./api/xpack.security.delete_user.js', opts), - disable_user: lazyLoad('./api/xpack.security.disable_user.js', opts), - disableUser: lazyLoad('./api/xpack.security.disable_user.js', opts), - enable_user: lazyLoad('./api/xpack.security.enable_user.js', opts), - enableUser: lazyLoad('./api/xpack.security.enable_user.js', opts), - get_privileges: lazyLoad('./api/xpack.security.get_privileges.js', opts), - getPrivileges: lazyLoad('./api/xpack.security.get_privileges.js', opts), - get_role: lazyLoad('./api/xpack.security.get_role.js', opts), - getRole: lazyLoad('./api/xpack.security.get_role.js', opts), - get_role_mapping: lazyLoad('./api/xpack.security.get_role_mapping.js', opts), - getRoleMapping: lazyLoad('./api/xpack.security.get_role_mapping.js', opts), - get_token: lazyLoad('./api/xpack.security.get_token.js', opts), - getToken: lazyLoad('./api/xpack.security.get_token.js', opts), - get_user: lazyLoad('./api/xpack.security.get_user.js', opts), - getUser: lazyLoad('./api/xpack.security.get_user.js', opts), - get_user_privileges: lazyLoad('./api/xpack.security.get_user_privileges.js', opts), - getUserPrivileges: lazyLoad('./api/xpack.security.get_user_privileges.js', opts), - has_privileges: lazyLoad('./api/xpack.security.has_privileges.js', opts), - hasPrivileges: lazyLoad('./api/xpack.security.has_privileges.js', opts), - invalidate_token: lazyLoad('./api/xpack.security.invalidate_token.js', opts), - invalidateToken: lazyLoad('./api/xpack.security.invalidate_token.js', opts), - put_privileges: lazyLoad('./api/xpack.security.put_privileges.js', opts), - putPrivileges: lazyLoad('./api/xpack.security.put_privileges.js', opts), - put_role: lazyLoad('./api/xpack.security.put_role.js', opts), - putRole: lazyLoad('./api/xpack.security.put_role.js', opts), - put_role_mapping: lazyLoad('./api/xpack.security.put_role_mapping.js', opts), - putRoleMapping: lazyLoad('./api/xpack.security.put_role_mapping.js', opts), - put_user: lazyLoad('./api/xpack.security.put_user.js', opts), - putUser: lazyLoad('./api/xpack.security.put_user.js', opts) - }, sql: { clear_cursor: lazyLoad('./api/xpack.sql.clear_cursor.js', opts), clearCursor: lazyLoad('./api/xpack.sql.clear_cursor.js', opts), query: lazyLoad('./api/xpack.sql.query.js', opts), translate: lazyLoad('./api/xpack.sql.translate.js', opts) }, - ssl: { - certificates: lazyLoad('./api/xpack.ssl.certificates.js', opts) - }, usage: lazyLoad('./api/xpack.usage.js', opts), watcher: { ack_watch: lazyLoad('./api/xpack.watcher.ack_watch.js', opts), @@ -422,7 +443,6 @@ function ESAPI (opts) { getWatch: lazyLoad('./api/xpack.watcher.get_watch.js', opts), put_watch: lazyLoad('./api/xpack.watcher.put_watch.js', opts), putWatch: lazyLoad('./api/xpack.watcher.put_watch.js', opts), - restart: lazyLoad('./api/xpack.watcher.restart.js', opts), start: lazyLoad('./api/xpack.watcher.start.js', opts), stats: lazyLoad('./api/xpack.watcher.stats.js', opts), stop: lazyLoad('./api/xpack.watcher.stop.js', opts) diff --git a/api/requestParams.d.ts b/api/requestParams.d.ts index 8277562fe..637bc48b1 100644 --- a/api/requestParams.d.ts +++ b/api/requestParams.d.ts @@ -15,10 +15,9 @@ export interface Bulk extends Generic { refresh?: 'true' | 'false' | 'wait_for'; routing?: string; timeout?: string; - fields?: string | string[]; _source?: string | string[]; - _source_exclude?: string | string[]; - _source_include?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; pipeline?: string; body: any; } @@ -302,6 +301,8 @@ export interface ClusterState extends Generic { local?: boolean; master_timeout?: string; flat_settings?: boolean; + wait_for_metadata_version?: number; + wait_for_timeout?: string; ignore_unavailable?: boolean; allow_no_indices?: boolean; expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; @@ -317,6 +318,7 @@ export interface Count extends Generic { index?: string | string[]; type?: string | string[]; ignore_unavailable?: boolean; + ignore_throttled?: boolean; allow_no_indices?: boolean; expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; min_score?: number; @@ -350,7 +352,7 @@ export interface Create extends Generic { export interface Delete extends Generic { id: string; index: string; - type: string; + type?: string; wait_for_active_shards?: string; parent?: string; refresh?: 'true' | 'false' | 'wait_for'; @@ -382,8 +384,8 @@ export interface DeleteByQuery extends Generic { size?: number; sort?: string | string[]; _source?: string | string[]; - _source_exclude?: string | string[]; - _source_include?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; terminate_after?: number; stats?: string | string[]; version?: boolean; @@ -412,7 +414,7 @@ export interface DeleteScript extends Generic { export interface Exists extends Generic { id: string; index: string; - type: string; + type?: string; stored_fields?: string | string[]; parent?: string; preference?: string; @@ -420,8 +422,8 @@ export interface Exists extends Generic { refresh?: boolean; routing?: string; _source?: string | string[]; - _source_exclude?: string | string[]; - _source_include?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; version?: number; version_type?: 'internal' | 'external' | 'external_gte' | 'force'; } @@ -436,8 +438,8 @@ export interface ExistsSource extends Generic { refresh?: boolean; routing?: string; _source?: string | string[]; - _source_exclude?: string | string[]; - _source_include?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; version?: number; version_type?: 'internal' | 'external' | 'external_gte' | 'force'; } @@ -445,7 +447,7 @@ export interface ExistsSource extends Generic { export interface Explain extends Generic { id: string; index: string; - type: string; + type?: string; analyze_wildcard?: boolean; analyzer?: string; default_operator?: 'AND' | 'OR'; @@ -457,8 +459,8 @@ export interface Explain extends Generic { q?: string; routing?: string; _source?: string | string[]; - _source_exclude?: string | string[]; - _source_include?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; body?: any; } @@ -468,13 +470,12 @@ export interface FieldCaps extends Generic { ignore_unavailable?: boolean; allow_no_indices?: boolean; expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; - body?: any; } export interface Get extends Generic { id: string; index: string; - type: string; + type?: string; stored_fields?: string | string[]; parent?: string; preference?: string; @@ -482,6 +483,8 @@ export interface Get extends Generic { refresh?: boolean; routing?: string; _source?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; _source_exclude?: string | string[]; _source_include?: string | string[]; version?: number; @@ -503,8 +506,8 @@ export interface GetSource extends Generic { refresh?: boolean; routing?: string; _source?: string | string[]; - _source_exclude?: string | string[]; - _source_include?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; version?: number; version_type?: 'internal' | 'external' | 'external_gte' | 'force'; } @@ -512,7 +515,7 @@ export interface GetSource extends Generic { export interface Index extends Generic { id?: string; index: string; - type: string; + type?: string; wait_for_active_shards?: string; op_type?: 'index' | 'create'; parent?: string; @@ -532,14 +535,12 @@ export interface IndicesAnalyze extends Generic { export interface IndicesClearCache extends Generic { index?: string | string[]; - field_data?: boolean; fielddata?: boolean; fields?: string | string[]; query?: boolean; ignore_unavailable?: boolean; allow_no_indices?: boolean; expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; - request_cache?: boolean; request?: boolean; } @@ -554,10 +555,10 @@ export interface IndicesClose extends Generic { export interface IndicesCreate extends Generic { index: string; + include_type_name?: string; wait_for_active_shards?: string; timeout?: string; master_timeout?: string; - update_all_types?: boolean; body?: any; } @@ -678,6 +679,7 @@ export interface IndicesGetFieldMapping extends Generic { export interface IndicesGetMapping extends Generic { index?: string | string[]; type?: string | string[]; + include_type_name?: string; ignore_unavailable?: boolean; allow_no_indices?: boolean; expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; @@ -731,13 +733,13 @@ export interface IndicesPutAlias extends Generic { export interface IndicesPutMapping extends Generic { index?: string | string[]; - type: string; + type?: string; + include_type_name?: string; timeout?: string; master_timeout?: string; ignore_unavailable?: boolean; allow_no_indices?: boolean; expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; - update_all_types?: boolean; body: any; } @@ -906,8 +908,8 @@ export interface Mget extends Generic { refresh?: boolean; routing?: string; _source?: string | string[]; - _source_exclude?: string | string[]; - _source_include?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; body: any; } @@ -919,6 +921,7 @@ export interface Msearch extends Generic { typed_keys?: boolean; pre_filter_shard_size?: number; max_concurrent_shard_requests?: number; + rest_total_hits_as_int?: boolean; body: any; } @@ -928,6 +931,7 @@ export interface MsearchTemplate extends Generic { search_type?: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch'; typed_keys?: boolean; max_concurrent_searches?: number; + rest_total_hits_as_int?: boolean; body: any; } @@ -1038,6 +1042,7 @@ export interface ScriptsPainlessExecute extends Generic { export interface Scroll extends Generic { scroll_id?: string; scroll?: string; + rest_total_hits_as_int?: boolean; body?: any; } @@ -1053,6 +1058,7 @@ export interface Search extends Generic { docvalue_fields?: string | string[]; from?: number; ignore_unavailable?: boolean; + ignore_throttled?: boolean; allow_no_indices?: boolean; expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; lenient?: boolean; @@ -1064,8 +1070,8 @@ export interface Search extends Generic { size?: number; sort?: string | string[]; _source?: string | string[]; - _source_exclude?: string | string[]; - _source_include?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; terminate_after?: number; stats?: string | string[]; suggest_field?: string; @@ -1082,6 +1088,7 @@ export interface Search extends Generic { batched_reduce_size?: number; max_concurrent_shard_requests?: number; pre_filter_shard_size?: number; + rest_total_hits_as_int?: boolean; body?: any; } @@ -1099,6 +1106,7 @@ export interface SearchTemplate extends Generic { index?: string | string[]; type?: string | string[]; ignore_unavailable?: boolean; + ignore_throttled?: boolean; allow_no_indices?: boolean; expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; preference?: string; @@ -1108,6 +1116,7 @@ export interface SearchTemplate extends Generic { explain?: boolean; profile?: boolean; typed_keys?: boolean; + rest_total_hits_as_int?: boolean; body: any; } @@ -1199,7 +1208,7 @@ export interface TasksList extends Generic { export interface Termvectors extends Generic { index: string; - type: string; + type?: string; id?: string; term_statistics?: boolean; field_statistics?: boolean; @@ -1219,12 +1228,11 @@ export interface Termvectors extends Generic { export interface Update extends Generic { id: string; index: string; - type: string; + type?: string; wait_for_active_shards?: string; - fields?: string | string[]; _source?: string | string[]; - _source_exclude?: string | string[]; - _source_include?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; lang?: string; parent?: string; refresh?: 'true' | 'false' | 'wait_for'; @@ -1259,8 +1267,8 @@ export interface UpdateByQuery extends Generic { size?: number; sort?: string | string[]; _source?: string | string[]; - _source_exclude?: string | string[]; - _source_include?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; terminate_after?: number; stats?: string | string[]; version?: boolean; @@ -1319,6 +1327,481 @@ export interface CcrUnfollow extends Generic { index: string; } +export interface IlmDeleteLifecycle extends Generic { + policy?: string; +} + +export interface IlmExplainLifecycle extends Generic { + index?: string; + human?: boolean; +} + +export interface IlmGetLifecycle extends Generic { + policy?: string; +} + +export interface IlmGetStatus extends Generic { +} + +export interface IlmMoveToStep extends Generic { + index?: string; + body?: any; +} + +export interface IlmPutLifecycle extends Generic { + policy?: string; + body?: any; +} + +export interface IlmRemovePolicy extends Generic { + index?: string; +} + +export interface IlmRetry extends Generic { + index?: string; +} + +export interface IlmStart extends Generic { +} + +export interface IlmStop extends Generic { +} + +export interface IndicesFreeze extends Generic { + index: string; + timeout?: string; + master_timeout?: string; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + wait_for_active_shards?: string; +} + +export interface IndicesUnfreeze extends Generic { + index: string; + timeout?: string; + master_timeout?: string; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + wait_for_active_shards?: string; +} + +export interface MlCloseJob extends Generic { + job_id: string; + allow_no_jobs?: boolean; + force?: boolean; + timeout?: string; +} + +export interface MlDeleteCalendar extends Generic { + calendar_id: string; +} + +export interface MlDeleteCalendarEvent extends Generic { + calendar_id: string; + event_id: string; +} + +export interface MlDeleteCalendarJob extends Generic { + calendar_id: string; + job_id: string; +} + +export interface MlDeleteDatafeed extends Generic { + datafeed_id: string; + force?: boolean; +} + +export interface MlDeleteExpiredData extends Generic { +} + +export interface MlDeleteFilter extends Generic { + filter_id: string; +} + +export interface MlDeleteForecast extends Generic { + job_id: string; + forecast_id?: string; + allow_no_forecasts?: boolean; + timeout?: string; +} + +export interface MlDeleteJob extends Generic { + job_id: string; + force?: boolean; + wait_for_completion?: boolean; +} + +export interface MlDeleteModelSnapshot extends Generic { + job_id: string; + snapshot_id: string; +} + +export interface MlFindFileStructure extends Generic { + lines_to_sample?: number; + timeout?: string; + charset?: string; + format?: 'ndjson' | 'xml' | 'delimited' | 'semi_structured_text'; + has_header_row?: boolean; + column_names?: string | string[]; + delimiter?: string; + quote?: string; + should_trim_fields?: boolean; + grok_pattern?: string; + timestamp_field?: string; + timestamp_format?: string; + explain?: boolean; + body: any; +} + +export interface MlFlushJob extends Generic { + job_id: string; + calc_interim?: boolean; + start?: string; + end?: string; + advance_time?: string; + skip_time?: string; + body?: any; +} + +export interface MlForecast extends Generic { + job_id: string; + duration?: string; + expires_in?: string; +} + +export interface MlGetBuckets extends Generic { + job_id: string; + timestamp?: string; + expand?: boolean; + exclude_interim?: boolean; + from?: number; + size?: number; + start?: string; + end?: string; + anomaly_score?: number; + sort?: string; + desc?: boolean; + body?: any; +} + +export interface MlGetCalendarEvents extends Generic { + calendar_id: string; + job_id?: string; + start?: string; + end?: string; + from?: number; + size?: number; +} + +export interface MlGetCalendars extends Generic { + calendar_id?: string; + from?: number; + size?: number; +} + +export interface MlGetCategories extends Generic { + job_id: string; + category_id?: number; + from?: number; + size?: number; + body?: any; +} + +export interface MlGetDatafeedStats extends Generic { + datafeed_id?: string; + allow_no_datafeeds?: boolean; +} + +export interface MlGetDatafeeds extends Generic { + datafeed_id?: string; + allow_no_datafeeds?: boolean; +} + +export interface MlGetFilters extends Generic { + filter_id?: string; + from?: number; + size?: number; +} + +export interface MlGetInfluencers extends Generic { + job_id: string; + exclude_interim?: boolean; + from?: number; + size?: number; + start?: string; + end?: string; + influencer_score?: number; + sort?: string; + desc?: boolean; + body?: any; +} + +export interface MlGetJobStats extends Generic { + job_id?: string; + allow_no_jobs?: boolean; +} + +export interface MlGetJobs extends Generic { + job_id?: string; + allow_no_jobs?: boolean; +} + +export interface MlGetModelSnapshots extends Generic { + job_id: string; + snapshot_id?: string; + from?: number; + size?: number; + start?: string; + end?: string; + sort?: string; + desc?: boolean; + body?: any; +} + +export interface MlGetOverallBuckets extends Generic { + job_id: string; + top_n?: number; + bucket_span?: string; + overall_score?: number; + exclude_interim?: boolean; + start?: string; + end?: string; + allow_no_jobs?: boolean; + body?: any; +} + +export interface MlGetRecords extends Generic { + job_id: string; + exclude_interim?: boolean; + from?: number; + size?: number; + start?: string; + end?: string; + record_score?: number; + sort?: string; + desc?: boolean; + body?: any; +} + +export interface MlInfo extends Generic { +} + +export interface MlOpenJob extends Generic { + job_id: string; + ignore_downtime?: boolean; + timeout?: string; +} + +export interface MlPostCalendarEvents extends Generic { + calendar_id: string; + body: any; +} + +export interface MlPostData extends Generic { + job_id: string; + reset_start?: string; + reset_end?: string; + body: any; +} + +export interface MlPreviewDatafeed extends Generic { + datafeed_id: string; +} + +export interface MlPutCalendar extends Generic { + calendar_id: string; + body?: any; +} + +export interface MlPutCalendarJob extends Generic { + calendar_id: string; + job_id: string; +} + +export interface MlPutDatafeed extends Generic { + datafeed_id: string; + body: any; +} + +export interface MlPutFilter extends Generic { + filter_id: string; + body: any; +} + +export interface MlPutJob extends Generic { + job_id: string; + body: any; +} + +export interface MlRevertModelSnapshot extends Generic { + job_id: string; + snapshot_id: string; + delete_intervening_results?: boolean; + body?: any; +} + +export interface MlStartDatafeed extends Generic { + datafeed_id: string; + start?: string; + end?: string; + timeout?: string; + body?: any; +} + +export interface MlStopDatafeed extends Generic { + datafeed_id: string; + allow_no_datafeeds?: boolean; + force?: boolean; + timeout?: string; +} + +export interface MlUpdateDatafeed extends Generic { + datafeed_id: string; + body: any; +} + +export interface MlUpdateFilter extends Generic { + filter_id: string; + body: any; +} + +export interface MlUpdateJob extends Generic { + job_id: string; + body: any; +} + +export interface MlUpdateModelSnapshot extends Generic { + job_id: string; + snapshot_id: string; + body: any; +} + +export interface MlValidate extends Generic { + body: any; +} + +export interface MlValidateDetector extends Generic { + body: any; +} + +export interface MonitoringBulk extends Generic { + type?: string; + system_id?: string; + system_api_version?: string; + interval?: string; + body: any; +} + +export interface SecurityAuthenticate extends Generic { +} + +export interface SecurityChangePassword extends Generic { + username?: string; + refresh?: 'true' | 'false' | 'wait_for'; + body: any; +} + +export interface SecurityClearCachedRealms extends Generic { + realms: string | string[]; + usernames?: string | string[]; +} + +export interface SecurityClearCachedRoles extends Generic { + name: string | string[]; +} + +export interface SecurityDeletePrivileges extends Generic { + application: string; + name: string; + refresh?: 'true' | 'false' | 'wait_for'; +} + +export interface SecurityDeleteRole extends Generic { + name: string; + refresh?: 'true' | 'false' | 'wait_for'; +} + +export interface SecurityDeleteRoleMapping extends Generic { + name: string; + refresh?: 'true' | 'false' | 'wait_for'; +} + +export interface SecurityDeleteUser extends Generic { + username: string; + refresh?: 'true' | 'false' | 'wait_for'; +} + +export interface SecurityDisableUser extends Generic { + username?: string; + refresh?: 'true' | 'false' | 'wait_for'; +} + +export interface SecurityEnableUser extends Generic { + username?: string; + refresh?: 'true' | 'false' | 'wait_for'; +} + +export interface SecurityGetPrivileges extends Generic { + application?: string; + name?: string; +} + +export interface SecurityGetRole extends Generic { + name?: string; +} + +export interface SecurityGetRoleMapping extends Generic { + name?: string; +} + +export interface SecurityGetToken extends Generic { + body: any; +} + +export interface SecurityGetUser extends Generic { + username?: string | string[]; +} + +export interface SecurityGetUserPrivileges extends Generic { +} + +export interface SecurityHasPrivileges extends Generic { + user?: string; + body: any; +} + +export interface SecurityInvalidateToken extends Generic { + body: any; +} + +export interface SecurityPutPrivileges extends Generic { + refresh?: 'true' | 'false' | 'wait_for'; + body: any; +} + +export interface SecurityPutRole extends Generic { + name: string; + refresh?: 'true' | 'false' | 'wait_for'; + body: any; +} + +export interface SecurityPutRoleMapping extends Generic { + name: string; + refresh?: 'true' | 'false' | 'wait_for'; + body: any; +} + +export interface SecurityPutUser extends Generic { + username: string; + refresh?: 'true' | 'false' | 'wait_for'; + body: any; +} + +export interface SslCertificates extends Generic { +} + export interface XpackGraphExplore extends Generic { index?: string | string[]; type?: string | string[]; @@ -1374,313 +1857,6 @@ export interface XpackMigrationUpgrade extends Generic { wait_for_completion?: boolean; } -export interface XpackMlCloseJob extends Generic { - job_id: string; - allow_no_jobs?: boolean; - force?: boolean; - timeout?: string; -} - -export interface XpackMlDeleteCalendar extends Generic { - calendar_id: string; -} - -export interface XpackMlDeleteCalendarEvent extends Generic { - calendar_id: string; - event_id: string; -} - -export interface XpackMlDeleteCalendarJob extends Generic { - calendar_id: string; - job_id: string; -} - -export interface XpackMlDeleteDatafeed extends Generic { - datafeed_id: string; - force?: boolean; -} - -export interface XpackMlDeleteExpiredData extends Generic { -} - -export interface XpackMlDeleteFilter extends Generic { - filter_id: string; -} - -export interface XpackMlDeleteForecast extends Generic { - job_id: string; - forecast_id?: string; - allow_no_forecasts?: boolean; - timeout?: string; -} - -export interface XpackMlDeleteJob extends Generic { - job_id: string; - force?: boolean; - wait_for_completion?: boolean; -} - -export interface XpackMlDeleteModelSnapshot extends Generic { - job_id: string; - snapshot_id: string; -} - -export interface XpackMlFindFileStructure extends Generic { - lines_to_sample?: number; - timeout?: string; - charset?: string; - format?: 'ndjson' | 'xml' | 'delimited' | 'semi_structured_text'; - has_header_row?: boolean; - column_names?: string | string[]; - delimiter?: string; - quote?: string; - should_trim_fields?: boolean; - grok_pattern?: string; - timestamp_field?: string; - timestamp_format?: string; - explain?: boolean; - body: any; -} - -export interface XpackMlFlushJob extends Generic { - job_id: string; - calc_interim?: boolean; - start?: string; - end?: string; - advance_time?: string; - skip_time?: string; - body?: any; -} - -export interface XpackMlForecast extends Generic { - job_id: string; - duration?: string; - expires_in?: string; -} - -export interface XpackMlGetBuckets extends Generic { - job_id: string; - timestamp?: string; - expand?: boolean; - exclude_interim?: boolean; - from?: number; - size?: number; - start?: string; - end?: string; - anomaly_score?: number; - sort?: string; - desc?: boolean; - body?: any; -} - -export interface XpackMlGetCalendarEvents extends Generic { - calendar_id: string; - job_id?: string; - start?: string; - end?: string; - from?: number; - size?: number; -} - -export interface XpackMlGetCalendars extends Generic { - calendar_id?: string; - from?: number; - size?: number; -} - -export interface XpackMlGetCategories extends Generic { - job_id: string; - category_id?: number; - from?: number; - size?: number; - body?: any; -} - -export interface XpackMlGetDatafeedStats extends Generic { - datafeed_id?: string; - allow_no_datafeeds?: boolean; -} - -export interface XpackMlGetDatafeeds extends Generic { - datafeed_id?: string; - allow_no_datafeeds?: boolean; -} - -export interface XpackMlGetFilters extends Generic { - filter_id?: string; - from?: number; - size?: number; -} - -export interface XpackMlGetInfluencers extends Generic { - job_id: string; - exclude_interim?: boolean; - from?: number; - size?: number; - start?: string; - end?: string; - influencer_score?: number; - sort?: string; - desc?: boolean; - body?: any; -} - -export interface XpackMlGetJobStats extends Generic { - job_id?: string; - allow_no_jobs?: boolean; -} - -export interface XpackMlGetJobs extends Generic { - job_id?: string; - allow_no_jobs?: boolean; -} - -export interface XpackMlGetModelSnapshots extends Generic { - job_id: string; - snapshot_id?: string; - from?: number; - size?: number; - start?: string; - end?: string; - sort?: string; - desc?: boolean; - body?: any; -} - -export interface XpackMlGetOverallBuckets extends Generic { - job_id: string; - top_n?: number; - bucket_span?: string; - overall_score?: number; - exclude_interim?: boolean; - start?: string; - end?: string; - allow_no_jobs?: boolean; - body?: any; -} - -export interface XpackMlGetRecords extends Generic { - job_id: string; - exclude_interim?: boolean; - from?: number; - size?: number; - start?: string; - end?: string; - record_score?: number; - sort?: string; - desc?: boolean; - body?: any; -} - -export interface XpackMlInfo extends Generic { -} - -export interface XpackMlOpenJob extends Generic { - job_id: string; - ignore_downtime?: boolean; - timeout?: string; -} - -export interface XpackMlPostCalendarEvents extends Generic { - calendar_id: string; - body: any; -} - -export interface XpackMlPostData extends Generic { - job_id: string; - reset_start?: string; - reset_end?: string; - body: any; -} - -export interface XpackMlPreviewDatafeed extends Generic { - datafeed_id: string; -} - -export interface XpackMlPutCalendar extends Generic { - calendar_id: string; - body?: any; -} - -export interface XpackMlPutCalendarJob extends Generic { - calendar_id: string; - job_id: string; -} - -export interface XpackMlPutDatafeed extends Generic { - datafeed_id: string; - body: any; -} - -export interface XpackMlPutFilter extends Generic { - filter_id: string; - body: any; -} - -export interface XpackMlPutJob extends Generic { - job_id: string; - body: any; -} - -export interface XpackMlRevertModelSnapshot extends Generic { - job_id: string; - snapshot_id: string; - delete_intervening_results?: boolean; - body?: any; -} - -export interface XpackMlStartDatafeed extends Generic { - datafeed_id: string; - start?: string; - end?: string; - timeout?: string; - body?: any; -} - -export interface XpackMlStopDatafeed extends Generic { - datafeed_id: string; - allow_no_datafeeds?: boolean; - force?: boolean; - timeout?: string; -} - -export interface XpackMlUpdateDatafeed extends Generic { - datafeed_id: string; - body: any; -} - -export interface XpackMlUpdateFilter extends Generic { - filter_id: string; - body: any; -} - -export interface XpackMlUpdateJob extends Generic { - job_id: string; - body: any; -} - -export interface XpackMlUpdateModelSnapshot extends Generic { - job_id: string; - snapshot_id: string; - body: any; -} - -export interface XpackMlValidate extends Generic { - body: any; -} - -export interface XpackMlValidateDetector extends Generic { - body: any; -} - -export interface XpackMonitoringBulk extends Generic { - type?: string; - system_id?: string; - system_api_version?: string; - interval?: string; - body: any; -} - export interface XpackRollupDeleteJob extends Generic { id: string; } @@ -1705,6 +1881,8 @@ export interface XpackRollupPutJob extends Generic { export interface XpackRollupRollupSearch extends Generic { index: string; type?: string; + typed_keys?: boolean; + rest_total_hits_as_int?: boolean; body: any; } @@ -1714,111 +1892,8 @@ export interface XpackRollupStartJob extends Generic { export interface XpackRollupStopJob extends Generic { id: string; -} - -export interface XpackSecurityAuthenticate extends Generic { -} - -export interface XpackSecurityChangePassword extends Generic { - username?: string; - refresh?: 'true' | 'false' | 'wait_for'; - body: any; -} - -export interface XpackSecurityClearCachedRealms extends Generic { - realms: string | string[]; - usernames?: string | string[]; -} - -export interface XpackSecurityClearCachedRoles extends Generic { - name: string | string[]; -} - -export interface XpackSecurityDeletePrivileges extends Generic { - application: string; - name: string; - refresh?: 'true' | 'false' | 'wait_for'; -} - -export interface XpackSecurityDeleteRole extends Generic { - name: string; - refresh?: 'true' | 'false' | 'wait_for'; -} - -export interface XpackSecurityDeleteRoleMapping extends Generic { - name: string; - refresh?: 'true' | 'false' | 'wait_for'; -} - -export interface XpackSecurityDeleteUser extends Generic { - username: string; - refresh?: 'true' | 'false' | 'wait_for'; -} - -export interface XpackSecurityDisableUser extends Generic { - username?: string; - refresh?: 'true' | 'false' | 'wait_for'; -} - -export interface XpackSecurityEnableUser extends Generic { - username?: string; - refresh?: 'true' | 'false' | 'wait_for'; -} - -export interface XpackSecurityGetPrivileges extends Generic { - application?: string; - name?: string; -} - -export interface XpackSecurityGetRole extends Generic { - name?: string; -} - -export interface XpackSecurityGetRoleMapping extends Generic { - name?: string; -} - -export interface XpackSecurityGetToken extends Generic { - body: any; -} - -export interface XpackSecurityGetUser extends Generic { - username?: string | string[]; -} - -export interface XpackSecurityGetUserPrivileges extends Generic { -} - -export interface XpackSecurityHasPrivileges extends Generic { - user?: string; - body: any; -} - -export interface XpackSecurityInvalidateToken extends Generic { - body: any; -} - -export interface XpackSecurityPutPrivileges extends Generic { - refresh?: 'true' | 'false' | 'wait_for'; - body: any; -} - -export interface XpackSecurityPutRole extends Generic { - name: string; - refresh?: 'true' | 'false' | 'wait_for'; - body: any; -} - -export interface XpackSecurityPutRoleMapping extends Generic { - name: string; - refresh?: 'true' | 'false' | 'wait_for'; - body: any; -} - -export interface XpackSecurityPutUser extends Generic { - username: string; - refresh?: 'true' | 'false' | 'wait_for'; - body: any; + wait_for_completion?: boolean; + timeout?: string; } export interface XpackSqlClearCursor extends Generic { @@ -1834,9 +1909,6 @@ export interface XpackSqlTranslate extends Generic { body: any; } -export interface XpackSslCertificates extends Generic { -} - export interface XpackUsage extends Generic { master_timeout?: string; } @@ -1844,22 +1916,18 @@ export interface XpackUsage extends Generic { export interface XpackWatcherAckWatch extends Generic { watch_id: string; action_id?: string | string[]; - master_timeout?: string; } export interface XpackWatcherActivateWatch extends Generic { watch_id: string; - master_timeout?: string; } export interface XpackWatcherDeactivateWatch extends Generic { watch_id: string; - master_timeout?: string; } export interface XpackWatcherDeleteWatch extends Generic { id: string; - master_timeout?: string; } export interface XpackWatcherExecuteWatch extends Generic { @@ -1874,20 +1942,16 @@ export interface XpackWatcherGetWatch extends Generic { export interface XpackWatcherPutWatch extends Generic { id: string; - master_timeout?: string; active?: boolean; version?: number; body?: any; } -export interface XpackWatcherRestart extends Generic { -} - export interface XpackWatcherStart extends Generic { } export interface XpackWatcherStats extends Generic { - metric?: '_all' | 'queued_watches' | 'pending_watches'; + metric?: '_all' | 'queued_watches' | 'current_watches' | 'pending_watches'; emit_stacktraces?: boolean; } diff --git a/index.d.ts b/index.d.ts index 76c140c35..55c878df9 100644 --- a/index.d.ts +++ b/index.d.ts @@ -128,6 +128,25 @@ declare class Client extends EventEmitter { getScript: ApiMethod get_source: ApiMethod getSource: ApiMethod + ilm: { + delete_lifecycle: ApiMethod + deleteLifecycle: ApiMethod + explain_lifecycle: ApiMethod + explainLifecycle: ApiMethod + get_lifecycle: ApiMethod + getLifecycle: ApiMethod + get_status: ApiMethod + getStatus: ApiMethod + move_to_step: ApiMethod + moveToStep: ApiMethod + put_lifecycle: ApiMethod + putLifecycle: ApiMethod + remove_policy: ApiMethod + removePolicy: ApiMethod + retry: ApiMethod + start: ApiMethod + stop: ApiMethod + } index: ApiMethod indices: { analyze: ApiMethod @@ -151,6 +170,7 @@ declare class Client extends EventEmitter { flush_synced: ApiMethod flushSynced: ApiMethod forcemerge: ApiMethod + freeze: ApiMethod get: ApiMethod get_alias: ApiMethod getAlias: ApiMethod @@ -182,6 +202,7 @@ declare class Client extends EventEmitter { shrink: ApiMethod split: ApiMethod stats: ApiMethod + unfreeze: ApiMethod update_aliases: ApiMethod updateAliases: ApiMethod upgrade: ApiMethod @@ -201,6 +222,98 @@ declare class Client extends EventEmitter { simulate: ApiMethod } mget: ApiMethod + ml: { + close_job: ApiMethod + closeJob: ApiMethod + delete_calendar: ApiMethod + deleteCalendar: ApiMethod + delete_calendar_event: ApiMethod + deleteCalendarEvent: ApiMethod + delete_calendar_job: ApiMethod + deleteCalendarJob: ApiMethod + delete_datafeed: ApiMethod + deleteDatafeed: ApiMethod + delete_expired_data: ApiMethod + deleteExpiredData: ApiMethod + delete_filter: ApiMethod + deleteFilter: ApiMethod + delete_forecast: ApiMethod + deleteForecast: ApiMethod + delete_job: ApiMethod + deleteJob: ApiMethod + delete_model_snapshot: ApiMethod + deleteModelSnapshot: ApiMethod + find_file_structure: ApiMethod + findFileStructure: ApiMethod + flush_job: ApiMethod + flushJob: ApiMethod + forecast: ApiMethod + get_buckets: ApiMethod + getBuckets: ApiMethod + get_calendar_events: ApiMethod + getCalendarEvents: ApiMethod + get_calendars: ApiMethod + getCalendars: ApiMethod + get_categories: ApiMethod + getCategories: ApiMethod + get_datafeed_stats: ApiMethod + getDatafeedStats: ApiMethod + get_datafeeds: ApiMethod + getDatafeeds: ApiMethod + get_filters: ApiMethod + getFilters: ApiMethod + get_influencers: ApiMethod + getInfluencers: ApiMethod + get_job_stats: ApiMethod + getJobStats: ApiMethod + get_jobs: ApiMethod + getJobs: ApiMethod + get_model_snapshots: ApiMethod + getModelSnapshots: ApiMethod + get_overall_buckets: ApiMethod + getOverallBuckets: ApiMethod + get_records: ApiMethod + getRecords: ApiMethod + info: ApiMethod + open_job: ApiMethod + openJob: ApiMethod + post_calendar_events: ApiMethod + postCalendarEvents: ApiMethod + post_data: ApiMethod + postData: ApiMethod + preview_datafeed: ApiMethod + previewDatafeed: ApiMethod + put_calendar: ApiMethod + putCalendar: ApiMethod + put_calendar_job: ApiMethod + putCalendarJob: ApiMethod + put_datafeed: ApiMethod + putDatafeed: ApiMethod + put_filter: ApiMethod + putFilter: ApiMethod + put_job: ApiMethod + putJob: ApiMethod + revert_model_snapshot: ApiMethod + revertModelSnapshot: ApiMethod + start_datafeed: ApiMethod + startDatafeed: ApiMethod + stop_datafeed: ApiMethod + stopDatafeed: ApiMethod + update_datafeed: ApiMethod + updateDatafeed: ApiMethod + update_filter: ApiMethod + updateFilter: ApiMethod + update_job: ApiMethod + updateJob: ApiMethod + update_model_snapshot: ApiMethod + updateModelSnapshot: ApiMethod + validate: ApiMethod + validate_detector: ApiMethod + validateDetector: ApiMethod + } + monitoring: { + bulk: ApiMethod + } msearch: ApiMethod msearch_template: ApiMethod msearchTemplate: ApiMethod @@ -232,6 +345,51 @@ declare class Client extends EventEmitter { searchShards: ApiMethod search_template: ApiMethod searchTemplate: ApiMethod + security: { + authenticate: ApiMethod + change_password: ApiMethod + changePassword: ApiMethod + clear_cached_realms: ApiMethod + clearCachedRealms: ApiMethod + clear_cached_roles: ApiMethod + clearCachedRoles: ApiMethod + delete_privileges: ApiMethod + deletePrivileges: ApiMethod + delete_role: ApiMethod + deleteRole: ApiMethod + delete_role_mapping: ApiMethod + deleteRoleMapping: ApiMethod + delete_user: ApiMethod + deleteUser: ApiMethod + disable_user: ApiMethod + disableUser: ApiMethod + enable_user: ApiMethod + enableUser: ApiMethod + get_privileges: ApiMethod + getPrivileges: ApiMethod + get_role: ApiMethod + getRole: ApiMethod + get_role_mapping: ApiMethod + getRoleMapping: ApiMethod + get_token: ApiMethod + getToken: ApiMethod + get_user: ApiMethod + getUser: ApiMethod + get_user_privileges: ApiMethod + getUserPrivileges: ApiMethod + has_privileges: ApiMethod + hasPrivileges: ApiMethod + invalidate_token: ApiMethod + invalidateToken: ApiMethod + put_privileges: ApiMethod + putPrivileges: ApiMethod + put_role: ApiMethod + putRole: ApiMethod + put_role_mapping: ApiMethod + putRoleMapping: ApiMethod + put_user: ApiMethod + putUser: ApiMethod + } snapshot: { create: ApiMethod create_repository: ApiMethod @@ -247,6 +405,9 @@ declare class Client extends EventEmitter { verify_repository: ApiMethod verifyRepository: ApiMethod } + ssl: { + certificates: ApiMethod + } tasks: { cancel: ApiMethod get: ApiMethod @@ -282,98 +443,6 @@ declare class Client extends EventEmitter { getAssistance: ApiMethod upgrade: ApiMethod } - ml: { - close_job: ApiMethod - closeJob: ApiMethod - delete_calendar: ApiMethod - deleteCalendar: ApiMethod - delete_calendar_event: ApiMethod - deleteCalendarEvent: ApiMethod - delete_calendar_job: ApiMethod - deleteCalendarJob: ApiMethod - delete_datafeed: ApiMethod - deleteDatafeed: ApiMethod - delete_expired_data: ApiMethod - deleteExpiredData: ApiMethod - delete_filter: ApiMethod - deleteFilter: ApiMethod - delete_forecast: ApiMethod - deleteForecast: ApiMethod - delete_job: ApiMethod - deleteJob: ApiMethod - delete_model_snapshot: ApiMethod - deleteModelSnapshot: ApiMethod - find_file_structure: ApiMethod - findFileStructure: ApiMethod - flush_job: ApiMethod - flushJob: ApiMethod - forecast: ApiMethod - get_buckets: ApiMethod - getBuckets: ApiMethod - get_calendar_events: ApiMethod - getCalendarEvents: ApiMethod - get_calendars: ApiMethod - getCalendars: ApiMethod - get_categories: ApiMethod - getCategories: ApiMethod - get_datafeed_stats: ApiMethod - getDatafeedStats: ApiMethod - get_datafeeds: ApiMethod - getDatafeeds: ApiMethod - get_filters: ApiMethod - getFilters: ApiMethod - get_influencers: ApiMethod - getInfluencers: ApiMethod - get_job_stats: ApiMethod - getJobStats: ApiMethod - get_jobs: ApiMethod - getJobs: ApiMethod - get_model_snapshots: ApiMethod - getModelSnapshots: ApiMethod - get_overall_buckets: ApiMethod - getOverallBuckets: ApiMethod - get_records: ApiMethod - getRecords: ApiMethod - info: ApiMethod - open_job: ApiMethod - openJob: ApiMethod - post_calendar_events: ApiMethod - postCalendarEvents: ApiMethod - post_data: ApiMethod - postData: ApiMethod - preview_datafeed: ApiMethod - previewDatafeed: ApiMethod - put_calendar: ApiMethod - putCalendar: ApiMethod - put_calendar_job: ApiMethod - putCalendarJob: ApiMethod - put_datafeed: ApiMethod - putDatafeed: ApiMethod - put_filter: ApiMethod - putFilter: ApiMethod - put_job: ApiMethod - putJob: ApiMethod - revert_model_snapshot: ApiMethod - revertModelSnapshot: ApiMethod - start_datafeed: ApiMethod - startDatafeed: ApiMethod - stop_datafeed: ApiMethod - stopDatafeed: ApiMethod - update_datafeed: ApiMethod - updateDatafeed: ApiMethod - update_filter: ApiMethod - updateFilter: ApiMethod - update_job: ApiMethod - updateJob: ApiMethod - update_model_snapshot: ApiMethod - updateModelSnapshot: ApiMethod - validate: ApiMethod - validate_detector: ApiMethod - validateDetector: ApiMethod - } - monitoring: { - bulk: ApiMethod - } rollup: { delete_job: ApiMethod deleteJob: ApiMethod @@ -392,60 +461,12 @@ declare class Client extends EventEmitter { stop_job: ApiMethod stopJob: ApiMethod } - security: { - authenticate: ApiMethod - change_password: ApiMethod - changePassword: ApiMethod - clear_cached_realms: ApiMethod - clearCachedRealms: ApiMethod - clear_cached_roles: ApiMethod - clearCachedRoles: ApiMethod - delete_privileges: ApiMethod - deletePrivileges: ApiMethod - delete_role: ApiMethod - deleteRole: ApiMethod - delete_role_mapping: ApiMethod - deleteRoleMapping: ApiMethod - delete_user: ApiMethod - deleteUser: ApiMethod - disable_user: ApiMethod - disableUser: ApiMethod - enable_user: ApiMethod - enableUser: ApiMethod - get_privileges: ApiMethod - getPrivileges: ApiMethod - get_role: ApiMethod - getRole: ApiMethod - get_role_mapping: ApiMethod - getRoleMapping: ApiMethod - get_token: ApiMethod - getToken: ApiMethod - get_user: ApiMethod - getUser: ApiMethod - get_user_privileges: ApiMethod - getUserPrivileges: ApiMethod - has_privileges: ApiMethod - hasPrivileges: ApiMethod - invalidate_token: ApiMethod - invalidateToken: ApiMethod - put_privileges: ApiMethod - putPrivileges: ApiMethod - put_role: ApiMethod - putRole: ApiMethod - put_role_mapping: ApiMethod - putRoleMapping: ApiMethod - put_user: ApiMethod - putUser: ApiMethod - } sql: { clear_cursor: ApiMethod clearCursor: ApiMethod query: ApiMethod translate: ApiMethod } - ssl: { - certificates: ApiMethod - } usage: ApiMethod watcher: { ack_watch: ApiMethod @@ -462,7 +483,6 @@ declare class Client extends EventEmitter { getWatch: ApiMethod put_watch: ApiMethod putWatch: ApiMethod - restart: ApiMethod start: ApiMethod stats: ApiMethod stop: ApiMethod diff --git a/scripts/es-docker.sh b/scripts/es-docker.sh index 74082aa06..c77bd3c54 100755 --- a/scripts/es-docker.sh +++ b/scripts/es-docker.sh @@ -5,8 +5,10 @@ exec docker run \ -e "node.attr.testattr=test" \ -e "path.repo=/tmp" \ -e "repositories.url.allowed_urls=http://snapshot.*" \ + -e "discovery.type=single-node" \ -p 9200:9200 \ - docker.elastic.co/elasticsearch/elasticsearch:6.5.0 + docker.elastic.co/elasticsearch/elasticsearch:7.0.0-alpha2 + # docker.elastic.co/elasticsearch/elasticsearch:6.5.4 # -e "xpack.security.enabled=true" \ # -e "ELASTIC_PASSWORD=passw0rd" \ diff --git a/scripts/utils/generate.js b/scripts/utils/generate.js index c9be7dce2..fade273a4 100644 --- a/scripts/utils/generate.js +++ b/scripts/utils/generate.js @@ -7,8 +7,11 @@ const allowedMethods = { } // list of apis that does not need any kind of validation -// because of how the url is built +// because of how the url is built or the `type` handling in ES7 const noPathValidation = [ + 'exists', + 'explain', + 'get', 'indices.get_alias', 'indices.exists_alias', 'indices.get_field_mapping', @@ -19,7 +22,9 @@ const noPathValidation = [ 'nodes.info', 'nodes.stats', 'nodes.usage', - 'tasks.cancel' + 'tasks.cancel', + 'termvectors', + 'update' ] // apis that uses bulkBody property @@ -36,7 +41,7 @@ function generate (spec, common) { .replace(/_([a-z])/g, k => k[1].toUpperCase()) const methods = spec[api].methods - const { path, paths, parts, params } = spec[api].url + const { paths, parts, params } = spec[api].url const acceptedQuerystring = [] const required = [] @@ -131,11 +136,14 @@ function generate (spec, common) { ignore = [ignore] } + + var path = '' + ${buildPath(api)} + // build request object - const parts = ${getUrlParts()} const request = { method, - ${buildPath(api)} + path, ${genBody(api, methods, spec[api].body)} querystring } @@ -241,91 +249,76 @@ function generate (spec, common) { } function buildPath () { - // if the default path is static, we should add a dynamic check - // to figure out which path to use, see cluster.stats - // otherwise we can skip that check - const p1 = paths - .reduce((a, b) => a.split('/').length > b.split('/').length ? a : b) - .split('/') - .filter(chunk => !chunk.startsWith('{')) - .join('/') - - const p2 = path - .split('/') - .filter(chunk => !chunk.startsWith('{')) - .join('/') - - if (p1 === p2 || !needsPathValidation(api)) { - return `path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),`.trim() + const toCamelCase = str => { + return str[0] === '_' + ? '_' + str.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase()) + : str.replace(/_([a-z])/g, k => k[1].toUpperCase()) } - const dynamicParts = checkDynamicParts() - if (dynamicParts.length) { - return ` - path: ${dynamicParts} - ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') - : '${path}', - `.trim() - } else { - return `path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),`.trim() + const genAccessKey = str => { + const camelStr = toCamelCase(str) + return camelStr === str + ? `params['${str}']` + : `params['${str}'] || params['${camelStr}']` } - } - function checkDynamicParts () { - const chunks = paths - .reduce((a, b) => a.split('/').length > b.split('/').length ? a : b) - .split('/') - .filter(Boolean) + const genCheck = path => { + return path + .split('/') + .filter(Boolean) + .map(p => p.startsWith('{') ? `(${genAccessKey(p.slice(1, -1))}) != null` : false) + .filter(Boolean) + .join(' && ') + } - var str = '' - chunks.forEach((chunk, index) => { - if (chunk.startsWith('{') && chunk.endsWith('}')) { - chunk = chunk.slice(1, -1) - // url parts can be declared in camelCase fashion - var camelCased = chunk[0] === '_' - ? '_' + chunk.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase()) - : chunk.replace(/_([a-z])/g, k => k[1].toUpperCase()) + const genPath = path => { + path = path + .split('/') + .filter(Boolean) + .map(p => p.startsWith('{') ? `encodeURIComponent(${genAccessKey(p.slice(1, -1))})` : `'${p}'`) + .join(' + \'/\' + ') + return path.length > 0 ? ('\'/\' + ' + path) : '\'/\'' + } - if (chunk === camelCased) { - str += `params['${chunk}'] != null && ` - } else { - str += `(params['${chunk}'] || params['${camelCased}']) != null && ` + var code = '' + var hasStaticPath = false + var singlePathComponent = false + paths + .filter(path => { + if (path.indexOf('{') > -1) return true + if (hasStaticPath === false) { + hasStaticPath = true + return true } - } - }) - - // removes last ' && ' - return str.slice(0, -4) - } - - function getUrlParts () { - const chunks = paths - .reduce((a, b) => a.split('/').length > b.split('/').length ? a : b) - .split('/') - .filter(Boolean) - var str = '[' - chunks.forEach((chunk, index) => { - if (chunk.startsWith('{') && chunk.endsWith('}')) { - chunk = chunk.slice(1, -1) - // url parts can be declared in camelCase fashion - var camelCased = chunk[0] === '_' - ? '_' + chunk.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase()) - : chunk.replace(/_([a-z])/g, k => k[1].toUpperCase()) - - if (chunk === camelCased) { - str += `params['${chunk}']` + return false + }) + .sort((a, b) => (b.split('{').length + b.split('/').length) - (a.split('{').length + a.split('/').length)) + .forEach((path, index, arr) => { + if (arr.length === 1) { + singlePathComponent = true + code += ` + path = ${genPath(path)} + ` + } else if (index === 0) { + code += ` + if (${genCheck(path)}) { + path = ${genPath(path)} + ` + } else if (index === arr.length - 1) { + code += ` + } else { + path = ${genPath(path)} + ` } else { - str += `params['${chunk}'] || params['${camelCased}']` + code += ` + } else if (${genCheck(path)}) { + path = ${genPath(path)} + ` } - } else { - str += `'${chunk}'` - } - if (index !== chunks.length - 1) { - str += ', ' - } - }) - str += ']' - return str + }) + + code += singlePathComponent ? '' : '}' + return code } } diff --git a/test/integration/index.js b/test/integration/index.js index 67f5a1473..e3625a8f6 100644 --- a/test/integration/index.js +++ b/test/integration/index.js @@ -15,6 +15,14 @@ const esRepo = 'https://github.com/elastic/elasticsearch.git' const esFolder = join(__dirname, '..', '..', 'elasticsearch') const yamlFolder = join(esFolder, 'rest-api-spec', 'src', 'main', 'resources', 'rest-api-spec', 'test') // const xPackYamlFolder = join(esFolder, 'x-pack', 'plugin', 'src', 'test', 'resources', 'rest-api-spec', 'test') +const customSkips = [ + // skipping because we are booting ES with `discovery.type=single-node` + // and this test will fail because of this configuration + 'nodes.stats/30_discovery.yml', + // the expected error is returning a 503, + // which triggers a retry and the node to be marked as dead + 'search.aggregation/240_max_buckets.yml' +] function Runner (opts) { if (!(this instanceof Runner)) { @@ -35,11 +43,14 @@ Runner.prototype.start = function () { const parse = this.parse.bind(this) const client = this.client - // client.on('response', (request, response) => { - // console.log('\n\n') - // console.log('REQUEST', request) - // console.log('\n') - // console.log('RESPONSE', response) + // client.on('response', (err, meta) => { + // console.log('Request', meta.request) + // if (err) { + // console.log('Error', err) + // } else { + // console.log('Response', JSON.stringify(meta.response, null, 2)) + // } + // console.log() // }) // Get the build hash of Elasticsearch @@ -72,6 +83,9 @@ Runner.prototype.start = function () { files.forEach(runTestFile.bind(this)) function runTestFile (file) { + for (var i = 0; i < customSkips.length; i++) { + if (file.endsWith(customSkips[i])) return + } // create a subtest for the specific folder tap.test(file.slice(file.indexOf(`${sep}elasticsearch${sep}`)), { jobs: 1 }, tap1 => { // read the yaml file @@ -237,7 +251,7 @@ if (require.main === module) { default: { // node: 'http://elastic:passw0rd@localhost:9200', node: process.env.TEST_ES_SERVER || 'http://localhost:9200', - version: '6.5', + version: '7.0', bailout: false } }) diff --git a/test/unit/connection.test.js b/test/unit/connection.test.js index b2e8d92d6..8eb248c9b 100644 --- a/test/unit/connection.test.js +++ b/test/unit/connection.test.js @@ -582,7 +582,7 @@ test('Should disallow two-byte characters in URL path', t => { url: new URL('http://localhost:9200') }) connection.request({ - path: '/thisisinvalid' + encodeURIComponent('\uffe2'), + path: '/thisisinvalid\uffe2', method: 'GET' }, (err, res) => { t.strictEqual( From 23cfe11e44c49a9b62aaf0cc793b551eba7c854d Mon Sep 17 00:00:00 2001 From: Tomas Della Vedova Date: Tue, 29 Jan 2019 17:31:43 +0100 Subject: [PATCH 095/172] Unknown parameters handling (#761) --- api/api/bulk.js | 124 ++++----- api/api/cat.aliases.js | 110 ++++---- api/api/cat.allocation.js | 113 ++++----- api/api/cat.count.js | 110 ++++---- api/api/cat.fielddata.js | 116 +++++---- api/api/cat.health.js | 109 ++++---- api/api/cat.help.js | 90 +++---- api/api/cat.indices.js | 119 +++++---- api/api/cat.master.js | 106 ++++---- api/api/cat.nodeattrs.js | 106 ++++---- api/api/cat.nodes.js | 110 ++++---- api/api/cat.pending_tasks.js | 106 ++++---- api/api/cat.plugins.js | 106 ++++---- api/api/cat.recovery.js | 110 ++++---- api/api/cat.repositories.js | 106 ++++---- api/api/cat.segments.js | 106 ++++---- api/api/cat.shards.js | 113 ++++----- api/api/cat.snapshots.js | 111 ++++---- api/api/cat.tasks.js | 113 ++++----- api/api/cat.templates.js | 110 ++++---- api/api/cat.thread_pool.js | 113 ++++----- api/api/ccr.delete_auto_follow_pattern.js | 75 +++--- api/api/ccr.follow.js | 75 +++--- api/api/ccr.follow_stats.js | 73 +++--- api/api/ccr.get_auto_follow_pattern.js | 75 +++--- api/api/ccr.pause_follow.js | 75 +++--- api/api/ccr.put_auto_follow_pattern.js | 75 +++--- api/api/ccr.resume_follow.js | 75 +++--- api/api/ccr.stats.js | 71 +++--- api/api/ccr.unfollow.js | 75 +++--- api/api/clear_scroll.js | 90 ++++--- api/api/cluster.allocation_explain.js | 94 +++---- api/api/cluster.get_settings.js | 99 ++++---- api/api/cluster.health.js | 125 ++++----- api/api/cluster.pending_tasks.js | 91 +++---- api/api/cluster.put_settings.js | 97 +++---- api/api/cluster.remote_info.js | 84 +++--- api/api/cluster.reroute.js | 107 ++++---- api/api/cluster.state.js | 123 ++++----- api/api/cluster.stats.js | 95 +++---- api/api/count.js | 144 +++++------ api/api/create.js | 114 ++++----- api/api/delete.js | 113 +++++---- api/api/delete_by_query.js | 203 +++++++-------- api/api/delete_by_query_rethrottle.js | 90 ++++--- api/api/delete_script.js | 93 +++---- api/api/exists.js | 127 +++++----- api/api/exists_source.js | 119 +++++---- api/api/explain.js | 136 +++++----- api/api/field_caps.js | 103 ++++---- api/api/get.js | 135 +++++----- api/api/get_script.js | 90 ++++--- api/api/get_source.js | 119 +++++---- api/api/ilm.delete_lifecycle.js | 73 +++--- api/api/ilm.explain_lifecycle.js | 73 +++--- api/api/ilm.get_lifecycle.js | 75 +++--- api/api/ilm.get_status.js | 71 +++--- api/api/ilm.move_to_step.js | 75 +++--- api/api/ilm.put_lifecycle.js | 75 +++--- api/api/ilm.remove_policy.js | 73 +++--- api/api/ilm.retry.js | 73 +++--- api/api/ilm.start.js | 71 +++--- api/api/ilm.stop.js | 71 +++--- api/api/index.js | 130 +++++----- api/api/indices.analyze.js | 93 +++---- api/api/indices.clear_cache.js | 115 ++++----- api/api/indices.close.js | 105 ++++---- api/api/indices.create.js | 103 ++++---- api/api/indices.delete.js | 105 ++++---- api/api/indices.delete_alias.js | 97 +++---- api/api/indices.delete_template.js | 93 +++---- api/api/indices.exists.js | 109 ++++---- api/api/indices.exists_alias.js | 105 ++++---- api/api/indices.exists_template.js | 97 +++---- api/api/indices.exists_type.js | 101 ++++---- api/api/indices.flush.js | 107 ++++---- api/api/indices.flush_synced.js | 100 ++++---- api/api/indices.forcemerge.js | 111 ++++---- api/api/indices.freeze.js | 92 ++++--- api/api/indices.get.js | 113 +++++---- api/api/indices.get_alias.js | 111 ++++---- api/api/indices.get_field_mapping.js | 117 +++++---- api/api/indices.get_mapping.js | 119 ++++----- api/api/indices.get_settings.js | 123 ++++----- api/api/indices.get_template.js | 99 ++++---- api/api/indices.get_upgrade.js | 100 ++++---- api/api/indices.open.js | 109 ++++---- api/api/indices.put_alias.js | 99 ++++---- api/api/indices.put_mapping.js | 139 +++++----- api/api/indices.put_settings.js | 117 +++++---- api/api/indices.put_template.js | 105 ++++---- api/api/indices.recovery.js | 95 +++---- api/api/indices.refresh.js | 100 ++++---- api/api/indices.rollover.js | 107 ++++---- api/api/indices.segments.js | 103 ++++---- api/api/indices.shard_stores.js | 103 ++++---- api/api/indices.shrink.js | 103 ++++---- api/api/indices.split.js | 103 ++++---- api/api/indices.stats.js | 120 ++++----- api/api/indices.unfreeze.js | 92 ++++--- api/api/indices.update_aliases.js | 93 +++---- api/api/indices.upgrade.js | 108 ++++---- api/api/indices.validate_query.js | 136 +++++----- api/api/info.js | 84 +++--- api/api/ingest.delete_pipeline.js | 93 +++---- api/api/ingest.get_pipeline.js | 92 +++---- api/api/ingest.processor_grok.js | 84 +++--- api/api/ingest.put_pipeline.js | 95 +++---- api/api/ingest.simulate.js | 93 +++---- api/api/mget.js | 121 ++++----- api/api/ml.close_job.js | 82 +++--- api/api/ml.delete_calendar.js | 73 +++--- api/api/ml.delete_calendar_event.js | 73 +++--- api/api/ml.delete_calendar_job.js | 73 +++--- api/api/ml.delete_datafeed.js | 73 +++--- api/api/ml.delete_expired_data.js | 71 +++--- api/api/ml.delete_filter.js | 73 +++--- api/api/ml.delete_forecast.js | 81 +++--- api/api/ml.delete_job.js | 76 +++--- api/api/ml.delete_model_snapshot.js | 73 +++--- api/api/ml.find_file_structure.js | 116 +++++---- api/api/ml.flush_job.js | 89 ++++--- api/api/ml.forecast.js | 76 +++--- api/api/ml.get_buckets.js | 105 ++++---- api/api/ml.get_calendar_events.js | 86 ++++--- api/api/ml.get_calendars.js | 78 +++--- api/api/ml.get_categories.js | 82 +++--- api/api/ml.get_datafeed_stats.js | 75 +++--- api/api/ml.get_datafeeds.js | 75 +++--- api/api/ml.get_filters.js | 78 +++--- api/api/ml.get_influencers.js | 98 +++---- api/api/ml.get_job_stats.js | 75 +++--- api/api/ml.get_jobs.js | 75 +++--- api/api/ml.get_model_snapshots.js | 94 +++---- api/api/ml.get_overall_buckets.js | 97 +++---- api/api/ml.get_records.js | 98 +++---- api/api/ml.info.js | 71 +++--- api/api/ml.open_job.js | 73 +++--- api/api/ml.post_calendar_events.js | 75 +++--- api/api/ml.post_data.js | 79 +++--- api/api/ml.preview_datafeed.js | 73 +++--- api/api/ml.put_calendar.js | 75 +++--- api/api/ml.put_calendar_job.js | 73 +++--- api/api/ml.put_datafeed.js | 75 +++--- api/api/ml.put_filter.js | 75 +++--- api/api/ml.put_job.js | 75 +++--- api/api/ml.revert_model_snapshot.js | 75 +++--- api/api/ml.start_datafeed.js | 81 +++--- api/api/ml.stop_datafeed.js | 82 +++--- api/api/ml.update_datafeed.js | 75 +++--- api/api/ml.update_filter.js | 75 +++--- api/api/ml.update_job.js | 75 +++--- api/api/ml.update_model_snapshot.js | 75 +++--- api/api/ml.validate.js | 73 +++--- api/api/ml.validate_detector.js | 73 +++--- api/api/monitoring.bulk.js | 85 ++++--- api/api/msearch.js | 118 +++++---- api/api/msearch_template.js | 110 ++++---- api/api/mtermvectors.js | 136 +++++----- api/api/nodes.hot_threads.js | 119 ++++----- api/api/nodes.info.js | 103 ++++---- api/api/nodes.reload_secure_settings.js | 91 +++---- api/api/nodes.stats.js | 131 +++++----- api/api/nodes.usage.js | 99 ++++---- api/api/ping.js | 84 +++--- api/api/put_script.js | 102 ++++---- api/api/rank_eval.js | 102 ++++---- api/api/reindex.js | 107 ++++---- api/api/reindex_rethrottle.js | 90 ++++--- api/api/render_search_template.js | 90 ++++--- api/api/scripts_painless_execute.js | 86 ++++--- api/api/scroll.js | 101 ++++---- api/api/search.js | 239 +++++++++--------- api/api/search_shards.js | 109 ++++---- api/api/search_template.js | 137 +++++----- api/api/security.authenticate.js | 71 +++--- api/api/security.change_password.js | 77 +++--- api/api/security.clear_cached_realms.js | 73 +++--- api/api/security.clear_cached_roles.js | 73 +++--- api/api/security.delete_privileges.js | 73 +++--- api/api/security.delete_role.js | 73 +++--- api/api/security.delete_role_mapping.js | 73 +++--- api/api/security.delete_user.js | 73 +++--- api/api/security.disable_user.js | 73 +++--- api/api/security.enable_user.js | 73 +++--- api/api/security.get_privileges.js | 73 +++--- api/api/security.get_role.js | 75 +++--- api/api/security.get_role_mapping.js | 75 +++--- api/api/security.get_token.js | 73 +++--- api/api/security.get_user.js | 75 +++--- api/api/security.get_user_privileges.js | 71 +++--- api/api/security.has_privileges.js | 77 +++--- api/api/security.invalidate_token.js | 73 +++--- api/api/security.put_privileges.js | 73 +++--- api/api/security.put_role.js | 75 +++--- api/api/security.put_role_mapping.js | 75 +++--- api/api/security.put_user.js | 75 +++--- api/api/snapshot.create.js | 96 +++---- api/api/snapshot.create_repository.js | 98 +++---- api/api/snapshot.delete.js | 90 ++++--- api/api/snapshot.delete_repository.js | 93 +++---- api/api/snapshot.get.js | 97 +++---- api/api/snapshot.get_repository.js | 95 +++---- api/api/snapshot.restore.js | 96 +++---- api/api/snapshot.status.js | 100 ++++---- api/api/snapshot.verify_repository.js | 93 +++---- api/api/ssl.certificates.js | 71 +++--- api/api/tasks.cancel.js | 98 +++---- api/api/tasks.get.js | 93 +++---- api/api/tasks.list.js | 108 ++++---- api/api/termvectors.js | 139 +++++----- api/api/update.js | 133 +++++----- api/api/update_by_query.js | 210 ++++++++------- api/api/update_by_query_rethrottle.js | 90 ++++--- api/api/xpack.graph.explore.js | 82 +++--- api/api/xpack.info.js | 71 +++--- api/api/xpack.license.delete.js | 71 +++--- api/api/xpack.license.get.js | 71 +++--- api/api/xpack.license.get_basic_status.js | 71 +++--- api/api/xpack.license.get_trial_status.js | 71 +++--- api/api/xpack.license.post.js | 73 +++--- api/api/xpack.license.post_start_basic.js | 71 +++--- api/api/xpack.license.post_start_trial.js | 74 +++--- api/api/xpack.migration.deprecations.js | 75 +++--- api/api/xpack.migration.get_assistance.js | 83 +++--- api/api/xpack.migration.upgrade.js | 75 +++--- api/api/xpack.rollup.delete_job.js | 75 +++--- api/api/xpack.rollup.get_jobs.js | 75 +++--- api/api/xpack.rollup.get_rollup_caps.js | 75 +++--- api/api/xpack.rollup.get_rollup_index_caps.js | 73 +++--- api/api/xpack.rollup.put_job.js | 75 +++--- api/api/xpack.rollup.rollup_search.js | 83 +++--- api/api/xpack.rollup.start_job.js | 75 +++--- api/api/xpack.rollup.stop_job.js | 79 +++--- api/api/xpack.sql.clear_cursor.js | 73 +++--- api/api/xpack.sql.query.js | 73 +++--- api/api/xpack.sql.translate.js | 73 +++--- api/api/xpack.usage.js | 71 +++--- api/api/xpack.watcher.ack_watch.js | 77 +++--- api/api/xpack.watcher.activate_watch.js | 73 +++--- api/api/xpack.watcher.deactivate_watch.js | 73 +++--- api/api/xpack.watcher.delete_watch.js | 73 +++--- api/api/xpack.watcher.execute_watch.js | 77 +++--- api/api/xpack.watcher.get_watch.js | 73 +++--- api/api/xpack.watcher.put_watch.js | 78 +++--- api/api/xpack.watcher.start.js | 71 +++--- api/api/xpack.watcher.stats.js | 78 +++--- api/api/xpack.watcher.stop.js | 71 +++--- lib/Transport.js | 5 +- scripts/utils/generate.js | 126 +++++---- test/integration/test-runner.js | 5 +- test/unit/api.test.js | 28 ++ test/unit/transport.test.js | 39 +++ 253 files changed, 12369 insertions(+), 10836 deletions(-) diff --git a/api/api/bulk.js b/api/api/bulk.js index 9a310438a..660be80f8 100644 --- a/api/api/bulk.js +++ b/api/api/bulk.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildBulk (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -19,6 +22,32 @@ function buildBulk (opts) { * @param {string} pipeline - The pipeline id to preprocess incoming documents with * @param {object} body - The operation definition and data (action-data pairs), separated by newlines */ + + const acceptedQuerystring = [ + 'wait_for_active_shards', + 'refresh', + 'routing', + 'timeout', + 'type', + '_source', + '_source_excludes', + '_source_includes', + 'pipeline', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + waitForActiveShards: 'wait_for_active_shards', + _sourceExcludes: '_source_excludes', + _sourceIncludes: '_source_includes', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function bulk (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -55,68 +84,22 @@ function buildBulk (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'wait_for_active_shards', - 'refresh', - 'routing', - 'timeout', - 'type', - '_source', - '_source_excludes', - '_source_includes', - 'pipeline', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'waitForActiveShards', - 'refresh', - 'routing', - 'timeout', - 'type', - '_source', - '_sourceExcludes', - '_sourceIncludes', - 'pipeline', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'type']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -124,10 +107,10 @@ function buildBulk (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_bulk' - } else if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_bulk' + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_bulk' + } else if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_bulk' } else { path = '/' + '_bulk' } @@ -136,7 +119,7 @@ function buildBulk (opts) { const request = { method, path, - bulkBody: params.body, + bulkBody: body, querystring } @@ -145,10 +128,27 @@ function buildBulk (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cat.aliases.js b/api/api/cat.aliases.js index 44a925878..6514d256e 100644 --- a/api/api/cat.aliases.js +++ b/api/api/cat.aliases.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCatAliases (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -15,6 +18,28 @@ function buildCatAliases (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ + + const acceptedQuerystring = [ + 'format', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function catAliases (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,64 +68,22 @@ function buildCatAliases (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'format', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'format', - 'local', - 'masterTimeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -108,8 +91,8 @@ function buildCatAliases (opts) { var path = '' - if ((params['name']) != null) { - path = '/' + '_cat' + '/' + 'aliases' + '/' + encodeURIComponent(params['name']) + if ((name) != null) { + path = '/' + '_cat' + '/' + 'aliases' + '/' + encodeURIComponent(name) } else { path = '/' + '_cat' + '/' + 'aliases' } @@ -127,10 +110,27 @@ function buildCatAliases (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cat.allocation.js b/api/api/cat.allocation.js index 483da3e42..937af2fb1 100644 --- a/api/api/cat.allocation.js +++ b/api/api/cat.allocation.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCatAllocation (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -16,6 +19,29 @@ function buildCatAllocation (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ + + const acceptedQuerystring = [ + 'format', + 'bytes', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function catAllocation (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,66 +70,22 @@ function buildCatAllocation (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'format', - 'bytes', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'format', - 'bytes', - 'local', - 'masterTimeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, nodeId, node_id } = params + var querystring = semicopy(params, ['method', 'body', 'nodeId', 'node_id']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -111,8 +93,8 @@ function buildCatAllocation (opts) { var path = '' - if ((params['node_id'] || params['nodeId']) != null) { - path = '/' + '_cat' + '/' + 'allocation' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + if ((node_id || nodeId) != null) { + path = '/' + '_cat' + '/' + 'allocation' + '/' + encodeURIComponent(node_id || nodeId) } else { path = '/' + '_cat' + '/' + 'allocation' } @@ -130,10 +112,27 @@ function buildCatAllocation (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cat.count.js b/api/api/cat.count.js index 351f119d2..c15de6550 100644 --- a/api/api/cat.count.js +++ b/api/api/cat.count.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCatCount (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -15,6 +18,28 @@ function buildCatCount (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ + + const acceptedQuerystring = [ + 'format', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function catCount (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,64 +68,22 @@ function buildCatCount (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'format', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'format', - 'local', - 'masterTimeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -108,8 +91,8 @@ function buildCatCount (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + '_cat' + '/' + 'count' + '/' + encodeURIComponent(params['index']) + if ((index) != null) { + path = '/' + '_cat' + '/' + 'count' + '/' + encodeURIComponent(index) } else { path = '/' + '_cat' + '/' + 'count' } @@ -127,10 +110,27 @@ function buildCatCount (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cat.fielddata.js b/api/api/cat.fielddata.js index 484467085..d75cd3df4 100644 --- a/api/api/cat.fielddata.js +++ b/api/api/cat.fielddata.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCatFielddata (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -17,6 +20,30 @@ function buildCatFielddata (opts) { * @param {boolean} v - Verbose mode. Display column headers * @param {list} fields - A comma-separated list of fields to return in the output */ + + const acceptedQuerystring = [ + 'format', + 'bytes', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'fields', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function catFielddata (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -45,68 +72,22 @@ function buildCatFielddata (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'format', - 'bytes', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'v', - 'fields', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'format', - 'bytes', - 'local', - 'masterTimeout', - 'h', - 'help', - 's', - 'v', - 'fields', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, fields } = params + var querystring = semicopy(params, ['method', 'body', 'fields']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -114,8 +95,8 @@ function buildCatFielddata (opts) { var path = '' - if ((params['fields']) != null) { - path = '/' + '_cat' + '/' + 'fielddata' + '/' + encodeURIComponent(params['fields']) + if ((fields) != null) { + path = '/' + '_cat' + '/' + 'fielddata' + '/' + encodeURIComponent(fields) } else { path = '/' + '_cat' + '/' + 'fielddata' } @@ -133,10 +114,27 @@ function buildCatFielddata (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cat.health.js b/api/api/cat.health.js index a22eeef1b..4c0bedc77 100644 --- a/api/api/cat.health.js +++ b/api/api/cat.health.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCatHealth (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -15,6 +18,29 @@ function buildCatHealth (opts) { * @param {boolean} ts - Set to false to disable timestamping * @param {boolean} v - Verbose mode. Display column headers */ + + const acceptedQuerystring = [ + 'format', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'ts', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function catHealth (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,66 +69,22 @@ function buildCatHealth (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'format', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'ts', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'format', - 'local', - 'masterTimeout', - 'h', - 'help', - 's', - 'ts', - 'v', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -125,10 +107,27 @@ function buildCatHealth (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cat.help.js b/api/api/cat.help.js index 55838067e..2c9039ee3 100644 --- a/api/api/cat.help.js +++ b/api/api/cat.help.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCatHelp (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,22 @@ function buildCatHelp (opts) { * @param {boolean} help - Return help information * @param {list} s - Comma-separated list of column names or column aliases to sort by */ + + const acceptedQuerystring = [ + 'help', + 's', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function catHelp (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -37,54 +56,22 @@ function buildCatHelp (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'help', - 's', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'help', - 's', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -107,10 +94,27 @@ function buildCatHelp (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cat.indices.js b/api/api/cat.indices.js index 7f4231376..94aea079e 100644 --- a/api/api/cat.indices.js +++ b/api/api/cat.indices.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCatIndices (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -18,6 +21,31 @@ function buildCatIndices (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ + + const acceptedQuerystring = [ + 'format', + 'bytes', + 'local', + 'master_timeout', + 'h', + 'health', + 'help', + 'pri', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function catIndices (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -46,70 +74,22 @@ function buildCatIndices (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'format', - 'bytes', - 'local', - 'master_timeout', - 'h', - 'health', - 'help', - 'pri', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'format', - 'bytes', - 'local', - 'masterTimeout', - 'h', - 'health', - 'help', - 'pri', - 's', - 'v', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -117,8 +97,8 @@ function buildCatIndices (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + '_cat' + '/' + 'indices' + '/' + encodeURIComponent(params['index']) + if ((index) != null) { + path = '/' + '_cat' + '/' + 'indices' + '/' + encodeURIComponent(index) } else { path = '/' + '_cat' + '/' + 'indices' } @@ -136,10 +116,27 @@ function buildCatIndices (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cat.master.js b/api/api/cat.master.js index c7474c209..85768b27b 100644 --- a/api/api/cat.master.js +++ b/api/api/cat.master.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCatMaster (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,28 @@ function buildCatMaster (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ + + const acceptedQuerystring = [ + 'format', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function catMaster (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -42,64 +67,22 @@ function buildCatMaster (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'format', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'format', - 'local', - 'masterTimeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -122,10 +105,27 @@ function buildCatMaster (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cat.nodeattrs.js b/api/api/cat.nodeattrs.js index 1b491a9b6..e41b56adb 100644 --- a/api/api/cat.nodeattrs.js +++ b/api/api/cat.nodeattrs.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCatNodeattrs (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,28 @@ function buildCatNodeattrs (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ + + const acceptedQuerystring = [ + 'format', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function catNodeattrs (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -42,64 +67,22 @@ function buildCatNodeattrs (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'format', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'format', - 'local', - 'masterTimeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -122,10 +105,27 @@ function buildCatNodeattrs (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cat.nodes.js b/api/api/cat.nodes.js index 8191197c6..e75e3161d 100644 --- a/api/api/cat.nodes.js +++ b/api/api/cat.nodes.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCatNodes (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -15,6 +18,30 @@ function buildCatNodes (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ + + const acceptedQuerystring = [ + 'format', + 'full_id', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + fullId: 'full_id', + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function catNodes (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,66 +70,22 @@ function buildCatNodes (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'format', - 'full_id', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'format', - 'fullId', - 'local', - 'masterTimeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -125,10 +108,27 @@ function buildCatNodes (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cat.pending_tasks.js b/api/api/cat.pending_tasks.js index 755c78feb..cf25a99ef 100644 --- a/api/api/cat.pending_tasks.js +++ b/api/api/cat.pending_tasks.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCatPendingTasks (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,28 @@ function buildCatPendingTasks (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ + + const acceptedQuerystring = [ + 'format', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function catPendingTasks (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -42,64 +67,22 @@ function buildCatPendingTasks (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'format', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'format', - 'local', - 'masterTimeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -122,10 +105,27 @@ function buildCatPendingTasks (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cat.plugins.js b/api/api/cat.plugins.js index 2cfd47dd5..ac8dd626f 100644 --- a/api/api/cat.plugins.js +++ b/api/api/cat.plugins.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCatPlugins (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,28 @@ function buildCatPlugins (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ + + const acceptedQuerystring = [ + 'format', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function catPlugins (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -42,64 +67,22 @@ function buildCatPlugins (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'format', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'format', - 'local', - 'masterTimeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -122,10 +105,27 @@ function buildCatPlugins (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cat.recovery.js b/api/api/cat.recovery.js index 204bffe54..cadf47b85 100644 --- a/api/api/cat.recovery.js +++ b/api/api/cat.recovery.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCatRecovery (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -15,6 +18,28 @@ function buildCatRecovery (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ + + const acceptedQuerystring = [ + 'format', + 'bytes', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function catRecovery (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,64 +68,22 @@ function buildCatRecovery (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'format', - 'bytes', - 'master_timeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'format', - 'bytes', - 'masterTimeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -108,8 +91,8 @@ function buildCatRecovery (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + '_cat' + '/' + 'recovery' + '/' + encodeURIComponent(params['index']) + if ((index) != null) { + path = '/' + '_cat' + '/' + 'recovery' + '/' + encodeURIComponent(index) } else { path = '/' + '_cat' + '/' + 'recovery' } @@ -127,10 +110,27 @@ function buildCatRecovery (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cat.repositories.js b/api/api/cat.repositories.js index 6b2f01746..8d7637bea 100644 --- a/api/api/cat.repositories.js +++ b/api/api/cat.repositories.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCatRepositories (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,28 @@ function buildCatRepositories (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ + + const acceptedQuerystring = [ + 'format', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function catRepositories (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -42,64 +67,22 @@ function buildCatRepositories (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'format', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'format', - 'local', - 'masterTimeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -122,10 +105,27 @@ function buildCatRepositories (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cat.segments.js b/api/api/cat.segments.js index 2a502db05..974dbd559 100644 --- a/api/api/cat.segments.js +++ b/api/api/cat.segments.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCatSegments (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,26 @@ function buildCatSegments (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ + + const acceptedQuerystring = [ + 'format', + 'bytes', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function catSegments (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -42,62 +65,22 @@ function buildCatSegments (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'format', - 'bytes', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'format', - 'bytes', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -105,8 +88,8 @@ function buildCatSegments (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + '_cat' + '/' + 'segments' + '/' + encodeURIComponent(params['index']) + if ((index) != null) { + path = '/' + '_cat' + '/' + 'segments' + '/' + encodeURIComponent(index) } else { path = '/' + '_cat' + '/' + 'segments' } @@ -124,10 +107,27 @@ function buildCatSegments (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cat.shards.js b/api/api/cat.shards.js index c9cecbdee..a5bf81bd2 100644 --- a/api/api/cat.shards.js +++ b/api/api/cat.shards.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCatShards (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -16,6 +19,29 @@ function buildCatShards (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ + + const acceptedQuerystring = [ + 'format', + 'bytes', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function catShards (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,66 +70,22 @@ function buildCatShards (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'format', - 'bytes', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'format', - 'bytes', - 'local', - 'masterTimeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -111,8 +93,8 @@ function buildCatShards (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + '_cat' + '/' + 'shards' + '/' + encodeURIComponent(params['index']) + if ((index) != null) { + path = '/' + '_cat' + '/' + 'shards' + '/' + encodeURIComponent(index) } else { path = '/' + '_cat' + '/' + 'shards' } @@ -130,10 +112,27 @@ function buildCatShards (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cat.snapshots.js b/api/api/cat.snapshots.js index 1a36c6994..4d94b6b88 100644 --- a/api/api/cat.snapshots.js +++ b/api/api/cat.snapshots.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCatSnapshots (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -15,6 +18,29 @@ function buildCatSnapshots (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ + + const acceptedQuerystring = [ + 'format', + 'ignore_unavailable', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + ignoreUnavailable: 'ignore_unavailable', + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function catSnapshots (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,64 +69,22 @@ function buildCatSnapshots (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'format', - 'ignore_unavailable', - 'master_timeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'format', - 'ignoreUnavailable', - 'masterTimeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, repository } = params + var querystring = semicopy(params, ['method', 'body', 'repository']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -108,8 +92,8 @@ function buildCatSnapshots (opts) { var path = '' - if ((params['repository']) != null) { - path = '/' + '_cat' + '/' + 'snapshots' + '/' + encodeURIComponent(params['repository']) + if ((repository) != null) { + path = '/' + '_cat' + '/' + 'snapshots' + '/' + encodeURIComponent(repository) } else { path = '/' + '_cat' + '/' + 'snapshots' } @@ -127,10 +111,27 @@ function buildCatSnapshots (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cat.tasks.js b/api/api/cat.tasks.js index b51c5d0e5..db8bf7ad0 100644 --- a/api/api/cat.tasks.js +++ b/api/api/cat.tasks.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCatTasks (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -16,6 +19,31 @@ function buildCatTasks (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ + + const acceptedQuerystring = [ + 'format', + 'node_id', + 'actions', + 'detailed', + 'parent_task', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + nodeId: 'node_id', + parentTask: 'parent_task', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function catTasks (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,68 +72,22 @@ function buildCatTasks (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'format', - 'node_id', - 'actions', - 'detailed', - 'parent_task', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'format', - 'nodeId', - 'actions', - 'detailed', - 'parentTask', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -128,10 +110,27 @@ function buildCatTasks (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cat.templates.js b/api/api/cat.templates.js index 1fbcf3549..e455e5db8 100644 --- a/api/api/cat.templates.js +++ b/api/api/cat.templates.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCatTemplates (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -15,6 +18,28 @@ function buildCatTemplates (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ + + const acceptedQuerystring = [ + 'format', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function catTemplates (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,64 +68,22 @@ function buildCatTemplates (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'format', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'format', - 'local', - 'masterTimeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -108,8 +91,8 @@ function buildCatTemplates (opts) { var path = '' - if ((params['name']) != null) { - path = '/' + '_cat' + '/' + 'templates' + '/' + encodeURIComponent(params['name']) + if ((name) != null) { + path = '/' + '_cat' + '/' + 'templates' + '/' + encodeURIComponent(name) } else { path = '/' + '_cat' + '/' + 'templates' } @@ -127,10 +110,27 @@ function buildCatTemplates (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cat.thread_pool.js b/api/api/cat.thread_pool.js index c32c15d5e..d4c062897 100644 --- a/api/api/cat.thread_pool.js +++ b/api/api/cat.thread_pool.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCatThreadPool (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -16,6 +19,29 @@ function buildCatThreadPool (opts) { * @param {list} s - Comma-separated list of column names or column aliases to sort by * @param {boolean} v - Verbose mode. Display column headers */ + + const acceptedQuerystring = [ + 'format', + 'size', + 'local', + 'master_timeout', + 'h', + 'help', + 's', + 'v', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function catThreadPool (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,66 +70,22 @@ function buildCatThreadPool (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'format', - 'size', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'format', - 'size', - 'local', - 'masterTimeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, threadPoolPatterns, thread_pool_patterns } = params + var querystring = semicopy(params, ['method', 'body', 'threadPoolPatterns', 'thread_pool_patterns']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -111,8 +93,8 @@ function buildCatThreadPool (opts) { var path = '' - if ((params['thread_pool_patterns'] || params['threadPoolPatterns']) != null) { - path = '/' + '_cat' + '/' + 'thread_pool' + '/' + encodeURIComponent(params['thread_pool_patterns'] || params['threadPoolPatterns']) + if ((thread_pool_patterns || threadPoolPatterns) != null) { + path = '/' + '_cat' + '/' + 'thread_pool' + '/' + encodeURIComponent(thread_pool_patterns || threadPoolPatterns) } else { path = '/' + '_cat' + '/' + 'thread_pool' } @@ -130,10 +112,27 @@ function buildCatThreadPool (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ccr.delete_auto_follow_pattern.js b/api/api/ccr.delete_auto_follow_pattern.js index 83f4f279b..c8c0f6360 100644 --- a/api/api/ccr.delete_auto_follow_pattern.js +++ b/api/api/ccr.delete_auto_follow_pattern.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCcrDeleteAutoFollowPattern (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildCcrDeleteAutoFollowPattern (opts) { * * @param {string} name - The name of the auto follow pattern. */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function ccrDeleteAutoFollowPattern (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildCcrDeleteAutoFollowPattern (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -79,13 +71,13 @@ function buildCcrDeleteAutoFollowPattern (opts) { var path = '' - path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(params['name']) + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -94,10 +86,27 @@ function buildCcrDeleteAutoFollowPattern (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ccr.follow.js b/api/api/ccr.follow.js index 2ac210f45..864f1fb07 100644 --- a/api/api/ccr.follow.js +++ b/api/api/ccr.follow.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCcrFollow (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildCcrFollow (opts) { * @param {string} index - The name of the follower index * @param {object} body - The name of the leader index and other optional ccr related parameters */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function ccrFollow (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,42 +55,22 @@ function buildCcrFollow (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -86,13 +78,13 @@ function buildCcrFollow (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + '/' + '_ccr' + '/' + 'follow' + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'follow' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -101,10 +93,27 @@ function buildCcrFollow (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ccr.follow_stats.js b/api/api/ccr.follow_stats.js index f095eb271..98cb1ba5a 100644 --- a/api/api/ccr.follow_stats.js +++ b/api/api/ccr.follow_stats.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCcrFollowStats (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildCcrFollowStats (opts) { * * @param {list} index - A comma-separated list of index patterns; use `_all` to perform the operation on all indices */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function ccrFollowStats (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -28,42 +40,22 @@ function buildCcrFollowStats (opts) { }) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -71,7 +63,7 @@ function buildCcrFollowStats (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + '/' + '_ccr' + '/' + 'stats' + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'stats' // build request object const request = { @@ -86,10 +78,27 @@ function buildCcrFollowStats (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ccr.get_auto_follow_pattern.js b/api/api/ccr.get_auto_follow_pattern.js index ee2f82606..2e53add8d 100644 --- a/api/api/ccr.get_auto_follow_pattern.js +++ b/api/api/ccr.get_auto_follow_pattern.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCcrGetAutoFollowPattern (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildCcrGetAutoFollowPattern (opts) { * * @param {string} name - The name of the auto follow pattern. */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function ccrGetAutoFollowPattern (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -28,42 +40,22 @@ function buildCcrGetAutoFollowPattern (opts) { }) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -71,8 +63,8 @@ function buildCcrGetAutoFollowPattern (opts) { var path = '' - if ((params['name']) != null) { - path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(params['name']) + if ((name) != null) { + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) } else { path = '/' + '_ccr' + '/' + 'auto_follow' } @@ -90,10 +82,27 @@ function buildCcrGetAutoFollowPattern (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ccr.pause_follow.js b/api/api/ccr.pause_follow.js index 2b79f162e..e10a26fc9 100644 --- a/api/api/ccr.pause_follow.js +++ b/api/api/ccr.pause_follow.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCcrPauseFollow (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildCcrPauseFollow (opts) { * * @param {string} index - The name of the follower index that should pause following its leader index. */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function ccrPauseFollow (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildCcrPauseFollow (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -79,13 +71,13 @@ function buildCcrPauseFollow (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + '/' + '_ccr' + '/' + 'pause_follow' + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'pause_follow' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -94,10 +86,27 @@ function buildCcrPauseFollow (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ccr.put_auto_follow_pattern.js b/api/api/ccr.put_auto_follow_pattern.js index 49ae7ff06..afe577b98 100644 --- a/api/api/ccr.put_auto_follow_pattern.js +++ b/api/api/ccr.put_auto_follow_pattern.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCcrPutAutoFollowPattern (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildCcrPutAutoFollowPattern (opts) { * @param {string} name - The name of the auto follow pattern. * @param {object} body - The specification of the auto follow pattern */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function ccrPutAutoFollowPattern (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,42 +55,22 @@ function buildCcrPutAutoFollowPattern (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -86,13 +78,13 @@ function buildCcrPutAutoFollowPattern (opts) { var path = '' - path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(params['name']) + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -101,10 +93,27 @@ function buildCcrPutAutoFollowPattern (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ccr.resume_follow.js b/api/api/ccr.resume_follow.js index 7ee6ba6c5..977e452ba 100644 --- a/api/api/ccr.resume_follow.js +++ b/api/api/ccr.resume_follow.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCcrResumeFollow (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildCcrResumeFollow (opts) { * @param {string} index - The name of the follow index to resume following. * @param {object} body - The name of the leader index and other optional ccr related parameters */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function ccrResumeFollow (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,42 +55,22 @@ function buildCcrResumeFollow (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -86,13 +78,13 @@ function buildCcrResumeFollow (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + '/' + '_ccr' + '/' + 'resume_follow' + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'resume_follow' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -101,10 +93,27 @@ function buildCcrResumeFollow (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ccr.stats.js b/api/api/ccr.stats.js index 00e94ea6d..86cafe603 100644 --- a/api/api/ccr.stats.js +++ b/api/api/ccr.stats.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCcrStats (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -7,6 +10,15 @@ function buildCcrStats (opts) { * Perform a [ccr.stats](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html) request * */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function ccrStats (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -27,42 +39,22 @@ function buildCcrStats (opts) { }) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -85,10 +77,27 @@ function buildCcrStats (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ccr.unfollow.js b/api/api/ccr.unfollow.js index bd810eaa9..d13568d70 100644 --- a/api/api/ccr.unfollow.js +++ b/api/api/ccr.unfollow.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCcrUnfollow (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildCcrUnfollow (opts) { * * @param {string} index - The name of the follower index that should be turned into a regular index. */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function ccrUnfollow (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildCcrUnfollow (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -79,13 +71,13 @@ function buildCcrUnfollow (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + '/' + '_ccr' + '/' + 'unfollow' + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'unfollow' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -94,10 +86,27 @@ function buildCcrUnfollow (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/clear_scroll.js b/api/api/clear_scroll.js index 229df18d6..311650b04 100644 --- a/api/api/clear_scroll.js +++ b/api/api/clear_scroll.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildClearScroll (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,20 @@ function buildClearScroll (opts) { * @param {list} scroll_id - A comma-separated list of scroll IDs to clear * @param {object} body - A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter */ + + const acceptedQuerystring = [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function clearScroll (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -29,50 +46,22 @@ function buildClearScroll (opts) { }) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, scrollId, scroll_id } = params + var querystring = semicopy(params, ['method', 'body', 'scrollId', 'scroll_id']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -80,8 +69,8 @@ function buildClearScroll (opts) { var path = '' - if ((params['scroll_id'] || params['scrollId']) != null) { - path = '/' + '_search' + '/' + 'scroll' + '/' + encodeURIComponent(params['scroll_id'] || params['scrollId']) + if ((scroll_id || scrollId) != null) { + path = '/' + '_search' + '/' + 'scroll' + '/' + encodeURIComponent(scroll_id || scrollId) } else { path = '/' + '_search' + '/' + 'scroll' } @@ -90,7 +79,7 @@ function buildClearScroll (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -99,10 +88,27 @@ function buildClearScroll (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cluster.allocation_explain.js b/api/api/cluster.allocation_explain.js index c7cecff23..a4aada4a1 100644 --- a/api/api/cluster.allocation_explain.js +++ b/api/api/cluster.allocation_explain.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildClusterAllocationExplain (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,24 @@ function buildClusterAllocationExplain (opts) { * @param {boolean} include_disk_info - Return information about disk usage and shard sizes (default: false) * @param {object} body - The index, shard, and primary flag to explain. Empty means 'explain the first unassigned shard' */ + + const acceptedQuerystring = [ + 'include_yes_decisions', + 'include_disk_info', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + includeYesDecisions: 'include_yes_decisions', + includeDiskInfo: 'include_disk_info', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function clusterAllocationExplain (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -30,54 +51,22 @@ function buildClusterAllocationExplain (opts) { }) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'include_yes_decisions', - 'include_disk_info', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'includeYesDecisions', - 'includeDiskInfo', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -91,7 +80,7 @@ function buildClusterAllocationExplain (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -100,10 +89,27 @@ function buildClusterAllocationExplain (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cluster.get_settings.js b/api/api/cluster.get_settings.js index dd35c7343..2d2646ef2 100644 --- a/api/api/cluster.get_settings.js +++ b/api/api/cluster.get_settings.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildClusterGetSettings (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -11,6 +14,27 @@ function buildClusterGetSettings (opts) { * @param {time} timeout - Explicit operation timeout * @param {boolean} include_defaults - Whether to return all default clusters setting. */ + + const acceptedQuerystring = [ + 'flat_settings', + 'master_timeout', + 'timeout', + 'include_defaults', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + flatSettings: 'flat_settings', + masterTimeout: 'master_timeout', + includeDefaults: 'include_defaults', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function clusterGetSettings (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -39,58 +63,22 @@ function buildClusterGetSettings (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'flat_settings', - 'master_timeout', - 'timeout', - 'include_defaults', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'flatSettings', - 'masterTimeout', - 'timeout', - 'includeDefaults', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -113,10 +101,27 @@ function buildClusterGetSettings (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cluster.health.js b/api/api/cluster.health.js index 9fce75525..e3786ab4a 100644 --- a/api/api/cluster.health.js +++ b/api/api/cluster.health.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildClusterHealth (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -18,6 +21,37 @@ function buildClusterHealth (opts) { * @param {boolean} wait_for_no_initializing_shards - Whether to wait until there are no initializing shards in the cluster * @param {enum} wait_for_status - Wait until cluster is in a specific state */ + + const acceptedQuerystring = [ + 'level', + 'local', + 'master_timeout', + 'timeout', + 'wait_for_active_shards', + 'wait_for_nodes', + 'wait_for_events', + 'wait_for_no_relocating_shards', + 'wait_for_no_initializing_shards', + 'wait_for_status', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + waitForActiveShards: 'wait_for_active_shards', + waitForNodes: 'wait_for_nodes', + waitForEvents: 'wait_for_events', + waitForNoRelocatingShards: 'wait_for_no_relocating_shards', + waitForNoInitializingShards: 'wait_for_no_initializing_shards', + waitForStatus: 'wait_for_status', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function clusterHealth (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -46,70 +80,22 @@ function buildClusterHealth (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'level', - 'local', - 'master_timeout', - 'timeout', - 'wait_for_active_shards', - 'wait_for_nodes', - 'wait_for_events', - 'wait_for_no_relocating_shards', - 'wait_for_no_initializing_shards', - 'wait_for_status', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'level', - 'local', - 'masterTimeout', - 'timeout', - 'waitForActiveShards', - 'waitForNodes', - 'waitForEvents', - 'waitForNoRelocatingShards', - 'waitForNoInitializingShards', - 'waitForStatus', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -117,8 +103,8 @@ function buildClusterHealth (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + '_cluster' + '/' + 'health' + '/' + encodeURIComponent(params['index']) + if ((index) != null) { + path = '/' + '_cluster' + '/' + 'health' + '/' + encodeURIComponent(index) } else { path = '/' + '_cluster' + '/' + 'health' } @@ -136,10 +122,27 @@ function buildClusterHealth (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cluster.pending_tasks.js b/api/api/cluster.pending_tasks.js index afcaafe78..2670ab2e0 100644 --- a/api/api/cluster.pending_tasks.js +++ b/api/api/cluster.pending_tasks.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildClusterPendingTasks (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,23 @@ function buildClusterPendingTasks (opts) { * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) * @param {time} master_timeout - Specify timeout for connection to master */ + + const acceptedQuerystring = [ + 'local', + 'master_timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function clusterPendingTasks (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -37,54 +57,22 @@ function buildClusterPendingTasks (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'local', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'local', - 'masterTimeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -107,10 +95,27 @@ function buildClusterPendingTasks (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cluster.put_settings.js b/api/api/cluster.put_settings.js index 74edae830..e76483e1a 100644 --- a/api/api/cluster.put_settings.js +++ b/api/api/cluster.put_settings.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildClusterPutSettings (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -11,6 +14,25 @@ function buildClusterPutSettings (opts) { * @param {time} timeout - Explicit operation timeout * @param {object} body - The settings to be updated. Can be either `transient` or `persistent` (survives cluster restart). */ + + const acceptedQuerystring = [ + 'flat_settings', + 'master_timeout', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + flatSettings: 'flat_settings', + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function clusterPutSettings (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -39,56 +61,22 @@ function buildClusterPutSettings (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'flat_settings', - 'master_timeout', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'flatSettings', - 'masterTimeout', - 'timeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -102,7 +90,7 @@ function buildClusterPutSettings (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -111,10 +99,27 @@ function buildClusterPutSettings (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cluster.remote_info.js b/api/api/cluster.remote_info.js index 97ba00e6b..947a6452a 100644 --- a/api/api/cluster.remote_info.js +++ b/api/api/cluster.remote_info.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildClusterRemoteInfo (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -7,6 +10,20 @@ function buildClusterRemoteInfo (opts) { * Perform a [cluster.remote_info](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-remote-info.html) request * */ + + const acceptedQuerystring = [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function clusterRemoteInfo (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -35,50 +52,22 @@ function buildClusterRemoteInfo (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -101,10 +90,27 @@ function buildClusterRemoteInfo (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cluster.reroute.js b/api/api/cluster.reroute.js index f4f114305..9c1c71997 100644 --- a/api/api/cluster.reroute.js +++ b/api/api/cluster.reroute.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildClusterReroute (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,29 @@ function buildClusterReroute (opts) { * @param {time} timeout - Explicit operation timeout * @param {object} body - The definition of `commands` to perform (`move`, `cancel`, `allocate`) */ + + const acceptedQuerystring = [ + 'dry_run', + 'explain', + 'retry_failed', + 'metric', + 'master_timeout', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + dryRun: 'dry_run', + retryFailed: 'retry_failed', + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function clusterReroute (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -34,62 +60,22 @@ function buildClusterReroute (opts) { }) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'dry_run', - 'explain', - 'retry_failed', - 'metric', - 'master_timeout', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'dryRun', - 'explain', - 'retryFailed', - 'metric', - 'masterTimeout', - 'timeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -103,7 +89,7 @@ function buildClusterReroute (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -112,10 +98,27 @@ function buildClusterReroute (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cluster.state.js b/api/api/cluster.state.js index 70e1307ec..ef7f4d9fa 100644 --- a/api/api/cluster.state.js +++ b/api/api/cluster.state.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildClusterState (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -17,6 +20,35 @@ function buildClusterState (opts) { * @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. */ + + const acceptedQuerystring = [ + 'local', + 'master_timeout', + 'flat_settings', + 'wait_for_metadata_version', + 'wait_for_timeout', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + flatSettings: 'flat_settings', + waitForMetadataVersion: 'wait_for_metadata_version', + waitForTimeout: 'wait_for_timeout', + ignoreUnavailable: 'ignore_unavailable', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function clusterState (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -53,66 +85,22 @@ function buildClusterState (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'local', - 'master_timeout', - 'flat_settings', - 'wait_for_metadata_version', - 'wait_for_timeout', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'local', - 'masterTimeout', - 'flatSettings', - 'waitForMetadataVersion', - 'waitForTimeout', - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, metric } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'metric']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -120,10 +108,10 @@ function buildClusterState (opts) { var path = '' - if ((params['metric']) != null && (params['index']) != null) { - path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(params['metric']) + '/' + encodeURIComponent(params['index']) - } else if ((params['metric']) != null) { - path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(params['metric']) + if ((metric) != null && (index) != null) { + path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(metric) + '/' + encodeURIComponent(index) + } else if ((metric) != null) { + path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(metric) } else { path = '/' + '_cluster' + '/' + 'state' } @@ -141,10 +129,27 @@ function buildClusterState (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/cluster.stats.js b/api/api/cluster.stats.js index 50a797066..a14ef97cb 100644 --- a/api/api/cluster.stats.js +++ b/api/api/cluster.stats.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildClusterStats (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,23 @@ function buildClusterStats (opts) { * @param {boolean} flat_settings - Return settings in flat format (default: false) * @param {time} timeout - Explicit operation timeout */ + + const acceptedQuerystring = [ + 'flat_settings', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + flatSettings: 'flat_settings', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function clusterStats (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -38,54 +58,22 @@ function buildClusterStats (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'flat_settings', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'flatSettings', - 'timeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, nodeId, node_id } = params + var querystring = semicopy(params, ['method', 'body', 'nodeId', 'node_id']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -93,8 +81,8 @@ function buildClusterStats (opts) { var path = '' - if ((params['node_id'] || params['nodeId']) != null) { - path = '/' + '_cluster' + '/' + 'stats' + '/' + 'nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + if ((node_id || nodeId) != null) { + path = '/' + '_cluster' + '/' + 'stats' + '/' + 'nodes' + '/' + encodeURIComponent(node_id || nodeId) } else { path = '/' + '_cluster' + '/' + 'stats' } @@ -112,10 +100,27 @@ function buildClusterStats (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/count.js b/api/api/count.js index 74e261b14..f2333f66a 100644 --- a/api/api/count.js +++ b/api/api/count.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCount (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -24,6 +27,42 @@ function buildCount (opts) { * @param {number} terminate_after - The maximum count for each shard, upon reaching which the query execution will terminate early * @param {object} body - A query to restrict the results specified with the Query DSL (optional) */ + + const acceptedQuerystring = [ + 'ignore_unavailable', + 'ignore_throttled', + 'allow_no_indices', + 'expand_wildcards', + 'min_score', + 'preference', + 'routing', + 'q', + 'analyzer', + 'analyze_wildcard', + 'default_operator', + 'df', + 'lenient', + 'terminate_after', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + ignoreUnavailable: 'ignore_unavailable', + ignoreThrottled: 'ignore_throttled', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + minScore: 'min_score', + analyzeWildcard: 'analyze_wildcard', + defaultOperator: 'default_operator', + terminateAfter: 'terminate_after', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function count (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -52,78 +91,22 @@ function buildCount (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'ignore_unavailable', - 'ignore_throttled', - 'allow_no_indices', - 'expand_wildcards', - 'min_score', - 'preference', - 'routing', - 'q', - 'analyzer', - 'analyze_wildcard', - 'default_operator', - 'df', - 'lenient', - 'terminate_after', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'ignoreUnavailable', - 'ignoreThrottled', - 'allowNoIndices', - 'expandWildcards', - 'minScore', - 'preference', - 'routing', - 'q', - 'analyzer', - 'analyzeWildcard', - 'defaultOperator', - 'df', - 'lenient', - 'terminateAfter', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'type']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -131,10 +114,10 @@ function buildCount (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_count' - } else if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_count' + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_count' + } else if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_count' } else { path = '/' + '_count' } @@ -143,7 +126,7 @@ function buildCount (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -152,10 +135,27 @@ function buildCount (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/create.js b/api/api/create.js index b20a5269a..f5ecd7ad6 100644 --- a/api/api/create.js +++ b/api/api/create.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildCreate (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -19,6 +22,30 @@ function buildCreate (opts) { * @param {string} pipeline - The pipeline id to preprocess incoming documents with * @param {object} body - The document */ + + const acceptedQuerystring = [ + 'wait_for_active_shards', + 'parent', + 'refresh', + 'routing', + 'timeout', + 'version', + 'version_type', + 'pipeline', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + waitForActiveShards: 'wait_for_active_shards', + versionType: 'version_type', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function create (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -78,66 +105,22 @@ function buildCreate (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'wait_for_active_shards', - 'parent', - 'refresh', - 'routing', - 'timeout', - 'version', - 'version_type', - 'pipeline', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'waitForActiveShards', - 'parent', - 'refresh', - 'routing', - 'timeout', - 'version', - 'versionType', - 'pipeline', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -145,13 +128,13 @@ function buildCreate (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_create' + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_create' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -160,10 +143,27 @@ function buildCreate (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/delete.js b/api/api/delete.js index d4b227a4f..d5e5fbdd1 100644 --- a/api/api/delete.js +++ b/api/api/delete.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildDelete (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -17,6 +20,29 @@ function buildDelete (opts) { * @param {number} version - Explicit version number for concurrency control * @param {enum} version_type - Specific version type */ + + const acceptedQuerystring = [ + 'wait_for_active_shards', + 'parent', + 'refresh', + 'routing', + 'timeout', + 'version', + 'version_type', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + waitForActiveShards: 'wait_for_active_shards', + versionType: 'version_type', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function _delete (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -65,64 +91,22 @@ function buildDelete (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'wait_for_active_shards', - 'parent', - 'refresh', - 'routing', - 'timeout', - 'version', - 'version_type', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'waitForActiveShards', - 'parent', - 'refresh', - 'routing', - 'timeout', - 'version', - 'versionType', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -130,10 +114,10 @@ function buildDelete (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null && (params['id']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + if ((index) != null && (type) != null && (id) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) } else { - path = '/' + encodeURIComponent(params['index']) + '/' + '_doc' + '/' + encodeURIComponent(params['id']) + path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id) } // build request object @@ -149,10 +133,27 @@ function buildDelete (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/delete_by_query.js b/api/api/delete_by_query.js index 91302e500..289436e70 100644 --- a/api/api/delete_by_query.js +++ b/api/api/delete_by_query.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildDeleteByQuery (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -42,6 +45,67 @@ function buildDeleteByQuery (opts) { * @param {number} slices - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. * @param {object} body - The search definition using the Query DSL */ + + const acceptedQuerystring = [ + 'analyzer', + 'analyze_wildcard', + 'default_operator', + 'df', + 'from', + 'ignore_unavailable', + 'allow_no_indices', + 'conflicts', + 'expand_wildcards', + 'lenient', + 'preference', + 'q', + 'routing', + 'scroll', + 'search_type', + 'search_timeout', + 'size', + 'sort', + '_source', + '_source_excludes', + '_source_includes', + 'terminate_after', + 'stats', + 'version', + 'request_cache', + 'refresh', + 'timeout', + 'wait_for_active_shards', + 'scroll_size', + 'wait_for_completion', + 'requests_per_second', + 'slices', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + analyzeWildcard: 'analyze_wildcard', + defaultOperator: 'default_operator', + ignoreUnavailable: 'ignore_unavailable', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + searchType: 'search_type', + searchTimeout: 'search_timeout', + _sourceExcludes: '_source_excludes', + _sourceIncludes: '_source_includes', + terminateAfter: 'terminate_after', + requestCache: 'request_cache', + waitForActiveShards: 'wait_for_active_shards', + scrollSize: 'scroll_size', + waitForCompletion: 'wait_for_completion', + requestsPerSecond: 'requests_per_second', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function deleteByQuery (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -84,114 +148,22 @@ function buildDeleteByQuery (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'analyzer', - 'analyze_wildcard', - 'default_operator', - 'df', - 'from', - 'ignore_unavailable', - 'allow_no_indices', - 'conflicts', - 'expand_wildcards', - 'lenient', - 'preference', - 'q', - 'routing', - 'scroll', - 'search_type', - 'search_timeout', - 'size', - 'sort', - '_source', - '_source_excludes', - '_source_includes', - 'terminate_after', - 'stats', - 'version', - 'request_cache', - 'refresh', - 'timeout', - 'wait_for_active_shards', - 'scroll_size', - 'wait_for_completion', - 'requests_per_second', - 'slices', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'analyzer', - 'analyzeWildcard', - 'defaultOperator', - 'df', - 'from', - 'ignoreUnavailable', - 'allowNoIndices', - 'conflicts', - 'expandWildcards', - 'lenient', - 'preference', - 'q', - 'routing', - 'scroll', - 'searchType', - 'searchTimeout', - 'size', - 'sort', - '_source', - '_sourceExcludes', - '_sourceIncludes', - 'terminateAfter', - 'stats', - 'version', - 'requestCache', - 'refresh', - 'timeout', - 'waitForActiveShards', - 'scrollSize', - 'waitForCompletion', - 'requestsPerSecond', - 'slices', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'type']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -199,17 +171,17 @@ function buildDeleteByQuery (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_delete_by_query' + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_delete_by_query' } else { - path = '/' + encodeURIComponent(params['index']) + '/' + '_delete_by_query' + path = '/' + encodeURIComponent(index) + '/' + '_delete_by_query' } // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -218,10 +190,27 @@ function buildDeleteByQuery (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/delete_by_query_rethrottle.js b/api/api/delete_by_query_rethrottle.js index ef307c463..588518983 100644 --- a/api/api/delete_by_query_rethrottle.js +++ b/api/api/delete_by_query_rethrottle.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildDeleteByQueryRethrottle (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,22 @@ function buildDeleteByQueryRethrottle (opts) { * @param {string} task_id - The task id to rethrottle * @param {number} requests_per_second - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. */ + + const acceptedQuerystring = [ + 'requests_per_second', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + requestsPerSecond: 'requests_per_second', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function deleteByQueryRethrottle (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -49,52 +68,22 @@ function buildDeleteByQueryRethrottle (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'requests_per_second', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'requestsPerSecond', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, taskId, task_id } = params + var querystring = semicopy(params, ['method', 'body', 'taskId', 'task_id']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -102,7 +91,7 @@ function buildDeleteByQueryRethrottle (opts) { var path = '' - path = '/' + '_delete_by_query' + '/' + encodeURIComponent(params['task_id'] || params['taskId']) + '/' + '_rethrottle' + path = '/' + '_delete_by_query' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_rethrottle' // build request object const request = { @@ -117,10 +106,27 @@ function buildDeleteByQueryRethrottle (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/delete_script.js b/api/api/delete_script.js index 280b73d46..371f0fd94 100644 --- a/api/api/delete_script.js +++ b/api/api/delete_script.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildDeleteScript (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,23 @@ function buildDeleteScript (opts) { * @param {time} timeout - Explicit operation timeout * @param {time} master_timeout - Specify timeout for connection to master */ + + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function deleteScript (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,54 +64,22 @@ function buildDeleteScript (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'timeout', - 'masterTimeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -99,7 +87,7 @@ function buildDeleteScript (opts) { var path = '' - path = '/' + '_scripts' + '/' + encodeURIComponent(params['id']) + path = '/' + '_scripts' + '/' + encodeURIComponent(id) // build request object const request = { @@ -114,10 +102,27 @@ function buildDeleteScript (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/exists.js b/api/api/exists.js index d2be719f3..aad3649d5 100644 --- a/api/api/exists.js +++ b/api/api/exists.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildExists (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -21,6 +24,35 @@ function buildExists (opts) { * @param {number} version - Explicit version number for concurrency control * @param {enum} version_type - Specific version type */ + + const acceptedQuerystring = [ + 'stored_fields', + 'parent', + 'preference', + 'realtime', + 'refresh', + 'routing', + '_source', + '_source_excludes', + '_source_includes', + 'version', + 'version_type', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + storedFields: 'stored_fields', + _sourceExcludes: '_source_excludes', + _sourceIncludes: '_source_includes', + versionType: 'version_type', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function exists (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -61,72 +93,22 @@ function buildExists (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'stored_fields', - 'parent', - 'preference', - 'realtime', - 'refresh', - 'routing', - '_source', - '_source_excludes', - '_source_includes', - 'version', - 'version_type', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'storedFields', - 'parent', - 'preference', - 'realtime', - 'refresh', - 'routing', - '_source', - '_sourceExcludes', - '_sourceIncludes', - 'version', - 'versionType', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'HEAD' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type']) + + if (method == null) { + method = 'HEAD' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -134,10 +116,10 @@ function buildExists (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null && (params['id']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + if ((index) != null && (type) != null && (id) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) } else { - path = '/' + encodeURIComponent(params['index']) + '/' + '_doc' + '/' + encodeURIComponent(params['id']) + path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id) } // build request object @@ -153,10 +135,27 @@ function buildExists (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/exists_source.js b/api/api/exists_source.js index 47d5cd451..9a769a75d 100644 --- a/api/api/exists_source.js +++ b/api/api/exists_source.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildExistsSource (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -20,6 +23,33 @@ function buildExistsSource (opts) { * @param {number} version - Explicit version number for concurrency control * @param {enum} version_type - Specific version type */ + + const acceptedQuerystring = [ + 'parent', + 'preference', + 'realtime', + 'refresh', + 'routing', + '_source', + '_source_excludes', + '_source_includes', + 'version', + 'version_type', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + _sourceExcludes: '_source_excludes', + _sourceIncludes: '_source_includes', + versionType: 'version_type', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function existsSource (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -79,70 +109,22 @@ function buildExistsSource (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'parent', - 'preference', - 'realtime', - 'refresh', - 'routing', - '_source', - '_source_excludes', - '_source_includes', - 'version', - 'version_type', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'parent', - 'preference', - 'realtime', - 'refresh', - 'routing', - '_source', - '_sourceExcludes', - '_sourceIncludes', - 'version', - 'versionType', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'HEAD' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type']) + + if (method == null) { + method = 'HEAD' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -150,7 +132,7 @@ function buildExistsSource (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_source' + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source' // build request object const request = { @@ -165,10 +147,27 @@ function buildExistsSource (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/explain.js b/api/api/explain.js index aa3c60c12..6a207098a 100644 --- a/api/api/explain.js +++ b/api/api/explain.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildExplain (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -24,6 +27,38 @@ function buildExplain (opts) { * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {object} body - The query definition using the Query DSL */ + + const acceptedQuerystring = [ + 'analyze_wildcard', + 'analyzer', + 'default_operator', + 'df', + 'stored_fields', + 'lenient', + 'parent', + 'preference', + 'q', + 'routing', + '_source', + '_source_excludes', + '_source_includes', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + analyzeWildcard: 'analyze_wildcard', + defaultOperator: 'default_operator', + storedFields: 'stored_fields', + _sourceExcludes: '_source_excludes', + _sourceIncludes: '_source_includes', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function explain (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -58,76 +93,22 @@ function buildExplain (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'analyze_wildcard', - 'analyzer', - 'default_operator', - 'df', - 'stored_fields', - 'lenient', - 'parent', - 'preference', - 'q', - 'routing', - '_source', - '_source_excludes', - '_source_includes', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'analyzeWildcard', - 'analyzer', - 'defaultOperator', - 'df', - 'storedFields', - 'lenient', - 'parent', - 'preference', - 'q', - 'routing', - '_source', - '_sourceExcludes', - '_sourceIncludes', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -135,17 +116,17 @@ function buildExplain (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null && (params['id']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_explain' + if ((index) != null && (type) != null && (id) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_explain' } else { - path = '/' + encodeURIComponent(params['index']) + '/' + '_explain' + '/' + encodeURIComponent(params['id']) + path = '/' + encodeURIComponent(index) + '/' + '_explain' + '/' + encodeURIComponent(id) } // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -154,10 +135,27 @@ function buildExplain (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/field_caps.js b/api/api/field_caps.js index 836651834..1fa8281ac 100644 --- a/api/api/field_caps.js +++ b/api/api/field_caps.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildFieldCaps (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -12,6 +15,27 @@ function buildFieldCaps (opts) { * @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. */ + + const acceptedQuerystring = [ + 'fields', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + '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 fieldCaps (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -40,58 +64,22 @@ function buildFieldCaps (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'fields', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'fields', - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -99,8 +87,8 @@ function buildFieldCaps (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_field_caps' + if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_field_caps' } else { path = '/' + '_field_caps' } @@ -118,10 +106,27 @@ function buildFieldCaps (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/get.js b/api/api/get.js index 861bf49bc..692e30cda 100644 --- a/api/api/get.js +++ b/api/api/get.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildGet (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -23,6 +26,39 @@ function buildGet (opts) { * @param {number} version - Explicit version number for concurrency control * @param {enum} version_type - Specific version type */ + + const acceptedQuerystring = [ + 'stored_fields', + 'parent', + 'preference', + 'realtime', + 'refresh', + 'routing', + '_source', + '_source_excludes', + '_source_includes', + '_source_exclude', + '_source_include', + 'version', + 'version_type', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + storedFields: 'stored_fields', + _sourceExcludes: '_source_excludes', + _sourceIncludes: '_source_includes', + _sourceExclude: '_source_exclude', + _sourceInclude: '_source_include', + versionType: 'version_type', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function get (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -63,76 +99,22 @@ function buildGet (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'stored_fields', - 'parent', - 'preference', - 'realtime', - 'refresh', - 'routing', - '_source', - '_source_excludes', - '_source_includes', - '_source_exclude', - '_source_include', - 'version', - 'version_type', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'storedFields', - 'parent', - 'preference', - 'realtime', - 'refresh', - 'routing', - '_source', - '_sourceExcludes', - '_sourceIncludes', - '_sourceExclude', - '_sourceInclude', - 'version', - 'versionType', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -140,10 +122,10 @@ function buildGet (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null && (params['id']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + if ((index) != null && (type) != null && (id) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) } else { - path = '/' + encodeURIComponent(params['index']) + '/' + '_doc' + '/' + encodeURIComponent(params['id']) + path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id) } // build request object @@ -159,10 +141,27 @@ function buildGet (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/get_script.js b/api/api/get_script.js index 37b6c09ca..188c45ed6 100644 --- a/api/api/get_script.js +++ b/api/api/get_script.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildGetScript (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,22 @@ function buildGetScript (opts) { * @param {string} id - Script ID * @param {time} master_timeout - Specify timeout for connection to master */ + + const acceptedQuerystring = [ + 'master_timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function getScript (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,52 +62,22 @@ function buildGetScript (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'masterTimeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -96,7 +85,7 @@ function buildGetScript (opts) { var path = '' - path = '/' + '_scripts' + '/' + encodeURIComponent(params['id']) + path = '/' + '_scripts' + '/' + encodeURIComponent(id) // build request object const request = { @@ -111,10 +100,27 @@ function buildGetScript (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/get_source.js b/api/api/get_source.js index 700b58940..7911c3c97 100644 --- a/api/api/get_source.js +++ b/api/api/get_source.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildGetSource (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -20,6 +23,33 @@ function buildGetSource (opts) { * @param {number} version - Explicit version number for concurrency control * @param {enum} version_type - Specific version type */ + + const acceptedQuerystring = [ + 'parent', + 'preference', + 'realtime', + 'refresh', + 'routing', + '_source', + '_source_excludes', + '_source_includes', + 'version', + 'version_type', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + _sourceExcludes: '_source_excludes', + _sourceIncludes: '_source_includes', + versionType: 'version_type', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function getSource (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -79,70 +109,22 @@ function buildGetSource (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'parent', - 'preference', - 'realtime', - 'refresh', - 'routing', - '_source', - '_source_excludes', - '_source_includes', - 'version', - 'version_type', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'parent', - 'preference', - 'realtime', - 'refresh', - 'routing', - '_source', - '_sourceExcludes', - '_sourceIncludes', - 'version', - 'versionType', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -150,7 +132,7 @@ function buildGetSource (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_source' + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source' // build request object const request = { @@ -165,10 +147,27 @@ function buildGetSource (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ilm.delete_lifecycle.js b/api/api/ilm.delete_lifecycle.js index 69968d7d3..59b75e48f 100644 --- a/api/api/ilm.delete_lifecycle.js +++ b/api/api/ilm.delete_lifecycle.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIlmDeleteLifecycle (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildIlmDeleteLifecycle (opts) { * * @param {string} policy - The name of the index lifecycle policy */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function ilmDeleteLifecycle (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildIlmDeleteLifecycle (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, policy } = params + var querystring = semicopy(params, ['method', 'body', 'policy']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -79,7 +71,7 @@ function buildIlmDeleteLifecycle (opts) { var path = '' - path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(params['policy']) + path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(policy) // build request object const request = { @@ -94,10 +86,27 @@ function buildIlmDeleteLifecycle (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ilm.explain_lifecycle.js b/api/api/ilm.explain_lifecycle.js index 56ddafcfd..e92f21ba7 100644 --- a/api/api/ilm.explain_lifecycle.js +++ b/api/api/ilm.explain_lifecycle.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIlmExplainLifecycle (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildIlmExplainLifecycle (opts) { * @param {string} index - The name of the index to explain * @param {boolean} human - Return data such as dates in a human readable format */ + + const acceptedQuerystring = [ + 'human' + ] + + const snakeCase = { + + } + return function ilmExplainLifecycle (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -37,42 +49,22 @@ function buildIlmExplainLifecycle (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'human' - ] - const acceptedQuerystringCamelCased = [ - 'human' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -80,7 +72,7 @@ function buildIlmExplainLifecycle (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + '/' + '_ilm' + '/' + 'explain' + path = '/' + encodeURIComponent(index) + '/' + '_ilm' + '/' + 'explain' // build request object const request = { @@ -95,10 +87,27 @@ function buildIlmExplainLifecycle (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ilm.get_lifecycle.js b/api/api/ilm.get_lifecycle.js index 93869ca64..70c21d35e 100644 --- a/api/api/ilm.get_lifecycle.js +++ b/api/api/ilm.get_lifecycle.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIlmGetLifecycle (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildIlmGetLifecycle (opts) { * * @param {string} policy - The name of the index lifecycle policy */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function ilmGetLifecycle (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildIlmGetLifecycle (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, policy } = params + var querystring = semicopy(params, ['method', 'body', 'policy']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -79,8 +71,8 @@ function buildIlmGetLifecycle (opts) { var path = '' - if ((params['policy']) != null) { - path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(params['policy']) + if ((policy) != null) { + path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(policy) } else { path = '/' + '_ilm' + '/' + 'policy' } @@ -98,10 +90,27 @@ function buildIlmGetLifecycle (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ilm.get_status.js b/api/api/ilm.get_status.js index 7d4bfaed5..f51dec6f3 100644 --- a/api/api/ilm.get_status.js +++ b/api/api/ilm.get_status.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIlmGetStatus (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -7,6 +10,15 @@ function buildIlmGetStatus (opts) { * Perform a [ilm.get_status](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-status.html) request * */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function ilmGetStatus (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -35,42 +47,22 @@ function buildIlmGetStatus (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -93,10 +85,27 @@ function buildIlmGetStatus (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ilm.move_to_step.js b/api/api/ilm.move_to_step.js index e1562289d..da5154d7e 100644 --- a/api/api/ilm.move_to_step.js +++ b/api/api/ilm.move_to_step.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIlmMoveToStep (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildIlmMoveToStep (opts) { * @param {string} index - The name of the index whose lifecycle step is to change * @param {object} body - The new lifecycle step to move to */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function ilmMoveToStep (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -29,42 +41,22 @@ function buildIlmMoveToStep (opts) { }) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -72,13 +64,13 @@ function buildIlmMoveToStep (opts) { var path = '' - path = '/' + '_ilm' + '/' + 'move' + '/' + encodeURIComponent(params['index']) + path = '/' + '_ilm' + '/' + 'move' + '/' + encodeURIComponent(index) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -87,10 +79,27 @@ function buildIlmMoveToStep (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ilm.put_lifecycle.js b/api/api/ilm.put_lifecycle.js index 7f2c7d447..0508242da 100644 --- a/api/api/ilm.put_lifecycle.js +++ b/api/api/ilm.put_lifecycle.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIlmPutLifecycle (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildIlmPutLifecycle (opts) { * @param {string} policy - The name of the index lifecycle policy * @param {object} body - The lifecycle policy definition to register */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function ilmPutLifecycle (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -29,42 +41,22 @@ function buildIlmPutLifecycle (opts) { }) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, policy } = params + var querystring = semicopy(params, ['method', 'body', 'policy']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -72,13 +64,13 @@ function buildIlmPutLifecycle (opts) { var path = '' - path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(params['policy']) + path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(policy) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -87,10 +79,27 @@ function buildIlmPutLifecycle (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ilm.remove_policy.js b/api/api/ilm.remove_policy.js index 09e429ebc..2dd9f5ba2 100644 --- a/api/api/ilm.remove_policy.js +++ b/api/api/ilm.remove_policy.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIlmRemovePolicy (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildIlmRemovePolicy (opts) { * * @param {string} index - The name of the index to remove policy on */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function ilmRemovePolicy (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildIlmRemovePolicy (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -79,7 +71,7 @@ function buildIlmRemovePolicy (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + '/' + '_ilm' + '/' + 'remove' + path = '/' + encodeURIComponent(index) + '/' + '_ilm' + '/' + 'remove' // build request object const request = { @@ -94,10 +86,27 @@ function buildIlmRemovePolicy (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ilm.retry.js b/api/api/ilm.retry.js index 0e3f7dc2c..152ac10a3 100644 --- a/api/api/ilm.retry.js +++ b/api/api/ilm.retry.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIlmRetry (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildIlmRetry (opts) { * * @param {string} index - The name of the indices (comma-separated) whose failed lifecycle step is to be retry */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function ilmRetry (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildIlmRetry (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -79,7 +71,7 @@ function buildIlmRetry (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + '/' + '_ilm' + '/' + 'retry' + path = '/' + encodeURIComponent(index) + '/' + '_ilm' + '/' + 'retry' // build request object const request = { @@ -94,10 +86,27 @@ function buildIlmRetry (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ilm.start.js b/api/api/ilm.start.js index f0b9a77ca..e73515d8e 100644 --- a/api/api/ilm.start.js +++ b/api/api/ilm.start.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIlmStart (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -7,6 +10,15 @@ function buildIlmStart (opts) { * Perform a [ilm.start](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-start.html) request * */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function ilmStart (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -35,42 +47,22 @@ function buildIlmStart (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -93,10 +85,27 @@ function buildIlmStart (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ilm.stop.js b/api/api/ilm.stop.js index 500e10a3e..753105de4 100644 --- a/api/api/ilm.stop.js +++ b/api/api/ilm.stop.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIlmStop (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -7,6 +10,15 @@ function buildIlmStop (opts) { * Perform a [ilm.stop](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-stop.html) request * */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function ilmStop (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -35,42 +47,22 @@ function buildIlmStop (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -93,10 +85,27 @@ function buildIlmStop (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/index.js b/api/api/index.js index db8aa2648..bd8d0d785 100644 --- a/api/api/index.js +++ b/api/api/index.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndex (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -20,6 +23,32 @@ function buildIndex (opts) { * @param {string} pipeline - The pipeline id to preprocess incoming documents with * @param {object} body - The document */ + + const acceptedQuerystring = [ + 'wait_for_active_shards', + 'op_type', + 'parent', + 'refresh', + 'routing', + 'timeout', + 'version', + 'version_type', + 'pipeline', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + waitForActiveShards: 'wait_for_active_shards', + opType: 'op_type', + versionType: 'version_type', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function index (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -62,68 +91,22 @@ function buildIndex (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'wait_for_active_shards', - 'op_type', - 'parent', - 'refresh', - 'routing', - 'timeout', - 'version', - 'version_type', - 'pipeline', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'waitForActiveShards', - 'opType', - 'parent', - 'refresh', - 'routing', - 'timeout', - 'version', - 'versionType', - 'pipeline', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -131,21 +114,21 @@ function buildIndex (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null && (params['id']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) - } else if ((params['index']) != null && (params['id']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_doc' + '/' + encodeURIComponent(params['id']) - } else if ((params['index']) != null && (params['type']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + if ((index) != null && (type) != null && (id) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + } else if ((index) != null && (id) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id) + } else if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) } else { - path = '/' + encodeURIComponent(params['index']) + '/' + '_doc' + path = '/' + encodeURIComponent(index) + '/' + '_doc' } // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -154,10 +137,27 @@ function buildIndex (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.analyze.js b/api/api/indices.analyze.js index 87ef4e735..f548bb91e 100644 --- a/api/api/indices.analyze.js +++ b/api/api/indices.analyze.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesAnalyze (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,21 @@ function buildIndicesAnalyze (opts) { * @param {string} index - The name of the index to scope the operation * @param {object} body - Define analyzer/tokenizer parameters and the text on which the analysis should be performed */ + + const acceptedQuerystring = [ + 'index', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesAnalyze (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -30,52 +48,22 @@ function buildIndicesAnalyze (opts) { }) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'index', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'index', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -83,8 +71,8 @@ function buildIndicesAnalyze (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_analyze' + if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_analyze' } else { path = '/' + '_analyze' } @@ -93,7 +81,7 @@ function buildIndicesAnalyze (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -102,10 +90,27 @@ function buildIndicesAnalyze (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.clear_cache.js b/api/api/indices.clear_cache.js index 8b5b78219..37948ece0 100644 --- a/api/api/indices.clear_cache.js +++ b/api/api/indices.clear_cache.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesClearCache (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -16,6 +19,31 @@ function buildIndicesClearCache (opts) { * @param {list} index - A comma-separated list of index name to limit the operation * @param {boolean} request - Clear request cache */ + + const acceptedQuerystring = [ + 'fielddata', + 'fields', + 'query', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'index', + 'request', + '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 indicesClearCache (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,66 +72,22 @@ function buildIndicesClearCache (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'fielddata', - 'fields', - 'query', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'index', - 'request', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'fielddata', - 'fields', - 'query', - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'index', - 'request', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -111,8 +95,8 @@ function buildIndicesClearCache (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_cache' + '/' + 'clear' + if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_cache' + '/' + 'clear' } else { path = '/' + '_cache' + '/' + 'clear' } @@ -130,10 +114,27 @@ function buildIndicesClearCache (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.close.js b/api/api/indices.close.js index 22eec8674..05a0c4af5 100644 --- a/api/api/indices.close.js +++ b/api/api/indices.close.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesClose (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -13,6 +16,29 @@ function buildIndicesClose (opts) { * @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. */ + + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + ignoreUnavailable: 'ignore_unavailable', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesClose (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -47,60 +73,22 @@ function buildIndicesClose (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'timeout', - 'masterTimeout', - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -108,7 +96,7 @@ function buildIndicesClose (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + '/' + '_close' + path = '/' + encodeURIComponent(index) + '/' + '_close' // build request object const request = { @@ -123,10 +111,27 @@ function buildIndicesClose (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.create.js b/api/api/indices.create.js index 97e913b91..4c1e52a3f 100644 --- a/api/api/indices.create.js +++ b/api/api/indices.create.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesCreate (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -13,6 +16,27 @@ function buildIndicesCreate (opts) { * @param {time} master_timeout - Specify timeout for connection to master * @param {object} body - The configuration for the index (`settings` and `mappings`) */ + + const acceptedQuerystring = [ + 'include_type_name', + 'wait_for_active_shards', + 'timeout', + 'master_timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + includeTypeName: 'include_type_name', + waitForActiveShards: 'wait_for_active_shards', + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesCreate (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -41,58 +65,22 @@ function buildIndicesCreate (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'include_type_name', - 'wait_for_active_shards', - 'timeout', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'includeTypeName', - 'waitForActiveShards', - 'timeout', - 'masterTimeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -100,13 +88,13 @@ function buildIndicesCreate (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + path = '/' + encodeURIComponent(index) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -115,10 +103,27 @@ function buildIndicesCreate (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.delete.js b/api/api/indices.delete.js index a0c9c2f70..bcacded57 100644 --- a/api/api/indices.delete.js +++ b/api/api/indices.delete.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesDelete (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -13,6 +16,29 @@ function buildIndicesDelete (opts) { * @param {boolean} allow_no_indices - Ignore if a wildcard expression resolves to no concrete indices (default: false) * @param {enum} expand_wildcards - Whether wildcard expressions should get expanded to open or closed indices (default: open) */ + + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + ignoreUnavailable: 'ignore_unavailable', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesDelete (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -47,60 +73,22 @@ function buildIndicesDelete (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'timeout', - 'masterTimeout', - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -108,7 +96,7 @@ function buildIndicesDelete (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + path = '/' + encodeURIComponent(index) // build request object const request = { @@ -123,10 +111,27 @@ function buildIndicesDelete (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.delete_alias.js b/api/api/indices.delete_alias.js index d4725eb62..b32b1a9f0 100644 --- a/api/api/indices.delete_alias.js +++ b/api/api/indices.delete_alias.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesDeleteAlias (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -11,6 +14,23 @@ function buildIndicesDeleteAlias (opts) { * @param {time} timeout - Explicit timestamp for the document * @param {time} master_timeout - Specify timeout for connection to master */ + + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesDeleteAlias (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -59,54 +79,22 @@ function buildIndicesDeleteAlias (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'timeout', - 'masterTimeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, name } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'name']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -114,10 +102,10 @@ function buildIndicesDeleteAlias (opts) { var path = '' - if ((params['index']) != null && (params['name']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_alias' + '/' + encodeURIComponent(params['name']) + if ((index) != null && (name) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name) } else { - path = '/' + encodeURIComponent(params['index']) + '/' + '_aliases' + '/' + encodeURIComponent(params['name']) + path = '/' + encodeURIComponent(index) + '/' + '_aliases' + '/' + encodeURIComponent(name) } // build request object @@ -133,10 +121,27 @@ function buildIndicesDeleteAlias (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.delete_template.js b/api/api/indices.delete_template.js index 9cbd307c8..072ca2740 100644 --- a/api/api/indices.delete_template.js +++ b/api/api/indices.delete_template.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesDeleteTemplate (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,23 @@ function buildIndicesDeleteTemplate (opts) { * @param {time} timeout - Explicit operation timeout * @param {time} master_timeout - Specify timeout for connection to master */ + + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesDeleteTemplate (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,54 +64,22 @@ function buildIndicesDeleteTemplate (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'timeout', - 'masterTimeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -99,7 +87,7 @@ function buildIndicesDeleteTemplate (opts) { var path = '' - path = '/' + '_template' + '/' + encodeURIComponent(params['name']) + path = '/' + '_template' + '/' + encodeURIComponent(name) // build request object const request = { @@ -114,10 +102,27 @@ function buildIndicesDeleteTemplate (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.exists.js b/api/api/indices.exists.js index 145e754d0..0384da2b7 100644 --- a/api/api/indices.exists.js +++ b/api/api/indices.exists.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesExists (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,31 @@ function buildIndicesExists (opts) { * @param {boolean} flat_settings - Return settings in flat format (default: false) * @param {boolean} include_defaults - Whether to return all default setting for each of the indices. */ + + const acceptedQuerystring = [ + 'local', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'flat_settings', + 'include_defaults', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + ignoreUnavailable: 'ignore_unavailable', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + flatSettings: 'flat_settings', + includeDefaults: 'include_defaults', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesExists (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -48,62 +76,22 @@ function buildIndicesExists (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'local', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'flat_settings', - 'include_defaults', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'local', - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'flatSettings', - 'includeDefaults', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'HEAD' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'HEAD' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -111,7 +99,7 @@ function buildIndicesExists (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + path = '/' + encodeURIComponent(index) // build request object const request = { @@ -126,10 +114,27 @@ function buildIndicesExists (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.exists_alias.js b/api/api/indices.exists_alias.js index 61e218698..8f6a3d726 100644 --- a/api/api/indices.exists_alias.js +++ b/api/api/indices.exists_alias.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesExistsAlias (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -13,6 +16,27 @@ function buildIndicesExistsAlias (opts) { * @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 indicesExistsAlias (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -47,58 +71,22 @@ function buildIndicesExistsAlias (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'local', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'local', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'HEAD' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, name } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'name']) + + if (method == null) { + method = 'HEAD' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -106,10 +94,10 @@ function buildIndicesExistsAlias (opts) { var path = '' - if ((params['index']) != null && (params['name']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_alias' + '/' + encodeURIComponent(params['name']) + if ((index) != null && (name) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name) } else { - path = '/' + '_alias' + '/' + encodeURIComponent(params['name']) + path = '/' + '_alias' + '/' + encodeURIComponent(name) } // build request object @@ -125,10 +113,27 @@ function buildIndicesExistsAlias (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.exists_template.js b/api/api/indices.exists_template.js index 1902bd5c2..d7b9effd5 100644 --- a/api/api/indices.exists_template.js +++ b/api/api/indices.exists_template.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesExistsTemplate (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -11,6 +14,25 @@ function buildIndicesExistsTemplate (opts) { * @param {time} master_timeout - Explicit operation timeout for connection to master node * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) */ + + const acceptedQuerystring = [ + 'flat_settings', + 'master_timeout', + 'local', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + flatSettings: 'flat_settings', + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesExistsTemplate (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -45,56 +67,22 @@ function buildIndicesExistsTemplate (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'flat_settings', - 'master_timeout', - 'local', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'flatSettings', - 'masterTimeout', - 'local', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'HEAD' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'HEAD' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -102,7 +90,7 @@ function buildIndicesExistsTemplate (opts) { var path = '' - path = '/' + '_template' + '/' + encodeURIComponent(params['name']) + path = '/' + '_template' + '/' + encodeURIComponent(name) // build request object const request = { @@ -117,10 +105,27 @@ function buildIndicesExistsTemplate (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.exists_type.js b/api/api/indices.exists_type.js index 4e9305263..c08fd8695 100644 --- a/api/api/indices.exists_type.js +++ b/api/api/indices.exists_type.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesExistsType (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -13,6 +16,27 @@ function buildIndicesExistsType (opts) { * @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 indicesExistsType (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -61,58 +85,22 @@ function buildIndicesExistsType (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'local', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'local', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'HEAD' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'type']) + + if (method == null) { + method = 'HEAD' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -120,7 +108,7 @@ function buildIndicesExistsType (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + '/' + encodeURIComponent(params['type']) + path = '/' + encodeURIComponent(index) + '/' + '_mapping' + '/' + encodeURIComponent(type) // build request object const request = { @@ -135,10 +123,27 @@ function buildIndicesExistsType (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.flush.js b/api/api/indices.flush.js index 87a8d76f9..e8e1aca59 100644 --- a/api/api/indices.flush.js +++ b/api/api/indices.flush.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesFlush (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -13,6 +16,29 @@ function buildIndicesFlush (opts) { * @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. */ + + const acceptedQuerystring = [ + 'force', + 'wait_if_ongoing', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + waitIfOngoing: 'wait_if_ongoing', + ignoreUnavailable: 'ignore_unavailable', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesFlush (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -41,60 +67,22 @@ function buildIndicesFlush (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'force', - 'wait_if_ongoing', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'force', - 'waitIfOngoing', - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -102,8 +90,8 @@ function buildIndicesFlush (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_flush' + if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_flush' } else { path = '/' + '_flush' } @@ -121,10 +109,27 @@ function buildIndicesFlush (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.flush_synced.js b/api/api/indices.flush_synced.js index 857670661..ec4f7086a 100644 --- a/api/api/indices.flush_synced.js +++ b/api/api/indices.flush_synced.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesFlushSynced (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -11,6 +14,26 @@ function buildIndicesFlushSynced (opts) { * @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. */ + + const acceptedQuerystring = [ + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + '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 indicesFlushSynced (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -39,56 +62,22 @@ function buildIndicesFlushSynced (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -96,8 +85,8 @@ function buildIndicesFlushSynced (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_flush' + '/' + 'synced' + if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_flush' + '/' + 'synced' } else { path = '/' + '_flush' + '/' + 'synced' } @@ -115,10 +104,27 @@ function buildIndicesFlushSynced (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.forcemerge.js b/api/api/indices.forcemerge.js index ea8633ae8..3ee9383c9 100644 --- a/api/api/indices.forcemerge.js +++ b/api/api/indices.forcemerge.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesForcemerge (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,31 @@ function buildIndicesForcemerge (opts) { * @param {number} max_num_segments - The number of segments the index should be merged into (default: dynamic) * @param {boolean} only_expunge_deletes - Specify whether the operation should only expunge deleted documents */ + + const acceptedQuerystring = [ + 'flush', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'max_num_segments', + 'only_expunge_deletes', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + ignoreUnavailable: 'ignore_unavailable', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + maxNumSegments: 'max_num_segments', + onlyExpungeDeletes: 'only_expunge_deletes', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesForcemerge (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -42,62 +70,22 @@ function buildIndicesForcemerge (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'flush', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'max_num_segments', - 'only_expunge_deletes', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'flush', - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'maxNumSegments', - 'onlyExpungeDeletes', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -105,8 +93,8 @@ function buildIndicesForcemerge (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_forcemerge' + if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_forcemerge' } else { path = '/' + '_forcemerge' } @@ -124,10 +112,27 @@ function buildIndicesForcemerge (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.freeze.js b/api/api/indices.freeze.js index 5226f6064..deb10d22e 100644 --- a/api/api/indices.freeze.js +++ b/api/api/indices.freeze.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesFreeze (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,24 @@ function buildIndicesFreeze (opts) { * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {string} wait_for_active_shards - Sets the number of active shards to wait for before the operation returns. */ + + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'wait_for_active_shards' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + ignoreUnavailable: 'ignore_unavailable', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + waitForActiveShards: 'wait_for_active_shards' + } + return function indicesFreeze (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -48,52 +69,22 @@ function buildIndicesFreeze (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'wait_for_active_shards' - ] - const acceptedQuerystringCamelCased = [ - 'timeout', - 'masterTimeout', - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'waitForActiveShards' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -101,7 +92,7 @@ function buildIndicesFreeze (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + '/' + '_freeze' + path = '/' + encodeURIComponent(index) + '/' + '_freeze' // build request object const request = { @@ -116,10 +107,27 @@ function buildIndicesFreeze (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.get.js b/api/api/indices.get.js index b0a9b8dad..685665cc4 100644 --- a/api/api/indices.get.js +++ b/api/api/indices.get.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesGet (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -15,6 +18,33 @@ function buildIndicesGet (opts) { * @param {boolean} include_defaults - Whether to return all default setting for each of the indices. * @param {time} master_timeout - Specify timeout for connection to master */ + + const acceptedQuerystring = [ + 'local', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'flat_settings', + 'include_defaults', + 'master_timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + ignoreUnavailable: 'ignore_unavailable', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + flatSettings: 'flat_settings', + includeDefaults: 'include_defaults', + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesGet (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -49,64 +79,22 @@ function buildIndicesGet (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'local', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'flat_settings', - 'include_defaults', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'local', - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'flatSettings', - 'includeDefaults', - 'masterTimeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -114,7 +102,7 @@ function buildIndicesGet (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + path = '/' + encodeURIComponent(index) // build request object const request = { @@ -129,10 +117,27 @@ function buildIndicesGet (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.get_alias.js b/api/api/indices.get_alias.js index b5401a1bd..ce82cc7fb 100644 --- a/api/api/indices.get_alias.js +++ b/api/api/indices.get_alias.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesGetAlias (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -13,6 +16,27 @@ function buildIndicesGetAlias (opts) { * @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') { @@ -41,58 +65,22 @@ function buildIndicesGetAlias (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'local', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'local', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, name } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'name']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -100,12 +88,12 @@ function buildIndicesGetAlias (opts) { var path = '' - if ((params['index']) != null && (params['name']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_alias' + '/' + encodeURIComponent(params['name']) - } else if ((params['name']) != null) { - path = '/' + '_alias' + '/' + encodeURIComponent(params['name']) - } else if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_alias' + 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' } @@ -123,10 +111,27 @@ function buildIndicesGetAlias (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.get_field_mapping.js b/api/api/indices.get_field_mapping.js index 63fa23006..da0e264c5 100644 --- a/api/api/indices.get_field_mapping.js +++ b/api/api/indices.get_field_mapping.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesGetFieldMapping (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -15,6 +18,29 @@ function buildIndicesGetFieldMapping (opts) { * @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 = [ + 'include_defaults', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'local', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + includeDefaults: 'include_defaults', + ignoreUnavailable: 'ignore_unavailable', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesGetFieldMapping (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -49,60 +75,22 @@ function buildIndicesGetFieldMapping (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'include_defaults', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'local', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'includeDefaults', - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'local', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, type, fields } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'type', 'fields']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -110,14 +98,14 @@ function buildIndicesGetFieldMapping (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null && (params['fields']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + '/' + encodeURIComponent(params['type']) + '/' + 'field' + '/' + encodeURIComponent(params['fields']) - } else if ((params['index']) != null && (params['fields']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + '/' + 'field' + '/' + encodeURIComponent(params['fields']) - } else if ((params['type']) != null && (params['fields']) != null) { - path = '/' + '_mapping' + '/' + encodeURIComponent(params['type']) + '/' + 'field' + '/' + encodeURIComponent(params['fields']) + if ((index) != null && (type) != null && (fields) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_mapping' + '/' + encodeURIComponent(type) + '/' + 'field' + '/' + encodeURIComponent(fields) + } else if ((index) != null && (fields) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_mapping' + '/' + 'field' + '/' + encodeURIComponent(fields) + } else if ((type) != null && (fields) != null) { + path = '/' + '_mapping' + '/' + encodeURIComponent(type) + '/' + 'field' + '/' + encodeURIComponent(fields) } else { - path = '/' + '_mapping' + '/' + 'field' + '/' + encodeURIComponent(params['fields']) + path = '/' + '_mapping' + '/' + 'field' + '/' + encodeURIComponent(fields) } // build request object @@ -133,10 +121,27 @@ function buildIndicesGetFieldMapping (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.get_mapping.js b/api/api/indices.get_mapping.js index 84c8f249c..4130c2e4e 100644 --- a/api/api/indices.get_mapping.js +++ b/api/api/indices.get_mapping.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesGetMapping (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -15,6 +18,31 @@ function buildIndicesGetMapping (opts) { * @param {time} master_timeout - Specify timeout for connection to master * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) */ + + const acceptedQuerystring = [ + 'include_type_name', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'master_timeout', + 'local', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + includeTypeName: 'include_type_name', + ignoreUnavailable: 'ignore_unavailable', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesGetMapping (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,62 +71,22 @@ function buildIndicesGetMapping (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'include_type_name', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'master_timeout', - 'local', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'includeTypeName', - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'masterTimeout', - 'local', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'type']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -106,12 +94,12 @@ function buildIndicesGetMapping (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + '/' + encodeURIComponent(params['type']) - } else if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' - } else if ((params['type']) != null) { - path = '/' + '_mapping' + '/' + encodeURIComponent(params['type']) + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_mapping' + '/' + encodeURIComponent(type) + } else if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_mapping' + } else if ((type) != null) { + path = '/' + '_mapping' + '/' + encodeURIComponent(type) } else { path = '/' + '_mapping' } @@ -129,10 +117,27 @@ function buildIndicesGetMapping (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.get_settings.js b/api/api/indices.get_settings.js index 22a8639a9..887161848 100644 --- a/api/api/indices.get_settings.js +++ b/api/api/indices.get_settings.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesGetSettings (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -16,6 +19,33 @@ function buildIndicesGetSettings (opts) { * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) * @param {boolean} include_defaults - Whether to return all default setting for each of the indices. */ + + const acceptedQuerystring = [ + 'master_timeout', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'flat_settings', + 'local', + 'include_defaults', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + ignoreUnavailable: 'ignore_unavailable', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + flatSettings: 'flat_settings', + includeDefaults: 'include_defaults', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesGetSettings (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,64 +74,22 @@ function buildIndicesGetSettings (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'master_timeout', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'flat_settings', - 'local', - 'include_defaults', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'masterTimeout', - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'flatSettings', - 'local', - 'includeDefaults', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, name } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'name']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -109,12 +97,12 @@ function buildIndicesGetSettings (opts) { var path = '' - if ((params['index']) != null && (params['name']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_settings' + '/' + encodeURIComponent(params['name']) - } else if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_settings' - } else if ((params['name']) != null) { - path = '/' + '_settings' + '/' + encodeURIComponent(params['name']) + if ((index) != null && (name) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_settings' + '/' + encodeURIComponent(name) + } else if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_settings' + } else if ((name) != null) { + path = '/' + '_settings' + '/' + encodeURIComponent(name) } else { path = '/' + '_settings' } @@ -132,10 +120,27 @@ function buildIndicesGetSettings (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.get_template.js b/api/api/indices.get_template.js index f22726bf2..ac4702461 100644 --- a/api/api/indices.get_template.js +++ b/api/api/indices.get_template.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesGetTemplate (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -11,6 +14,25 @@ function buildIndicesGetTemplate (opts) { * @param {time} master_timeout - Explicit operation timeout for connection to master node * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) */ + + const acceptedQuerystring = [ + 'flat_settings', + 'master_timeout', + 'local', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + flatSettings: 'flat_settings', + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesGetTemplate (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -39,56 +61,22 @@ function buildIndicesGetTemplate (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'flat_settings', - 'master_timeout', - 'local', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'flatSettings', - 'masterTimeout', - 'local', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -96,8 +84,8 @@ function buildIndicesGetTemplate (opts) { var path = '' - if ((params['name']) != null) { - path = '/' + '_template' + '/' + encodeURIComponent(params['name']) + if ((name) != null) { + path = '/' + '_template' + '/' + encodeURIComponent(name) } else { path = '/' + '_template' } @@ -115,10 +103,27 @@ function buildIndicesGetTemplate (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.get_upgrade.js b/api/api/indices.get_upgrade.js index 02e1a01bf..90e6f5eb0 100644 --- a/api/api/indices.get_upgrade.js +++ b/api/api/indices.get_upgrade.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesGetUpgrade (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -11,6 +14,26 @@ function buildIndicesGetUpgrade (opts) { * @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. */ + + const acceptedQuerystring = [ + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + '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 indicesGetUpgrade (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -39,56 +62,22 @@ function buildIndicesGetUpgrade (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -96,8 +85,8 @@ function buildIndicesGetUpgrade (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_upgrade' + if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_upgrade' } else { path = '/' + '_upgrade' } @@ -115,10 +104,27 @@ function buildIndicesGetUpgrade (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.open.js b/api/api/indices.open.js index 76a014b5d..76de5efd1 100644 --- a/api/api/indices.open.js +++ b/api/api/indices.open.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesOpen (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,31 @@ function buildIndicesOpen (opts) { * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {string} wait_for_active_shards - Sets the number of active shards to wait for before the operation returns. */ + + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'wait_for_active_shards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + ignoreUnavailable: 'ignore_unavailable', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + waitForActiveShards: 'wait_for_active_shards', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesOpen (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -48,62 +76,22 @@ function buildIndicesOpen (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'wait_for_active_shards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'timeout', - 'masterTimeout', - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'waitForActiveShards', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -111,7 +99,7 @@ function buildIndicesOpen (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + '/' + '_open' + path = '/' + encodeURIComponent(index) + '/' + '_open' // build request object const request = { @@ -126,10 +114,27 @@ function buildIndicesOpen (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.put_alias.js b/api/api/indices.put_alias.js index 200e833e6..2208b9008 100644 --- a/api/api/indices.put_alias.js +++ b/api/api/indices.put_alias.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesPutAlias (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -12,6 +15,23 @@ function buildIndicesPutAlias (opts) { * @param {time} master_timeout - Specify timeout for connection to master * @param {object} body - The settings for the alias, such as `routing` or `filter` */ + + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesPutAlias (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -54,54 +74,22 @@ function buildIndicesPutAlias (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'timeout', - 'masterTimeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, name } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'name']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -109,17 +97,17 @@ function buildIndicesPutAlias (opts) { var path = '' - if ((params['index']) != null && (params['name']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_alias' + '/' + encodeURIComponent(params['name']) + if ((index) != null && (name) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name) } else { - path = '/' + encodeURIComponent(params['index']) + '/' + '_aliases' + '/' + encodeURIComponent(params['name']) + path = '/' + encodeURIComponent(index) + '/' + '_aliases' + '/' + encodeURIComponent(name) } // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -128,10 +116,27 @@ function buildIndicesPutAlias (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.put_mapping.js b/api/api/indices.put_mapping.js index 8a04ed0c9..a6dae7d40 100644 --- a/api/api/indices.put_mapping.js +++ b/api/api/indices.put_mapping.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesPutMapping (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -16,6 +19,31 @@ function buildIndicesPutMapping (opts) { * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {object} body - The mapping definition */ + + const acceptedQuerystring = [ + 'include_type_name', + 'timeout', + 'master_timeout', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + includeTypeName: 'include_type_name', + masterTimeout: 'master_timeout', + ignoreUnavailable: 'ignore_unavailable', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesPutMapping (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,62 +72,22 @@ function buildIndicesPutMapping (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'include_type_name', - 'timeout', - 'master_timeout', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'includeTypeName', - 'timeout', - 'masterTimeout', - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'type']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -107,29 +95,29 @@ function buildIndicesPutMapping (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_mapping' - } else if ((params['index']) != null && (params['type']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + '/' + encodeURIComponent(params['type']) - } else if ((params['index']) != null && (params['type']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_mappings' - } else if ((params['index']) != null && (params['type']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_mappings' + '/' + encodeURIComponent(params['type']) - } else if ((params['type']) != null) { - path = '/' + '_mapping' + '/' + encodeURIComponent(params['type']) - } else if ((params['type']) != null) { - path = '/' + '_mappings' + '/' + encodeURIComponent(params['type']) - } else if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_mappings' + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_mapping' + } else if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_mapping' + '/' + encodeURIComponent(type) + } else if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_mappings' + } else if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_mappings' + '/' + encodeURIComponent(type) + } else if ((type) != null) { + path = '/' + '_mapping' + '/' + encodeURIComponent(type) + } else if ((type) != null) { + path = '/' + '_mappings' + '/' + encodeURIComponent(type) + } else if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_mappings' } else { - path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + path = '/' + encodeURIComponent(index) + '/' + '_mapping' } // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -138,10 +126,27 @@ function buildIndicesPutMapping (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.put_settings.js b/api/api/indices.put_settings.js index 0c2532df3..9d4ec22a8 100644 --- a/api/api/indices.put_settings.js +++ b/api/api/indices.put_settings.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesPutSettings (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -16,6 +19,33 @@ function buildIndicesPutSettings (opts) { * @param {boolean} flat_settings - Return settings in flat format (default: false) * @param {object} body - The index settings to be updated */ + + const acceptedQuerystring = [ + 'master_timeout', + 'timeout', + 'preserve_existing', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'flat_settings', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + preserveExisting: 'preserve_existing', + ignoreUnavailable: 'ignore_unavailable', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + flatSettings: 'flat_settings', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesPutSettings (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,64 +74,22 @@ function buildIndicesPutSettings (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'master_timeout', - 'timeout', - 'preserve_existing', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'flat_settings', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'masterTimeout', - 'timeout', - 'preserveExisting', - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'flatSettings', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -109,8 +97,8 @@ function buildIndicesPutSettings (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_settings' + if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_settings' } else { path = '/' + '_settings' } @@ -119,7 +107,7 @@ function buildIndicesPutSettings (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -128,10 +116,27 @@ function buildIndicesPutSettings (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.put_template.js b/api/api/indices.put_template.js index 97b317e0f..92f577446 100644 --- a/api/api/indices.put_template.js +++ b/api/api/indices.put_template.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesPutTemplate (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,27 @@ function buildIndicesPutTemplate (opts) { * @param {boolean} flat_settings - Return settings in flat format (default: false) * @param {object} body - The template definition */ + + const acceptedQuerystring = [ + 'order', + 'create', + 'timeout', + 'master_timeout', + 'flat_settings', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + flatSettings: 'flat_settings', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesPutTemplate (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -48,60 +72,22 @@ function buildIndicesPutTemplate (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'order', - 'create', - 'timeout', - 'master_timeout', - 'flat_settings', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'order', - 'create', - 'timeout', - 'masterTimeout', - 'flatSettings', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -109,13 +95,13 @@ function buildIndicesPutTemplate (opts) { var path = '' - path = '/' + '_template' + '/' + encodeURIComponent(params['name']) + path = '/' + '_template' + '/' + encodeURIComponent(name) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -124,10 +110,27 @@ function buildIndicesPutTemplate (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.recovery.js b/api/api/indices.recovery.js index f36f31d01..3a5ba3f90 100644 --- a/api/api/indices.recovery.js +++ b/api/api/indices.recovery.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesRecovery (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,23 @@ function buildIndicesRecovery (opts) { * @param {boolean} detailed - Whether to display detailed information about shard recovery * @param {boolean} active_only - Display only those recoveries that are currently on-going */ + + const acceptedQuerystring = [ + 'detailed', + 'active_only', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + activeOnly: 'active_only', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesRecovery (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -38,54 +58,22 @@ function buildIndicesRecovery (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'detailed', - 'active_only', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'detailed', - 'activeOnly', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -93,8 +81,8 @@ function buildIndicesRecovery (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_recovery' + if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_recovery' } else { path = '/' + '_recovery' } @@ -112,10 +100,27 @@ function buildIndicesRecovery (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.refresh.js b/api/api/indices.refresh.js index 0e264b781..e73865227 100644 --- a/api/api/indices.refresh.js +++ b/api/api/indices.refresh.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesRefresh (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -11,6 +14,26 @@ function buildIndicesRefresh (opts) { * @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. */ + + const acceptedQuerystring = [ + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + '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 indicesRefresh (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -39,56 +62,22 @@ function buildIndicesRefresh (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -96,8 +85,8 @@ function buildIndicesRefresh (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_refresh' + if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_refresh' } else { path = '/' + '_refresh' } @@ -115,10 +104,27 @@ function buildIndicesRefresh (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.rollover.js b/api/api/indices.rollover.js index 166c41856..3713d8a74 100644 --- a/api/api/indices.rollover.js +++ b/api/api/indices.rollover.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesRollover (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,27 @@ function buildIndicesRollover (opts) { * @param {string} wait_for_active_shards - Set the number of active shards to wait for on the newly created rollover index before the operation returns. * @param {object} body - The conditions that needs to be met for executing rollover */ + + const acceptedQuerystring = [ + 'timeout', + 'dry_run', + 'master_timeout', + 'wait_for_active_shards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + dryRun: 'dry_run', + masterTimeout: 'master_timeout', + waitForActiveShards: 'wait_for_active_shards', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesRollover (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -50,58 +74,22 @@ function buildIndicesRollover (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'timeout', - 'dry_run', - 'master_timeout', - 'wait_for_active_shards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'timeout', - 'dryRun', - 'masterTimeout', - 'waitForActiveShards', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, alias, newIndex, new_index } = params + var querystring = semicopy(params, ['method', 'body', 'alias', 'newIndex', 'new_index']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -109,17 +97,17 @@ function buildIndicesRollover (opts) { var path = '' - if ((params['alias']) != null && (params['new_index'] || params['newIndex']) != null) { - path = '/' + encodeURIComponent(params['alias']) + '/' + '_rollover' + '/' + encodeURIComponent(params['new_index'] || params['newIndex']) + if ((alias) != null && (new_index || newIndex) != null) { + path = '/' + encodeURIComponent(alias) + '/' + '_rollover' + '/' + encodeURIComponent(new_index || newIndex) } else { - path = '/' + encodeURIComponent(params['alias']) + '/' + '_rollover' + path = '/' + encodeURIComponent(alias) + '/' + '_rollover' } // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -128,10 +116,27 @@ function buildIndicesRollover (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.segments.js b/api/api/indices.segments.js index e8f044e1a..79d1d3f23 100644 --- a/api/api/indices.segments.js +++ b/api/api/indices.segments.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesSegments (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -12,6 +15,27 @@ function buildIndicesSegments (opts) { * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {boolean} verbose - Includes detailed memory usage by Lucene. */ + + const acceptedQuerystring = [ + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'verbose', + '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 indicesSegments (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -40,58 +64,22 @@ function buildIndicesSegments (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'verbose', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'verbose', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -99,8 +87,8 @@ function buildIndicesSegments (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_segments' + if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_segments' } else { path = '/' + '_segments' } @@ -118,10 +106,27 @@ function buildIndicesSegments (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.shard_stores.js b/api/api/indices.shard_stores.js index 663841e74..e0c03498a 100644 --- a/api/api/indices.shard_stores.js +++ b/api/api/indices.shard_stores.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesShardStores (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -12,6 +15,27 @@ function buildIndicesShardStores (opts) { * @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. */ + + const acceptedQuerystring = [ + 'status', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + '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 indicesShardStores (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -40,58 +64,22 @@ function buildIndicesShardStores (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'status', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'status', - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -99,8 +87,8 @@ function buildIndicesShardStores (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_shard_stores' + if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_shard_stores' } else { path = '/' + '_shard_stores' } @@ -118,10 +106,27 @@ function buildIndicesShardStores (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.shrink.js b/api/api/indices.shrink.js index db423b13f..3b76d6de3 100644 --- a/api/api/indices.shrink.js +++ b/api/api/indices.shrink.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesShrink (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,27 @@ function buildIndicesShrink (opts) { * @param {string} wait_for_active_shards - Set the number of active shards to wait for on the shrunken index before the operation returns. * @param {object} body - The configuration for the target index (`settings` and `aliases`) */ + + const acceptedQuerystring = [ + 'copy_settings', + 'timeout', + 'master_timeout', + 'wait_for_active_shards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + copySettings: 'copy_settings', + masterTimeout: 'master_timeout', + waitForActiveShards: 'wait_for_active_shards', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesShrink (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -56,58 +80,22 @@ function buildIndicesShrink (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'copy_settings', - 'timeout', - 'master_timeout', - 'wait_for_active_shards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'copySettings', - 'timeout', - 'masterTimeout', - 'waitForActiveShards', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, target } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'target']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -115,13 +103,13 @@ function buildIndicesShrink (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + '/' + '_shrink' + '/' + encodeURIComponent(params['target']) + path = '/' + encodeURIComponent(index) + '/' + '_shrink' + '/' + encodeURIComponent(target) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -130,10 +118,27 @@ function buildIndicesShrink (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.split.js b/api/api/indices.split.js index b2ce07cf7..7e7b45d1f 100644 --- a/api/api/indices.split.js +++ b/api/api/indices.split.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesSplit (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,27 @@ function buildIndicesSplit (opts) { * @param {string} wait_for_active_shards - Set the number of active shards to wait for on the shrunken index before the operation returns. * @param {object} body - The configuration for the target index (`settings` and `aliases`) */ + + const acceptedQuerystring = [ + 'copy_settings', + 'timeout', + 'master_timeout', + 'wait_for_active_shards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + copySettings: 'copy_settings', + masterTimeout: 'master_timeout', + waitForActiveShards: 'wait_for_active_shards', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesSplit (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -56,58 +80,22 @@ function buildIndicesSplit (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'copy_settings', - 'timeout', - 'master_timeout', - 'wait_for_active_shards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'copySettings', - 'timeout', - 'masterTimeout', - 'waitForActiveShards', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, target } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'target']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -115,13 +103,13 @@ function buildIndicesSplit (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + '/' + '_split' + '/' + encodeURIComponent(params['target']) + path = '/' + encodeURIComponent(index) + '/' + '_split' + '/' + encodeURIComponent(target) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -130,10 +118,27 @@ function buildIndicesSplit (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.stats.js b/api/api/indices.stats.js index 63bb90ab4..ce2467410 100644 --- a/api/api/indices.stats.js +++ b/api/api/indices.stats.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesStats (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -16,6 +19,30 @@ function buildIndicesStats (opts) { * @param {list} types - A comma-separated list of document types for the `indexing` index metric * @param {boolean} include_segment_file_sizes - Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) */ + + const acceptedQuerystring = [ + 'completion_fields', + 'fielddata_fields', + 'fields', + 'groups', + 'level', + 'types', + 'include_segment_file_sizes', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + completionFields: 'completion_fields', + fielddataFields: 'fielddata_fields', + includeSegmentFileSizes: 'include_segment_file_sizes', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesStats (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,64 +71,22 @@ function buildIndicesStats (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'completion_fields', - 'fielddata_fields', - 'fields', - 'groups', - 'level', - 'types', - 'include_segment_file_sizes', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'completionFields', - 'fielddataFields', - 'fields', - 'groups', - 'level', - 'types', - 'includeSegmentFileSizes', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, metric } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'metric']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -109,12 +94,12 @@ function buildIndicesStats (opts) { var path = '' - if ((params['index']) != null && (params['metric']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_stats' + '/' + encodeURIComponent(params['metric']) - } else if ((params['metric']) != null) { - path = '/' + '_stats' + '/' + encodeURIComponent(params['metric']) - } else if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_stats' + if ((index) != null && (metric) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_stats' + '/' + encodeURIComponent(metric) + } else if ((metric) != null) { + path = '/' + '_stats' + '/' + encodeURIComponent(metric) + } else if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_stats' } else { path = '/' + '_stats' } @@ -132,10 +117,27 @@ function buildIndicesStats (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.unfreeze.js b/api/api/indices.unfreeze.js index 3f6ade686..d9ef9d2ad 100644 --- a/api/api/indices.unfreeze.js +++ b/api/api/indices.unfreeze.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesUnfreeze (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,24 @@ function buildIndicesUnfreeze (opts) { * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {string} wait_for_active_shards - Sets the number of active shards to wait for before the operation returns. */ + + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'wait_for_active_shards' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + ignoreUnavailable: 'ignore_unavailable', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + waitForActiveShards: 'wait_for_active_shards' + } + return function indicesUnfreeze (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -48,52 +69,22 @@ function buildIndicesUnfreeze (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'wait_for_active_shards' - ] - const acceptedQuerystringCamelCased = [ - 'timeout', - 'masterTimeout', - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'waitForActiveShards' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -101,7 +92,7 @@ function buildIndicesUnfreeze (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + '/' + '_unfreeze' + path = '/' + encodeURIComponent(index) + '/' + '_unfreeze' // build request object const request = { @@ -116,10 +107,27 @@ function buildIndicesUnfreeze (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.update_aliases.js b/api/api/indices.update_aliases.js index cb2b8f91b..cb869edbd 100644 --- a/api/api/indices.update_aliases.js +++ b/api/api/indices.update_aliases.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesUpdateAliases (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,23 @@ function buildIndicesUpdateAliases (opts) { * @param {time} master_timeout - Specify timeout for connection to master * @param {object} body - The definition of `actions` to perform */ + + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesUpdateAliases (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -38,54 +58,22 @@ function buildIndicesUpdateAliases (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'timeout', - 'masterTimeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -99,7 +87,7 @@ function buildIndicesUpdateAliases (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -108,10 +96,27 @@ function buildIndicesUpdateAliases (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.upgrade.js b/api/api/indices.upgrade.js index bfa521d65..88894487b 100644 --- a/api/api/indices.upgrade.js +++ b/api/api/indices.upgrade.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesUpgrade (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -13,6 +16,30 @@ function buildIndicesUpgrade (opts) { * @param {boolean} wait_for_completion - Specify whether the request should block until the all segments are upgraded (default: false) * @param {boolean} only_ancient_segments - If true, only ancient (an older Lucene major release) segments will be upgraded */ + + const acceptedQuerystring = [ + 'allow_no_indices', + 'expand_wildcards', + 'ignore_unavailable', + 'wait_for_completion', + 'only_ancient_segments', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + ignoreUnavailable: 'ignore_unavailable', + waitForCompletion: 'wait_for_completion', + onlyAncientSegments: 'only_ancient_segments', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesUpgrade (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -41,60 +68,22 @@ function buildIndicesUpgrade (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'allow_no_indices', - 'expand_wildcards', - 'ignore_unavailable', - 'wait_for_completion', - 'only_ancient_segments', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'allowNoIndices', - 'expandWildcards', - 'ignoreUnavailable', - 'waitForCompletion', - 'onlyAncientSegments', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -102,8 +91,8 @@ function buildIndicesUpgrade (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_upgrade' + if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_upgrade' } else { path = '/' + '_upgrade' } @@ -121,10 +110,27 @@ function buildIndicesUpgrade (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/indices.validate_query.js b/api/api/indices.validate_query.js index 2c3d76aae..02b9d0786 100644 --- a/api/api/indices.validate_query.js +++ b/api/api/indices.validate_query.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIndicesValidateQuery (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -22,6 +25,38 @@ function buildIndicesValidateQuery (opts) { * @param {boolean} all_shards - Execute validation on all shards instead of one random shard per index * @param {object} body - The query definition specified with the Query DSL */ + + const acceptedQuerystring = [ + 'explain', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'q', + 'analyzer', + 'analyze_wildcard', + 'default_operator', + 'df', + 'lenient', + 'rewrite', + 'all_shards', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + ignoreUnavailable: 'ignore_unavailable', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + analyzeWildcard: 'analyze_wildcard', + defaultOperator: 'default_operator', + allShards: 'all_shards', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function indicesValidateQuery (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -50,74 +85,22 @@ function buildIndicesValidateQuery (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'explain', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'q', - 'analyzer', - 'analyze_wildcard', - 'default_operator', - 'df', - 'lenient', - 'rewrite', - 'all_shards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'explain', - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'q', - 'analyzer', - 'analyzeWildcard', - 'defaultOperator', - 'df', - 'lenient', - 'rewrite', - 'allShards', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'type']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -125,10 +108,10 @@ function buildIndicesValidateQuery (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_validate' + '/' + 'query' - } else if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_validate' + '/' + 'query' + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_validate' + '/' + 'query' + } else if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_validate' + '/' + 'query' } else { path = '/' + '_validate' + '/' + 'query' } @@ -137,7 +120,7 @@ function buildIndicesValidateQuery (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -146,10 +129,27 @@ function buildIndicesValidateQuery (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/info.js b/api/api/info.js index 280d74b2b..5f8b99a46 100644 --- a/api/api/info.js +++ b/api/api/info.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildInfo (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -7,6 +10,20 @@ function buildInfo (opts) { * Perform a [info](http://www.elastic.co/guide/) request * */ + + const acceptedQuerystring = [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function info (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -35,50 +52,22 @@ function buildInfo (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -101,10 +90,27 @@ function buildInfo (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ingest.delete_pipeline.js b/api/api/ingest.delete_pipeline.js index 48ed5832a..73cf41fad 100644 --- a/api/api/ingest.delete_pipeline.js +++ b/api/api/ingest.delete_pipeline.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIngestDeletePipeline (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,23 @@ function buildIngestDeletePipeline (opts) { * @param {time} master_timeout - Explicit operation timeout for connection to master node * @param {time} timeout - Explicit operation timeout */ + + const acceptedQuerystring = [ + 'master_timeout', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function ingestDeletePipeline (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,54 +64,22 @@ function buildIngestDeletePipeline (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'master_timeout', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'masterTimeout', - 'timeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -99,7 +87,7 @@ function buildIngestDeletePipeline (opts) { var path = '' - path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(params['id']) + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id) // build request object const request = { @@ -114,10 +102,27 @@ function buildIngestDeletePipeline (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ingest.get_pipeline.js b/api/api/ingest.get_pipeline.js index b275e6283..c5194f5d4 100644 --- a/api/api/ingest.get_pipeline.js +++ b/api/api/ingest.get_pipeline.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIngestGetPipeline (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,22 @@ function buildIngestGetPipeline (opts) { * @param {string} id - Comma separated list of pipeline ids. Wildcards supported * @param {time} master_timeout - Explicit operation timeout for connection to master node */ + + const acceptedQuerystring = [ + 'master_timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function ingestGetPipeline (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -37,52 +56,22 @@ function buildIngestGetPipeline (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'masterTimeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -90,8 +79,8 @@ function buildIngestGetPipeline (opts) { var path = '' - if ((params['id']) != null) { - path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(params['id']) + if ((id) != null) { + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id) } else { path = '/' + '_ingest' + '/' + 'pipeline' } @@ -109,10 +98,27 @@ function buildIngestGetPipeline (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ingest.processor_grok.js b/api/api/ingest.processor_grok.js index c64b7c6b2..a74871868 100644 --- a/api/api/ingest.processor_grok.js +++ b/api/api/ingest.processor_grok.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIngestProcessorGrok (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -7,6 +10,20 @@ function buildIngestProcessorGrok (opts) { * Perform a [ingest.processor_grok](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request * */ + + const acceptedQuerystring = [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function ingestProcessorGrok (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -35,50 +52,22 @@ function buildIngestProcessorGrok (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -101,10 +90,27 @@ function buildIngestProcessorGrok (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ingest.put_pipeline.js b/api/api/ingest.put_pipeline.js index 2a50f23b2..457a43446 100644 --- a/api/api/ingest.put_pipeline.js +++ b/api/api/ingest.put_pipeline.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIngestPutPipeline (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -11,6 +14,23 @@ function buildIngestPutPipeline (opts) { * @param {time} timeout - Explicit operation timeout * @param {object} body - The ingest definition */ + + const acceptedQuerystring = [ + 'master_timeout', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function ingestPutPipeline (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -45,54 +65,22 @@ function buildIngestPutPipeline (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'master_timeout', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'masterTimeout', - 'timeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -100,13 +88,13 @@ function buildIngestPutPipeline (opts) { var path = '' - path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(params['id']) + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -115,10 +103,27 @@ function buildIngestPutPipeline (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ingest.simulate.js b/api/api/ingest.simulate.js index d5e961359..88646cb22 100644 --- a/api/api/ingest.simulate.js +++ b/api/api/ingest.simulate.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildIngestSimulate (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,21 @@ function buildIngestSimulate (opts) { * @param {boolean} verbose - Verbose mode. Display data output for each processor in executed pipeline * @param {object} body - The simulate definition */ + + const acceptedQuerystring = [ + 'verbose', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function ingestSimulate (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -38,52 +56,22 @@ function buildIngestSimulate (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'verbose', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'verbose', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -91,8 +79,8 @@ function buildIngestSimulate (opts) { var path = '' - if ((params['id']) != null) { - path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(params['id']) + '/' + '_simulate' + if ((id) != null) { + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id) + '/' + '_simulate' } else { path = '/' + '_ingest' + '/' + 'pipeline' + '/' + '_simulate' } @@ -101,7 +89,7 @@ function buildIngestSimulate (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -110,10 +98,27 @@ function buildIngestSimulate (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/mget.js b/api/api/mget.js index 2213dff78..7f145470f 100644 --- a/api/api/mget.js +++ b/api/api/mget.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMget (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -18,6 +21,31 @@ function buildMget (opts) { * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {object} body - Document identifiers; can be either `docs` (containing full document information) or `ids` (when index and type is provided in the URL. */ + + const acceptedQuerystring = [ + 'stored_fields', + 'preference', + 'realtime', + 'refresh', + 'routing', + '_source', + '_source_excludes', + '_source_includes', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + storedFields: 'stored_fields', + _sourceExcludes: '_source_excludes', + _sourceIncludes: '_source_includes', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function mget (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -54,66 +82,22 @@ function buildMget (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'stored_fields', - 'preference', - 'realtime', - 'refresh', - 'routing', - '_source', - '_source_excludes', - '_source_includes', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'storedFields', - 'preference', - 'realtime', - 'refresh', - 'routing', - '_source', - '_sourceExcludes', - '_sourceIncludes', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'type']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -121,10 +105,10 @@ function buildMget (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_mget' - } else if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_mget' + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_mget' + } else if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_mget' } else { path = '/' + '_mget' } @@ -133,7 +117,7 @@ function buildMget (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -142,10 +126,27 @@ function buildMget (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.close_job.js b/api/api/ml.close_job.js index b69411c12..8fefaab84 100644 --- a/api/api/ml.close_job.js +++ b/api/api/ml.close_job.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlCloseJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -11,6 +14,18 @@ function buildMlCloseJob (opts) { * @param {boolean} force - True if the job should be forcefully closed * @param {time} timeout - Controls the time to wait until a job has closed. Default to 30 minutes */ + + const acceptedQuerystring = [ + 'allow_no_jobs', + 'force', + 'timeout' + ] + + const snakeCase = { + allowNoJobs: 'allow_no_jobs' + + } + return function mlCloseJob (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -39,46 +54,22 @@ function buildMlCloseJob (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'allow_no_jobs', - 'force', - 'timeout' - ] - const acceptedQuerystringCamelCased = [ - 'allowNoJobs', - 'force', - 'timeout' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -86,13 +77,13 @@ function buildMlCloseJob (opts) { var path = '' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_close' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_close' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -101,10 +92,27 @@ function buildMlCloseJob (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.delete_calendar.js b/api/api/ml.delete_calendar.js index e287d0a81..81c9225ea 100644 --- a/api/api/ml.delete_calendar.js +++ b/api/api/ml.delete_calendar.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlDeleteCalendar (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildMlDeleteCalendar (opts) { * * @param {string} calendar_id - The ID of the calendar to delete */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function mlDeleteCalendar (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -42,42 +54,22 @@ function buildMlDeleteCalendar (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, calendarId, calendar_id } = params + var querystring = semicopy(params, ['method', 'body', 'calendarId', 'calendar_id']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -85,7 +77,7 @@ function buildMlDeleteCalendar (opts) { var path = '' - path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) // build request object const request = { @@ -100,10 +92,27 @@ function buildMlDeleteCalendar (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.delete_calendar_event.js b/api/api/ml.delete_calendar_event.js index 9a8e67ed5..b041a90ec 100644 --- a/api/api/ml.delete_calendar_event.js +++ b/api/api/ml.delete_calendar_event.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlDeleteCalendarEvent (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildMlDeleteCalendarEvent (opts) { * @param {string} calendar_id - The ID of the calendar to modify * @param {string} event_id - The ID of the event to remove from the calendar */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function mlDeleteCalendarEvent (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -57,42 +69,22 @@ function buildMlDeleteCalendarEvent (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, calendarId, calendar_id, eventId, event_id } = params + var querystring = semicopy(params, ['method', 'body', 'calendarId', 'calendar_id', 'eventId', 'event_id']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -100,7 +92,7 @@ function buildMlDeleteCalendarEvent (opts) { var path = '' - path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + '/' + 'events' + '/' + encodeURIComponent(params['event_id'] || params['eventId']) + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'events' + '/' + encodeURIComponent(event_id || eventId) // build request object const request = { @@ -115,10 +107,27 @@ function buildMlDeleteCalendarEvent (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.delete_calendar_job.js b/api/api/ml.delete_calendar_job.js index 17dcac080..2be5f5fb7 100644 --- a/api/api/ml.delete_calendar_job.js +++ b/api/api/ml.delete_calendar_job.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlDeleteCalendarJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildMlDeleteCalendarJob (opts) { * @param {string} calendar_id - The ID of the calendar to modify * @param {string} job_id - The ID of the job to remove from the calendar */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function mlDeleteCalendarJob (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -57,42 +69,22 @@ function buildMlDeleteCalendarJob (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, calendarId, calendar_id, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'calendarId', 'calendar_id', 'jobId', 'job_id']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -100,7 +92,7 @@ function buildMlDeleteCalendarJob (opts) { var path = '' - path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + '/' + 'jobs' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'jobs' + '/' + encodeURIComponent(job_id || jobId) // build request object const request = { @@ -115,10 +107,27 @@ function buildMlDeleteCalendarJob (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.delete_datafeed.js b/api/api/ml.delete_datafeed.js index ff4b9e3f3..ed60d1f23 100644 --- a/api/api/ml.delete_datafeed.js +++ b/api/api/ml.delete_datafeed.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlDeleteDatafeed (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildMlDeleteDatafeed (opts) { * @param {string} datafeed_id - The ID of the datafeed to delete * @param {boolean} force - True if the datafeed should be forcefully deleted */ + + const acceptedQuerystring = [ + 'force' + ] + + const snakeCase = { + + } + return function mlDeleteDatafeed (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,42 +55,22 @@ function buildMlDeleteDatafeed (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'force' - ] - const acceptedQuerystringCamelCased = [ - 'force' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, datafeedId, datafeed_id } = params + var querystring = semicopy(params, ['method', 'body', 'datafeedId', 'datafeed_id']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -86,7 +78,7 @@ function buildMlDeleteDatafeed (opts) { var path = '' - path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) // build request object const request = { @@ -101,10 +93,27 @@ function buildMlDeleteDatafeed (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.delete_expired_data.js b/api/api/ml.delete_expired_data.js index 95bd3781c..614ad1f44 100644 --- a/api/api/ml.delete_expired_data.js +++ b/api/api/ml.delete_expired_data.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlDeleteExpiredData (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -7,6 +10,15 @@ function buildMlDeleteExpiredData (opts) { * Perform a [ml.delete_expired_data](undefined) request * */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function mlDeleteExpiredData (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -35,42 +47,22 @@ function buildMlDeleteExpiredData (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -93,10 +85,27 @@ function buildMlDeleteExpiredData (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.delete_filter.js b/api/api/ml.delete_filter.js index d8306bbda..0f2e705e2 100644 --- a/api/api/ml.delete_filter.js +++ b/api/api/ml.delete_filter.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlDeleteFilter (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildMlDeleteFilter (opts) { * * @param {string} filter_id - The ID of the filter to delete */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function mlDeleteFilter (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -42,42 +54,22 @@ function buildMlDeleteFilter (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, filterId, filter_id } = params + var querystring = semicopy(params, ['method', 'body', 'filterId', 'filter_id']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -85,7 +77,7 @@ function buildMlDeleteFilter (opts) { var path = '' - path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(params['filter_id'] || params['filterId']) + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(filter_id || filterId) // build request object const request = { @@ -100,10 +92,27 @@ function buildMlDeleteFilter (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.delete_forecast.js b/api/api/ml.delete_forecast.js index e235dcb55..0d7943e79 100644 --- a/api/api/ml.delete_forecast.js +++ b/api/api/ml.delete_forecast.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlDeleteForecast (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -11,6 +14,17 @@ function buildMlDeleteForecast (opts) { * @param {boolean} allow_no_forecasts - Whether to ignore if `_all` matches no forecasts * @param {time} timeout - Controls the time to wait until the forecast(s) are deleted. Default to 30 seconds */ + + const acceptedQuerystring = [ + 'allow_no_forecasts', + 'timeout' + ] + + const snakeCase = { + allowNoForecasts: 'allow_no_forecasts' + + } + return function mlDeleteForecast (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -53,44 +67,22 @@ function buildMlDeleteForecast (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'allow_no_forecasts', - 'timeout' - ] - const acceptedQuerystringCamelCased = [ - 'allowNoForecasts', - 'timeout' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, jobId, job_id, forecastId, forecast_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id', 'forecastId', 'forecast_id']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -98,10 +90,10 @@ function buildMlDeleteForecast (opts) { var path = '' - if ((params['job_id'] || params['jobId']) != null && (params['forecast_id'] || params['forecastId']) != null) { - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_forecast' + '/' + encodeURIComponent(params['forecast_id'] || params['forecastId']) + if ((job_id || jobId) != null && (forecast_id || forecastId) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_forecast' + '/' + encodeURIComponent(forecast_id || forecastId) } else { - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_forecast' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_forecast' } // build request object @@ -117,10 +109,27 @@ function buildMlDeleteForecast (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.delete_job.js b/api/api/ml.delete_job.js index dfa895748..cb167cf1e 100644 --- a/api/api/ml.delete_job.js +++ b/api/api/ml.delete_job.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlDeleteJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,16 @@ function buildMlDeleteJob (opts) { * @param {boolean} force - True if the job should be forcefully deleted * @param {boolean} wait_for_completion - Should this request wait until the operation has completed before returning */ + + const acceptedQuerystring = [ + 'force', + 'wait_for_completion' + ] + + const snakeCase = { + waitForCompletion: 'wait_for_completion' + } + return function mlDeleteJob (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,44 +57,22 @@ function buildMlDeleteJob (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'force', - 'wait_for_completion' - ] - const acceptedQuerystringCamelCased = [ - 'force', - 'waitForCompletion' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -89,7 +80,7 @@ function buildMlDeleteJob (opts) { var path = '' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) // build request object const request = { @@ -104,10 +95,27 @@ function buildMlDeleteJob (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.delete_model_snapshot.js b/api/api/ml.delete_model_snapshot.js index 61c1b8737..ffa300a1a 100644 --- a/api/api/ml.delete_model_snapshot.js +++ b/api/api/ml.delete_model_snapshot.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlDeleteModelSnapshot (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildMlDeleteModelSnapshot (opts) { * @param {string} job_id - The ID of the job to fetch * @param {string} snapshot_id - The ID of the snapshot to delete */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function mlDeleteModelSnapshot (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -57,42 +69,22 @@ function buildMlDeleteModelSnapshot (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, jobId, job_id, snapshotId, snapshot_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id', 'snapshotId', 'snapshot_id']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -100,7 +92,7 @@ function buildMlDeleteModelSnapshot (opts) { var path = '' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'model_snapshots' + '/' + encodeURIComponent(params['snapshot_id'] || params['snapshotId']) + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + '/' + encodeURIComponent(snapshot_id || snapshotId) // build request object const request = { @@ -115,10 +107,27 @@ function buildMlDeleteModelSnapshot (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.find_file_structure.js b/api/api/ml.find_file_structure.js index cc22f0c0d..203794b29 100644 --- a/api/api/ml.find_file_structure.js +++ b/api/api/ml.find_file_structure.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlFindFileStructure (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -21,6 +24,34 @@ function buildMlFindFileStructure (opts) { * @param {boolean} explain - Whether to include a commentary on how the structure was derived * @param {object} body - The contents of the file to be analyzed */ + + const acceptedQuerystring = [ + 'lines_to_sample', + 'timeout', + 'charset', + 'format', + 'has_header_row', + 'column_names', + 'delimiter', + 'quote', + 'should_trim_fields', + 'grok_pattern', + 'timestamp_field', + 'timestamp_format', + 'explain' + ] + + const snakeCase = { + linesToSample: 'lines_to_sample', + hasHeaderRow: 'has_header_row', + columnNames: 'column_names', + shouldTrimFields: 'should_trim_fields', + grokPattern: 'grok_pattern', + timestampField: 'timestamp_field', + timestampFormat: 'timestamp_format' + + } + return function mlFindFileStructure (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -49,66 +80,22 @@ function buildMlFindFileStructure (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'lines_to_sample', - 'timeout', - 'charset', - 'format', - 'has_header_row', - 'column_names', - 'delimiter', - 'quote', - 'should_trim_fields', - 'grok_pattern', - 'timestamp_field', - 'timestamp_format', - 'explain' - ] - const acceptedQuerystringCamelCased = [ - 'linesToSample', - 'timeout', - 'charset', - 'format', - 'hasHeaderRow', - 'columnNames', - 'delimiter', - 'quote', - 'shouldTrimFields', - 'grokPattern', - 'timestampField', - 'timestampFormat', - 'explain' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -122,7 +109,7 @@ function buildMlFindFileStructure (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -131,10 +118,27 @@ function buildMlFindFileStructure (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.flush_job.js b/api/api/ml.flush_job.js index 8f47ecdb2..1b230efe3 100644 --- a/api/api/ml.flush_job.js +++ b/api/api/ml.flush_job.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlFlushJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,21 @@ function buildMlFlushJob (opts) { * @param {string} skip_time - Skips time to the given value without generating results or updating the model for the skipped interval * @param {object} body - Flush parameters */ + + const acceptedQuerystring = [ + 'calc_interim', + 'start', + 'end', + 'advance_time', + 'skip_time' + ] + + const snakeCase = { + calcInterim: 'calc_interim', + advanceTime: 'advance_time', + skipTime: 'skip_time' + } + return function mlFlushJob (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -42,50 +60,22 @@ function buildMlFlushJob (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'calc_interim', - 'start', - 'end', - 'advance_time', - 'skip_time' - ] - const acceptedQuerystringCamelCased = [ - 'calcInterim', - 'start', - 'end', - 'advanceTime', - 'skipTime' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -93,13 +83,13 @@ function buildMlFlushJob (opts) { var path = '' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_flush' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_flush' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -108,10 +98,27 @@ function buildMlFlushJob (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.forecast.js b/api/api/ml.forecast.js index f6c0119b9..edd250141 100644 --- a/api/api/ml.forecast.js +++ b/api/api/ml.forecast.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlForecast (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,16 @@ function buildMlForecast (opts) { * @param {time} duration - The duration of the forecast * @param {time} expires_in - The time interval after which the forecast expires. Expired forecasts will be deleted at the first opportunity. */ + + const acceptedQuerystring = [ + 'duration', + 'expires_in' + ] + + const snakeCase = { + expiresIn: 'expires_in' + } + return function mlForecast (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,44 +57,22 @@ function buildMlForecast (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'duration', - 'expires_in' - ] - const acceptedQuerystringCamelCased = [ - 'duration', - 'expiresIn' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -89,7 +80,7 @@ function buildMlForecast (opts) { var path = '' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_forecast' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_forecast' // build request object const request = { @@ -104,10 +95,27 @@ function buildMlForecast (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.get_buckets.js b/api/api/ml.get_buckets.js index bda3bdbaa..c96696282 100644 --- a/api/api/ml.get_buckets.js +++ b/api/api/ml.get_buckets.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlGetBuckets (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -19,6 +22,25 @@ function buildMlGetBuckets (opts) { * @param {boolean} desc - Set the sort direction * @param {object} body - Bucket selection details if not provided in URI */ + + const acceptedQuerystring = [ + 'expand', + 'exclude_interim', + 'from', + 'size', + 'start', + 'end', + 'anomaly_score', + 'sort', + 'desc' + ] + + const snakeCase = { + excludeInterim: 'exclude_interim', + anomalyScore: 'anomaly_score' + + } + return function mlGetBuckets (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -55,58 +77,22 @@ function buildMlGetBuckets (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'expand', - 'exclude_interim', - 'from', - 'size', - 'start', - 'end', - 'anomaly_score', - 'sort', - 'desc' - ] - const acceptedQuerystringCamelCased = [ - 'expand', - 'excludeInterim', - 'from', - 'size', - 'start', - 'end', - 'anomalyScore', - 'sort', - 'desc' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, jobId, job_id, timestamp } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id', 'timestamp']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -114,17 +100,17 @@ function buildMlGetBuckets (opts) { var path = '' - if ((params['job_id'] || params['jobId']) != null && (params['timestamp']) != null) { - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'results' + '/' + 'buckets' + '/' + encodeURIComponent(params['timestamp']) + if ((job_id || jobId) != null && (timestamp) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'buckets' + '/' + encodeURIComponent(timestamp) } else { - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'results' + '/' + 'buckets' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'buckets' } // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -133,10 +119,27 @@ function buildMlGetBuckets (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.get_calendar_events.js b/api/api/ml.get_calendar_events.js index 4a9f9872e..28d45f003 100644 --- a/api/api/ml.get_calendar_events.js +++ b/api/api/ml.get_calendar_events.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlGetCalendarEvents (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -13,6 +16,20 @@ function buildMlGetCalendarEvents (opts) { * @param {int} from - Skips a number of events * @param {int} size - Specifies a max number of events to get */ + + const acceptedQuerystring = [ + 'job_id', + 'start', + 'end', + 'from', + 'size' + ] + + const snakeCase = { + jobId: 'job_id' + + } + return function mlGetCalendarEvents (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -47,50 +64,22 @@ function buildMlGetCalendarEvents (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'job_id', - 'start', - 'end', - 'from', - 'size' - ] - const acceptedQuerystringCamelCased = [ - 'jobId', - 'start', - 'end', - 'from', - 'size' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, calendarId, calendar_id } = params + var querystring = semicopy(params, ['method', 'body', 'calendarId', 'calendar_id']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -98,7 +87,7 @@ function buildMlGetCalendarEvents (opts) { var path = '' - path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + '/' + 'events' + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'events' // build request object const request = { @@ -113,10 +102,27 @@ function buildMlGetCalendarEvents (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.get_calendars.js b/api/api/ml.get_calendars.js index 1ff78b88e..3c8e4ae09 100644 --- a/api/api/ml.get_calendars.js +++ b/api/api/ml.get_calendars.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlGetCalendars (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,16 @@ function buildMlGetCalendars (opts) { * @param {int} from - skips a number of calendars * @param {int} size - specifies a max number of calendars to get */ + + const acceptedQuerystring = [ + 'from', + 'size' + ] + + const snakeCase = { + + } + return function mlGetCalendars (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -38,44 +51,22 @@ function buildMlGetCalendars (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'from', - 'size' - ] - const acceptedQuerystringCamelCased = [ - 'from', - 'size' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, calendarId, calendar_id } = params + var querystring = semicopy(params, ['method', 'body', 'calendarId', 'calendar_id']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -83,8 +74,8 @@ function buildMlGetCalendars (opts) { var path = '' - if ((params['calendar_id'] || params['calendarId']) != null) { - path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + if ((calendar_id || calendarId) != null) { + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) } else { path = '/' + '_ml' + '/' + 'calendars' } @@ -102,10 +93,27 @@ function buildMlGetCalendars (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.get_categories.js b/api/api/ml.get_categories.js index 268a64846..fc2b281ec 100644 --- a/api/api/ml.get_categories.js +++ b/api/api/ml.get_categories.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlGetCategories (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -12,6 +15,16 @@ function buildMlGetCategories (opts) { * @param {int} size - specifies a max number of categories to get * @param {object} body - Category selection details if not provided in URI */ + + const acceptedQuerystring = [ + 'from', + 'size' + ] + + const snakeCase = { + + } + return function mlGetCategories (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -40,44 +53,22 @@ function buildMlGetCategories (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'from', - 'size' - ] - const acceptedQuerystringCamelCased = [ - 'from', - 'size' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, jobId, job_id, categoryId, category_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id', 'categoryId', 'category_id']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -85,17 +76,17 @@ function buildMlGetCategories (opts) { var path = '' - if ((params['job_id'] || params['jobId']) != null && (params['category_id'] || params['categoryId']) != null) { - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'results' + '/' + 'categories' + '/' + encodeURIComponent(params['category_id'] || params['categoryId']) + if ((job_id || jobId) != null && (category_id || categoryId) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'categories' + '/' + encodeURIComponent(category_id || categoryId) } else { - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'results' + '/' + 'categories' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'categories' } // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -104,10 +95,27 @@ function buildMlGetCategories (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.get_datafeed_stats.js b/api/api/ml.get_datafeed_stats.js index 6d84d3f61..464989ada 100644 --- a/api/api/ml.get_datafeed_stats.js +++ b/api/api/ml.get_datafeed_stats.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlGetDatafeedStats (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildMlGetDatafeedStats (opts) { * @param {string} datafeed_id - The ID of the datafeeds stats to fetch * @param {boolean} allow_no_datafeeds - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) */ + + const acceptedQuerystring = [ + 'allow_no_datafeeds' + ] + + const snakeCase = { + allowNoDatafeeds: 'allow_no_datafeeds' + } + return function mlGetDatafeedStats (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -37,42 +49,22 @@ function buildMlGetDatafeedStats (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'allow_no_datafeeds' - ] - const acceptedQuerystringCamelCased = [ - 'allowNoDatafeeds' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, datafeedId, datafeed_id } = params + var querystring = semicopy(params, ['method', 'body', 'datafeedId', 'datafeed_id']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -80,8 +72,8 @@ function buildMlGetDatafeedStats (opts) { var path = '' - if ((params['datafeed_id'] || params['datafeedId']) != null) { - path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + '/' + '_stats' + if ((datafeed_id || datafeedId) != null) { + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_stats' } else { path = '/' + '_ml' + '/' + 'datafeeds' + '/' + '_stats' } @@ -99,10 +91,27 @@ function buildMlGetDatafeedStats (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.get_datafeeds.js b/api/api/ml.get_datafeeds.js index 98a90d8db..a8e4402e5 100644 --- a/api/api/ml.get_datafeeds.js +++ b/api/api/ml.get_datafeeds.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlGetDatafeeds (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildMlGetDatafeeds (opts) { * @param {string} datafeed_id - The ID of the datafeeds to fetch * @param {boolean} allow_no_datafeeds - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) */ + + const acceptedQuerystring = [ + 'allow_no_datafeeds' + ] + + const snakeCase = { + allowNoDatafeeds: 'allow_no_datafeeds' + } + return function mlGetDatafeeds (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -37,42 +49,22 @@ function buildMlGetDatafeeds (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'allow_no_datafeeds' - ] - const acceptedQuerystringCamelCased = [ - 'allowNoDatafeeds' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, datafeedId, datafeed_id } = params + var querystring = semicopy(params, ['method', 'body', 'datafeedId', 'datafeed_id']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -80,8 +72,8 @@ function buildMlGetDatafeeds (opts) { var path = '' - if ((params['datafeed_id'] || params['datafeedId']) != null) { - path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + if ((datafeed_id || datafeedId) != null) { + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) } else { path = '/' + '_ml' + '/' + 'datafeeds' } @@ -99,10 +91,27 @@ function buildMlGetDatafeeds (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.get_filters.js b/api/api/ml.get_filters.js index 952af25a9..b671bfe3c 100644 --- a/api/api/ml.get_filters.js +++ b/api/api/ml.get_filters.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlGetFilters (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,16 @@ function buildMlGetFilters (opts) { * @param {int} from - skips a number of filters * @param {int} size - specifies a max number of filters to get */ + + const acceptedQuerystring = [ + 'from', + 'size' + ] + + const snakeCase = { + + } + return function mlGetFilters (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -38,44 +51,22 @@ function buildMlGetFilters (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'from', - 'size' - ] - const acceptedQuerystringCamelCased = [ - 'from', - 'size' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, filterId, filter_id } = params + var querystring = semicopy(params, ['method', 'body', 'filterId', 'filter_id']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -83,8 +74,8 @@ function buildMlGetFilters (opts) { var path = '' - if ((params['filter_id'] || params['filterId']) != null) { - path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(params['filter_id'] || params['filterId']) + if ((filter_id || filterId) != null) { + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(filter_id || filterId) } else { path = '/' + '_ml' + '/' + 'filters' } @@ -102,10 +93,27 @@ function buildMlGetFilters (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.get_influencers.js b/api/api/ml.get_influencers.js index d7629cb08..1ed056d00 100644 --- a/api/api/ml.get_influencers.js +++ b/api/api/ml.get_influencers.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlGetInfluencers (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -17,6 +20,24 @@ function buildMlGetInfluencers (opts) { * @param {boolean} desc - whether the results should be sorted in decending order * @param {object} body - Influencer selection criteria */ + + const acceptedQuerystring = [ + 'exclude_interim', + 'from', + 'size', + 'start', + 'end', + 'influencer_score', + 'sort', + 'desc' + ] + + const snakeCase = { + excludeInterim: 'exclude_interim', + influencerScore: 'influencer_score' + + } + return function mlGetInfluencers (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -45,56 +66,22 @@ function buildMlGetInfluencers (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'exclude_interim', - 'from', - 'size', - 'start', - 'end', - 'influencer_score', - 'sort', - 'desc' - ] - const acceptedQuerystringCamelCased = [ - 'excludeInterim', - 'from', - 'size', - 'start', - 'end', - 'influencerScore', - 'sort', - 'desc' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -102,13 +89,13 @@ function buildMlGetInfluencers (opts) { var path = '' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'results' + '/' + 'influencers' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'influencers' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -117,10 +104,27 @@ function buildMlGetInfluencers (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.get_job_stats.js b/api/api/ml.get_job_stats.js index 0b96ccb0f..dc220fc07 100644 --- a/api/api/ml.get_job_stats.js +++ b/api/api/ml.get_job_stats.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlGetJobStats (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildMlGetJobStats (opts) { * @param {string} job_id - The ID of the jobs stats to fetch * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) */ + + const acceptedQuerystring = [ + 'allow_no_jobs' + ] + + const snakeCase = { + allowNoJobs: 'allow_no_jobs' + } + return function mlGetJobStats (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -37,42 +49,22 @@ function buildMlGetJobStats (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'allow_no_jobs' - ] - const acceptedQuerystringCamelCased = [ - 'allowNoJobs' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -80,8 +72,8 @@ function buildMlGetJobStats (opts) { var path = '' - if ((params['job_id'] || params['jobId']) != null) { - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_stats' + if ((job_id || jobId) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_stats' } else { path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_stats' } @@ -99,10 +91,27 @@ function buildMlGetJobStats (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.get_jobs.js b/api/api/ml.get_jobs.js index 5d471a4af..64d26e01a 100644 --- a/api/api/ml.get_jobs.js +++ b/api/api/ml.get_jobs.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlGetJobs (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildMlGetJobs (opts) { * @param {string} job_id - The ID of the jobs to fetch * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) */ + + const acceptedQuerystring = [ + 'allow_no_jobs' + ] + + const snakeCase = { + allowNoJobs: 'allow_no_jobs' + } + return function mlGetJobs (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -37,42 +49,22 @@ function buildMlGetJobs (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'allow_no_jobs' - ] - const acceptedQuerystringCamelCased = [ - 'allowNoJobs' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -80,8 +72,8 @@ function buildMlGetJobs (opts) { var path = '' - if ((params['job_id'] || params['jobId']) != null) { - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + if ((job_id || jobId) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) } else { path = '/' + '_ml' + '/' + 'anomaly_detectors' } @@ -99,10 +91,27 @@ function buildMlGetJobs (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.get_model_snapshots.js b/api/api/ml.get_model_snapshots.js index 49511b048..baf9e4310 100644 --- a/api/api/ml.get_model_snapshots.js +++ b/api/api/ml.get_model_snapshots.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlGetModelSnapshots (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -16,6 +19,20 @@ function buildMlGetModelSnapshots (opts) { * @param {boolean} desc - True if the results should be sorted in descending order * @param {object} body - Model snapshot selection criteria */ + + const acceptedQuerystring = [ + 'from', + 'size', + 'start', + 'end', + 'sort', + 'desc' + ] + + const snakeCase = { + + } + return function mlGetModelSnapshots (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -52,52 +69,22 @@ function buildMlGetModelSnapshots (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'from', - 'size', - 'start', - 'end', - 'sort', - 'desc' - ] - const acceptedQuerystringCamelCased = [ - 'from', - 'size', - 'start', - 'end', - 'sort', - 'desc' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, jobId, job_id, snapshotId, snapshot_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id', 'snapshotId', 'snapshot_id']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -105,17 +92,17 @@ function buildMlGetModelSnapshots (opts) { var path = '' - if ((params['job_id'] || params['jobId']) != null && (params['snapshot_id'] || params['snapshotId']) != null) { - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'model_snapshots' + '/' + encodeURIComponent(params['snapshot_id'] || params['snapshotId']) + if ((job_id || jobId) != null && (snapshot_id || snapshotId) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + '/' + encodeURIComponent(snapshot_id || snapshotId) } else { - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'model_snapshots' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' } // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -124,10 +111,27 @@ function buildMlGetModelSnapshots (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.get_overall_buckets.js b/api/api/ml.get_overall_buckets.js index a9db109a2..d47e3fa2f 100644 --- a/api/api/ml.get_overall_buckets.js +++ b/api/api/ml.get_overall_buckets.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlGetOverallBuckets (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -16,6 +19,25 @@ function buildMlGetOverallBuckets (opts) { * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) * @param {object} body - Overall bucket selection details if not provided in URI */ + + const acceptedQuerystring = [ + 'top_n', + 'bucket_span', + 'overall_score', + 'exclude_interim', + 'start', + 'end', + 'allow_no_jobs' + ] + + const snakeCase = { + topN: 'top_n', + bucketSpan: 'bucket_span', + overallScore: 'overall_score', + excludeInterim: 'exclude_interim', + allowNoJobs: 'allow_no_jobs' + } + return function mlGetOverallBuckets (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,54 +66,22 @@ function buildMlGetOverallBuckets (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'top_n', - 'bucket_span', - 'overall_score', - 'exclude_interim', - 'start', - 'end', - 'allow_no_jobs' - ] - const acceptedQuerystringCamelCased = [ - 'topN', - 'bucketSpan', - 'overallScore', - 'excludeInterim', - 'start', - 'end', - 'allowNoJobs' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -99,13 +89,13 @@ function buildMlGetOverallBuckets (opts) { var path = '' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'results' + '/' + 'overall_buckets' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'overall_buckets' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -114,10 +104,27 @@ function buildMlGetOverallBuckets (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.get_records.js b/api/api/ml.get_records.js index 5f8b35aba..fdf2c5057 100644 --- a/api/api/ml.get_records.js +++ b/api/api/ml.get_records.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlGetRecords (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -17,6 +20,24 @@ function buildMlGetRecords (opts) { * @param {boolean} desc - Set the sort direction * @param {object} body - Record selection criteria */ + + const acceptedQuerystring = [ + 'exclude_interim', + 'from', + 'size', + 'start', + 'end', + 'record_score', + 'sort', + 'desc' + ] + + const snakeCase = { + excludeInterim: 'exclude_interim', + recordScore: 'record_score' + + } + return function mlGetRecords (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -45,56 +66,22 @@ function buildMlGetRecords (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'exclude_interim', - 'from', - 'size', - 'start', - 'end', - 'record_score', - 'sort', - 'desc' - ] - const acceptedQuerystringCamelCased = [ - 'excludeInterim', - 'from', - 'size', - 'start', - 'end', - 'recordScore', - 'sort', - 'desc' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -102,13 +89,13 @@ function buildMlGetRecords (opts) { var path = '' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'results' + '/' + 'records' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'records' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -117,10 +104,27 @@ function buildMlGetRecords (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.info.js b/api/api/ml.info.js index 3885261f9..860f1f2a4 100644 --- a/api/api/ml.info.js +++ b/api/api/ml.info.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlInfo (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -7,6 +10,15 @@ function buildMlInfo (opts) { * Perform a [ml.info](undefined) request * */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function mlInfo (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -27,42 +39,22 @@ function buildMlInfo (opts) { }) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -85,10 +77,27 @@ function buildMlInfo (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.open_job.js b/api/api/ml.open_job.js index 47df12f64..6077b8532 100644 --- a/api/api/ml.open_job.js +++ b/api/api/ml.open_job.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlOpenJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,15 @@ function buildMlOpenJob (opts) { * @param {boolean} ignore_downtime - Controls if gaps in data are treated as anomalous or as a maintenance window after a job re-start * @param {time} timeout - Controls the time to wait until a job has opened. Default to 30 minutes */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function mlOpenJob (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,42 +56,22 @@ function buildMlOpenJob (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, jobId, job_id, ignoreDowntime, ignore_downtime, timeout } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id', 'ignoreDowntime', 'ignore_downtime', 'timeout']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -87,7 +79,7 @@ function buildMlOpenJob (opts) { var path = '' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_open' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_open' // build request object const request = { @@ -102,10 +94,27 @@ function buildMlOpenJob (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.post_calendar_events.js b/api/api/ml.post_calendar_events.js index 565807442..8d8bda98b 100644 --- a/api/api/ml.post_calendar_events.js +++ b/api/api/ml.post_calendar_events.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlPostCalendarEvents (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildMlPostCalendarEvents (opts) { * @param {string} calendar_id - The ID of the calendar to modify * @param {object} body - A list of events */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function mlPostCalendarEvents (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,42 +55,22 @@ function buildMlPostCalendarEvents (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, calendarId, calendar_id } = params + var querystring = semicopy(params, ['method', 'body', 'calendarId', 'calendar_id']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -86,13 +78,13 @@ function buildMlPostCalendarEvents (opts) { var path = '' - path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + '/' + 'events' + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'events' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -101,10 +93,27 @@ function buildMlPostCalendarEvents (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.post_data.js b/api/api/ml.post_data.js index 708b4fdf8..6d131ed40 100644 --- a/api/api/ml.post_data.js +++ b/api/api/ml.post_data.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlPostData (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -11,6 +14,17 @@ function buildMlPostData (opts) { * @param {string} reset_end - Optional parameter to specify the end of the bucket resetting range * @param {object} body - The data to process */ + + const acceptedQuerystring = [ + 'reset_start', + 'reset_end' + ] + + const snakeCase = { + resetStart: 'reset_start', + resetEnd: 'reset_end' + } + return function mlPostData (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -45,44 +59,22 @@ function buildMlPostData (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'reset_start', - 'reset_end' - ] - const acceptedQuerystringCamelCased = [ - 'resetStart', - 'resetEnd' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -90,13 +82,13 @@ function buildMlPostData (opts) { var path = '' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_data' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_data' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -105,10 +97,27 @@ function buildMlPostData (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.preview_datafeed.js b/api/api/ml.preview_datafeed.js index 6d0c27191..8901a0ccb 100644 --- a/api/api/ml.preview_datafeed.js +++ b/api/api/ml.preview_datafeed.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlPreviewDatafeed (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildMlPreviewDatafeed (opts) { * * @param {string} datafeed_id - The ID of the datafeed to preview */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function mlPreviewDatafeed (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -42,42 +54,22 @@ function buildMlPreviewDatafeed (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, datafeedId, datafeed_id } = params + var querystring = semicopy(params, ['method', 'body', 'datafeedId', 'datafeed_id']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -85,7 +77,7 @@ function buildMlPreviewDatafeed (opts) { var path = '' - path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + '/' + '_preview' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_preview' // build request object const request = { @@ -100,10 +92,27 @@ function buildMlPreviewDatafeed (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.put_calendar.js b/api/api/ml.put_calendar.js index 16220fea7..4a70cf521 100644 --- a/api/api/ml.put_calendar.js +++ b/api/api/ml.put_calendar.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlPutCalendar (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildMlPutCalendar (opts) { * @param {string} calendar_id - The ID of the calendar to create * @param {object} body - The calendar details */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function mlPutCalendar (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -37,42 +49,22 @@ function buildMlPutCalendar (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, calendarId, calendar_id } = params + var querystring = semicopy(params, ['method', 'body', 'calendarId', 'calendar_id']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -80,13 +72,13 @@ function buildMlPutCalendar (opts) { var path = '' - path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -95,10 +87,27 @@ function buildMlPutCalendar (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.put_calendar_job.js b/api/api/ml.put_calendar_job.js index d61cdce3f..17f7d3ca6 100644 --- a/api/api/ml.put_calendar_job.js +++ b/api/api/ml.put_calendar_job.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlPutCalendarJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildMlPutCalendarJob (opts) { * @param {string} calendar_id - The ID of the calendar to modify * @param {string} job_id - The ID of the job to add to the calendar */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function mlPutCalendarJob (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -57,42 +69,22 @@ function buildMlPutCalendarJob (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, calendarId, calendar_id, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'calendarId', 'calendar_id', 'jobId', 'job_id']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -100,7 +92,7 @@ function buildMlPutCalendarJob (opts) { var path = '' - path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + '/' + 'jobs' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'jobs' + '/' + encodeURIComponent(job_id || jobId) // build request object const request = { @@ -115,10 +107,27 @@ function buildMlPutCalendarJob (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.put_datafeed.js b/api/api/ml.put_datafeed.js index 3cc416c86..dae7e4811 100644 --- a/api/api/ml.put_datafeed.js +++ b/api/api/ml.put_datafeed.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlPutDatafeed (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildMlPutDatafeed (opts) { * @param {string} datafeed_id - The ID of the datafeed to create * @param {object} body - The datafeed config */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function mlPutDatafeed (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,42 +55,22 @@ function buildMlPutDatafeed (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, datafeedId, datafeed_id } = params + var querystring = semicopy(params, ['method', 'body', 'datafeedId', 'datafeed_id']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -86,13 +78,13 @@ function buildMlPutDatafeed (opts) { var path = '' - path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -101,10 +93,27 @@ function buildMlPutDatafeed (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.put_filter.js b/api/api/ml.put_filter.js index 2f2645f05..9fe5e7967 100644 --- a/api/api/ml.put_filter.js +++ b/api/api/ml.put_filter.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlPutFilter (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildMlPutFilter (opts) { * @param {string} filter_id - The ID of the filter to create * @param {object} body - The filter details */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function mlPutFilter (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,42 +55,22 @@ function buildMlPutFilter (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, filterId, filter_id } = params + var querystring = semicopy(params, ['method', 'body', 'filterId', 'filter_id']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -86,13 +78,13 @@ function buildMlPutFilter (opts) { var path = '' - path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(params['filter_id'] || params['filterId']) + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(filter_id || filterId) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -101,10 +93,27 @@ function buildMlPutFilter (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.put_job.js b/api/api/ml.put_job.js index b9abe9a4e..c75b38431 100644 --- a/api/api/ml.put_job.js +++ b/api/api/ml.put_job.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlPutJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildMlPutJob (opts) { * @param {string} job_id - The ID of the job to create * @param {object} body - The job */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function mlPutJob (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,42 +55,22 @@ function buildMlPutJob (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -86,13 +78,13 @@ function buildMlPutJob (opts) { var path = '' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -101,10 +93,27 @@ function buildMlPutJob (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.revert_model_snapshot.js b/api/api/ml.revert_model_snapshot.js index dd4446ada..9f9167741 100644 --- a/api/api/ml.revert_model_snapshot.js +++ b/api/api/ml.revert_model_snapshot.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlRevertModelSnapshot (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -11,6 +14,15 @@ function buildMlRevertModelSnapshot (opts) { * @param {boolean} delete_intervening_results - Should we reset the results back to the time of the snapshot? * @param {object} body - Reversion options */ + + const acceptedQuerystring = [ + 'delete_intervening_results' + ] + + const snakeCase = { + deleteInterveningResults: 'delete_intervening_results' + } + return function mlRevertModelSnapshot (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -53,42 +65,22 @@ function buildMlRevertModelSnapshot (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'delete_intervening_results' - ] - const acceptedQuerystringCamelCased = [ - 'deleteInterveningResults' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, jobId, job_id, snapshotId, snapshot_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id', 'snapshotId', 'snapshot_id']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -96,13 +88,13 @@ function buildMlRevertModelSnapshot (opts) { var path = '' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'model_snapshots' + '/' + encodeURIComponent(params['snapshot_id'] || params['snapshotId']) + '/' + '_revert' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + '/' + encodeURIComponent(snapshot_id || snapshotId) + '/' + '_revert' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -111,10 +103,27 @@ function buildMlRevertModelSnapshot (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.start_datafeed.js b/api/api/ml.start_datafeed.js index 789b906f8..1ecaddc9d 100644 --- a/api/api/ml.start_datafeed.js +++ b/api/api/ml.start_datafeed.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlStartDatafeed (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -12,6 +15,17 @@ function buildMlStartDatafeed (opts) { * @param {time} timeout - Controls the time to wait until a datafeed has started. Default to 20 seconds * @param {object} body - The start datafeed parameters */ + + const acceptedQuerystring = [ + 'start', + 'end', + 'timeout' + ] + + const snakeCase = { + + } + return function mlStartDatafeed (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -40,46 +54,22 @@ function buildMlStartDatafeed (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'start', - 'end', - 'timeout' - ] - const acceptedQuerystringCamelCased = [ - 'start', - 'end', - 'timeout' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, datafeedId, datafeed_id } = params + var querystring = semicopy(params, ['method', 'body', 'datafeedId', 'datafeed_id']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -87,13 +77,13 @@ function buildMlStartDatafeed (opts) { var path = '' - path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + '/' + '_start' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_start' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -102,10 +92,27 @@ function buildMlStartDatafeed (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.stop_datafeed.js b/api/api/ml.stop_datafeed.js index 59ec92d8e..2b88f2b66 100644 --- a/api/api/ml.stop_datafeed.js +++ b/api/api/ml.stop_datafeed.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlStopDatafeed (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -11,6 +14,18 @@ function buildMlStopDatafeed (opts) { * @param {boolean} force - True if the datafeed should be forcefully stopped. * @param {time} timeout - Controls the time to wait until a datafeed has stopped. Default to 20 seconds */ + + const acceptedQuerystring = [ + 'allow_no_datafeeds', + 'force', + 'timeout' + ] + + const snakeCase = { + allowNoDatafeeds: 'allow_no_datafeeds' + + } + return function mlStopDatafeed (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -39,46 +54,22 @@ function buildMlStopDatafeed (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'allow_no_datafeeds', - 'force', - 'timeout' - ] - const acceptedQuerystringCamelCased = [ - 'allowNoDatafeeds', - 'force', - 'timeout' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, datafeedId, datafeed_id } = params + var querystring = semicopy(params, ['method', 'body', 'datafeedId', 'datafeed_id']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -86,13 +77,13 @@ function buildMlStopDatafeed (opts) { var path = '' - path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + '/' + '_stop' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_stop' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -101,10 +92,27 @@ function buildMlStopDatafeed (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.update_datafeed.js b/api/api/ml.update_datafeed.js index e2742e273..0cd667d38 100644 --- a/api/api/ml.update_datafeed.js +++ b/api/api/ml.update_datafeed.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlUpdateDatafeed (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildMlUpdateDatafeed (opts) { * @param {string} datafeed_id - The ID of the datafeed to update * @param {object} body - The datafeed update settings */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function mlUpdateDatafeed (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,42 +55,22 @@ function buildMlUpdateDatafeed (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, datafeedId, datafeed_id } = params + var querystring = semicopy(params, ['method', 'body', 'datafeedId', 'datafeed_id']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -86,13 +78,13 @@ function buildMlUpdateDatafeed (opts) { var path = '' - path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + '/' + '_update' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_update' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -101,10 +93,27 @@ function buildMlUpdateDatafeed (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.update_filter.js b/api/api/ml.update_filter.js index 1f5e094c7..ed8c87e4d 100644 --- a/api/api/ml.update_filter.js +++ b/api/api/ml.update_filter.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlUpdateFilter (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildMlUpdateFilter (opts) { * @param {string} filter_id - The ID of the filter to update * @param {object} body - The filter update */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function mlUpdateFilter (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,42 +55,22 @@ function buildMlUpdateFilter (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, filterId, filter_id } = params + var querystring = semicopy(params, ['method', 'body', 'filterId', 'filter_id']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -86,13 +78,13 @@ function buildMlUpdateFilter (opts) { var path = '' - path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(params['filter_id'] || params['filterId']) + '/' + '_update' + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(filter_id || filterId) + '/' + '_update' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -101,10 +93,27 @@ function buildMlUpdateFilter (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.update_job.js b/api/api/ml.update_job.js index 5d4ee264e..1c2eda031 100644 --- a/api/api/ml.update_job.js +++ b/api/api/ml.update_job.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlUpdateJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildMlUpdateJob (opts) { * @param {string} job_id - The ID of the job to create * @param {object} body - The job update settings */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function mlUpdateJob (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,42 +55,22 @@ function buildMlUpdateJob (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -86,13 +78,13 @@ function buildMlUpdateJob (opts) { var path = '' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_update' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_update' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -101,10 +93,27 @@ function buildMlUpdateJob (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.update_model_snapshot.js b/api/api/ml.update_model_snapshot.js index e2fe7ec1b..6fc8943c2 100644 --- a/api/api/ml.update_model_snapshot.js +++ b/api/api/ml.update_model_snapshot.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlUpdateModelSnapshot (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,15 @@ function buildMlUpdateModelSnapshot (opts) { * @param {string} snapshot_id - The ID of the snapshot to update * @param {object} body - The model snapshot properties to update */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function mlUpdateModelSnapshot (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -58,42 +70,22 @@ function buildMlUpdateModelSnapshot (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, jobId, job_id, snapshotId, snapshot_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id', 'snapshotId', 'snapshot_id']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -101,13 +93,13 @@ function buildMlUpdateModelSnapshot (opts) { var path = '' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'model_snapshots' + '/' + encodeURIComponent(params['snapshot_id'] || params['snapshotId']) + '/' + '_update' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + '/' + encodeURIComponent(snapshot_id || snapshotId) + '/' + '_update' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -116,10 +108,27 @@ function buildMlUpdateModelSnapshot (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.validate.js b/api/api/ml.validate.js index 2f9dd9e22..b6fcae44d 100644 --- a/api/api/ml.validate.js +++ b/api/api/ml.validate.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlValidate (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildMlValidate (opts) { * * @param {object} body - The job config */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function mlValidate (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildMlValidate (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -85,7 +77,7 @@ function buildMlValidate (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -94,10 +86,27 @@ function buildMlValidate (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ml.validate_detector.js b/api/api/ml.validate_detector.js index 93cceaf23..6829c5922 100644 --- a/api/api/ml.validate_detector.js +++ b/api/api/ml.validate_detector.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMlValidateDetector (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildMlValidateDetector (opts) { * * @param {object} body - The detector */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function mlValidateDetector (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildMlValidateDetector (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -85,7 +77,7 @@ function buildMlValidateDetector (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -94,10 +86,27 @@ function buildMlValidateDetector (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/monitoring.bulk.js b/api/api/monitoring.bulk.js index aa71f8154..f8c58b7a8 100644 --- a/api/api/monitoring.bulk.js +++ b/api/api/monitoring.bulk.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMonitoringBulk (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -12,6 +15,19 @@ function buildMonitoringBulk (opts) { * @param {string} interval - Collection interval (e.g., '10s' or '10000ms') of the payload * @param {object} body - The operation definition and data (action-data pairs), separated by newlines */ + + const acceptedQuerystring = [ + 'system_id', + 'system_api_version', + 'interval' + ] + + const snakeCase = { + systemId: 'system_id', + systemApiVersion: 'system_api_version' + + } + return function monitoringBulk (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -40,46 +56,22 @@ function buildMonitoringBulk (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'system_id', - 'system_api_version', - 'interval' - ] - const acceptedQuerystringCamelCased = [ - 'systemId', - 'systemApiVersion', - 'interval' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, type } = params + var querystring = semicopy(params, ['method', 'body', 'type']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -87,8 +79,8 @@ function buildMonitoringBulk (opts) { var path = '' - if ((params['type']) != null) { - path = '/' + '_monitoring' + '/' + encodeURIComponent(params['type']) + '/' + 'bulk' + if ((type) != null) { + path = '/' + '_monitoring' + '/' + encodeURIComponent(type) + '/' + 'bulk' } else { path = '/' + '_monitoring' + '/' + 'bulk' } @@ -97,7 +89,7 @@ function buildMonitoringBulk (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -106,10 +98,27 @@ function buildMonitoringBulk (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/msearch.js b/api/api/msearch.js index 8cc3c750d..50b9d1ee7 100644 --- a/api/api/msearch.js +++ b/api/api/msearch.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMsearch (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -16,6 +19,32 @@ function buildMsearch (opts) { * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response * @param {object} body - The request definitions (metadata-search request definition pairs), separated by newlines */ + + const acceptedQuerystring = [ + 'search_type', + 'max_concurrent_searches', + 'typed_keys', + 'pre_filter_shard_size', + 'max_concurrent_shard_requests', + 'rest_total_hits_as_int', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + searchType: 'search_type', + maxConcurrentSearches: 'max_concurrent_searches', + typedKeys: 'typed_keys', + preFilterShardSize: 'pre_filter_shard_size', + maxConcurrentShardRequests: 'max_concurrent_shard_requests', + restTotalHitsAsInt: 'rest_total_hits_as_int', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function msearch (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -52,62 +81,22 @@ function buildMsearch (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'search_type', - 'max_concurrent_searches', - 'typed_keys', - 'pre_filter_shard_size', - 'max_concurrent_shard_requests', - 'rest_total_hits_as_int', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'searchType', - 'maxConcurrentSearches', - 'typedKeys', - 'preFilterShardSize', - 'maxConcurrentShardRequests', - 'restTotalHitsAsInt', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'type']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -115,10 +104,10 @@ function buildMsearch (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_msearch' - } else if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_msearch' + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_msearch' + } else if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_msearch' } else { path = '/' + '_msearch' } @@ -127,7 +116,7 @@ function buildMsearch (opts) { const request = { method, path, - bulkBody: params.body, + bulkBody: body, querystring } @@ -136,10 +125,27 @@ function buildMsearch (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/msearch_template.js b/api/api/msearch_template.js index d0b6ed126..70b51cb3b 100644 --- a/api/api/msearch_template.js +++ b/api/api/msearch_template.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMsearchTemplate (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,28 @@ function buildMsearchTemplate (opts) { * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response * @param {object} body - The request definitions (metadata-search request definition pairs), separated by newlines */ + + const acceptedQuerystring = [ + 'search_type', + 'typed_keys', + 'max_concurrent_searches', + 'rest_total_hits_as_int', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + searchType: 'search_type', + typedKeys: 'typed_keys', + maxConcurrentSearches: 'max_concurrent_searches', + restTotalHitsAsInt: 'rest_total_hits_as_int', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function msearchTemplate (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -50,58 +75,22 @@ function buildMsearchTemplate (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'search_type', - 'typed_keys', - 'max_concurrent_searches', - 'rest_total_hits_as_int', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'searchType', - 'typedKeys', - 'maxConcurrentSearches', - 'restTotalHitsAsInt', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'type']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -109,10 +98,10 @@ function buildMsearchTemplate (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_msearch' + '/' + 'template' - } else if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_msearch' + '/' + 'template' + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_msearch' + '/' + 'template' + } else if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_msearch' + '/' + 'template' } else { path = '/' + '_msearch' + '/' + 'template' } @@ -121,7 +110,7 @@ function buildMsearchTemplate (opts) { const request = { method, path, - bulkBody: params.body, + bulkBody: body, querystring } @@ -130,10 +119,27 @@ function buildMsearchTemplate (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/mtermvectors.js b/api/api/mtermvectors.js index eb743c9fd..aa52d2c05 100644 --- a/api/api/mtermvectors.js +++ b/api/api/mtermvectors.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildMtermvectors (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -23,6 +26,36 @@ function buildMtermvectors (opts) { * @param {enum} version_type - Specific version type * @param {object} body - Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation. */ + + const acceptedQuerystring = [ + 'ids', + 'term_statistics', + 'field_statistics', + 'fields', + 'offsets', + 'positions', + 'payloads', + 'preference', + 'routing', + 'parent', + 'realtime', + 'version', + 'version_type', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + termStatistics: 'term_statistics', + fieldStatistics: 'field_statistics', + versionType: 'version_type', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function mtermvectors (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -51,76 +84,22 @@ function buildMtermvectors (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'ids', - 'term_statistics', - 'field_statistics', - 'fields', - 'offsets', - 'positions', - 'payloads', - 'preference', - 'routing', - 'parent', - 'realtime', - 'version', - 'version_type', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'ids', - 'termStatistics', - 'fieldStatistics', - 'fields', - 'offsets', - 'positions', - 'payloads', - 'preference', - 'routing', - 'parent', - 'realtime', - 'version', - 'versionType', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'type']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -128,10 +107,10 @@ function buildMtermvectors (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_mtermvectors' - } else if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_mtermvectors' + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_mtermvectors' + } else if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_mtermvectors' } else { path = '/' + '_mtermvectors' } @@ -140,7 +119,7 @@ function buildMtermvectors (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -149,10 +128,27 @@ function buildMtermvectors (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/nodes.hot_threads.js b/api/api/nodes.hot_threads.js index 9eb77104d..6d514706e 100644 --- a/api/api/nodes.hot_threads.js +++ b/api/api/nodes.hot_threads.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildNodesHotThreads (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,27 @@ function buildNodesHotThreads (opts) { * @param {enum} type - The type to sample (default: cpu) * @param {time} timeout - Explicit operation timeout */ + + const acceptedQuerystring = [ + 'interval', + 'snapshots', + 'threads', + 'ignore_idle_threads', + 'type', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + ignoreIdleThreads: 'ignore_idle_threads', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function nodesHotThreads (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -42,62 +66,22 @@ function buildNodesHotThreads (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'interval', - 'snapshots', - 'threads', - 'ignore_idle_threads', - 'type', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'interval', - 'snapshots', - 'threads', - 'ignoreIdleThreads', - 'type', - 'timeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, nodeId, node_id } = params + var querystring = semicopy(params, ['method', 'body', 'nodeId', 'node_id']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -105,14 +89,14 @@ function buildNodesHotThreads (opts) { var path = '' - if ((params['node_id'] || params['nodeId']) != null) { - path = '/' + '_cluster' + '/' + 'nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'hotthreads' - } else if ((params['node_id'] || params['nodeId']) != null) { - path = '/' + '_cluster' + '/' + 'nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'hot_threads' - } else if ((params['node_id'] || params['nodeId']) != null) { - path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'hotthreads' - } else if ((params['node_id'] || params['nodeId']) != null) { - path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'hot_threads' + if ((node_id || nodeId) != null) { + path = '/' + '_cluster' + '/' + 'nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hotthreads' + } else if ((node_id || nodeId) != null) { + path = '/' + '_cluster' + '/' + 'nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hot_threads' + } else if ((node_id || nodeId) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hotthreads' + } else if ((node_id || nodeId) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hot_threads' } else { path = '/' + '_cluster' + '/' + 'nodes' + '/' + 'hotthreads' } @@ -130,10 +114,27 @@ function buildNodesHotThreads (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/nodes.info.js b/api/api/nodes.info.js index 0fe37efdd..dce92830c 100644 --- a/api/api/nodes.info.js +++ b/api/api/nodes.info.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildNodesInfo (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -11,6 +14,23 @@ function buildNodesInfo (opts) { * @param {boolean} flat_settings - Return settings in flat format (default: false) * @param {time} timeout - Explicit operation timeout */ + + const acceptedQuerystring = [ + 'flat_settings', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + flatSettings: 'flat_settings', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function nodesInfo (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -39,54 +59,22 @@ function buildNodesInfo (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'flat_settings', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'flatSettings', - 'timeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, nodeId, node_id, metric } = params + var querystring = semicopy(params, ['method', 'body', 'nodeId', 'node_id', 'metric']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -94,12 +82,12 @@ function buildNodesInfo (opts) { var path = '' - if ((params['node_id'] || params['nodeId']) != null && (params['metric']) != null) { - path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + encodeURIComponent(params['metric']) - } else if ((params['node_id'] || params['nodeId']) != null) { - path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) - } else if ((params['metric']) != null) { - path = '/' + '_nodes' + '/' + encodeURIComponent(params['metric']) + if ((node_id || nodeId) != null && (metric) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + encodeURIComponent(metric) + } else if ((node_id || nodeId) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + } else if ((metric) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(metric) } else { path = '/' + '_nodes' } @@ -117,10 +105,27 @@ function buildNodesInfo (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/nodes.reload_secure_settings.js b/api/api/nodes.reload_secure_settings.js index 0f04f3c0a..68ee34580 100644 --- a/api/api/nodes.reload_secure_settings.js +++ b/api/api/nodes.reload_secure_settings.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildNodesReloadSecureSettings (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,21 @@ function buildNodesReloadSecureSettings (opts) { * @param {list} node_id - A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes. * @param {time} timeout - Explicit operation timeout */ + + const acceptedQuerystring = [ + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function nodesReloadSecureSettings (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -37,52 +55,22 @@ function buildNodesReloadSecureSettings (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'timeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, nodeId, node_id } = params + var querystring = semicopy(params, ['method', 'body', 'nodeId', 'node_id']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -90,8 +78,8 @@ function buildNodesReloadSecureSettings (opts) { var path = '' - if ((params['node_id'] || params['nodeId']) != null) { - path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'reload_secure_settings' + if ((node_id || nodeId) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'reload_secure_settings' } else { path = '/' + '_nodes' + '/' + 'reload_secure_settings' } @@ -109,10 +97,27 @@ function buildNodesReloadSecureSettings (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/nodes.stats.js b/api/api/nodes.stats.js index dc80a9363..1fd5e8de4 100644 --- a/api/api/nodes.stats.js +++ b/api/api/nodes.stats.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildNodesStats (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -18,6 +21,31 @@ function buildNodesStats (opts) { * @param {time} timeout - Explicit operation timeout * @param {boolean} include_segment_file_sizes - Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) */ + + const acceptedQuerystring = [ + 'completion_fields', + 'fielddata_fields', + 'fields', + 'groups', + 'level', + 'types', + 'timeout', + 'include_segment_file_sizes', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + completionFields: 'completion_fields', + fielddataFields: 'fielddata_fields', + includeSegmentFileSizes: 'include_segment_file_sizes', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function nodesStats (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -46,66 +74,22 @@ function buildNodesStats (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'completion_fields', - 'fielddata_fields', - 'fields', - 'groups', - 'level', - 'types', - 'timeout', - 'include_segment_file_sizes', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'completionFields', - 'fielddataFields', - 'fields', - 'groups', - 'level', - 'types', - 'timeout', - 'includeSegmentFileSizes', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, metric, indexMetric, index_metric, nodeId, node_id } = params + var querystring = semicopy(params, ['method', 'body', 'metric', 'indexMetric', 'index_metric', 'nodeId', 'node_id']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -113,16 +97,16 @@ function buildNodesStats (opts) { var path = '' - if ((params['node_id'] || params['nodeId']) != null && (params['metric']) != null && (params['index_metric'] || params['indexMetric']) != null) { - path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'stats' + '/' + encodeURIComponent(params['metric']) + '/' + encodeURIComponent(params['index_metric'] || params['indexMetric']) - } else if ((params['node_id'] || params['nodeId']) != null && (params['metric']) != null) { - path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'stats' + '/' + encodeURIComponent(params['metric']) - } else if ((params['metric']) != null && (params['index_metric'] || params['indexMetric']) != null) { - path = '/' + '_nodes' + '/' + 'stats' + '/' + encodeURIComponent(params['metric']) + '/' + encodeURIComponent(params['index_metric'] || params['indexMetric']) - } else if ((params['node_id'] || params['nodeId']) != null) { - path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'stats' - } else if ((params['metric']) != null) { - path = '/' + '_nodes' + '/' + 'stats' + '/' + encodeURIComponent(params['metric']) + if ((node_id || nodeId) != null && (metric) != null && (index_metric || indexMetric) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'stats' + '/' + encodeURIComponent(metric) + '/' + encodeURIComponent(index_metric || indexMetric) + } else if ((node_id || nodeId) != null && (metric) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'stats' + '/' + encodeURIComponent(metric) + } else if ((metric) != null && (index_metric || indexMetric) != null) { + path = '/' + '_nodes' + '/' + 'stats' + '/' + encodeURIComponent(metric) + '/' + encodeURIComponent(index_metric || indexMetric) + } else if ((node_id || nodeId) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'stats' + } else if ((metric) != null) { + path = '/' + '_nodes' + '/' + 'stats' + '/' + encodeURIComponent(metric) } else { path = '/' + '_nodes' + '/' + 'stats' } @@ -140,10 +124,27 @@ function buildNodesStats (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/nodes.usage.js b/api/api/nodes.usage.js index 13a1010e1..d8fed1279 100644 --- a/api/api/nodes.usage.js +++ b/api/api/nodes.usage.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildNodesUsage (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,21 @@ function buildNodesUsage (opts) { * @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes * @param {time} timeout - Explicit operation timeout */ + + const acceptedQuerystring = [ + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function nodesUsage (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -38,52 +56,22 @@ function buildNodesUsage (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'timeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, metric, nodeId, node_id } = params + var querystring = semicopy(params, ['method', 'body', 'metric', 'nodeId', 'node_id']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -91,12 +79,12 @@ function buildNodesUsage (opts) { var path = '' - if ((params['node_id'] || params['nodeId']) != null && (params['metric']) != null) { - path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'usage' + '/' + encodeURIComponent(params['metric']) - } else if ((params['node_id'] || params['nodeId']) != null) { - path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'usage' - } else if ((params['metric']) != null) { - path = '/' + '_nodes' + '/' + 'usage' + '/' + encodeURIComponent(params['metric']) + if ((node_id || nodeId) != null && (metric) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'usage' + '/' + encodeURIComponent(metric) + } else if ((node_id || nodeId) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'usage' + } else if ((metric) != null) { + path = '/' + '_nodes' + '/' + 'usage' + '/' + encodeURIComponent(metric) } else { path = '/' + '_nodes' + '/' + 'usage' } @@ -114,10 +102,27 @@ function buildNodesUsage (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ping.js b/api/api/ping.js index ea12fc318..1c158919d 100644 --- a/api/api/ping.js +++ b/api/api/ping.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildPing (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -7,6 +10,20 @@ function buildPing (opts) { * Perform a [ping](http://www.elastic.co/guide/) request * */ + + const acceptedQuerystring = [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function ping (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -35,50 +52,22 @@ function buildPing (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'HEAD' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'HEAD' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -101,10 +90,27 @@ function buildPing (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/put_script.js b/api/api/put_script.js index a1597dbc1..d2f42a925 100644 --- a/api/api/put_script.js +++ b/api/api/put_script.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildPutScript (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -13,6 +16,24 @@ function buildPutScript (opts) { * @param {string} context - Context name to compile script against * @param {object} body - The document */ + + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'context', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function putScript (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -55,56 +76,22 @@ function buildPutScript (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'context', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'timeout', - 'masterTimeout', - 'context', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id, context } = params + var querystring = semicopy(params, ['method', 'body', 'id', 'context']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -112,17 +99,17 @@ function buildPutScript (opts) { var path = '' - if ((params['id']) != null && (params['context']) != null) { - path = '/' + '_scripts' + '/' + encodeURIComponent(params['id']) + '/' + encodeURIComponent(params['context']) + if ((id) != null && (context) != null) { + path = '/' + '_scripts' + '/' + encodeURIComponent(id) + '/' + encodeURIComponent(context) } else { - path = '/' + '_scripts' + '/' + encodeURIComponent(params['id']) + path = '/' + '_scripts' + '/' + encodeURIComponent(id) } // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -131,10 +118,27 @@ function buildPutScript (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/rank_eval.js b/api/api/rank_eval.js index 26590c7d2..bbeb9d38d 100644 --- a/api/api/rank_eval.js +++ b/api/api/rank_eval.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildRankEval (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -12,6 +15,26 @@ function buildRankEval (opts) { * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {object} body - The ranking evaluation search definition, including search requests, document ratings and ranking metric definition. */ + + const acceptedQuerystring = [ + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + '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 rankEval (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -40,56 +63,22 @@ function buildRankEval (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -97,8 +86,8 @@ function buildRankEval (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_rank_eval' + if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_rank_eval' } else { path = '/' + '_rank_eval' } @@ -107,7 +96,7 @@ function buildRankEval (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -116,10 +105,27 @@ function buildRankEval (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/reindex.js b/api/api/reindex.js index 6a5a1f43d..83fb25f16 100644 --- a/api/api/reindex.js +++ b/api/api/reindex.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildReindex (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,29 @@ function buildReindex (opts) { * @param {number} slices - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. * @param {object} body - The search definition using the Query DSL and the prototype for the index request. */ + + const acceptedQuerystring = [ + 'refresh', + 'timeout', + 'wait_for_active_shards', + 'wait_for_completion', + 'requests_per_second', + 'slices', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + waitForActiveShards: 'wait_for_active_shards', + waitForCompletion: 'wait_for_completion', + requestsPerSecond: 'requests_per_second', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function reindex (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -42,62 +68,22 @@ function buildReindex (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'refresh', - 'timeout', - 'wait_for_active_shards', - 'wait_for_completion', - 'requests_per_second', - 'slices', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'refresh', - 'timeout', - 'waitForActiveShards', - 'waitForCompletion', - 'requestsPerSecond', - 'slices', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -111,7 +97,7 @@ function buildReindex (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -120,10 +106,27 @@ function buildReindex (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/reindex_rethrottle.js b/api/api/reindex_rethrottle.js index 35961aa79..ffc4dffa9 100644 --- a/api/api/reindex_rethrottle.js +++ b/api/api/reindex_rethrottle.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildReindexRethrottle (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,22 @@ function buildReindexRethrottle (opts) { * @param {string} task_id - The task id to rethrottle * @param {number} requests_per_second - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. */ + + const acceptedQuerystring = [ + 'requests_per_second', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + requestsPerSecond: 'requests_per_second', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function reindexRethrottle (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -49,52 +68,22 @@ function buildReindexRethrottle (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'requests_per_second', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'requestsPerSecond', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, taskId, task_id } = params + var querystring = semicopy(params, ['method', 'body', 'taskId', 'task_id']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -102,7 +91,7 @@ function buildReindexRethrottle (opts) { var path = '' - path = '/' + '_reindex' + '/' + encodeURIComponent(params['task_id'] || params['taskId']) + '/' + '_rethrottle' + path = '/' + '_reindex' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_rethrottle' // build request object const request = { @@ -117,10 +106,27 @@ function buildReindexRethrottle (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/render_search_template.js b/api/api/render_search_template.js index e4a8e742c..19c34ffaf 100644 --- a/api/api/render_search_template.js +++ b/api/api/render_search_template.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildRenderSearchTemplate (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,20 @@ function buildRenderSearchTemplate (opts) { * @param {string} id - The id of the stored search template * @param {object} body - The search definition template and its params */ + + const acceptedQuerystring = [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function renderSearchTemplate (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -29,50 +46,22 @@ function buildRenderSearchTemplate (opts) { }) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -80,8 +69,8 @@ function buildRenderSearchTemplate (opts) { var path = '' - if ((params['id']) != null) { - path = '/' + '_render' + '/' + 'template' + '/' + encodeURIComponent(params['id']) + if ((id) != null) { + path = '/' + '_render' + '/' + 'template' + '/' + encodeURIComponent(id) } else { path = '/' + '_render' + '/' + 'template' } @@ -90,7 +79,7 @@ function buildRenderSearchTemplate (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -99,10 +88,27 @@ function buildRenderSearchTemplate (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/scripts_painless_execute.js b/api/api/scripts_painless_execute.js index 1093a6333..d7306b551 100644 --- a/api/api/scripts_painless_execute.js +++ b/api/api/scripts_painless_execute.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildScriptsPainlessExecute (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,20 @@ function buildScriptsPainlessExecute (opts) { * * @param {object} body - The script to execute */ + + const acceptedQuerystring = [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function scriptsPainlessExecute (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -28,50 +45,22 @@ function buildScriptsPainlessExecute (opts) { }) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -85,7 +74,7 @@ function buildScriptsPainlessExecute (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -94,10 +83,27 @@ function buildScriptsPainlessExecute (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/scroll.js b/api/api/scroll.js index f1b7063b8..466950dde 100644 --- a/api/api/scroll.js +++ b/api/api/scroll.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildScroll (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -12,6 +15,25 @@ function buildScroll (opts) { * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response * @param {object} body - The scroll ID if not passed by URL or query parameter. */ + + const acceptedQuerystring = [ + 'scroll', + 'scroll_id', + 'rest_total_hits_as_int', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + scrollId: 'scroll_id', + restTotalHitsAsInt: 'rest_total_hits_as_int', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function scroll (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -32,56 +54,22 @@ function buildScroll (opts) { }) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'scroll', - 'scroll_id', - 'rest_total_hits_as_int', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'scroll', - 'scrollId', - 'restTotalHitsAsInt', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, scrollId, scroll_id } = params + var querystring = semicopy(params, ['method', 'body', 'scrollId', 'scroll_id']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -89,8 +77,8 @@ function buildScroll (opts) { var path = '' - if ((params['scroll_id'] || params['scrollId']) != null) { - path = '/' + '_search' + '/' + 'scroll' + '/' + encodeURIComponent(params['scroll_id'] || params['scrollId']) + if ((scroll_id || scrollId) != null) { + path = '/' + '_search' + '/' + 'scroll' + '/' + encodeURIComponent(scroll_id || scrollId) } else { path = '/' + '_search' + '/' + 'scroll' } @@ -99,7 +87,7 @@ function buildScroll (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -108,10 +96,27 @@ function buildScroll (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/search.js b/api/api/search.js index 2b49563a7..aa59a2310 100644 --- a/api/api/search.js +++ b/api/api/search.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSearch (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -50,6 +53,85 @@ function buildSearch (opts) { * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response * @param {object} body - The search definition using the Query DSL */ + + const acceptedQuerystring = [ + 'analyzer', + 'analyze_wildcard', + 'default_operator', + 'df', + 'explain', + 'stored_fields', + 'docvalue_fields', + 'from', + 'ignore_unavailable', + 'ignore_throttled', + 'allow_no_indices', + 'expand_wildcards', + 'lenient', + 'preference', + 'q', + 'routing', + 'scroll', + 'search_type', + 'size', + 'sort', + '_source', + '_source_excludes', + '_source_includes', + 'terminate_after', + 'stats', + 'suggest_field', + 'suggest_mode', + 'suggest_size', + 'suggest_text', + 'timeout', + 'track_scores', + 'track_total_hits', + 'allow_partial_search_results', + 'typed_keys', + 'version', + 'request_cache', + 'batched_reduce_size', + 'max_concurrent_shard_requests', + 'pre_filter_shard_size', + 'rest_total_hits_as_int', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + analyzeWildcard: 'analyze_wildcard', + defaultOperator: 'default_operator', + storedFields: 'stored_fields', + docvalueFields: 'docvalue_fields', + ignoreUnavailable: 'ignore_unavailable', + ignoreThrottled: 'ignore_throttled', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + searchType: 'search_type', + _sourceExcludes: '_source_excludes', + _sourceIncludes: '_source_includes', + terminateAfter: 'terminate_after', + suggestField: 'suggest_field', + suggestMode: 'suggest_mode', + suggestSize: 'suggest_size', + suggestText: 'suggest_text', + trackScores: 'track_scores', + trackTotalHits: 'track_total_hits', + allowPartialSearchResults: 'allow_partial_search_results', + typedKeys: 'typed_keys', + requestCache: 'request_cache', + batchedReduceSize: 'batched_reduce_size', + maxConcurrentShardRequests: 'max_concurrent_shard_requests', + preFilterShardSize: 'pre_filter_shard_size', + restTotalHitsAsInt: 'rest_total_hits_as_int', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function search (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -78,130 +160,22 @@ function buildSearch (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'analyzer', - 'analyze_wildcard', - 'default_operator', - 'df', - 'explain', - 'stored_fields', - 'docvalue_fields', - 'from', - 'ignore_unavailable', - 'ignore_throttled', - 'allow_no_indices', - 'expand_wildcards', - 'lenient', - 'preference', - 'q', - 'routing', - 'scroll', - 'search_type', - 'size', - 'sort', - '_source', - '_source_excludes', - '_source_includes', - 'terminate_after', - 'stats', - 'suggest_field', - 'suggest_mode', - 'suggest_size', - 'suggest_text', - 'timeout', - 'track_scores', - 'track_total_hits', - 'allow_partial_search_results', - 'typed_keys', - 'version', - 'request_cache', - 'batched_reduce_size', - 'max_concurrent_shard_requests', - 'pre_filter_shard_size', - 'rest_total_hits_as_int', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'analyzer', - 'analyzeWildcard', - 'defaultOperator', - 'df', - 'explain', - 'storedFields', - 'docvalueFields', - 'from', - 'ignoreUnavailable', - 'ignoreThrottled', - 'allowNoIndices', - 'expandWildcards', - 'lenient', - 'preference', - 'q', - 'routing', - 'scroll', - 'searchType', - 'size', - 'sort', - '_source', - '_sourceExcludes', - '_sourceIncludes', - 'terminateAfter', - 'stats', - 'suggestField', - 'suggestMode', - 'suggestSize', - 'suggestText', - 'timeout', - 'trackScores', - 'trackTotalHits', - 'allowPartialSearchResults', - 'typedKeys', - 'version', - 'requestCache', - 'batchedReduceSize', - 'maxConcurrentShardRequests', - 'preFilterShardSize', - 'restTotalHitsAsInt', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'type']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -209,10 +183,10 @@ function buildSearch (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_search' - } else if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_search' + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_search' + } else if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_search' } else { path = '/' + '_search' } @@ -221,7 +195,7 @@ function buildSearch (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -230,10 +204,27 @@ function buildSearch (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/search_shards.js b/api/api/search_shards.js index 95ade603e..e87adddcf 100644 --- a/api/api/search_shards.js +++ b/api/api/search_shards.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSearchShards (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,29 @@ function buildSearchShards (opts) { * @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. */ + + const acceptedQuerystring = [ + 'preference', + 'routing', + 'local', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + '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 searchShards (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -42,62 +68,22 @@ function buildSearchShards (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'preference', - 'routing', - 'local', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'preference', - 'routing', - 'local', - 'ignoreUnavailable', - 'allowNoIndices', - 'expandWildcards', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -105,8 +91,8 @@ function buildSearchShards (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_search_shards' + if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_search_shards' } else { path = '/' + '_search_shards' } @@ -124,10 +110,27 @@ function buildSearchShards (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/search_template.js b/api/api/search_template.js index 63cdbb441..06722fd98 100644 --- a/api/api/search_template.js +++ b/api/api/search_template.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSearchTemplate (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -22,6 +25,39 @@ function buildSearchTemplate (opts) { * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response * @param {object} body - The search definition template and its params */ + + const acceptedQuerystring = [ + 'ignore_unavailable', + 'ignore_throttled', + 'allow_no_indices', + 'expand_wildcards', + 'preference', + 'routing', + 'scroll', + 'search_type', + 'explain', + 'profile', + 'typed_keys', + 'rest_total_hits_as_int', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + ignoreUnavailable: 'ignore_unavailable', + ignoreThrottled: 'ignore_throttled', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + searchType: 'search_type', + typedKeys: 'typed_keys', + restTotalHitsAsInt: 'rest_total_hits_as_int', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function searchTemplate (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -58,74 +94,22 @@ function buildSearchTemplate (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'ignore_unavailable', - 'ignore_throttled', - 'allow_no_indices', - 'expand_wildcards', - 'preference', - 'routing', - 'scroll', - 'search_type', - 'explain', - 'profile', - 'typed_keys', - 'rest_total_hits_as_int', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'ignoreUnavailable', - 'ignoreThrottled', - 'allowNoIndices', - 'expandWildcards', - 'preference', - 'routing', - 'scroll', - 'searchType', - 'explain', - 'profile', - 'typedKeys', - 'restTotalHitsAsInt', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'type']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -133,10 +117,10 @@ function buildSearchTemplate (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_search' + '/' + 'template' - } else if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_search' + '/' + 'template' + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_search' + '/' + 'template' + } else if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_search' + '/' + 'template' } else { path = '/' + '_search' + '/' + 'template' } @@ -145,7 +129,7 @@ function buildSearchTemplate (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -154,10 +138,27 @@ function buildSearchTemplate (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.authenticate.js b/api/api/security.authenticate.js index d1bd8a815..aa80e1c18 100644 --- a/api/api/security.authenticate.js +++ b/api/api/security.authenticate.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityAuthenticate (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -7,6 +10,15 @@ function buildSecurityAuthenticate (opts) { * Perform a [security.authenticate](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-authenticate.html) request * */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function securityAuthenticate (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -35,42 +47,22 @@ function buildSecurityAuthenticate (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -93,10 +85,27 @@ function buildSecurityAuthenticate (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.change_password.js b/api/api/security.change_password.js index fc07667d7..662f5470c 100644 --- a/api/api/security.change_password.js +++ b/api/api/security.change_password.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityChangePassword (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,15 @@ function buildSecurityChangePassword (opts) { * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. * @param {object} body - the new password for the user */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + return function securityChangePassword (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -38,42 +50,22 @@ function buildSecurityChangePassword (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'refresh' - ] - const acceptedQuerystringCamelCased = [ - 'refresh' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, username } = params + var querystring = semicopy(params, ['method', 'body', 'username']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -81,8 +73,8 @@ function buildSecurityChangePassword (opts) { var path = '' - if ((params['username']) != null) { - path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(params['username']) + '/' + '_password' + if ((username) != null) { + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + '/' + '_password' } else { path = '/' + '_security' + '/' + 'user' + '/' + '_password' } @@ -91,7 +83,7 @@ function buildSecurityChangePassword (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -100,10 +92,27 @@ function buildSecurityChangePassword (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.clear_cached_realms.js b/api/api/security.clear_cached_realms.js index 0d89991dd..c837a1ba0 100644 --- a/api/api/security.clear_cached_realms.js +++ b/api/api/security.clear_cached_realms.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityClearCachedRealms (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildSecurityClearCachedRealms (opts) { * @param {list} realms - Comma-separated list of realms to clear * @param {list} usernames - Comma-separated list of usernames to clear from the cache */ + + const acceptedQuerystring = [ + 'usernames' + ] + + const snakeCase = { + + } + return function securityClearCachedRealms (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,42 +55,22 @@ function buildSecurityClearCachedRealms (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'usernames' - ] - const acceptedQuerystringCamelCased = [ - 'usernames' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, realms } = params + var querystring = semicopy(params, ['method', 'body', 'realms']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -86,7 +78,7 @@ function buildSecurityClearCachedRealms (opts) { var path = '' - path = '/' + '_security' + '/' + 'realm' + '/' + encodeURIComponent(params['realms']) + '/' + '_clear_cache' + path = '/' + '_security' + '/' + 'realm' + '/' + encodeURIComponent(realms) + '/' + '_clear_cache' // build request object const request = { @@ -101,10 +93,27 @@ function buildSecurityClearCachedRealms (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.clear_cached_roles.js b/api/api/security.clear_cached_roles.js index d4f658bcd..d0f1898ad 100644 --- a/api/api/security.clear_cached_roles.js +++ b/api/api/security.clear_cached_roles.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityClearCachedRoles (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildSecurityClearCachedRoles (opts) { * * @param {list} name - Role name */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function securityClearCachedRoles (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -42,42 +54,22 @@ function buildSecurityClearCachedRoles (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -85,7 +77,7 @@ function buildSecurityClearCachedRoles (opts) { var path = '' - path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(params['name']) + '/' + '_clear_cache' + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(name) + '/' + '_clear_cache' // build request object const request = { @@ -100,10 +92,27 @@ function buildSecurityClearCachedRoles (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.delete_privileges.js b/api/api/security.delete_privileges.js index 0a0f6492b..c62ae5d41 100644 --- a/api/api/security.delete_privileges.js +++ b/api/api/security.delete_privileges.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityDeletePrivileges (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,15 @@ function buildSecurityDeletePrivileges (opts) { * @param {string} name - Privilege name * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + return function securityDeletePrivileges (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -58,42 +70,22 @@ function buildSecurityDeletePrivileges (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'refresh' - ] - const acceptedQuerystringCamelCased = [ - 'refresh' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, application, name } = params + var querystring = semicopy(params, ['method', 'body', 'application', 'name']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -101,7 +93,7 @@ function buildSecurityDeletePrivileges (opts) { var path = '' - path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(params['application']) + '/' + encodeURIComponent(params['name']) + path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(application) + '/' + encodeURIComponent(name) // build request object const request = { @@ -116,10 +108,27 @@ function buildSecurityDeletePrivileges (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.delete_role.js b/api/api/security.delete_role.js index c7d2ccb83..cb3a4464d 100644 --- a/api/api/security.delete_role.js +++ b/api/api/security.delete_role.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityDeleteRole (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildSecurityDeleteRole (opts) { * @param {string} name - Role name * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + return function securityDeleteRole (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,42 +55,22 @@ function buildSecurityDeleteRole (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'refresh' - ] - const acceptedQuerystringCamelCased = [ - 'refresh' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -86,7 +78,7 @@ function buildSecurityDeleteRole (opts) { var path = '' - path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(params['name']) + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(name) // build request object const request = { @@ -101,10 +93,27 @@ function buildSecurityDeleteRole (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.delete_role_mapping.js b/api/api/security.delete_role_mapping.js index 0ddde9ce2..6528203cf 100644 --- a/api/api/security.delete_role_mapping.js +++ b/api/api/security.delete_role_mapping.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityDeleteRoleMapping (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildSecurityDeleteRoleMapping (opts) { * @param {string} name - Role-mapping name * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + return function securityDeleteRoleMapping (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,42 +55,22 @@ function buildSecurityDeleteRoleMapping (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'refresh' - ] - const acceptedQuerystringCamelCased = [ - 'refresh' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -86,7 +78,7 @@ function buildSecurityDeleteRoleMapping (opts) { var path = '' - path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(params['name']) + path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(name) // build request object const request = { @@ -101,10 +93,27 @@ function buildSecurityDeleteRoleMapping (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.delete_user.js b/api/api/security.delete_user.js index b5418ad91..ca8ac498b 100644 --- a/api/api/security.delete_user.js +++ b/api/api/security.delete_user.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityDeleteUser (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildSecurityDeleteUser (opts) { * @param {string} username - username * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + return function securityDeleteUser (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,42 +55,22 @@ function buildSecurityDeleteUser (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'refresh' - ] - const acceptedQuerystringCamelCased = [ - 'refresh' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, username } = params + var querystring = semicopy(params, ['method', 'body', 'username']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -86,7 +78,7 @@ function buildSecurityDeleteUser (opts) { var path = '' - path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(params['username']) + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) // build request object const request = { @@ -101,10 +93,27 @@ function buildSecurityDeleteUser (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.disable_user.js b/api/api/security.disable_user.js index 095724886..e4a447521 100644 --- a/api/api/security.disable_user.js +++ b/api/api/security.disable_user.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityDisableUser (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildSecurityDisableUser (opts) { * @param {string} username - The username of the user to disable * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + return function securityDisableUser (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -37,42 +49,22 @@ function buildSecurityDisableUser (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'refresh' - ] - const acceptedQuerystringCamelCased = [ - 'refresh' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, username } = params + var querystring = semicopy(params, ['method', 'body', 'username']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -80,7 +72,7 @@ function buildSecurityDisableUser (opts) { var path = '' - path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(params['username']) + '/' + '_disable' + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + '/' + '_disable' // build request object const request = { @@ -95,10 +87,27 @@ function buildSecurityDisableUser (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.enable_user.js b/api/api/security.enable_user.js index 24509b689..e3b12c29e 100644 --- a/api/api/security.enable_user.js +++ b/api/api/security.enable_user.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityEnableUser (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildSecurityEnableUser (opts) { * @param {string} username - The username of the user to enable * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + return function securityEnableUser (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -37,42 +49,22 @@ function buildSecurityEnableUser (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'refresh' - ] - const acceptedQuerystringCamelCased = [ - 'refresh' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, username } = params + var querystring = semicopy(params, ['method', 'body', 'username']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -80,7 +72,7 @@ function buildSecurityEnableUser (opts) { var path = '' - path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(params['username']) + '/' + '_enable' + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + '/' + '_enable' // build request object const request = { @@ -95,10 +87,27 @@ function buildSecurityEnableUser (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.get_privileges.js b/api/api/security.get_privileges.js index 816d288e6..04e38fca8 100644 --- a/api/api/security.get_privileges.js +++ b/api/api/security.get_privileges.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityGetPrivileges (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildSecurityGetPrivileges (opts) { * @param {string} application - Application name * @param {string} name - Privilege name */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function securityGetPrivileges (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -45,42 +57,22 @@ function buildSecurityGetPrivileges (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, application, name } = params + var querystring = semicopy(params, ['method', 'body', 'application', 'name']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -88,7 +80,7 @@ function buildSecurityGetPrivileges (opts) { var path = '' - path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(params['application']) + '/' + encodeURIComponent(params['name']) + path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(application) + '/' + encodeURIComponent(name) // build request object const request = { @@ -103,10 +95,27 @@ function buildSecurityGetPrivileges (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.get_role.js b/api/api/security.get_role.js index 6937deaab..2c05b4c24 100644 --- a/api/api/security.get_role.js +++ b/api/api/security.get_role.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityGetRole (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildSecurityGetRole (opts) { * * @param {string} name - Role name */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function securityGetRole (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildSecurityGetRole (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -79,8 +71,8 @@ function buildSecurityGetRole (opts) { var path = '' - if ((params['name']) != null) { - path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(params['name']) + if ((name) != null) { + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(name) } else { path = '/' + '_security' + '/' + 'role' } @@ -98,10 +90,27 @@ function buildSecurityGetRole (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.get_role_mapping.js b/api/api/security.get_role_mapping.js index 6730f8e25..00b0b309e 100644 --- a/api/api/security.get_role_mapping.js +++ b/api/api/security.get_role_mapping.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityGetRoleMapping (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildSecurityGetRoleMapping (opts) { * * @param {string} name - Role-Mapping name */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function securityGetRoleMapping (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildSecurityGetRoleMapping (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -79,8 +71,8 @@ function buildSecurityGetRoleMapping (opts) { var path = '' - if ((params['name']) != null) { - path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(params['name']) + if ((name) != null) { + path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(name) } else { path = '/' + '_security' + '/' + 'role_mapping' } @@ -98,10 +90,27 @@ function buildSecurityGetRoleMapping (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.get_token.js b/api/api/security.get_token.js index 7dcfc72cd..3ae6fb217 100644 --- a/api/api/security.get_token.js +++ b/api/api/security.get_token.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityGetToken (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildSecurityGetToken (opts) { * * @param {object} body - The token request to get */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function securityGetToken (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildSecurityGetToken (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -85,7 +77,7 @@ function buildSecurityGetToken (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -94,10 +86,27 @@ function buildSecurityGetToken (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.get_user.js b/api/api/security.get_user.js index 13fb8e9fe..6b66fd5d7 100644 --- a/api/api/security.get_user.js +++ b/api/api/security.get_user.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityGetUser (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildSecurityGetUser (opts) { * * @param {list} username - A comma-separated list of usernames */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function securityGetUser (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildSecurityGetUser (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, username } = params + var querystring = semicopy(params, ['method', 'body', 'username']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -79,8 +71,8 @@ function buildSecurityGetUser (opts) { var path = '' - if ((params['username']) != null) { - path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(params['username']) + if ((username) != null) { + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) } else { path = '/' + '_security' + '/' + 'user' } @@ -98,10 +90,27 @@ function buildSecurityGetUser (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.get_user_privileges.js b/api/api/security.get_user_privileges.js index 5403767bd..8730db65f 100644 --- a/api/api/security.get_user_privileges.js +++ b/api/api/security.get_user_privileges.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityGetUserPrivileges (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -7,6 +10,15 @@ function buildSecurityGetUserPrivileges (opts) { * Perform a [security.get_user_privileges](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-privileges.html) request * */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function securityGetUserPrivileges (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -35,42 +47,22 @@ function buildSecurityGetUserPrivileges (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -93,10 +85,27 @@ function buildSecurityGetUserPrivileges (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.has_privileges.js b/api/api/security.has_privileges.js index 7fa1f3e5c..494bed435 100644 --- a/api/api/security.has_privileges.js +++ b/api/api/security.has_privileges.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityHasPrivileges (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildSecurityHasPrivileges (opts) { * @param {string} user - Username * @param {object} body - The privileges to test */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function securityHasPrivileges (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -37,42 +49,22 @@ function buildSecurityHasPrivileges (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, user } = params + var querystring = semicopy(params, ['method', 'body', 'user']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -80,8 +72,8 @@ function buildSecurityHasPrivileges (opts) { var path = '' - if ((params['user']) != null) { - path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(params['user']) + '/' + '_has_privileges' + if ((user) != null) { + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(user) + '/' + '_has_privileges' } else { path = '/' + '_security' + '/' + 'user' + '/' + '_has_privileges' } @@ -90,7 +82,7 @@ function buildSecurityHasPrivileges (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -99,10 +91,27 @@ function buildSecurityHasPrivileges (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.invalidate_token.js b/api/api/security.invalidate_token.js index 45ec5bd9b..784137b73 100644 --- a/api/api/security.invalidate_token.js +++ b/api/api/security.invalidate_token.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityInvalidateToken (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildSecurityInvalidateToken (opts) { * * @param {object} body - The token to invalidate */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function securityInvalidateToken (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildSecurityInvalidateToken (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -85,7 +77,7 @@ function buildSecurityInvalidateToken (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -94,10 +86,27 @@ function buildSecurityInvalidateToken (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.put_privileges.js b/api/api/security.put_privileges.js index 6f18c7f68..96bac17ba 100644 --- a/api/api/security.put_privileges.js +++ b/api/api/security.put_privileges.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityPutPrivileges (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildSecurityPutPrivileges (opts) { * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. * @param {object} body - The privilege(s) to add */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + return function securityPutPrivileges (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -37,42 +49,22 @@ function buildSecurityPutPrivileges (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'refresh' - ] - const acceptedQuerystringCamelCased = [ - 'refresh' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -86,7 +78,7 @@ function buildSecurityPutPrivileges (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -95,10 +87,27 @@ function buildSecurityPutPrivileges (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.put_role.js b/api/api/security.put_role.js index 259ad1b0e..e1f457617 100644 --- a/api/api/security.put_role.js +++ b/api/api/security.put_role.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityPutRole (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,15 @@ function buildSecurityPutRole (opts) { * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. * @param {object} body - The role to add */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + return function securityPutRole (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,42 +56,22 @@ function buildSecurityPutRole (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'refresh' - ] - const acceptedQuerystringCamelCased = [ - 'refresh' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -87,13 +79,13 @@ function buildSecurityPutRole (opts) { var path = '' - path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(params['name']) + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(name) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -102,10 +94,27 @@ function buildSecurityPutRole (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.put_role_mapping.js b/api/api/security.put_role_mapping.js index 03b74a65f..0000d9fea 100644 --- a/api/api/security.put_role_mapping.js +++ b/api/api/security.put_role_mapping.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityPutRoleMapping (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,15 @@ function buildSecurityPutRoleMapping (opts) { * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. * @param {object} body - The role to add */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + return function securityPutRoleMapping (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,42 +56,22 @@ function buildSecurityPutRoleMapping (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'refresh' - ] - const acceptedQuerystringCamelCased = [ - 'refresh' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -87,13 +79,13 @@ function buildSecurityPutRoleMapping (opts) { var path = '' - path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(params['name']) + path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(name) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -102,10 +94,27 @@ function buildSecurityPutRoleMapping (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/security.put_user.js b/api/api/security.put_user.js index ddc512d15..1ac211dea 100644 --- a/api/api/security.put_user.js +++ b/api/api/security.put_user.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSecurityPutUser (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,15 @@ function buildSecurityPutUser (opts) { * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. * @param {object} body - The user to add */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + return function securityPutUser (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,42 +56,22 @@ function buildSecurityPutUser (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'refresh' - ] - const acceptedQuerystringCamelCased = [ - 'refresh' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, username } = params + var querystring = semicopy(params, ['method', 'body', 'username']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -87,13 +79,13 @@ function buildSecurityPutUser (opts) { var path = '' - path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(params['username']) + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -102,10 +94,27 @@ function buildSecurityPutUser (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/snapshot.create.js b/api/api/snapshot.create.js index 3b4f9a239..2566fc106 100644 --- a/api/api/snapshot.create.js +++ b/api/api/snapshot.create.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSnapshotCreate (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -12,6 +15,24 @@ function buildSnapshotCreate (opts) { * @param {boolean} wait_for_completion - Should this request wait until the operation has completed before returning * @param {object} body - The snapshot definition */ + + const acceptedQuerystring = [ + 'master_timeout', + 'wait_for_completion', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + waitForCompletion: 'wait_for_completion', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function snapshotCreate (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -54,54 +75,22 @@ function buildSnapshotCreate (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'master_timeout', - 'wait_for_completion', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'masterTimeout', - 'waitForCompletion', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, repository, snapshot } = params + var querystring = semicopy(params, ['method', 'body', 'repository', 'snapshot']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -109,13 +98,13 @@ function buildSnapshotCreate (opts) { var path = '' - path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + '/' + encodeURIComponent(params['snapshot']) + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -124,10 +113,27 @@ function buildSnapshotCreate (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/snapshot.create_repository.js b/api/api/snapshot.create_repository.js index a8845077f..a6408a229 100644 --- a/api/api/snapshot.create_repository.js +++ b/api/api/snapshot.create_repository.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSnapshotCreateRepository (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -12,6 +15,24 @@ function buildSnapshotCreateRepository (opts) { * @param {boolean} verify - Whether to verify the repository after creation * @param {object} body - The repository definition */ + + const acceptedQuerystring = [ + 'master_timeout', + 'timeout', + 'verify', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function snapshotCreateRepository (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -46,56 +67,22 @@ function buildSnapshotCreateRepository (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'master_timeout', - 'timeout', - 'verify', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'masterTimeout', - 'timeout', - 'verify', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, repository } = params + var querystring = semicopy(params, ['method', 'body', 'repository']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -103,13 +90,13 @@ function buildSnapshotCreateRepository (opts) { var path = '' - path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -118,10 +105,27 @@ function buildSnapshotCreateRepository (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/snapshot.delete.js b/api/api/snapshot.delete.js index 1e3753ae0..6032eb950 100644 --- a/api/api/snapshot.delete.js +++ b/api/api/snapshot.delete.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSnapshotDelete (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,22 @@ function buildSnapshotDelete (opts) { * @param {string} snapshot - A snapshot name * @param {time} master_timeout - Explicit operation timeout for connection to master node */ + + const acceptedQuerystring = [ + 'master_timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function snapshotDelete (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -58,52 +77,22 @@ function buildSnapshotDelete (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'masterTimeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, repository, snapshot } = params + var querystring = semicopy(params, ['method', 'body', 'repository', 'snapshot']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -111,7 +100,7 @@ function buildSnapshotDelete (opts) { var path = '' - path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + '/' + encodeURIComponent(params['snapshot']) + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) // build request object const request = { @@ -126,10 +115,27 @@ function buildSnapshotDelete (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/snapshot.delete_repository.js b/api/api/snapshot.delete_repository.js index 01b30678d..06282ccb8 100644 --- a/api/api/snapshot.delete_repository.js +++ b/api/api/snapshot.delete_repository.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSnapshotDeleteRepository (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,23 @@ function buildSnapshotDeleteRepository (opts) { * @param {time} master_timeout - Explicit operation timeout for connection to master node * @param {time} timeout - Explicit operation timeout */ + + const acceptedQuerystring = [ + 'master_timeout', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function snapshotDeleteRepository (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,54 +64,22 @@ function buildSnapshotDeleteRepository (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'master_timeout', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'masterTimeout', - 'timeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, repository } = params + var querystring = semicopy(params, ['method', 'body', 'repository']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -99,7 +87,7 @@ function buildSnapshotDeleteRepository (opts) { var path = '' - path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) // build request object const request = { @@ -114,10 +102,27 @@ function buildSnapshotDeleteRepository (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/snapshot.get.js b/api/api/snapshot.get.js index e3e74caf1..685a0dedc 100644 --- a/api/api/snapshot.get.js +++ b/api/api/snapshot.get.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSnapshotGet (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -12,6 +15,25 @@ function buildSnapshotGet (opts) { * @param {boolean} ignore_unavailable - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown * @param {boolean} verbose - Whether to show verbose snapshot info or only show the basic info found in the repository index blob */ + + const acceptedQuerystring = [ + 'master_timeout', + 'ignore_unavailable', + 'verbose', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + ignoreUnavailable: 'ignore_unavailable', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function snapshotGet (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -60,56 +82,22 @@ function buildSnapshotGet (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'master_timeout', - 'ignore_unavailable', - 'verbose', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'masterTimeout', - 'ignoreUnavailable', - 'verbose', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, repository, snapshot } = params + var querystring = semicopy(params, ['method', 'body', 'repository', 'snapshot']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -117,7 +105,7 @@ function buildSnapshotGet (opts) { var path = '' - path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + '/' + encodeURIComponent(params['snapshot']) + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) // build request object const request = { @@ -132,10 +120,27 @@ function buildSnapshotGet (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/snapshot.get_repository.js b/api/api/snapshot.get_repository.js index 02dc64e37..5f836c6e5 100644 --- a/api/api/snapshot.get_repository.js +++ b/api/api/snapshot.get_repository.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSnapshotGetRepository (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,23 @@ function buildSnapshotGetRepository (opts) { * @param {time} master_timeout - Explicit operation timeout for connection to master node * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) */ + + const acceptedQuerystring = [ + 'master_timeout', + 'local', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function snapshotGetRepository (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -38,54 +58,22 @@ function buildSnapshotGetRepository (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'master_timeout', - 'local', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'masterTimeout', - 'local', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, repository } = params + var querystring = semicopy(params, ['method', 'body', 'repository']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -93,8 +81,8 @@ function buildSnapshotGetRepository (opts) { var path = '' - if ((params['repository']) != null) { - path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + if ((repository) != null) { + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) } else { path = '/' + '_snapshot' } @@ -112,10 +100,27 @@ function buildSnapshotGetRepository (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/snapshot.restore.js b/api/api/snapshot.restore.js index da587e286..352059d9f 100644 --- a/api/api/snapshot.restore.js +++ b/api/api/snapshot.restore.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSnapshotRestore (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -12,6 +15,24 @@ function buildSnapshotRestore (opts) { * @param {boolean} wait_for_completion - Should this request wait until the operation has completed before returning * @param {object} body - Details of what to restore */ + + const acceptedQuerystring = [ + 'master_timeout', + 'wait_for_completion', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + waitForCompletion: 'wait_for_completion', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function snapshotRestore (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -54,54 +75,22 @@ function buildSnapshotRestore (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'master_timeout', - 'wait_for_completion', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'masterTimeout', - 'waitForCompletion', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, repository, snapshot } = params + var querystring = semicopy(params, ['method', 'body', 'repository', 'snapshot']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -109,13 +98,13 @@ function buildSnapshotRestore (opts) { var path = '' - path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + '/' + encodeURIComponent(params['snapshot']) + '/' + '_restore' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) + '/' + '_restore' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -124,10 +113,27 @@ function buildSnapshotRestore (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/snapshot.status.js b/api/api/snapshot.status.js index a80f9aed2..81281fcce 100644 --- a/api/api/snapshot.status.js +++ b/api/api/snapshot.status.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSnapshotStatus (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -11,6 +14,24 @@ function buildSnapshotStatus (opts) { * @param {time} master_timeout - Explicit operation timeout for connection to master node * @param {boolean} ignore_unavailable - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown */ + + const acceptedQuerystring = [ + 'master_timeout', + 'ignore_unavailable', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + ignoreUnavailable: 'ignore_unavailable', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function snapshotStatus (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -47,54 +68,22 @@ function buildSnapshotStatus (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'master_timeout', - 'ignore_unavailable', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'masterTimeout', - 'ignoreUnavailable', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, repository, snapshot } = params + var querystring = semicopy(params, ['method', 'body', 'repository', 'snapshot']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -102,10 +91,10 @@ function buildSnapshotStatus (opts) { var path = '' - if ((params['repository']) != null && (params['snapshot']) != null) { - path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + '/' + encodeURIComponent(params['snapshot']) + '/' + '_status' - } else if ((params['repository']) != null) { - path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + '/' + '_status' + if ((repository) != null && (snapshot) != null) { + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) + '/' + '_status' + } else if ((repository) != null) { + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + '_status' } else { path = '/' + '_snapshot' + '/' + '_status' } @@ -123,10 +112,27 @@ function buildSnapshotStatus (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/snapshot.verify_repository.js b/api/api/snapshot.verify_repository.js index ab26069cc..81a171072 100644 --- a/api/api/snapshot.verify_repository.js +++ b/api/api/snapshot.verify_repository.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSnapshotVerifyRepository (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,23 @@ function buildSnapshotVerifyRepository (opts) { * @param {time} master_timeout - Explicit operation timeout for connection to master node * @param {time} timeout - Explicit operation timeout */ + + const acceptedQuerystring = [ + 'master_timeout', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + masterTimeout: 'master_timeout', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function snapshotVerifyRepository (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,54 +64,22 @@ function buildSnapshotVerifyRepository (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'master_timeout', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'masterTimeout', - 'timeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, repository } = params + var querystring = semicopy(params, ['method', 'body', 'repository']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -99,7 +87,7 @@ function buildSnapshotVerifyRepository (opts) { var path = '' - path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + '/' + '_verify' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + '_verify' // build request object const request = { @@ -114,10 +102,27 @@ function buildSnapshotVerifyRepository (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/ssl.certificates.js b/api/api/ssl.certificates.js index 7e6adc9a1..5fd7432ff 100644 --- a/api/api/ssl.certificates.js +++ b/api/api/ssl.certificates.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildSslCertificates (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -7,6 +10,15 @@ function buildSslCertificates (opts) { * Perform a [ssl.certificates](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-ssl.html) request * */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function sslCertificates (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -35,42 +47,22 @@ function buildSslCertificates (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -93,10 +85,27 @@ function buildSslCertificates (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/tasks.cancel.js b/api/api/tasks.cancel.js index 14eb29793..95a4b488b 100644 --- a/api/api/tasks.cancel.js +++ b/api/api/tasks.cancel.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildTasksCancel (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -11,6 +14,24 @@ function buildTasksCancel (opts) { * @param {list} actions - A comma-separated list of actions that should be cancelled. Leave empty to cancel all. * @param {string} parent_task_id - Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all. */ + + const acceptedQuerystring = [ + 'nodes', + 'actions', + 'parent_task_id', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + parentTaskId: 'parent_task_id', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function tasksCancel (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -39,56 +60,22 @@ function buildTasksCancel (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'nodes', - 'actions', - 'parent_task_id', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'nodes', - 'actions', - 'parentTaskId', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, taskId, task_id } = params + var querystring = semicopy(params, ['method', 'body', 'taskId', 'task_id']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -96,8 +83,8 @@ function buildTasksCancel (opts) { var path = '' - if ((params['task_id'] || params['taskId']) != null) { - path = '/' + '_tasks' + '/' + encodeURIComponent(params['task_id'] || params['taskId']) + '/' + '_cancel' + if ((task_id || taskId) != null) { + path = '/' + '_tasks' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_cancel' } else { path = '/' + '_tasks' + '/' + '_cancel' } @@ -115,10 +102,27 @@ function buildTasksCancel (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/tasks.get.js b/api/api/tasks.get.js index 998a14f64..d8088c3bc 100644 --- a/api/api/tasks.get.js +++ b/api/api/tasks.get.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildTasksGet (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,23 @@ function buildTasksGet (opts) { * @param {boolean} wait_for_completion - Wait for the matching tasks to complete (default: false) * @param {time} timeout - Explicit operation timeout */ + + const acceptedQuerystring = [ + 'wait_for_completion', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + waitForCompletion: 'wait_for_completion', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function tasksGet (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -44,54 +64,22 @@ function buildTasksGet (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'wait_for_completion', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'waitForCompletion', - 'timeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, taskId, task_id } = params + var querystring = semicopy(params, ['method', 'body', 'taskId', 'task_id']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -99,7 +87,7 @@ function buildTasksGet (opts) { var path = '' - path = '/' + '_tasks' + '/' + encodeURIComponent(params['task_id'] || params['taskId']) + path = '/' + '_tasks' + '/' + encodeURIComponent(task_id || taskId) // build request object const request = { @@ -114,10 +102,27 @@ function buildTasksGet (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/tasks.list.js b/api/api/tasks.list.js index 8696defb6..a1b0ffacc 100644 --- a/api/api/tasks.list.js +++ b/api/api/tasks.list.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildTasksList (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -14,6 +17,30 @@ function buildTasksList (opts) { * @param {enum} group_by - Group tasks by nodes or parent/child relationships * @param {time} timeout - Explicit operation timeout */ + + const acceptedQuerystring = [ + 'nodes', + 'actions', + 'detailed', + 'parent_task_id', + 'wait_for_completion', + 'group_by', + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + parentTaskId: 'parent_task_id', + waitForCompletion: 'wait_for_completion', + groupBy: 'group_by', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function tasksList (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -42,64 +69,22 @@ function buildTasksList (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'nodes', - 'actions', - 'detailed', - 'parent_task_id', - 'wait_for_completion', - 'group_by', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'nodes', - 'actions', - 'detailed', - 'parentTaskId', - 'waitForCompletion', - 'groupBy', - 'timeout', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -122,10 +107,27 @@ function buildTasksList (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/termvectors.js b/api/api/termvectors.js index 3888a41aa..4b31b792f 100644 --- a/api/api/termvectors.js +++ b/api/api/termvectors.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildTermvectors (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -23,6 +26,35 @@ function buildTermvectors (opts) { * @param {enum} version_type - Specific version type * @param {object} body - Define parameters and or supply a document to get termvectors for. See documentation. */ + + const acceptedQuerystring = [ + 'term_statistics', + 'field_statistics', + 'fields', + 'offsets', + 'positions', + 'payloads', + 'preference', + 'routing', + 'parent', + 'realtime', + 'version', + 'version_type', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + termStatistics: 'term_statistics', + fieldStatistics: 'field_statistics', + versionType: 'version_type', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function termvectors (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -51,74 +83,22 @@ function buildTermvectors (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'term_statistics', - 'field_statistics', - 'fields', - 'offsets', - 'positions', - 'payloads', - 'preference', - 'routing', - 'parent', - 'realtime', - 'version', - 'version_type', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'termStatistics', - 'fieldStatistics', - 'fields', - 'offsets', - 'positions', - 'payloads', - 'preference', - 'routing', - 'parent', - 'realtime', - 'version', - 'versionType', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, type, id } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'type', 'id']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -126,21 +106,21 @@ function buildTermvectors (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null && (params['id']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_termvectors' - } else if ((params['index']) != null && (params['id']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_termvectors' + '/' + encodeURIComponent(params['id']) - } else if ((params['index']) != null && (params['type']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_termvectors' + if ((index) != null && (type) != null && (id) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_termvectors' + } else if ((index) != null && (id) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_termvectors' + '/' + encodeURIComponent(id) + } else if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_termvectors' } else { - path = '/' + encodeURIComponent(params['index']) + '/' + '_termvectors' + path = '/' + encodeURIComponent(index) + '/' + '_termvectors' } // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -149,10 +129,27 @@ function buildTermvectors (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/update.js b/api/api/update.js index 73bcfecf0..859e476f2 100644 --- a/api/api/update.js +++ b/api/api/update.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildUpdate (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -23,6 +26,37 @@ function buildUpdate (opts) { * @param {enum} version_type - Specific version type * @param {object} body - The request definition requires either `script` or partial `doc` */ + + const acceptedQuerystring = [ + 'wait_for_active_shards', + '_source', + '_source_excludes', + '_source_includes', + 'lang', + 'parent', + 'refresh', + 'retry_on_conflict', + 'routing', + 'timeout', + 'version', + 'version_type', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + waitForActiveShards: 'wait_for_active_shards', + _sourceExcludes: '_source_excludes', + _sourceIncludes: '_source_includes', + retryOnConflict: 'retry_on_conflict', + versionType: 'version_type', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function update (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -63,74 +97,22 @@ function buildUpdate (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'wait_for_active_shards', - '_source', - '_source_excludes', - '_source_includes', - 'lang', - 'parent', - 'refresh', - 'retry_on_conflict', - 'routing', - 'timeout', - 'version', - 'version_type', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'waitForActiveShards', - '_source', - '_sourceExcludes', - '_sourceIncludes', - 'lang', - 'parent', - 'refresh', - 'retryOnConflict', - 'routing', - 'timeout', - 'version', - 'versionType', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'id', 'index', 'type']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -138,17 +120,17 @@ function buildUpdate (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null && (params['id']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_update' + if ((index) != null && (type) != null && (id) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_update' } else { - path = '/' + encodeURIComponent(params['index']) + '/' + '_update' + '/' + encodeURIComponent(params['id']) + path = '/' + encodeURIComponent(index) + '/' + '_update' + '/' + encodeURIComponent(id) } // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -157,10 +139,27 @@ function buildUpdate (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/update_by_query.js b/api/api/update_by_query.js index e7b4c31bd..95ca38b5f 100644 --- a/api/api/update_by_query.js +++ b/api/api/update_by_query.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildUpdateByQuery (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -44,6 +47,70 @@ function buildUpdateByQuery (opts) { * @param {number} slices - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. * @param {object} body - The search definition using the Query DSL */ + + const acceptedQuerystring = [ + 'analyzer', + 'analyze_wildcard', + 'default_operator', + 'df', + 'from', + 'ignore_unavailable', + 'allow_no_indices', + 'conflicts', + 'expand_wildcards', + 'lenient', + 'pipeline', + 'preference', + 'q', + 'routing', + 'scroll', + 'search_type', + 'search_timeout', + 'size', + 'sort', + '_source', + '_source_excludes', + '_source_includes', + 'terminate_after', + 'stats', + 'version', + 'version_type', + 'request_cache', + 'refresh', + 'timeout', + 'wait_for_active_shards', + 'scroll_size', + 'wait_for_completion', + 'requests_per_second', + 'slices', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + analyzeWildcard: 'analyze_wildcard', + defaultOperator: 'default_operator', + ignoreUnavailable: 'ignore_unavailable', + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + searchType: 'search_type', + searchTimeout: 'search_timeout', + _sourceExcludes: '_source_excludes', + _sourceIncludes: '_source_includes', + terminateAfter: 'terminate_after', + versionType: 'version_type', + requestCache: 'request_cache', + waitForActiveShards: 'wait_for_active_shards', + scrollSize: 'scroll_size', + waitForCompletion: 'wait_for_completion', + requestsPerSecond: 'requests_per_second', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function updateByQuery (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -80,118 +147,22 @@ function buildUpdateByQuery (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'analyzer', - 'analyze_wildcard', - 'default_operator', - 'df', - 'from', - 'ignore_unavailable', - 'allow_no_indices', - 'conflicts', - 'expand_wildcards', - 'lenient', - 'pipeline', - 'preference', - 'q', - 'routing', - 'scroll', - 'search_type', - 'search_timeout', - 'size', - 'sort', - '_source', - '_source_excludes', - '_source_includes', - 'terminate_after', - 'stats', - 'version', - 'version_type', - 'request_cache', - 'refresh', - 'timeout', - 'wait_for_active_shards', - 'scroll_size', - 'wait_for_completion', - 'requests_per_second', - 'slices', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'analyzer', - 'analyzeWildcard', - 'defaultOperator', - 'df', - 'from', - 'ignoreUnavailable', - 'allowNoIndices', - 'conflicts', - 'expandWildcards', - 'lenient', - 'pipeline', - 'preference', - 'q', - 'routing', - 'scroll', - 'searchType', - 'searchTimeout', - 'size', - 'sort', - '_source', - '_sourceExcludes', - '_sourceIncludes', - 'terminateAfter', - 'stats', - 'version', - 'versionType', - 'requestCache', - 'refresh', - 'timeout', - 'waitForActiveShards', - 'scrollSize', - 'waitForCompletion', - 'requestsPerSecond', - 'slices', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'type']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -199,17 +170,17 @@ function buildUpdateByQuery (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_update_by_query' + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_update_by_query' } else { - path = '/' + encodeURIComponent(params['index']) + '/' + '_update_by_query' + path = '/' + encodeURIComponent(index) + '/' + '_update_by_query' } // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -218,10 +189,27 @@ function buildUpdateByQuery (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/update_by_query_rethrottle.js b/api/api/update_by_query_rethrottle.js index 4e55ab341..64af0aede 100644 --- a/api/api/update_by_query_rethrottle.js +++ b/api/api/update_by_query_rethrottle.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildUpdateByQueryRethrottle (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,22 @@ function buildUpdateByQueryRethrottle (opts) { * @param {string} task_id - The task id to rethrottle * @param {number} requests_per_second - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. */ + + const acceptedQuerystring = [ + 'requests_per_second', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + requestsPerSecond: 'requests_per_second', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + return function updateByQueryRethrottle (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -49,52 +68,22 @@ function buildUpdateByQueryRethrottle (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'requests_per_second', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - const acceptedQuerystringCamelCased = [ - 'requestsPerSecond', - 'pretty', - 'human', - 'errorTrace', - 'source', - 'filterPath' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, taskId, task_id } = params + var querystring = semicopy(params, ['method', 'body', 'taskId', 'task_id']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -102,7 +91,7 @@ function buildUpdateByQueryRethrottle (opts) { var path = '' - path = '/' + '_update_by_query' + '/' + encodeURIComponent(params['task_id'] || params['taskId']) + '/' + '_rethrottle' + path = '/' + '_update_by_query' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_rethrottle' // build request object const request = { @@ -117,10 +106,27 @@ function buildUpdateByQueryRethrottle (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.graph.explore.js b/api/api/xpack.graph.explore.js index 0513c7e8b..4025b0cd2 100644 --- a/api/api/xpack.graph.explore.js +++ b/api/api/xpack.graph.explore.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackGraphExplore (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -12,6 +15,16 @@ function buildXpackGraphExplore (opts) { * @param {time} timeout - Explicit operation timeout * @param {object} body - Graph Query DSL */ + + const acceptedQuerystring = [ + 'routing', + 'timeout' + ] + + const snakeCase = { + + } + return function xpackGraphExplore (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -40,44 +53,22 @@ function buildXpackGraphExplore (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'routing', - 'timeout' - ] - const acceptedQuerystringCamelCased = [ - 'routing', - 'timeout' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'type']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -85,17 +76,17 @@ function buildXpackGraphExplore (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_graph' + '/' + 'explore' + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_graph' + '/' + 'explore' } else { - path = '/' + encodeURIComponent(params['index']) + '/' + '_graph' + '/' + 'explore' + path = '/' + encodeURIComponent(index) + '/' + '_graph' + '/' + 'explore' } // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -104,10 +95,27 @@ function buildXpackGraphExplore (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.info.js b/api/api/xpack.info.js index 92bd594d8..4f3f706a9 100644 --- a/api/api/xpack.info.js +++ b/api/api/xpack.info.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackInfo (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildXpackInfo (opts) { * * @param {list} categories - Comma-separated list of info categories. Can be any of: build, license, features */ + + const acceptedQuerystring = [ + 'categories' + ] + + const snakeCase = { + + } + return function xpackInfo (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildXpackInfo (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'categories' - ] - const acceptedQuerystringCamelCased = [ - 'categories' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -94,10 +86,27 @@ function buildXpackInfo (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.license.delete.js b/api/api/xpack.license.delete.js index f021661f1..663db0779 100644 --- a/api/api/xpack.license.delete.js +++ b/api/api/xpack.license.delete.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackLicenseDelete (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -7,6 +10,15 @@ function buildXpackLicenseDelete (opts) { * Perform a [xpack.license.delete](https://www.elastic.co/guide/en/x-pack/current/license-management.html) request * */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function xpackLicenseDelete (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -35,42 +47,22 @@ function buildXpackLicenseDelete (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -93,10 +85,27 @@ function buildXpackLicenseDelete (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.license.get.js b/api/api/xpack.license.get.js index 6d2a404a2..cbc2ce78c 100644 --- a/api/api/xpack.license.get.js +++ b/api/api/xpack.license.get.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackLicenseGet (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildXpackLicenseGet (opts) { * * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) */ + + const acceptedQuerystring = [ + 'local' + ] + + const snakeCase = { + + } + return function xpackLicenseGet (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildXpackLicenseGet (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'local' - ] - const acceptedQuerystringCamelCased = [ - 'local' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -94,10 +86,27 @@ function buildXpackLicenseGet (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.license.get_basic_status.js b/api/api/xpack.license.get_basic_status.js index 80b700fae..bb8290150 100644 --- a/api/api/xpack.license.get_basic_status.js +++ b/api/api/xpack.license.get_basic_status.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackLicenseGetBasicStatus (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -7,6 +10,15 @@ function buildXpackLicenseGetBasicStatus (opts) { * Perform a [xpack.license.get_basic_status](https://www.elastic.co/guide/en/x-pack/current/license-management.html) request * */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function xpackLicenseGetBasicStatus (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -35,42 +47,22 @@ function buildXpackLicenseGetBasicStatus (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -93,10 +85,27 @@ function buildXpackLicenseGetBasicStatus (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.license.get_trial_status.js b/api/api/xpack.license.get_trial_status.js index b1875fcc3..4bea1caa6 100644 --- a/api/api/xpack.license.get_trial_status.js +++ b/api/api/xpack.license.get_trial_status.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackLicenseGetTrialStatus (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -7,6 +10,15 @@ function buildXpackLicenseGetTrialStatus (opts) { * Perform a [xpack.license.get_trial_status](https://www.elastic.co/guide/en/x-pack/current/license-management.html) request * */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function xpackLicenseGetTrialStatus (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -35,42 +47,22 @@ function buildXpackLicenseGetTrialStatus (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -93,10 +85,27 @@ function buildXpackLicenseGetTrialStatus (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.license.post.js b/api/api/xpack.license.post.js index 38cae7f83..5b1757e1c 100644 --- a/api/api/xpack.license.post.js +++ b/api/api/xpack.license.post.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackLicensePost (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildXpackLicensePost (opts) { * @param {boolean} acknowledge - whether the user has acknowledged acknowledge messages (default: false) * @param {object} body - licenses to be installed */ + + const acceptedQuerystring = [ + 'acknowledge' + ] + + const snakeCase = { + + } + return function xpackLicensePost (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -29,42 +41,22 @@ function buildXpackLicensePost (opts) { }) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'acknowledge' - ] - const acceptedQuerystringCamelCased = [ - 'acknowledge' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -78,7 +70,7 @@ function buildXpackLicensePost (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -87,10 +79,27 @@ function buildXpackLicensePost (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.license.post_start_basic.js b/api/api/xpack.license.post_start_basic.js index 39e16ebc1..0d13fdfdc 100644 --- a/api/api/xpack.license.post_start_basic.js +++ b/api/api/xpack.license.post_start_basic.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackLicensePostStartBasic (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildXpackLicensePostStartBasic (opts) { * * @param {boolean} acknowledge - whether the user has acknowledged acknowledge messages (default: false) */ + + const acceptedQuerystring = [ + 'acknowledge' + ] + + const snakeCase = { + + } + return function xpackLicensePostStartBasic (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildXpackLicensePostStartBasic (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'acknowledge' - ] - const acceptedQuerystringCamelCased = [ - 'acknowledge' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -94,10 +86,27 @@ function buildXpackLicensePostStartBasic (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.license.post_start_trial.js b/api/api/xpack.license.post_start_trial.js index b9c934e9d..6d7c2453b 100644 --- a/api/api/xpack.license.post_start_trial.js +++ b/api/api/xpack.license.post_start_trial.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackLicensePostStartTrial (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,16 @@ function buildXpackLicensePostStartTrial (opts) { * @param {string} type - The type of trial license to generate (default: "trial") * @param {boolean} acknowledge - whether the user has acknowledged acknowledge messages (default: false) */ + + const acceptedQuerystring = [ + 'type', + 'acknowledge' + ] + + const snakeCase = { + + } + return function xpackLicensePostStartTrial (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -37,44 +50,22 @@ function buildXpackLicensePostStartTrial (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'type', - 'acknowledge' - ] - const acceptedQuerystringCamelCased = [ - 'type', - 'acknowledge' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -97,10 +88,27 @@ function buildXpackLicensePostStartTrial (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.migration.deprecations.js b/api/api/xpack.migration.deprecations.js index 53cd0f260..3cc91e8ff 100644 --- a/api/api/xpack.migration.deprecations.js +++ b/api/api/xpack.migration.deprecations.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackMigrationDeprecations (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildXpackMigrationDeprecations (opts) { * * @param {string} index - Index pattern */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function xpackMigrationDeprecations (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildXpackMigrationDeprecations (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -79,8 +71,8 @@ function buildXpackMigrationDeprecations (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + '_migration' + '/' + 'deprecations' + if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_migration' + '/' + 'deprecations' } else { path = '/' + '_migration' + '/' + 'deprecations' } @@ -98,10 +90,27 @@ function buildXpackMigrationDeprecations (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.migration.get_assistance.js b/api/api/xpack.migration.get_assistance.js index 62b98ca71..632fe180d 100644 --- a/api/api/xpack.migration.get_assistance.js +++ b/api/api/xpack.migration.get_assistance.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackMigrationGetAssistance (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -11,6 +14,19 @@ function buildXpackMigrationGetAssistance (opts) { * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) */ + + const acceptedQuerystring = [ + 'allow_no_indices', + 'expand_wildcards', + 'ignore_unavailable' + ] + + const snakeCase = { + allowNoIndices: 'allow_no_indices', + expandWildcards: 'expand_wildcards', + ignoreUnavailable: 'ignore_unavailable' + } + return function xpackMigrationGetAssistance (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -31,46 +47,22 @@ function buildXpackMigrationGetAssistance (opts) { }) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'allow_no_indices', - 'expand_wildcards', - 'ignore_unavailable' - ] - const acceptedQuerystringCamelCased = [ - 'allowNoIndices', - 'expandWildcards', - 'ignoreUnavailable' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -78,8 +70,8 @@ function buildXpackMigrationGetAssistance (opts) { var path = '' - if ((params['index']) != null) { - path = '/' + '_migration' + '/' + 'assistance' + '/' + encodeURIComponent(params['index']) + if ((index) != null) { + path = '/' + '_migration' + '/' + 'assistance' + '/' + encodeURIComponent(index) } else { path = '/' + '_migration' + '/' + 'assistance' } @@ -97,10 +89,27 @@ function buildXpackMigrationGetAssistance (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.migration.upgrade.js b/api/api/xpack.migration.upgrade.js index 1c3cb5aa3..6d3225fc4 100644 --- a/api/api/xpack.migration.upgrade.js +++ b/api/api/xpack.migration.upgrade.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackMigrationUpgrade (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildXpackMigrationUpgrade (opts) { * @param {string} index - The name of the index * @param {boolean} wait_for_completion - Should the request block until the upgrade operation is completed */ + + const acceptedQuerystring = [ + 'wait_for_completion' + ] + + const snakeCase = { + waitForCompletion: 'wait_for_completion' + } + return function xpackMigrationUpgrade (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -37,42 +49,22 @@ function buildXpackMigrationUpgrade (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'wait_for_completion' - ] - const acceptedQuerystringCamelCased = [ - 'waitForCompletion' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -80,13 +72,13 @@ function buildXpackMigrationUpgrade (opts) { var path = '' - path = '/' + '_migration' + '/' + 'upgrade' + '/' + encodeURIComponent(params['index']) + path = '/' + '_migration' + '/' + 'upgrade' + '/' + encodeURIComponent(index) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -95,10 +87,27 @@ function buildXpackMigrationUpgrade (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.rollup.delete_job.js b/api/api/xpack.rollup.delete_job.js index d9df1880f..f23b0025f 100644 --- a/api/api/xpack.rollup.delete_job.js +++ b/api/api/xpack.rollup.delete_job.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackRollupDeleteJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildXpackRollupDeleteJob (opts) { * * @param {string} id - The ID of the job to delete */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function xpackRollupDeleteJob (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildXpackRollupDeleteJob (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -79,13 +71,13 @@ function buildXpackRollupDeleteJob (opts) { var path = '' - path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(params['id']) + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -94,10 +86,27 @@ function buildXpackRollupDeleteJob (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.rollup.get_jobs.js b/api/api/xpack.rollup.get_jobs.js index f9bf7992f..179f85d45 100644 --- a/api/api/xpack.rollup.get_jobs.js +++ b/api/api/xpack.rollup.get_jobs.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackRollupGetJobs (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildXpackRollupGetJobs (opts) { * * @param {string} id - The ID of the job(s) to fetch. Accepts glob patterns, or left blank for all jobs */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function xpackRollupGetJobs (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -28,42 +40,22 @@ function buildXpackRollupGetJobs (opts) { }) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -71,8 +63,8 @@ function buildXpackRollupGetJobs (opts) { var path = '' - if ((params['id']) != null) { - path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(params['id']) + if ((id) != null) { + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) } else { path = '/' + '_rollup' + '/' + 'job' } @@ -90,10 +82,27 @@ function buildXpackRollupGetJobs (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.rollup.get_rollup_caps.js b/api/api/xpack.rollup.get_rollup_caps.js index 083e6a905..59760de0b 100644 --- a/api/api/xpack.rollup.get_rollup_caps.js +++ b/api/api/xpack.rollup.get_rollup_caps.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackRollupGetRollupCaps (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildXpackRollupGetRollupCaps (opts) { * * @param {string} id - The ID of the index to check rollup capabilities on, or left blank for all jobs */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function xpackRollupGetRollupCaps (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -28,42 +40,22 @@ function buildXpackRollupGetRollupCaps (opts) { }) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -71,8 +63,8 @@ function buildXpackRollupGetRollupCaps (opts) { var path = '' - if ((params['id']) != null) { - path = '/' + '_rollup' + '/' + 'data' + '/' + encodeURIComponent(params['id']) + if ((id) != null) { + path = '/' + '_rollup' + '/' + 'data' + '/' + encodeURIComponent(id) } else { path = '/' + '_rollup' + '/' + 'data' } @@ -90,10 +82,27 @@ function buildXpackRollupGetRollupCaps (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.rollup.get_rollup_index_caps.js b/api/api/xpack.rollup.get_rollup_index_caps.js index 5a62668d6..7e92d5c51 100644 --- a/api/api/xpack.rollup.get_rollup_index_caps.js +++ b/api/api/xpack.rollup.get_rollup_index_caps.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackRollupGetRollupIndexCaps (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildXpackRollupGetRollupIndexCaps (opts) { * * @param {string} index - The rollup index or index pattern to obtain rollup capabilities from. */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function xpackRollupGetRollupIndexCaps (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildXpackRollupGetRollupIndexCaps (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -79,7 +71,7 @@ function buildXpackRollupGetRollupIndexCaps (opts) { var path = '' - path = '/' + encodeURIComponent(params['index']) + '/' + '_rollup' + '/' + 'data' + path = '/' + encodeURIComponent(index) + '/' + '_rollup' + '/' + 'data' // build request object const request = { @@ -94,10 +86,27 @@ function buildXpackRollupGetRollupIndexCaps (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.rollup.put_job.js b/api/api/xpack.rollup.put_job.js index df8f39fbf..c29e673df 100644 --- a/api/api/xpack.rollup.put_job.js +++ b/api/api/xpack.rollup.put_job.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackRollupPutJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildXpackRollupPutJob (opts) { * @param {string} id - The ID of the job to create * @param {object} body - The job configuration */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function xpackRollupPutJob (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -43,42 +55,22 @@ function buildXpackRollupPutJob (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -86,13 +78,13 @@ function buildXpackRollupPutJob (opts) { var path = '' - path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(params['id']) + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -101,10 +93,27 @@ function buildXpackRollupPutJob (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.rollup.rollup_search.js b/api/api/xpack.rollup.rollup_search.js index 68a8d1610..6f527492c 100644 --- a/api/api/xpack.rollup.rollup_search.js +++ b/api/api/xpack.rollup.rollup_search.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackRollupRollupSearch (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -12,6 +15,17 @@ function buildXpackRollupRollupSearch (opts) { * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response * @param {object} body - The search request body */ + + const acceptedQuerystring = [ + 'typed_keys', + 'rest_total_hits_as_int' + ] + + const snakeCase = { + typedKeys: 'typed_keys', + restTotalHitsAsInt: 'rest_total_hits_as_int' + } + return function xpackRollupRollupSearch (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -54,44 +68,22 @@ function buildXpackRollupRollupSearch (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'typed_keys', - 'rest_total_hits_as_int' - ] - const acceptedQuerystringCamelCased = [ - 'typedKeys', - 'restTotalHitsAsInt' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'type']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -99,17 +91,17 @@ function buildXpackRollupRollupSearch (opts) { var path = '' - if ((params['index']) != null && (params['type']) != null) { - path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_rollup_search' + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_rollup_search' } else { - path = '/' + encodeURIComponent(params['index']) + '/' + '_rollup_search' + path = '/' + encodeURIComponent(index) + '/' + '_rollup_search' } // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -118,10 +110,27 @@ function buildXpackRollupRollupSearch (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.rollup.start_job.js b/api/api/xpack.rollup.start_job.js index 7b2314546..347be84a4 100644 --- a/api/api/xpack.rollup.start_job.js +++ b/api/api/xpack.rollup.start_job.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackRollupStartJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildXpackRollupStartJob (opts) { * * @param {string} id - The ID of the job to start */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function xpackRollupStartJob (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildXpackRollupStartJob (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -79,13 +71,13 @@ function buildXpackRollupStartJob (opts) { var path = '' - path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(params['id']) + '/' + '_start' + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) + '/' + '_start' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -94,10 +86,27 @@ function buildXpackRollupStartJob (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.rollup.stop_job.js b/api/api/xpack.rollup.stop_job.js index c3215a3a0..fc61788e2 100644 --- a/api/api/xpack.rollup.stop_job.js +++ b/api/api/xpack.rollup.stop_job.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackRollupStopJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,17 @@ function buildXpackRollupStopJob (opts) { * @param {boolean} wait_for_completion - True if the API should block until the job has fully stopped, false if should be executed async. Defaults to false. * @param {time} timeout - Block for (at maximum) the specified duration while waiting for the job to stop. Defaults to 30s. */ + + const acceptedQuerystring = [ + 'wait_for_completion', + 'timeout' + ] + + const snakeCase = { + waitForCompletion: 'wait_for_completion' + + } + return function xpackRollupStopJob (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -38,44 +52,22 @@ function buildXpackRollupStopJob (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'wait_for_completion', - 'timeout' - ] - const acceptedQuerystringCamelCased = [ - 'waitForCompletion', - 'timeout' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -83,13 +75,13 @@ function buildXpackRollupStopJob (opts) { var path = '' - path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(params['id']) + '/' + '_stop' + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) + '/' + '_stop' // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -98,10 +90,27 @@ function buildXpackRollupStopJob (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.sql.clear_cursor.js b/api/api/xpack.sql.clear_cursor.js index 0d69796bc..2dcda2aff 100644 --- a/api/api/xpack.sql.clear_cursor.js +++ b/api/api/xpack.sql.clear_cursor.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackSqlClearCursor (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildXpackSqlClearCursor (opts) { * * @param {object} body - Specify the cursor value in the `cursor` element to clean the cursor. */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function xpackSqlClearCursor (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildXpackSqlClearCursor (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -85,7 +77,7 @@ function buildXpackSqlClearCursor (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -94,10 +86,27 @@ function buildXpackSqlClearCursor (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.sql.query.js b/api/api/xpack.sql.query.js index 6030181da..02af9e2b7 100644 --- a/api/api/xpack.sql.query.js +++ b/api/api/xpack.sql.query.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackSqlQuery (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildXpackSqlQuery (opts) { * @param {string} format - a short version of the Accept header, e.g. json, yaml * @param {object} body - Use the `query` element to start a query. Use the `cursor` element to continue a query. */ + + const acceptedQuerystring = [ + 'format' + ] + + const snakeCase = { + + } + return function xpackSqlQuery (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -37,42 +49,22 @@ function buildXpackSqlQuery (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'format' - ] - const acceptedQuerystringCamelCased = [ - 'format' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -86,7 +78,7 @@ function buildXpackSqlQuery (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -95,10 +87,27 @@ function buildXpackSqlQuery (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.sql.translate.js b/api/api/xpack.sql.translate.js index 2a3450652..5906ec135 100644 --- a/api/api/xpack.sql.translate.js +++ b/api/api/xpack.sql.translate.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackSqlTranslate (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildXpackSqlTranslate (opts) { * * @param {object} body - Specify the query in the `query` element. */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function xpackSqlTranslate (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildXpackSqlTranslate (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = params.body == null ? 'GET' : 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -85,7 +77,7 @@ function buildXpackSqlTranslate (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -94,10 +86,27 @@ function buildXpackSqlTranslate (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.usage.js b/api/api/xpack.usage.js index 09df41f17..6640c9b63 100644 --- a/api/api/xpack.usage.js +++ b/api/api/xpack.usage.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackUsage (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildXpackUsage (opts) { * * @param {time} master_timeout - Specify timeout for watch write operation */ + + const acceptedQuerystring = [ + 'master_timeout' + ] + + const snakeCase = { + masterTimeout: 'master_timeout' + } + return function xpackUsage (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -36,42 +48,22 @@ function buildXpackUsage (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'master_timeout' - ] - const acceptedQuerystringCamelCased = [ - 'masterTimeout' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -94,10 +86,27 @@ function buildXpackUsage (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.watcher.ack_watch.js b/api/api/xpack.watcher.ack_watch.js index bca2cc0df..28c83b82b 100644 --- a/api/api/xpack.watcher.ack_watch.js +++ b/api/api/xpack.watcher.ack_watch.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackWatcherAckWatch (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -9,6 +12,15 @@ function buildXpackWatcherAckWatch (opts) { * @param {string} watch_id - Watch ID * @param {list} action_id - A comma-separated list of the action ids to be acked */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function xpackWatcherAckWatch (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -51,42 +63,22 @@ function buildXpackWatcherAckWatch (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, watchId, watch_id, actionId, action_id } = params + var querystring = semicopy(params, ['method', 'body', 'watchId', 'watch_id', 'actionId', 'action_id']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -94,10 +86,10 @@ function buildXpackWatcherAckWatch (opts) { var path = '' - if ((params['watch_id'] || params['watchId']) != null && (params['action_id'] || params['actionId']) != null) { - path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['watch_id'] || params['watchId']) + '/' + '_ack' + '/' + encodeURIComponent(params['action_id'] || params['actionId']) + if ((watch_id || watchId) != null && (action_id || actionId) != null) { + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(watch_id || watchId) + '/' + '_ack' + '/' + encodeURIComponent(action_id || actionId) } else { - path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['watch_id'] || params['watchId']) + '/' + '_ack' + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(watch_id || watchId) + '/' + '_ack' } // build request object @@ -113,10 +105,27 @@ function buildXpackWatcherAckWatch (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.watcher.activate_watch.js b/api/api/xpack.watcher.activate_watch.js index cc2e7674b..9a4d50bc5 100644 --- a/api/api/xpack.watcher.activate_watch.js +++ b/api/api/xpack.watcher.activate_watch.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackWatcherActivateWatch (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildXpackWatcherActivateWatch (opts) { * * @param {string} watch_id - Watch ID */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function xpackWatcherActivateWatch (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -42,42 +54,22 @@ function buildXpackWatcherActivateWatch (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, watchId, watch_id } = params + var querystring = semicopy(params, ['method', 'body', 'watchId', 'watch_id']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -85,7 +77,7 @@ function buildXpackWatcherActivateWatch (opts) { var path = '' - path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['watch_id'] || params['watchId']) + '/' + '_activate' + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(watch_id || watchId) + '/' + '_activate' // build request object const request = { @@ -100,10 +92,27 @@ function buildXpackWatcherActivateWatch (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.watcher.deactivate_watch.js b/api/api/xpack.watcher.deactivate_watch.js index 5392ed21d..db78019ec 100644 --- a/api/api/xpack.watcher.deactivate_watch.js +++ b/api/api/xpack.watcher.deactivate_watch.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackWatcherDeactivateWatch (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildXpackWatcherDeactivateWatch (opts) { * * @param {string} watch_id - Watch ID */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function xpackWatcherDeactivateWatch (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -42,42 +54,22 @@ function buildXpackWatcherDeactivateWatch (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, watchId, watch_id } = params + var querystring = semicopy(params, ['method', 'body', 'watchId', 'watch_id']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -85,7 +77,7 @@ function buildXpackWatcherDeactivateWatch (opts) { var path = '' - path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['watch_id'] || params['watchId']) + '/' + '_deactivate' + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(watch_id || watchId) + '/' + '_deactivate' // build request object const request = { @@ -100,10 +92,27 @@ function buildXpackWatcherDeactivateWatch (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.watcher.delete_watch.js b/api/api/xpack.watcher.delete_watch.js index a0e590960..7aa38e077 100644 --- a/api/api/xpack.watcher.delete_watch.js +++ b/api/api/xpack.watcher.delete_watch.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackWatcherDeleteWatch (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildXpackWatcherDeleteWatch (opts) { * * @param {string} id - Watch ID */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function xpackWatcherDeleteWatch (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -42,42 +54,22 @@ function buildXpackWatcherDeleteWatch (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'DELETE' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'DELETE' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -85,7 +77,7 @@ function buildXpackWatcherDeleteWatch (opts) { var path = '' - path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['id']) + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(id) // build request object const request = { @@ -100,10 +92,27 @@ function buildXpackWatcherDeleteWatch (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.watcher.execute_watch.js b/api/api/xpack.watcher.execute_watch.js index 45c897650..833d495af 100644 --- a/api/api/xpack.watcher.execute_watch.js +++ b/api/api/xpack.watcher.execute_watch.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackWatcherExecuteWatch (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,15 @@ function buildXpackWatcherExecuteWatch (opts) { * @param {boolean} debug - indicates whether the watch should execute in debug mode * @param {object} body - Execution control */ + + const acceptedQuerystring = [ + 'debug' + ] + + const snakeCase = { + + } + return function xpackWatcherExecuteWatch (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -30,42 +42,22 @@ function buildXpackWatcherExecuteWatch (opts) { }) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'debug' - ] - const acceptedQuerystringCamelCased = [ - 'debug' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -73,8 +65,8 @@ function buildXpackWatcherExecuteWatch (opts) { var path = '' - if ((params['id']) != null) { - path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['id']) + '/' + '_execute' + if ((id) != null) { + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(id) + '/' + '_execute' } else { path = '/' + '_watcher' + '/' + 'watch' + '/' + '_execute' } @@ -83,7 +75,7 @@ function buildXpackWatcherExecuteWatch (opts) { const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -92,10 +84,27 @@ function buildXpackWatcherExecuteWatch (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.watcher.get_watch.js b/api/api/xpack.watcher.get_watch.js index 223cddf13..4122377a4 100644 --- a/api/api/xpack.watcher.get_watch.js +++ b/api/api/xpack.watcher.get_watch.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackWatcherGetWatch (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -8,6 +11,15 @@ function buildXpackWatcherGetWatch (opts) { * * @param {string} id - Watch ID */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function xpackWatcherGetWatch (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -42,42 +54,22 @@ function buildXpackWatcherGetWatch (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -85,7 +77,7 @@ function buildXpackWatcherGetWatch (opts) { var path = '' - path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['id']) + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(id) // build request object const request = { @@ -100,10 +92,27 @@ function buildXpackWatcherGetWatch (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.watcher.put_watch.js b/api/api/xpack.watcher.put_watch.js index 59317d9c3..7ccd85ebc 100644 --- a/api/api/xpack.watcher.put_watch.js +++ b/api/api/xpack.watcher.put_watch.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackWatcherPutWatch (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -11,6 +14,16 @@ function buildXpackWatcherPutWatch (opts) { * @param {number} version - Explicit version number for concurrency control * @param {object} body - The watch */ + + const acceptedQuerystring = [ + 'active', + 'version' + ] + + const snakeCase = { + + } + return function xpackWatcherPutWatch (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -39,44 +52,22 @@ function buildXpackWatcherPutWatch (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'active', - 'version' - ] - const acceptedQuerystringCamelCased = [ - 'active', - 'version' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'PUT' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'PUT' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -84,13 +75,13 @@ function buildXpackWatcherPutWatch (opts) { var path = '' - path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['id']) + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(id) // build request object const request = { method, path, - body: params.body || '', + body: body || '', querystring } @@ -99,10 +90,27 @@ function buildXpackWatcherPutWatch (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.watcher.start.js b/api/api/xpack.watcher.start.js index 0d2eae0e0..343bab037 100644 --- a/api/api/xpack.watcher.start.js +++ b/api/api/xpack.watcher.start.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackWatcherStart (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -7,6 +10,15 @@ function buildXpackWatcherStart (opts) { * Perform a [xpack.watcher.start](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-start.html) request * */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function xpackWatcherStart (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -35,42 +47,22 @@ function buildXpackWatcherStart (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -93,10 +85,27 @@ function buildXpackWatcherStart (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.watcher.stats.js b/api/api/xpack.watcher.stats.js index 64417cf55..cc4f02325 100644 --- a/api/api/xpack.watcher.stats.js +++ b/api/api/xpack.watcher.stats.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackWatcherStats (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -10,6 +13,16 @@ function buildXpackWatcherStats (opts) { * @param {enum} metric - Controls what additional stat metrics should be include in the response * @param {boolean} emit_stacktraces - Emits stack traces of currently running watches */ + + const acceptedQuerystring = [ + 'metric', + 'emit_stacktraces' + ] + + const snakeCase = { + emitStacktraces: 'emit_stacktraces' + } + return function xpackWatcherStats (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -38,44 +51,22 @@ function buildXpackWatcherStats (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - 'metric', - 'emit_stacktraces' - ] - const acceptedQuerystringCamelCased = [ - 'metric', - 'emitStacktraces' - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body, metric } = params + var querystring = semicopy(params, ['method', 'body', 'metric']) + + if (method == null) { + method = 'GET' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -83,8 +74,8 @@ function buildXpackWatcherStats (opts) { var path = '' - if ((params['metric']) != null) { - path = '/' + '_watcher' + '/' + 'stats' + '/' + encodeURIComponent(params['metric']) + if ((metric) != null) { + path = '/' + '_watcher' + '/' + 'stats' + '/' + encodeURIComponent(metric) } else { path = '/' + '_watcher' + '/' + 'stats' } @@ -102,10 +93,27 @@ function buildXpackWatcherStats (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/api/api/xpack.watcher.stop.js b/api/api/xpack.watcher.stop.js index a414bbb68..eeb2f2aac 100644 --- a/api/api/xpack.watcher.stop.js +++ b/api/api/xpack.watcher.stop.js @@ -1,5 +1,8 @@ 'use strict' +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + function buildXpackWatcherStop (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts @@ -7,6 +10,15 @@ function buildXpackWatcherStop (opts) { * Perform a [xpack.watcher.stop](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stop.html) request * */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + return function xpackWatcherStop (params, options, callback) { options = options || {} if (typeof options === 'function') { @@ -35,42 +47,22 @@ function buildXpackWatcherStop (opts) { ) } - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'POST' - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), result ) } + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -93,10 +85,27 @@ function buildXpackWatcherStop (opts) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } } diff --git a/lib/Transport.js b/lib/Transport.js index 4910654e2..ec10ddfef 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -62,7 +62,7 @@ class Transport { body: null, statusCode: null, headers: null, - warnings: null + warnings: options.warnings || null } const maxRetries = options.maxRetries || this.maxRetries var request = { abort: noop } @@ -153,8 +153,9 @@ class Transport { result.statusCode = statusCode result.headers = headers if (headers['warning'] != null) { + result.warnings = result.warnings || [] // split the string over the commas not inside quotes - result.warnings = headers['warning'].split(/(?!\B"[^"]*),(?![^"]*"\B)/) + result.warnings.push.apply(result.warnings, headers['warning'].split(/(?!\B"[^"]*),(?![^"]*"\B)/)) } if (options.asStream === true) { diff --git a/scripts/utils/generate.js b/scripts/utils/generate.js index fade273a4..b8d29d949 100644 --- a/scripts/utils/generate.js +++ b/scripts/utils/generate.js @@ -95,42 +95,22 @@ function generate (spec, common) { ${genUrlValidation(paths, api)} - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - ${genAcceptedQuerystring()} - ] - const acceptedQuerystringCamelCased = [ - ${genAcceptedQuerystringCamelCased()} - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - ${generatePickMethod(methods)} - } - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { + if (options.headers != null && typeof options.headers !== 'object') { return callback( - new ConfigurationError(\`Headers should be an object, instead got: \${typeof params.headers}\`), + new ConfigurationError(\`Headers should be an object, instead got: \${typeof options.headers}\`), result ) } + var warnings = null + var { ${genQueryBlacklist(false)} } = params + var querystring = semicopy(params, [${genQueryBlacklist()}]) + + if (method == null) { + ${generatePickMethod(methods)} + } + var ignore = options.ignore || null if (typeof ignore === 'number') { ignore = [ignore] @@ -153,20 +133,49 @@ function generate (spec, common) { requestTimeout: options.requestTimeout || null, maxRetries: options.maxRetries || null, asStream: options.asStream || false, - headers: options.headers || null + headers: options.headers || null, + warnings } return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } } `.trim() // always call trim to avoid newlines const fn = dedent` 'use strict' + /* eslint camelcase: 0 */ + /* eslint no-unused-vars: 0 */ + function build${name[0].toUpperCase() + name.slice(1)} (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts ${generateDocumentation(spec[api], api)} + + const acceptedQuerystring = [ + ${acceptedQuerystring.map(q => `'${q}'`).join(',\n')} + ] + + const snakeCase = { + ${genSnakeCaseMap()} + } + return ${code} } @@ -229,23 +238,40 @@ function generate (spec, common) { } } - function genAcceptedQuerystring () { - return acceptedQuerystring - .map(q => `'${q}'`) - .join(',\n ') + function genSnakeCaseMap () { + const toCamelCase = str => { + return str[0] === '_' + ? '_' + str.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase()) + : str.replace(/_([a-z])/g, k => k[1].toUpperCase()) + } + + return acceptedQuerystring.reduce((acc, val, index) => { + if (toCamelCase(val) !== val) { + acc += `${toCamelCase(val)}: '${val}'` + if (index !== acceptedQuerystring.length - 1) { + acc += ',\n' + } + } + return acc + }, '') } - function genAcceptedQuerystringCamelCased () { - return acceptedQuerystring - .map(q => { - // if the key starts with `_` we should not camelify the first occurence - // eg: _source_include => _sourceInclude - return q[0] === '_' - ? '_' + q.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase()) - : q.replace(/_([a-z])/g, k => k[1].toUpperCase()) + function genQueryBlacklist (addQuotes = true) { + const toCamelCase = str => { + return str[0] === '_' + ? '_' + str.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase()) + : str.replace(/_([a-z])/g, k => k[1].toUpperCase()) + } + + const blacklist = ['method', 'body'] + if (typeof parts === 'object' && parts !== null) { + Object.keys(parts).forEach(p => { + const camelStr = toCamelCase(p) + if (camelStr !== p) blacklist.push(`${camelStr}`) + blacklist.push(`${p}`) }) - .map(q => `'${q}'`) - .join(',\n ') + } + return addQuotes ? blacklist.map(q => `'${q}'`) : blacklist } function buildPath () { @@ -258,8 +284,8 @@ function generate (spec, common) { const genAccessKey = str => { const camelStr = toCamelCase(str) return camelStr === str - ? `params['${str}']` - : `params['${str}'] || params['${camelStr}']` + ? str + : `${str} || ${camelStr}` } const genCheck = path => { @@ -336,7 +362,7 @@ function generatePickMethod (methods) { const bodyMethod = getBodyMethod(methods) const noBodyMethod = getNoBodyMethod(methods) if (bodyMethod && noBodyMethod) { - return `method = params.body == null ? '${noBodyMethod}' : '${bodyMethod}'` + return `method = body == null ? '${noBodyMethod}' : '${bodyMethod}'` } else if (bodyMethod) { return ` method = '${bodyMethod}' @@ -351,12 +377,12 @@ function generatePickMethod (methods) { function genBody (api, methods, body) { const bodyMethod = getBodyMethod(methods) if (ndjsonApi.indexOf(api) > -1) { - return 'bulkBody: params.body,' + return 'bulkBody: body,' } if (body === null && bodyMethod) { return `body: '',` } else if (bodyMethod) { - return `body: params.body || '',` + return `body: body || '',` } else { return 'body: null,' } diff --git a/test/integration/test-runner.js b/test/integration/test-runner.js index 144310659..8cfbc2c48 100644 --- a/test/integration/test-runner.js +++ b/test/integration/test-runner.js @@ -40,14 +40,14 @@ TestRunner.prototype.cleanup = function (q, done) { this.stash = new Map() q.add((q, done) => { - this.client.indices.delete({ index: '*', ignore: 404 }, err => { + this.client.indices.delete({ index: '*' }, { ignore: 404 }, err => { this.tap.error(err, 'should not error: indices.delete') done() }) }) q.add((q, done) => { - this.client.indices.deleteTemplate({ name: '*', ignore: 404 }, err => { + this.client.indices.deleteTemplate({ name: '*' }, { ignore: 404 }, err => { this.tap.error(err, 'should not error: indices.deleteTemplate') done() }) @@ -253,6 +253,7 @@ TestRunner.prototype.do = function (action, done) { const cmd = this.parseDo(action) const api = delve(this.client, cmd.method).bind(this.client) const options = { ignore: cmd.params.ignore, headers: action.headers } + if (cmd.params.ignore) delete cmd.params.ignore api(cmd.params, options, (err, { body, warnings }) => { if (action.warnings && warnings === null) { this.tap.fail('We should get a warning header', action.warnings) diff --git a/test/unit/api.test.js b/test/unit/api.test.js index 13264379f..50ebceb88 100644 --- a/test/unit/api.test.js +++ b/test/unit/api.test.js @@ -221,3 +221,31 @@ test('Basic (options and promises)', t => { .catch(t.fail) }) }) + +test('Pass unknown parameters as query parameters (and get a warning)', t => { + t.plan(4) + + function handler (req, res) { + t.strictEqual(req.url, '/test/doc/_search?q=foo%3Abar&winter=is%20coming') + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const client = new Client({ + node: `http://localhost:${port}` + }) + + client.search({ + index: 'test', + type: 'doc', + q: 'foo:bar', + winter: 'is coming' + }, (err, { body, warnings }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + t.deepEqual(warnings, ['Client - Unknown parameter: "winter", sending it as query parameter']) + server.stop() + }) + }) +}) diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index 70ceb7b20..d65d7e329 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -1535,6 +1535,45 @@ test('Warning header', t => { }) }) + t.test('Multiple warnings and external warning', t => { + t.plan(5) + + const warn1 = '112 - "cache down" "Wed, 21 Oct 2015 07:28:00 GMT"' + const warn2 = '199 agent "Error message" "2015-01-01"' + function handler (req, res) { + res.setHeader('Content-Type', 'application/json;utf=8') + res.setHeader('Warning', warn1 + ',' + warn2) + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ Connection }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, { + warnings: ['winter is coming'] + }, (err, { warnings }) => { + t.error(err) + t.deepEqual(warnings, ['winter is coming', warn1, warn2]) + warnings.forEach(w => t.type(w, 'string')) + server.stop() + }) + }) + }) + t.end() }) From 2f3e2a6c962acf6c883202c0a616df58154fdf80 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 29 Jan 2019 17:33:16 +0100 Subject: [PATCH 096/172] Bumped v0.1.0-alpha.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e348e2689..b9d44fc4b 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "main": "index.js", "types": "index.d.ts", "homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html", - "version": "0.1.0-alpha.4", + "version": "0.1.0-alpha.5", "keywords": [ "elasticsearch", "elastic", From fbfb9479b21eda911c272fd5936981511cff1e93 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 30 Jan 2019 09:32:58 +0100 Subject: [PATCH 097/172] Updated code generation --- scripts/utils/generate.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/utils/generate.js b/scripts/utils/generate.js index b8d29d949..6b9961d71 100644 --- a/scripts/utils/generate.js +++ b/scripts/utils/generate.js @@ -349,10 +349,16 @@ function generate (spec, common) { } function safeWords (str) { - if (str === 'delete') { - return '_delete' + switch (str) { + // delete is a reserved word + case 'delete': + return '_delete' + // index is also a parameter + case 'index': + return '_index' + default: + return str } - return str } function generatePickMethod (methods) { From 3bb4fda004da55dba48b4ae3fa80157a4b1cf527 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 30 Jan 2019 09:33:04 +0100 Subject: [PATCH 098/172] API generation --- api/api/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/api/index.js b/api/api/index.js index bd8d0d785..f15b822b3 100644 --- a/api/api/index.js +++ b/api/api/index.js @@ -49,7 +49,7 @@ function buildIndex (opts) { filterPath: 'filter_path' } - return function index (params, options, callback) { + return function _index (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -63,7 +63,7 @@ function buildIndex (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - index(params, options, (err, body) => { + _index(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) From 95c4369f9b03d0ccb7e1ff5766734860f36f9e6e Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 30 Jan 2019 09:33:13 +0100 Subject: [PATCH 099/172] Updated test --- test/unit/api-async.js | 61 ++++++++++++++++++++++++++++++++++++++++++ test/unit/api.test.js | 4 +++ 2 files changed, 65 insertions(+) create mode 100644 test/unit/api-async.js diff --git a/test/unit/api-async.js b/test/unit/api-async.js new file mode 100644 index 000000000..dbfa7ea7f --- /dev/null +++ b/test/unit/api-async.js @@ -0,0 +1,61 @@ +'use strict' + +const { Client } = require('../../index') +const { buildServer } = require('../utils') + +function runAsyncTest (test) { + test('async await (search)', t => { + t.plan(1) + + function handler (req, res) { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, async ({ port }, server) => { + const client = new Client({ + node: `http://localhost:${port}` + }) + + try { + const { body } = await client.search({ + index: 'test', + type: 'doc', + q: 'foo:bar' + }) + t.deepEqual(body, { hello: 'world' }) + } catch (err) { + t.fail(err) + } + server.stop() + }) + }) + + test('async await (index)', t => { + t.plan(1) + + function handler (req, res) { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, async ({ port }, server) => { + const client = new Client({ + node: `http://localhost:${port}` + }) + + try { + await client.index({ + index: 'test', + body: { foo: 'bar' } + }) + t.pass('ok') + } catch (err) { + t.fail(err) + } + server.stop() + }) + }) +} + +module.exports = runAsyncTest diff --git a/test/unit/api.test.js b/test/unit/api.test.js index 50ebceb88..2a6b0eedc 100644 --- a/test/unit/api.test.js +++ b/test/unit/api.test.js @@ -249,3 +249,7 @@ test('Pass unknown parameters as query parameters (and get a warning)', t => { }) }) }) + +if (Number(process.version.split('.')[0].slice(1)) >= 8) { + require('./api-async')(test) +} From 140774128b1013f4da2724166698dc18518e3646 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 30 Jan 2019 11:38:29 +0100 Subject: [PATCH 100/172] Updated code generation --- scripts/utils/generate.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/utils/generate.js b/scripts/utils/generate.js index 6b9961d71..6f21b404d 100644 --- a/scripts/utils/generate.js +++ b/scripts/utils/generate.js @@ -31,7 +31,8 @@ const noPathValidation = [ const ndjsonApi = [ 'bulk', 'msearch', - 'msearch_template' + 'msearch_template', + 'monitoring.bulk' ] function generate (spec, common) { From 7c63c2d9e27fdca0ad1a4a356451238898e38973 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 30 Jan 2019 11:38:36 +0100 Subject: [PATCH 101/172] API generation --- api/api/monitoring.bulk.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/api/monitoring.bulk.js b/api/api/monitoring.bulk.js index f8c58b7a8..53415e9ae 100644 --- a/api/api/monitoring.bulk.js +++ b/api/api/monitoring.bulk.js @@ -89,7 +89,7 @@ function buildMonitoringBulk (opts) { const request = { method, path, - body: body || '', + bulkBody: body, querystring } From 5e7ca876e4a4cb69c1d42b17fcb3821babeba972 Mon Sep 17 00:00:00 2001 From: Tomas Della Vedova Date: Wed, 30 Jan 2019 19:10:59 +0100 Subject: [PATCH 102/172] Added extend method (#763) * Added extend method * Updated test --- index.js | 31 +++++++ test/unit/client.test.js | 194 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 224 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 8e0946566..badf6411d 100644 --- a/index.js +++ b/index.js @@ -87,6 +87,37 @@ class Client extends EventEmitter { }) } + extend (name, fn) { + var [namespace, method] = name.split('.') + if (method == null) { + method = namespace + namespace = null + } + + if (namespace != null) { + if (this[namespace] != null && this[namespace][method] != null) { + throw new Error(`The method "${method}" already exists on namespace "${namespace}"`) + } + + this[namespace] = this[namespace] || {} + this[namespace][method] = fn({ + makeRequest: this.transport.request.bind(this.transport), + result: { body: null, statusCode: null, headers: null, warnings: null }, + ConfigurationError + }) + } else { + if (this[method] != null) { + throw new Error(`The method "${method}" already exists`) + } + + this[method] = fn({ + makeRequest: this.transport.request.bind(this.transport), + result: { body: null, statusCode: null, headers: null, warnings: null }, + ConfigurationError + }) + } + } + close (callback) { if (callback == null) { return new Promise((resolve, reject) => { diff --git a/test/unit/client.test.js b/test/unit/client.test.js index 53510ba6a..ff895a740 100644 --- a/test/unit/client.test.js +++ b/test/unit/client.test.js @@ -2,7 +2,7 @@ const { test } = require('tap') const { URL } = require('url') -const { Client, ConnectionPool } = require('../../index') +const { Client, ConnectionPool, Transport } = require('../../index') const { buildServer } = require('../utils') test('Configure host', t => { @@ -304,3 +304,195 @@ test('Client close (promise)', t => { client.close() .then(() => t.pass('Closed')) }) + +test('Extend client APIs', t => { + t.test('Extend a single method', t => { + t.plan(5) + + const client = new Client({ node: 'http://localhost:9200' }) + client.extend('method', ({ makeRequest, result, ConfigurationError }) => { + t.type(makeRequest, 'function') + t.true(new ConfigurationError() instanceof Error) + t.deepEqual(result, { + body: null, + statusCode: null, + headers: null, + warnings: null + }) + + return (params, options) => { + t.deepEqual(params, { you_know: 'for search' }) + t.deepEqual(options, { winter: 'is coming' }) + } + }) + + client.method( + { you_know: 'for search' }, + { winter: 'is coming' } + ) + }) + + t.test('Create a namespace and a method', t => { + t.plan(5) + + const client = new Client({ node: 'http://localhost:9200' }) + client.extend('namespace.method', ({ makeRequest, result, ConfigurationError }) => { + t.type(makeRequest, 'function') + t.true(new ConfigurationError() instanceof Error) + t.deepEqual(result, { + body: null, + statusCode: null, + headers: null, + warnings: null + }) + + return (params, options) => { + t.deepEqual(params, { you_know: 'for search' }) + t.deepEqual(options, { winter: 'is coming' }) + } + }) + + client.namespace.method( + { you_know: 'for search' }, + { winter: 'is coming' } + ) + }) + + t.test('Create a namespace and multiple methods', t => { + t.plan(10) + + const client = new Client({ node: 'http://localhost:9200' }) + client.extend('namespace.method1', ({ makeRequest, result, ConfigurationError }) => { + t.type(makeRequest, 'function') + t.true(new ConfigurationError() instanceof Error) + t.deepEqual(result, { + body: null, + statusCode: null, + headers: null, + warnings: null + }) + + return (params, options) => { + t.deepEqual(params, { you_know: 'for search' }) + t.deepEqual(options, { winter: 'is coming' }) + } + }) + + client.extend('namespace.method2', ({ makeRequest, result, ConfigurationError }) => { + t.type(makeRequest, 'function') + t.true(new ConfigurationError() instanceof Error) + t.deepEqual(result, { + body: null, + statusCode: null, + headers: null, + warnings: null + }) + + return (params, options) => { + t.deepEqual(params, { you_know: 'for search' }) + t.deepEqual(options, { winter: 'is coming' }) + } + }) + + client.namespace.method1( + { you_know: 'for search' }, + { winter: 'is coming' } + ) + + client.namespace.method2( + { you_know: 'for search' }, + { winter: 'is coming' } + ) + }) + + t.test('Cannot override an existing method', t => { + t.plan(1) + + const client = new Client({ node: 'http://localhost:9200' }) + try { + client.extend('index', () => {}) + t.fail('Should throw') + } catch (err) { + t.is(err.message, 'The method "index" already exists') + } + }) + + t.test('Cannot override an existing namespace and method', t => { + t.plan(1) + + const client = new Client({ node: 'http://localhost:9200' }) + try { + client.extend('indices.delete', () => {}) + t.fail('Should throw') + } catch (err) { + t.is(err.message, 'The method "delete" already exists on namespace "indices"') + } + }) + + t.test('Should call the transport.request method', t => { + t.plan(2) + + class MyTransport extends Transport { + request (params, options) { + t.deepEqual(params, { you_know: 'for search' }) + t.deepEqual(options, { winter: 'is coming' }) + } + } + + const client = new Client({ + node: 'http://localhost:9200', + Transport: MyTransport + }) + client.extend('method', ({ makeRequest, result, ConfigurationError }) => { + return (params, options) => makeRequest(params, options) + }) + + client.method( + { you_know: 'for search' }, + { winter: 'is coming' } + ) + }) + + t.test('Should support callbacks', t => { + t.plan(2) + + const client = new Client({ node: 'http://localhost:9200' }) + client.extend('method', ({ makeRequest, result, ConfigurationError }) => { + return (params, options, callback) => { + callback(null, { hello: 'world' }) + } + }) + + client.method( + { you_know: 'for search' }, + { winter: 'is coming' }, + (err, res) => { + t.error(err) + t.deepEqual(res, { hello: 'world' }) + } + ) + }) + + t.test('Should support promises', t => { + t.plan(1) + + const client = new Client({ node: 'http://localhost:9200' }) + client.extend('method', ({ makeRequest, result, ConfigurationError }) => { + return (params, options) => { + return new Promise((resolve, reject) => { + resolve({ hello: 'world' }) + }) + } + }) + + client + .method( + { you_know: 'for search' }, + { winter: 'is coming' } + ) + .then(res => t.deepEqual(res, { hello: 'world' })) + .catch(err => t.fail(err)) + }) + + t.end() +}) From 8a14ede19fcf4736780fbb6a74c114be84870ece Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 11 Feb 2019 11:54:22 +0100 Subject: [PATCH 103/172] Updated typings --- index.d.ts | 6 ++++-- lib/ConnectionPool.d.ts | 2 -- lib/Transport.d.ts | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/index.d.ts b/index.d.ts index 55c878df9..4a511dbab 100644 --- a/index.d.ts +++ b/index.d.ts @@ -33,9 +33,9 @@ interface ClientOptions { sniffOnStart?: boolean; sniffEndpoint?: string; sniffOnConnectionFault?: boolean; - resurrectStrategy?: string; - randomizeHost?: boolean; + resurrectStrategy?: 'ping' | 'optimistic' | 'none'; suggestCompression?: boolean; + compression?: 'gzip'; ssl?: SecureContextOptions; agent?: AgentOptions; nodeFilter?: nodeFilterFn; @@ -47,6 +47,8 @@ declare class Client extends EventEmitter { transport: Transport; serializer: Serializer constructor(opts?: ClientOptions); + // TODO: update fn declaration + extends(method: string, fn: any): void; close(callback?: Function): Promise | void; bulk: ApiMethod cat: { diff --git a/lib/ConnectionPool.d.ts b/lib/ConnectionPool.d.ts index 83cddbb84..dd55540fd 100644 --- a/lib/ConnectionPool.d.ts +++ b/lib/ConnectionPool.d.ts @@ -15,7 +15,6 @@ interface ConnectionPoolOptions { ssl?: SecureContextOptions; agent?: AgentOptions; pingTimeout?: number; - randomizeHost?: boolean; Connection: typeof Connection; resurrectStrategy?: string; nodeFilter?: nodeFilterFn; @@ -46,7 +45,6 @@ export default class ConnectionPool { resurrectTimeout: number; resurrectTimeoutCutoff: number; pingTimeout: number; - randomizeHost: boolean; nodeFilter: nodeFilterFn; nodeSelector: nodeSelectorFn; Connection: typeof Connection; diff --git a/lib/Transport.d.ts b/lib/Transport.d.ts index 1c682d263..b9ecc7355 100644 --- a/lib/Transport.d.ts +++ b/lib/Transport.d.ts @@ -12,6 +12,7 @@ interface TransportOptions { maxRetries: number; requestTimeout: number | string; suggestCompression: boolean; + compression?: 'gzip'; sniffInterval: number; sniffOnConnectionFault: boolean; sniffEndpoint: string; @@ -63,6 +64,7 @@ export default class Transport { maxRetries: number; requestTimeout: number; suggestCompression: boolean; + compression: 'gzip' | false; sniffInterval: number; sniffOnConnectionFault: boolean; sniffEndpoint: string; From b19d93fb1e43ad99855bb66a91f9d00419cf0d03 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 11 Feb 2019 12:01:52 +0100 Subject: [PATCH 104/172] WIP: initial prototype - Added body compression - Removed old options --- index.js | 6 +++--- lib/ConnectionPool.js | 1 - lib/Transport.js | 21 ++++++++++++++++++--- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index badf6411d..1fc9aba54 100644 --- a/index.js +++ b/index.js @@ -37,8 +37,8 @@ class Client extends EventEmitter { sniffEndpoint: '_nodes/_all/http', sniffOnConnectionFault: false, resurrectStrategy: 'ping', - randomizeHost: true, suggestCompression: false, + compression: false, ssl: null, agent: null, nodeFilter: null, @@ -50,7 +50,6 @@ class Client extends EventEmitter { this.connectionPool = new options.ConnectionPool({ pingTimeout: options.pingTimeout, resurrectStrategy: options.resurrectStrategy, - randomizeHost: options.randomizeHost, ssl: options.ssl, agent: options.agent, nodeFilter: options.nodeFilter, @@ -73,7 +72,8 @@ class Client extends EventEmitter { sniffOnStart: options.sniffOnStart, sniffOnConnectionFault: options.sniffOnConnectionFault, sniffEndpoint: options.sniffEndpoint, - suggestCompression: options.suggestCompression + suggestCompression: options.suggestCompression, + compression: options.compression }) const apis = buildApi({ diff --git a/lib/ConnectionPool.js b/lib/ConnectionPool.js index fd9104390..e4221a16b 100644 --- a/lib/ConnectionPool.js +++ b/lib/ConnectionPool.js @@ -24,7 +24,6 @@ class ConnectionPool { // the timeout doesn't increase this.resurrectTimeoutCutoff = 5 this.pingTimeout = opts.pingTimeout - this.randomizeHost = opts.randomizeHost === true this.nodeFilter = opts.nodeFilter || defaultNodeFilter this.Connection = opts.Connection this.emit = opts.emit || noop diff --git a/lib/Transport.js b/lib/Transport.js index ec10ddfef..63a728092 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -2,24 +2,31 @@ const debug = require('debug')('elasticsearch') const once = require('once') +const { createGzip } = require('zlib') +const intoStream = require('into-stream') const ms = require('ms') const { ConnectionError, TimeoutError, NoLivingConnectionsError, - ResponseError + ResponseError, + ConfigurationError } = require('./errors') const noop = () => {} class Transport { constructor (opts = {}) { + if (typeof opts.compression === 'string' && opts.compression !== 'gzip') { + throw new ConfigurationError(`Invalid compression: '${opts.compression}'`) + } this.emit = opts.emit this.connectionPool = opts.connectionPool this.serializer = opts.serializer this.maxRetries = opts.maxRetries this.requestTimeout = toMs(opts.requestTimeout) this.suggestCompression = opts.suggestCompression === true + this.compression = opts.compression || false this.sniffInterval = opts.sniffInterval this.sniffOnConnectionFault = opts.sniffOnConnectionFault this.sniffEndpoint = opts.sniffEndpoint @@ -65,6 +72,7 @@ class Transport { warnings: options.warnings || null } const maxRetries = options.maxRetries || this.maxRetries + const compression = options.compression || this.compression var request = { abort: noop } const makeRequest = () => { @@ -75,6 +83,7 @@ class Transport { } const headers = options.headers || {} + // handle json body if (params.body != null) { if (shouldSerialize(params.body) === true) { @@ -85,6 +94,12 @@ class Transport { } } headers['Content-Type'] = 'application/json' + + if (compression === 'gzip') { + params.body = intoStream(params.body).pipe(createGzip()) + headers['Content-Encoding'] = compression + } + if (isStream(params.body) === false) { headers['Content-Length'] = '' + Buffer.byteLength(params.body) } @@ -207,8 +222,8 @@ class Transport { // if the statusCode is 502/3/4 we should run our retry strategy // and mark the connection as dead this.connectionPool.markDead(meta.connection) - // retry logic - if (meta.attempts < maxRetries) { + // retry logic (we shoukd not retry on "429 - Too Many Requests") + if (meta.attempts < maxRetries && statusCode !== 429) { meta.attempts++ debug(`Retrying request, there are still ${maxRetries - meta.attempts} attempts`, params) request = makeRequest(params, callback) From ca72e8b2f54f8840c3b27361877dcb1556cd0dd6 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 11 Feb 2019 12:03:40 +0100 Subject: [PATCH 105/172] Updated dependencies --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b9d44fc4b..cd88e35c8 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,6 @@ "@types/node": "^10.12.10", "dedent": "^0.7.0", "deepmerge": "^2.2.1", - "into-stream": "^4.0.0", "js-yaml": "^3.12.0", "lolex": "^3.0.0", "minimist": "^1.2.0", @@ -58,6 +57,7 @@ "dependencies": { "debug": "^4.1.0", "decompress-response": "^3.3.0", + "into-stream": "^4.0.0", "ms": "^2.1.1", "once": "^1.4.0", "pump": "^3.0.0" From 3023e45661e0e1ede6e7e33dc2e1ff41443a9177 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 11 Feb 2019 12:03:55 +0100 Subject: [PATCH 106/172] Updated test --- test/unit/transport.test.js | 167 +++++++++++++++++++++++++++++++++++- 1 file changed, 166 insertions(+), 1 deletion(-) diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index d65d7e329..45a2ada5d 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -2,6 +2,7 @@ const { test } = require('tap') const { URL } = require('url') +const { createGunzip } = require('zlib') const intoStream = require('into-stream') const { buildServer, @@ -13,7 +14,8 @@ const { DeserializationError, TimeoutError, ResponseError, - ConnectionError + ConnectionError, + ConfigurationError } = require('../../lib/errors') const ConnectionPool = require('../../lib/ConnectionPool') @@ -576,6 +578,51 @@ test('Custom retry mechanism', t => { }) }) +test('Should not retry on 429', t => { + t.plan(3) + + var count = 0 + function handler (req, res) { + t.strictEqual(count++, 0) + res.statusCode = 429 + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ Connection }) + pool.addConnection([{ + url: new URL(`http://localhost:${port}`), + id: 'node1' + }, { + url: new URL(`http://localhost:${port}`), + id: 'node2' + }, { + url: new URL(`http://localhost:${port}`), + id: 'node3' + }]) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 5, + requestTimeout: 250, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, result) => { + t.ok(err) + t.strictEqual(err.statusCode, 429) + server.stop() + }) + }) +}) + test('Should call markAlive with a successful response', t => { t.plan(3) @@ -1621,3 +1668,121 @@ test('asStream set to true', t => { }) }) }) + +test('Compress request', t => { + t.test('gzip as request option', t => { + t.plan(4) + function handler (req, res) { + t.match(req.headers, { + 'content-type': 'application/json', + 'content-encoding': 'gzip' + }) + var json = '' + req + .pipe(createGunzip()) + .on('data', chunk => { json += chunk }) + .on('error', err => t.fail(err)) + .on('end', () => { + t.deepEqual(JSON.parse(json), { you_know: 'for search' }) + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ you_know: 'for search' })) + }) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ Connection }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'POST', + path: '/hello', + body: { you_know: 'for search' } + }, { + compression: 'gzip' + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { you_know: 'for search' }) + server.stop() + }) + }) + }) + + t.test('gzip as transport option', t => { + t.plan(4) + function handler (req, res) { + t.match(req.headers, { + 'content-type': 'application/json', + 'content-encoding': 'gzip' + }) + var json = '' + req + .pipe(createGunzip()) + .on('data', chunk => { json += chunk }) + .on('error', err => t.fail(err)) + .on('end', () => { + t.deepEqual(JSON.parse(json), { you_know: 'for search' }) + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ you_know: 'for search' })) + }) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ Connection }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false, + compression: 'gzip' + }) + + transport.request({ + method: 'POST', + path: '/hello', + body: { you_know: 'for search' } + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { you_know: 'for search' }) + server.stop() + }) + }) + }) + + test('Should throw on invalid compression value', t => { + t.plan(2) + + try { + new Transport({ // eslint-disable-line + emit: () => {}, + connectionPool: new ConnectionPool({ Connection }), + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false, + compression: 'deflate' + }) + t.fail('Should throw') + } catch (err) { + t.true(err instanceof ConfigurationError) + t.is(err.message, 'Invalid compression: \'deflate\'') + } + }) + + t.end() +}) From 4962e604841bdd59bdff590939a5267ab36fa2ec Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 11 Feb 2019 12:04:07 +0100 Subject: [PATCH 107/172] Added README.md --- README.md | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 000000000..deac7f71b --- /dev/null +++ b/README.md @@ -0,0 +1,124 @@ + + +# @elastic/elasticsearch + +[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) [![Build Status](https://clients-ci.elastic.co/job/elastic+elasticsearch-js+master/badge/icon)](https://clients-ci.elastic.co/job/elastic+elasticsearch-js+master/) [![NPM downloads](https://img.shields.io/npm/dm/@elastic/elasticsearch.svg?style=flat)](https://www.npmjs.com/package/@elastic/elasticsearch) + +The official Node.js client for Elasticsearch. + +## Features +- One-to-one mapping with REST API. +- Generalized, pluggable architecture. +- Configurable, automatic discovery of cluster nodes. +- Persistent, Keep-Alive connections. +- Load balancing (with pluggable selection strategy) across all available nodes. + +## Install +``` +npm install @elastic/elasticsearch +``` +By default the latest version of the module will be installed, which is the same version of the current release of Elasticsearch.
+If you need to work with older versions of Elasticsearch, you should install the same version of the client as well.
+For example, if you are using Elasticsearch `v6.5.4`, you will need the client `v6`, and you can easily do that with `npm install @elastic/elasticsearch@6`. + +## Usage +```js +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ node: 'http://localhost:9200' }) + +// promise API +const result = await client.search({ + index: 'my-index', + body: { foo: 'bar' } +}) + +// callback API +client.search({ + index: 'my-index', + body: { foo: 'bar' } +}, (err, result) => { + if (err) console.log(err) +}) +``` +The returned value of **every** API call is formed as follows: +```ts +{ + body: object | boolean + statusCode: number + headers: object + warnings: [string] +} +``` +### Client options +The client is designed to be easily configured as you see fit for your needs, following you can see all the possible options that you can use to configure it. +```ts +{ + // the Elasticsearch endpoint to use + node: string | string[]; + // alias of above + nodes: string | string[]; + // custom connection class + Connection: typeof Connection; + // custom connection pool class + ConnectionPool: typeof ConnectionPool; + // custom transport class + Transport: typeof Transport; + // custom serializer class + Serializer: typeof Serializer; + // max number of retries for each request + maxRetries: number; + // max request timeout for each request + requestTimeout: number; + // max ping timeout for each request + pingTimeout: number; + // perform a sniff operation every `n` milliseconds + sniffInterval: number; + // perform a sniff once the client is started + sniffOnStart: boolean; + // custom sniff endpoint, defaults `_nodes/_all/http` + sniffEndpoint: string; + // perform a sniff on connection fault + sniffOnConnectionFault: boolean; + // configurethe node resurrection strategy, default `ping` + resurrectStrategy: 'ping' | 'optimistic' | 'none'; + // adds `accept-encoding` header to every request + suggestCompression: boolean; + // enable gzip request body compression + compression: 'gzip'; + // ssl configuraton + ssl: http.SecureContextOptions; + // http agent options + agent: http.AgentOptions; + // filters which node not to use for a request + nodeFilter: nodeFilterFn; + // custom selection strategy, defaults `round-robin` + nodeSelector: nodeSelectorFn | string; +} +``` + +### Request specific options +If needed you can pass request specific options in a second object: +```js +// promise API +const result = await client.search({ + index: 'my-index', + body: { foo: 'bar' } +}, { + ignore: [404], + maxRetries: 3 +}) +``` +The supported *request specific options* are: +```ts +{ + ignore: [number], // default `null` + requestTimeout: number, // client default + maxRetries: number, // default `5` + asStream: boolean, // default `false` + headers: object // default `null` +} +``` + +## License + +This software is licensed under the [Apache 2 license](./LICENSE). From fa0ee6e6c4959d2f207fd58a86fef24f839eeaba Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 11 Feb 2019 17:36:50 +0100 Subject: [PATCH 108/172] Bumped dependencies --- package.json | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index cd88e35c8..05efc7205 100644 --- a/package.json +++ b/package.json @@ -37,26 +37,26 @@ "company": "Elasticsearch BV" }, "devDependencies": { - "@types/node": "^10.12.10", - "dedent": "^0.7.0", - "deepmerge": "^2.2.1", - "js-yaml": "^3.12.0", - "lolex": "^3.0.0", + "@types/node": "^10.12.24", + "deepmerge": "^3.1.0", + "js-yaml": "^3.12.1", + "lolex": "^3.1.0", "minimist": "^1.2.0", "nanobench": "github:delvedor/nanobench#repetitions", - "ora": "^3.0.0", - "rimraf": "^2.6.2", + "ora": "^3.1.0", + "rimraf": "^2.6.3", "semver": "^5.6.0", - "simple-git": "^1.105.0", - "standard": "^12.0.0", - "stoppable": "^1.0.7", - "tap": "^12.0.1", - "typescript": "^3.1.6", + "simple-git": "^1.107.0", + "standard": "^12.0.1", + "stoppable": "^1.1.0", + "tap": "^12.5.2", + "typescript": "^3.3.3", "workq": "^2.1.0" }, "dependencies": { - "debug": "^4.1.0", - "decompress-response": "^3.3.0", + "debug": "^4.1.1", + "decompress-response": "^4.0.0", + "dedent": "^0.7.0", "into-stream": "^4.0.0", "ms": "^2.1.1", "once": "^1.4.0", From dbe45578483538aaf1e863dce0407145dbe9e45f Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 11 Feb 2019 17:37:16 +0100 Subject: [PATCH 109/172] Use custom client error class --- lib/errors.js | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/lib/errors.js b/lib/errors.js index 91a8b0038..585ec6996 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -1,8 +1,15 @@ 'use strict' -class TimeoutError extends Error { +class ElasticsearchClientError extends Error { + constructor (message) { + super(message) + this.name = 'ElasticsearchClientError' + } +} + +class TimeoutError extends ElasticsearchClientError { constructor (message, request) { - super() + super(message) Error.captureStackTrace(this, TimeoutError) this.name = 'TimeoutError' this.message = message || 'Timeout Error' @@ -10,9 +17,9 @@ class TimeoutError extends Error { } } -class ConnectionError extends Error { +class ConnectionError extends ElasticsearchClientError { constructor (message, request) { - super() + super(message) Error.captureStackTrace(this, ConnectionError) this.name = 'ConnectionError' this.message = message || 'Connection Error' @@ -20,45 +27,45 @@ class ConnectionError extends Error { } } -class NoLivingConnectionsError extends Error { +class NoLivingConnectionsError extends ElasticsearchClientError { constructor (message) { - super() + super(message) Error.captureStackTrace(this, NoLivingConnectionsError) this.name = 'NoLivingConnectionsError' this.message = message || 'No Living Connections Error' } } -class SerializationError extends Error { +class SerializationError extends ElasticsearchClientError { constructor (message) { - super() + super(message) Error.captureStackTrace(this, SerializationError) this.name = 'SerializationError' this.message = message || 'Serialization Error' } } -class DeserializationError extends Error { +class DeserializationError extends ElasticsearchClientError { constructor (message) { - super() + super(message) Error.captureStackTrace(this, DeserializationError) this.name = 'DeserializationError' this.message = message || 'Deserialization Error' } } -class ConfigurationError extends Error { +class ConfigurationError extends ElasticsearchClientError { constructor (message) { - super() + super(message) Error.captureStackTrace(this, ConfigurationError) this.name = 'ConfigurationError' this.message = message || 'Configuration Error' } } -class ResponseError extends Error { +class ResponseError extends ElasticsearchClientError { constructor ({ body, statusCode, headers }) { - super() + super('Response Error') Error.captureStackTrace(this, ResponseError) this.name = 'ResponseError' this.message = (body && body.error && body.error.type) || 'Response Error' @@ -71,6 +78,7 @@ class ResponseError extends Error { } module.exports = { + ElasticsearchClientError, TimeoutError, ConnectionError, NoLivingConnectionsError, From ecb2ba47a857cd0422d848a52abebd1660e77a90 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 11 Feb 2019 17:37:29 +0100 Subject: [PATCH 110/172] Small fixes --- lib/Connection.js | 18 +++++++++--------- lib/Transport.js | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/Connection.js b/lib/Connection.js index e5187ce78..a916f00d1 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -20,7 +20,7 @@ class Connection { this._openRequests = 0 this._status = opts.status || Connection.statuses.ALIVE - this.roles = Object.assign({}, defaultRoles, opts.roles) || Object.assign({}, defaultRoles) + this.roles = Object.assign({}, defaultRoles, opts.roles) if (!['http:', 'https:'].includes(this.url.protocol)) { throw new ConfigurationError(`Invalid protocol: '${this.url.protocol}'`) @@ -104,6 +104,7 @@ class Connection { // starts the request if (isStream(params.body) === true) { pump(params.body, request, err => { + /* istanbul ignore if */ if (err != null && ended === false) { ended = true this._openRequests-- @@ -129,14 +130,13 @@ class Connection { } setRole (role, enabled) { - assert( - ~validRoles.indexOf(role), - `Unsupported role: '${role}'` - ) - assert( - typeof enabled === 'boolean', - 'enabled should be a boolean' - ) + if (validRoles.indexOf(role) === -1) { + throw new ConfigurationError(`Unsupported role: '${role}'`) + } + if (typeof enabled !== 'boolean') { + throw new ConfigurationError('enabled should be a boolean') + } + this.roles[role] = enabled return this } diff --git a/lib/Transport.js b/lib/Transport.js index 63a728092..3123ef0dd 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -185,6 +185,7 @@ class Transport { // collect the payload response.setEncoding('utf8') response.on('data', chunk => { payload += chunk }) + /* istanbul ignore next */ response.on('error', err => { const error = new ConnectionError(err.message, params) this.emit('response', error, meta) From d9a5f24e246798aeed5f900c9b7494644f8a3d20 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 11 Feb 2019 17:37:44 +0100 Subject: [PATCH 111/172] Code coverage++ --- test/unit/connection-pool.test.js | 77 +++++++++++++++++++++++++++++++ test/unit/connection.test.js | 60 ++++++++++++++++++++++++ test/unit/transport.test.js | 26 +++++++++++ 3 files changed, 163 insertions(+) diff --git a/test/unit/connection-pool.test.js b/test/unit/connection-pool.test.js index cf054aade..734877d1f 100644 --- a/test/unit/connection-pool.test.js +++ b/test/unit/connection-pool.test.js @@ -490,3 +490,80 @@ test('API', t => { t.end() }) + +test('Node selector', t => { + t.test('round-robin', t => { + t.plan(1) + const pool = new ConnectionPool({ Connection, nodeSelector: 'round-robin' }) + pool.addConnection('http://localhost:9200/') + t.true(pool.getConnection() instanceof Connection) + }) + + t.test('random', t => { + t.plan(1) + const pool = new ConnectionPool({ Connection, nodeSelector: 'random' }) + pool.addConnection('http://localhost:9200/') + t.true(pool.getConnection() instanceof Connection) + }) + + t.test('custom function', t => { + t.plan(2) + const nodeSelector = connections => { + t.ok('called') + return connections[0] + } + const pool = new ConnectionPool({ Connection, nodeSelector }) + pool.addConnection('http://localhost:9200/') + t.true(pool.getConnection() instanceof Connection) + }) + + t.end() +}) + +test('Node filter', t => { + t.test('default', t => { + t.plan(1) + const pool = new ConnectionPool({ Connection }) + pool.addConnection({ url: new URL('http://localhost:9200/') }) + t.true(pool.getConnection() instanceof Connection) + }) + + t.test('Should filter master only nodes', t => { + t.plan(1) + const pool = new ConnectionPool({ Connection }) + pool.addConnection({ + url: new URL('http://localhost:9200/'), + roles: { + master: true, + data: false, + ingest: false, + ml: false + } + }) + t.strictEqual(pool.getConnection(), null) + }) + + t.test('custom', t => { + t.plan(2) + const nodeFilter = node => { + t.ok('called') + return true + } + const pool = new ConnectionPool({ Connection, nodeFilter }) + pool.addConnection({ url: new URL('http://localhost:9200/') }) + t.true(pool.getConnection() instanceof Connection) + }) + + t.test('custom (filter)', t => { + t.plan(2) + const nodeFilter = node => { + t.ok('called') + return false + } + const pool = new ConnectionPool({ Connection, nodeFilter }) + pool.addConnection({ url: new URL('http://localhost:9200/') }) + t.strictEqual(pool.getConnection(), null) + }) + + t.end() +}) diff --git a/test/unit/connection.test.js b/test/unit/connection.test.js index 8eb248c9b..92d6c6921 100644 --- a/test/unit/connection.test.js +++ b/test/unit/connection.test.js @@ -591,3 +591,63 @@ test('Should disallow two-byte characters in URL path', t => { ) }) }) + +test('setRole', t => { + t.test('Update the value of a role', t => { + t.plan(2) + + const connection = new Connection({ + url: new URL('http://localhost:9200') + }) + + t.deepEqual(connection.roles, { + master: true, + data: true, + ingest: true, + ml: false + }) + + connection.setRole('master', false) + + t.deepEqual(connection.roles, { + master: false, + data: true, + ingest: true, + ml: false + }) + }) + + t.test('Invalid role', t => { + t.plan(2) + + const connection = new Connection({ + url: new URL('http://localhost:9200') + }) + + try { + connection.setRole('car', true) + t.fail('Shoud throw') + } catch (err) { + t.true(err instanceof ConfigurationError) + t.is(err.message, 'Unsupported role: \'car\'') + } + }) + + t.test('Invalid value', t => { + t.plan(2) + + const connection = new Connection({ + url: new URL('http://localhost:9200') + }) + + try { + connection.setRole('master', 1) + t.fail('Shoud throw') + } catch (err) { + t.true(err instanceof ConfigurationError) + t.is(err.message, 'enabled should be a boolean') + } + }) + + t.end() +}) diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index 45a2ada5d..3cc88c9ce 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -377,6 +377,32 @@ test('SerializationError', t => { }) }) +test('SerializationError (bulk)', t => { + t.plan(1) + const pool = new ConnectionPool({ Connection }) + pool.addConnection('http://localhost:9200') + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + const bulkBody = { hello: 'world' } + bulkBody.o = bulkBody + transport.request({ + method: 'POST', + path: '/hello', + bulkBody + }, (err, { body }) => { + t.ok(err instanceof SerializationError) + }) +}) + test('DeserializationError', t => { t.plan(1) function handler (req, res) { From 422409627a2831697483c051fc467dd183ea1c09 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 11 Feb 2019 17:51:23 +0100 Subject: [PATCH 112/172] Bumped v0.1.0-alpha.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 05efc7205..7ca20297d 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "main": "index.js", "types": "index.d.ts", "homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html", - "version": "0.1.0-alpha.5", + "version": "0.1.0-alpha.6", "keywords": [ "elasticsearch", "elastic", From 1b519671eb431a4b914bc789d307672cf7488f32 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 12 Feb 2019 16:39:42 +0100 Subject: [PATCH 113/172] Updated code generation --- scripts/utils/generate.js | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/utils/generate.js b/scripts/utils/generate.js index 6f21b404d..e3531f7db 100644 --- a/scripts/utils/generate.js +++ b/scripts/utils/generate.js @@ -135,6 +135,7 @@ function generate (spec, common) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } From 0355322ef4691d611262fbe99aca6a4458c1decf Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 12 Feb 2019 16:39:49 +0100 Subject: [PATCH 114/172] API generation --- api/api/bulk.js | 1 + api/api/cat.aliases.js | 1 + api/api/cat.allocation.js | 1 + api/api/cat.count.js | 1 + api/api/cat.fielddata.js | 1 + api/api/cat.health.js | 1 + api/api/cat.help.js | 1 + api/api/cat.indices.js | 1 + api/api/cat.master.js | 1 + api/api/cat.nodeattrs.js | 1 + api/api/cat.nodes.js | 1 + api/api/cat.pending_tasks.js | 1 + api/api/cat.plugins.js | 1 + api/api/cat.recovery.js | 1 + api/api/cat.repositories.js | 1 + api/api/cat.segments.js | 1 + api/api/cat.shards.js | 1 + api/api/cat.snapshots.js | 1 + api/api/cat.tasks.js | 1 + api/api/cat.templates.js | 1 + api/api/cat.thread_pool.js | 1 + api/api/ccr.delete_auto_follow_pattern.js | 1 + api/api/ccr.follow.js | 1 + api/api/ccr.follow_stats.js | 1 + api/api/ccr.get_auto_follow_pattern.js | 1 + api/api/ccr.pause_follow.js | 1 + api/api/ccr.put_auto_follow_pattern.js | 1 + api/api/ccr.resume_follow.js | 1 + api/api/ccr.stats.js | 1 + api/api/ccr.unfollow.js | 1 + api/api/clear_scroll.js | 1 + api/api/cluster.allocation_explain.js | 1 + api/api/cluster.get_settings.js | 1 + api/api/cluster.health.js | 1 + api/api/cluster.pending_tasks.js | 1 + api/api/cluster.put_settings.js | 1 + api/api/cluster.remote_info.js | 1 + api/api/cluster.reroute.js | 1 + api/api/cluster.state.js | 1 + api/api/cluster.stats.js | 1 + api/api/count.js | 1 + api/api/create.js | 1 + api/api/delete.js | 1 + api/api/delete_by_query.js | 1 + api/api/delete_by_query_rethrottle.js | 1 + api/api/delete_script.js | 1 + api/api/exists.js | 1 + api/api/exists_source.js | 1 + api/api/explain.js | 1 + api/api/field_caps.js | 1 + api/api/get.js | 1 + api/api/get_script.js | 1 + api/api/get_source.js | 1 + api/api/ilm.delete_lifecycle.js | 1 + api/api/ilm.explain_lifecycle.js | 1 + api/api/ilm.get_lifecycle.js | 1 + api/api/ilm.get_status.js | 1 + api/api/ilm.move_to_step.js | 1 + api/api/ilm.put_lifecycle.js | 1 + api/api/ilm.remove_policy.js | 1 + api/api/ilm.retry.js | 1 + api/api/ilm.start.js | 1 + api/api/ilm.stop.js | 1 + api/api/index.js | 1 + api/api/indices.analyze.js | 1 + api/api/indices.clear_cache.js | 1 + api/api/indices.close.js | 1 + api/api/indices.create.js | 1 + api/api/indices.delete.js | 1 + api/api/indices.delete_alias.js | 1 + api/api/indices.delete_template.js | 1 + api/api/indices.exists.js | 1 + api/api/indices.exists_alias.js | 1 + api/api/indices.exists_template.js | 1 + api/api/indices.exists_type.js | 1 + api/api/indices.flush.js | 1 + api/api/indices.flush_synced.js | 1 + api/api/indices.forcemerge.js | 1 + api/api/indices.freeze.js | 1 + api/api/indices.get.js | 1 + api/api/indices.get_alias.js | 1 + api/api/indices.get_field_mapping.js | 1 + api/api/indices.get_mapping.js | 1 + api/api/indices.get_settings.js | 1 + api/api/indices.get_template.js | 1 + api/api/indices.get_upgrade.js | 1 + api/api/indices.open.js | 1 + api/api/indices.put_alias.js | 1 + api/api/indices.put_mapping.js | 1 + api/api/indices.put_settings.js | 1 + api/api/indices.put_template.js | 1 + api/api/indices.recovery.js | 1 + api/api/indices.refresh.js | 1 + api/api/indices.rollover.js | 1 + api/api/indices.segments.js | 1 + api/api/indices.shard_stores.js | 1 + api/api/indices.shrink.js | 1 + api/api/indices.split.js | 1 + api/api/indices.stats.js | 1 + api/api/indices.unfreeze.js | 1 + api/api/indices.update_aliases.js | 1 + api/api/indices.upgrade.js | 1 + api/api/indices.validate_query.js | 1 + api/api/info.js | 1 + api/api/ingest.delete_pipeline.js | 1 + api/api/ingest.get_pipeline.js | 1 + api/api/ingest.processor_grok.js | 1 + api/api/ingest.put_pipeline.js | 1 + api/api/ingest.simulate.js | 1 + api/api/mget.js | 1 + api/api/ml.close_job.js | 1 + api/api/ml.delete_calendar.js | 1 + api/api/ml.delete_calendar_event.js | 1 + api/api/ml.delete_calendar_job.js | 1 + api/api/ml.delete_datafeed.js | 1 + api/api/ml.delete_expired_data.js | 1 + api/api/ml.delete_filter.js | 1 + api/api/ml.delete_forecast.js | 1 + api/api/ml.delete_job.js | 1 + api/api/ml.delete_model_snapshot.js | 1 + api/api/ml.find_file_structure.js | 1 + api/api/ml.flush_job.js | 1 + api/api/ml.forecast.js | 1 + api/api/ml.get_buckets.js | 1 + api/api/ml.get_calendar_events.js | 1 + api/api/ml.get_calendars.js | 1 + api/api/ml.get_categories.js | 1 + api/api/ml.get_datafeed_stats.js | 1 + api/api/ml.get_datafeeds.js | 1 + api/api/ml.get_filters.js | 1 + api/api/ml.get_influencers.js | 1 + api/api/ml.get_job_stats.js | 1 + api/api/ml.get_jobs.js | 1 + api/api/ml.get_model_snapshots.js | 1 + api/api/ml.get_overall_buckets.js | 1 + api/api/ml.get_records.js | 1 + api/api/ml.info.js | 1 + api/api/ml.open_job.js | 1 + api/api/ml.post_calendar_events.js | 1 + api/api/ml.post_data.js | 1 + api/api/ml.preview_datafeed.js | 1 + api/api/ml.put_calendar.js | 1 + api/api/ml.put_calendar_job.js | 1 + api/api/ml.put_datafeed.js | 1 + api/api/ml.put_filter.js | 1 + api/api/ml.put_job.js | 1 + api/api/ml.revert_model_snapshot.js | 1 + api/api/ml.start_datafeed.js | 1 + api/api/ml.stop_datafeed.js | 1 + api/api/ml.update_datafeed.js | 1 + api/api/ml.update_filter.js | 1 + api/api/ml.update_job.js | 1 + api/api/ml.update_model_snapshot.js | 1 + api/api/ml.validate.js | 1 + api/api/ml.validate_detector.js | 1 + api/api/monitoring.bulk.js | 1 + api/api/msearch.js | 1 + api/api/msearch_template.js | 1 + api/api/mtermvectors.js | 1 + api/api/nodes.hot_threads.js | 1 + api/api/nodes.info.js | 1 + api/api/nodes.reload_secure_settings.js | 1 + api/api/nodes.stats.js | 1 + api/api/nodes.usage.js | 1 + api/api/ping.js | 1 + api/api/put_script.js | 1 + api/api/rank_eval.js | 1 + api/api/reindex.js | 1 + api/api/reindex_rethrottle.js | 1 + api/api/render_search_template.js | 1 + api/api/scripts_painless_execute.js | 1 + api/api/scroll.js | 1 + api/api/search.js | 1 + api/api/search_shards.js | 1 + api/api/search_template.js | 1 + api/api/security.authenticate.js | 1 + api/api/security.change_password.js | 1 + api/api/security.clear_cached_realms.js | 1 + api/api/security.clear_cached_roles.js | 1 + api/api/security.delete_privileges.js | 1 + api/api/security.delete_role.js | 1 + api/api/security.delete_role_mapping.js | 1 + api/api/security.delete_user.js | 1 + api/api/security.disable_user.js | 1 + api/api/security.enable_user.js | 1 + api/api/security.get_privileges.js | 1 + api/api/security.get_role.js | 1 + api/api/security.get_role_mapping.js | 1 + api/api/security.get_token.js | 1 + api/api/security.get_user.js | 1 + api/api/security.get_user_privileges.js | 1 + api/api/security.has_privileges.js | 1 + api/api/security.invalidate_token.js | 1 + api/api/security.put_privileges.js | 1 + api/api/security.put_role.js | 1 + api/api/security.put_role_mapping.js | 1 + api/api/security.put_user.js | 1 + api/api/snapshot.create.js | 1 + api/api/snapshot.create_repository.js | 1 + api/api/snapshot.delete.js | 1 + api/api/snapshot.delete_repository.js | 1 + api/api/snapshot.get.js | 1 + api/api/snapshot.get_repository.js | 1 + api/api/snapshot.restore.js | 1 + api/api/snapshot.status.js | 1 + api/api/snapshot.verify_repository.js | 1 + api/api/ssl.certificates.js | 1 + api/api/tasks.cancel.js | 1 + api/api/tasks.get.js | 1 + api/api/tasks.list.js | 1 + api/api/termvectors.js | 1 + api/api/update.js | 1 + api/api/update_by_query.js | 1 + api/api/update_by_query_rethrottle.js | 1 + api/api/xpack.graph.explore.js | 1 + api/api/xpack.info.js | 1 + api/api/xpack.license.delete.js | 1 + api/api/xpack.license.get.js | 1 + api/api/xpack.license.get_basic_status.js | 1 + api/api/xpack.license.get_trial_status.js | 1 + api/api/xpack.license.post.js | 1 + api/api/xpack.license.post_start_basic.js | 1 + api/api/xpack.license.post_start_trial.js | 1 + api/api/xpack.migration.deprecations.js | 1 + api/api/xpack.migration.get_assistance.js | 1 + api/api/xpack.migration.upgrade.js | 1 + api/api/xpack.rollup.delete_job.js | 1 + api/api/xpack.rollup.get_jobs.js | 1 + api/api/xpack.rollup.get_rollup_caps.js | 1 + api/api/xpack.rollup.get_rollup_index_caps.js | 1 + api/api/xpack.rollup.put_job.js | 1 + api/api/xpack.rollup.rollup_search.js | 1 + api/api/xpack.rollup.start_job.js | 1 + api/api/xpack.rollup.stop_job.js | 1 + api/api/xpack.sql.clear_cursor.js | 1 + api/api/xpack.sql.query.js | 1 + api/api/xpack.sql.translate.js | 1 + api/api/xpack.usage.js | 1 + api/api/xpack.watcher.ack_watch.js | 1 + api/api/xpack.watcher.activate_watch.js | 1 + api/api/xpack.watcher.deactivate_watch.js | 1 + api/api/xpack.watcher.delete_watch.js | 1 + api/api/xpack.watcher.execute_watch.js | 1 + api/api/xpack.watcher.get_watch.js | 1 + api/api/xpack.watcher.put_watch.js | 1 + api/api/xpack.watcher.start.js | 1 + api/api/xpack.watcher.stats.js | 1 + api/api/xpack.watcher.stop.js | 1 + 248 files changed, 248 insertions(+) diff --git a/api/api/bulk.js b/api/api/bulk.js index 660be80f8..3932fdacb 100644 --- a/api/api/bulk.js +++ b/api/api/bulk.js @@ -129,6 +129,7 @@ function buildBulk (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cat.aliases.js b/api/api/cat.aliases.js index 6514d256e..6f41c6ee2 100644 --- a/api/api/cat.aliases.js +++ b/api/api/cat.aliases.js @@ -111,6 +111,7 @@ function buildCatAliases (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cat.allocation.js b/api/api/cat.allocation.js index 937af2fb1..59760e42f 100644 --- a/api/api/cat.allocation.js +++ b/api/api/cat.allocation.js @@ -113,6 +113,7 @@ function buildCatAllocation (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cat.count.js b/api/api/cat.count.js index c15de6550..8e74ef322 100644 --- a/api/api/cat.count.js +++ b/api/api/cat.count.js @@ -111,6 +111,7 @@ function buildCatCount (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cat.fielddata.js b/api/api/cat.fielddata.js index d75cd3df4..99a130b78 100644 --- a/api/api/cat.fielddata.js +++ b/api/api/cat.fielddata.js @@ -115,6 +115,7 @@ function buildCatFielddata (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cat.health.js b/api/api/cat.health.js index 4c0bedc77..883ea5ad1 100644 --- a/api/api/cat.health.js +++ b/api/api/cat.health.js @@ -108,6 +108,7 @@ function buildCatHealth (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cat.help.js b/api/api/cat.help.js index 2c9039ee3..052d7388f 100644 --- a/api/api/cat.help.js +++ b/api/api/cat.help.js @@ -95,6 +95,7 @@ function buildCatHelp (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cat.indices.js b/api/api/cat.indices.js index 94aea079e..6b6f8d082 100644 --- a/api/api/cat.indices.js +++ b/api/api/cat.indices.js @@ -117,6 +117,7 @@ function buildCatIndices (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cat.master.js b/api/api/cat.master.js index 85768b27b..afc29f2a2 100644 --- a/api/api/cat.master.js +++ b/api/api/cat.master.js @@ -106,6 +106,7 @@ function buildCatMaster (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cat.nodeattrs.js b/api/api/cat.nodeattrs.js index e41b56adb..5b9a3399d 100644 --- a/api/api/cat.nodeattrs.js +++ b/api/api/cat.nodeattrs.js @@ -106,6 +106,7 @@ function buildCatNodeattrs (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cat.nodes.js b/api/api/cat.nodes.js index e75e3161d..24682d26b 100644 --- a/api/api/cat.nodes.js +++ b/api/api/cat.nodes.js @@ -109,6 +109,7 @@ function buildCatNodes (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cat.pending_tasks.js b/api/api/cat.pending_tasks.js index cf25a99ef..3c5270872 100644 --- a/api/api/cat.pending_tasks.js +++ b/api/api/cat.pending_tasks.js @@ -106,6 +106,7 @@ function buildCatPendingTasks (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cat.plugins.js b/api/api/cat.plugins.js index ac8dd626f..073373b53 100644 --- a/api/api/cat.plugins.js +++ b/api/api/cat.plugins.js @@ -106,6 +106,7 @@ function buildCatPlugins (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cat.recovery.js b/api/api/cat.recovery.js index cadf47b85..52f7f142c 100644 --- a/api/api/cat.recovery.js +++ b/api/api/cat.recovery.js @@ -111,6 +111,7 @@ function buildCatRecovery (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cat.repositories.js b/api/api/cat.repositories.js index 8d7637bea..d463091c7 100644 --- a/api/api/cat.repositories.js +++ b/api/api/cat.repositories.js @@ -106,6 +106,7 @@ function buildCatRepositories (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cat.segments.js b/api/api/cat.segments.js index 974dbd559..20e2e896d 100644 --- a/api/api/cat.segments.js +++ b/api/api/cat.segments.js @@ -108,6 +108,7 @@ function buildCatSegments (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cat.shards.js b/api/api/cat.shards.js index a5bf81bd2..0aac452e1 100644 --- a/api/api/cat.shards.js +++ b/api/api/cat.shards.js @@ -113,6 +113,7 @@ function buildCatShards (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cat.snapshots.js b/api/api/cat.snapshots.js index 4d94b6b88..03b0f8fa6 100644 --- a/api/api/cat.snapshots.js +++ b/api/api/cat.snapshots.js @@ -112,6 +112,7 @@ function buildCatSnapshots (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cat.tasks.js b/api/api/cat.tasks.js index db8bf7ad0..b830de190 100644 --- a/api/api/cat.tasks.js +++ b/api/api/cat.tasks.js @@ -111,6 +111,7 @@ function buildCatTasks (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cat.templates.js b/api/api/cat.templates.js index e455e5db8..cef9c6d6c 100644 --- a/api/api/cat.templates.js +++ b/api/api/cat.templates.js @@ -111,6 +111,7 @@ function buildCatTemplates (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cat.thread_pool.js b/api/api/cat.thread_pool.js index d4c062897..24c684f39 100644 --- a/api/api/cat.thread_pool.js +++ b/api/api/cat.thread_pool.js @@ -113,6 +113,7 @@ function buildCatThreadPool (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ccr.delete_auto_follow_pattern.js b/api/api/ccr.delete_auto_follow_pattern.js index c8c0f6360..cefe3edbb 100644 --- a/api/api/ccr.delete_auto_follow_pattern.js +++ b/api/api/ccr.delete_auto_follow_pattern.js @@ -87,6 +87,7 @@ function buildCcrDeleteAutoFollowPattern (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ccr.follow.js b/api/api/ccr.follow.js index 864f1fb07..8c7e1b803 100644 --- a/api/api/ccr.follow.js +++ b/api/api/ccr.follow.js @@ -94,6 +94,7 @@ function buildCcrFollow (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ccr.follow_stats.js b/api/api/ccr.follow_stats.js index 98cb1ba5a..9c7f354dd 100644 --- a/api/api/ccr.follow_stats.js +++ b/api/api/ccr.follow_stats.js @@ -79,6 +79,7 @@ function buildCcrFollowStats (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ccr.get_auto_follow_pattern.js b/api/api/ccr.get_auto_follow_pattern.js index 2e53add8d..1cd71c63f 100644 --- a/api/api/ccr.get_auto_follow_pattern.js +++ b/api/api/ccr.get_auto_follow_pattern.js @@ -83,6 +83,7 @@ function buildCcrGetAutoFollowPattern (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ccr.pause_follow.js b/api/api/ccr.pause_follow.js index e10a26fc9..926a3cf99 100644 --- a/api/api/ccr.pause_follow.js +++ b/api/api/ccr.pause_follow.js @@ -87,6 +87,7 @@ function buildCcrPauseFollow (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ccr.put_auto_follow_pattern.js b/api/api/ccr.put_auto_follow_pattern.js index afe577b98..fb7f5fa28 100644 --- a/api/api/ccr.put_auto_follow_pattern.js +++ b/api/api/ccr.put_auto_follow_pattern.js @@ -94,6 +94,7 @@ function buildCcrPutAutoFollowPattern (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ccr.resume_follow.js b/api/api/ccr.resume_follow.js index 977e452ba..961947862 100644 --- a/api/api/ccr.resume_follow.js +++ b/api/api/ccr.resume_follow.js @@ -94,6 +94,7 @@ function buildCcrResumeFollow (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ccr.stats.js b/api/api/ccr.stats.js index 86cafe603..7f7671702 100644 --- a/api/api/ccr.stats.js +++ b/api/api/ccr.stats.js @@ -78,6 +78,7 @@ function buildCcrStats (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ccr.unfollow.js b/api/api/ccr.unfollow.js index d13568d70..6b8eb217b 100644 --- a/api/api/ccr.unfollow.js +++ b/api/api/ccr.unfollow.js @@ -87,6 +87,7 @@ function buildCcrUnfollow (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/clear_scroll.js b/api/api/clear_scroll.js index 311650b04..b104cb77f 100644 --- a/api/api/clear_scroll.js +++ b/api/api/clear_scroll.js @@ -89,6 +89,7 @@ function buildClearScroll (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cluster.allocation_explain.js b/api/api/cluster.allocation_explain.js index a4aada4a1..b89da709d 100644 --- a/api/api/cluster.allocation_explain.js +++ b/api/api/cluster.allocation_explain.js @@ -90,6 +90,7 @@ function buildClusterAllocationExplain (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cluster.get_settings.js b/api/api/cluster.get_settings.js index 2d2646ef2..efb8ac131 100644 --- a/api/api/cluster.get_settings.js +++ b/api/api/cluster.get_settings.js @@ -102,6 +102,7 @@ function buildClusterGetSettings (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cluster.health.js b/api/api/cluster.health.js index e3786ab4a..679042f82 100644 --- a/api/api/cluster.health.js +++ b/api/api/cluster.health.js @@ -123,6 +123,7 @@ function buildClusterHealth (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cluster.pending_tasks.js b/api/api/cluster.pending_tasks.js index 2670ab2e0..ade3f4bd7 100644 --- a/api/api/cluster.pending_tasks.js +++ b/api/api/cluster.pending_tasks.js @@ -96,6 +96,7 @@ function buildClusterPendingTasks (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cluster.put_settings.js b/api/api/cluster.put_settings.js index e76483e1a..234e8f6f8 100644 --- a/api/api/cluster.put_settings.js +++ b/api/api/cluster.put_settings.js @@ -100,6 +100,7 @@ function buildClusterPutSettings (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cluster.remote_info.js b/api/api/cluster.remote_info.js index 947a6452a..370a2e49d 100644 --- a/api/api/cluster.remote_info.js +++ b/api/api/cluster.remote_info.js @@ -91,6 +91,7 @@ function buildClusterRemoteInfo (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cluster.reroute.js b/api/api/cluster.reroute.js index 9c1c71997..a93448f43 100644 --- a/api/api/cluster.reroute.js +++ b/api/api/cluster.reroute.js @@ -99,6 +99,7 @@ function buildClusterReroute (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cluster.state.js b/api/api/cluster.state.js index ef7f4d9fa..4e8a510dc 100644 --- a/api/api/cluster.state.js +++ b/api/api/cluster.state.js @@ -130,6 +130,7 @@ function buildClusterState (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/cluster.stats.js b/api/api/cluster.stats.js index a14ef97cb..abc9e133f 100644 --- a/api/api/cluster.stats.js +++ b/api/api/cluster.stats.js @@ -101,6 +101,7 @@ function buildClusterStats (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/count.js b/api/api/count.js index f2333f66a..ac8ab264d 100644 --- a/api/api/count.js +++ b/api/api/count.js @@ -136,6 +136,7 @@ function buildCount (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/create.js b/api/api/create.js index f5ecd7ad6..062e5c4c8 100644 --- a/api/api/create.js +++ b/api/api/create.js @@ -144,6 +144,7 @@ function buildCreate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/delete.js b/api/api/delete.js index d5e5fbdd1..abef3c447 100644 --- a/api/api/delete.js +++ b/api/api/delete.js @@ -134,6 +134,7 @@ function buildDelete (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/delete_by_query.js b/api/api/delete_by_query.js index 289436e70..3b787ad70 100644 --- a/api/api/delete_by_query.js +++ b/api/api/delete_by_query.js @@ -191,6 +191,7 @@ function buildDeleteByQuery (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/delete_by_query_rethrottle.js b/api/api/delete_by_query_rethrottle.js index 588518983..4e952fea8 100644 --- a/api/api/delete_by_query_rethrottle.js +++ b/api/api/delete_by_query_rethrottle.js @@ -107,6 +107,7 @@ function buildDeleteByQueryRethrottle (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/delete_script.js b/api/api/delete_script.js index 371f0fd94..36477947b 100644 --- a/api/api/delete_script.js +++ b/api/api/delete_script.js @@ -103,6 +103,7 @@ function buildDeleteScript (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/exists.js b/api/api/exists.js index aad3649d5..c4c5d8172 100644 --- a/api/api/exists.js +++ b/api/api/exists.js @@ -136,6 +136,7 @@ function buildExists (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/exists_source.js b/api/api/exists_source.js index 9a769a75d..afb2b531a 100644 --- a/api/api/exists_source.js +++ b/api/api/exists_source.js @@ -148,6 +148,7 @@ function buildExistsSource (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/explain.js b/api/api/explain.js index 6a207098a..dca065aae 100644 --- a/api/api/explain.js +++ b/api/api/explain.js @@ -136,6 +136,7 @@ function buildExplain (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/field_caps.js b/api/api/field_caps.js index 1fa8281ac..872bb18dd 100644 --- a/api/api/field_caps.js +++ b/api/api/field_caps.js @@ -107,6 +107,7 @@ function buildFieldCaps (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/get.js b/api/api/get.js index 692e30cda..f179f8459 100644 --- a/api/api/get.js +++ b/api/api/get.js @@ -142,6 +142,7 @@ function buildGet (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/get_script.js b/api/api/get_script.js index 188c45ed6..e54467593 100644 --- a/api/api/get_script.js +++ b/api/api/get_script.js @@ -101,6 +101,7 @@ function buildGetScript (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/get_source.js b/api/api/get_source.js index 7911c3c97..003667bbf 100644 --- a/api/api/get_source.js +++ b/api/api/get_source.js @@ -148,6 +148,7 @@ function buildGetSource (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ilm.delete_lifecycle.js b/api/api/ilm.delete_lifecycle.js index 59b75e48f..7e7c06e81 100644 --- a/api/api/ilm.delete_lifecycle.js +++ b/api/api/ilm.delete_lifecycle.js @@ -87,6 +87,7 @@ function buildIlmDeleteLifecycle (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ilm.explain_lifecycle.js b/api/api/ilm.explain_lifecycle.js index e92f21ba7..a50de9700 100644 --- a/api/api/ilm.explain_lifecycle.js +++ b/api/api/ilm.explain_lifecycle.js @@ -88,6 +88,7 @@ function buildIlmExplainLifecycle (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ilm.get_lifecycle.js b/api/api/ilm.get_lifecycle.js index 70c21d35e..8e9368741 100644 --- a/api/api/ilm.get_lifecycle.js +++ b/api/api/ilm.get_lifecycle.js @@ -91,6 +91,7 @@ function buildIlmGetLifecycle (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ilm.get_status.js b/api/api/ilm.get_status.js index f51dec6f3..42dfec166 100644 --- a/api/api/ilm.get_status.js +++ b/api/api/ilm.get_status.js @@ -86,6 +86,7 @@ function buildIlmGetStatus (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ilm.move_to_step.js b/api/api/ilm.move_to_step.js index da5154d7e..32be9e2a8 100644 --- a/api/api/ilm.move_to_step.js +++ b/api/api/ilm.move_to_step.js @@ -80,6 +80,7 @@ function buildIlmMoveToStep (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ilm.put_lifecycle.js b/api/api/ilm.put_lifecycle.js index 0508242da..e0d2352ec 100644 --- a/api/api/ilm.put_lifecycle.js +++ b/api/api/ilm.put_lifecycle.js @@ -80,6 +80,7 @@ function buildIlmPutLifecycle (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ilm.remove_policy.js b/api/api/ilm.remove_policy.js index 2dd9f5ba2..0fba4e140 100644 --- a/api/api/ilm.remove_policy.js +++ b/api/api/ilm.remove_policy.js @@ -87,6 +87,7 @@ function buildIlmRemovePolicy (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ilm.retry.js b/api/api/ilm.retry.js index 152ac10a3..60e3ea0af 100644 --- a/api/api/ilm.retry.js +++ b/api/api/ilm.retry.js @@ -87,6 +87,7 @@ function buildIlmRetry (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ilm.start.js b/api/api/ilm.start.js index e73515d8e..549350117 100644 --- a/api/api/ilm.start.js +++ b/api/api/ilm.start.js @@ -86,6 +86,7 @@ function buildIlmStart (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ilm.stop.js b/api/api/ilm.stop.js index 753105de4..f92de4797 100644 --- a/api/api/ilm.stop.js +++ b/api/api/ilm.stop.js @@ -86,6 +86,7 @@ function buildIlmStop (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/index.js b/api/api/index.js index f15b822b3..09508b801 100644 --- a/api/api/index.js +++ b/api/api/index.js @@ -138,6 +138,7 @@ function buildIndex (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.analyze.js b/api/api/indices.analyze.js index f548bb91e..206fbf71b 100644 --- a/api/api/indices.analyze.js +++ b/api/api/indices.analyze.js @@ -91,6 +91,7 @@ function buildIndicesAnalyze (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.clear_cache.js b/api/api/indices.clear_cache.js index 37948ece0..e95ec5ecb 100644 --- a/api/api/indices.clear_cache.js +++ b/api/api/indices.clear_cache.js @@ -115,6 +115,7 @@ function buildIndicesClearCache (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.close.js b/api/api/indices.close.js index 05a0c4af5..e78974573 100644 --- a/api/api/indices.close.js +++ b/api/api/indices.close.js @@ -112,6 +112,7 @@ function buildIndicesClose (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.create.js b/api/api/indices.create.js index 4c1e52a3f..a2ba5b0f8 100644 --- a/api/api/indices.create.js +++ b/api/api/indices.create.js @@ -104,6 +104,7 @@ function buildIndicesCreate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.delete.js b/api/api/indices.delete.js index bcacded57..7058d9340 100644 --- a/api/api/indices.delete.js +++ b/api/api/indices.delete.js @@ -112,6 +112,7 @@ function buildIndicesDelete (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.delete_alias.js b/api/api/indices.delete_alias.js index b32b1a9f0..fba43ea21 100644 --- a/api/api/indices.delete_alias.js +++ b/api/api/indices.delete_alias.js @@ -122,6 +122,7 @@ function buildIndicesDeleteAlias (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.delete_template.js b/api/api/indices.delete_template.js index 072ca2740..4362e1f0e 100644 --- a/api/api/indices.delete_template.js +++ b/api/api/indices.delete_template.js @@ -103,6 +103,7 @@ function buildIndicesDeleteTemplate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.exists.js b/api/api/indices.exists.js index 0384da2b7..65f34e8d6 100644 --- a/api/api/indices.exists.js +++ b/api/api/indices.exists.js @@ -115,6 +115,7 @@ function buildIndicesExists (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.exists_alias.js b/api/api/indices.exists_alias.js index 8f6a3d726..c423cf9aa 100644 --- a/api/api/indices.exists_alias.js +++ b/api/api/indices.exists_alias.js @@ -114,6 +114,7 @@ function buildIndicesExistsAlias (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.exists_template.js b/api/api/indices.exists_template.js index d7b9effd5..a22944510 100644 --- a/api/api/indices.exists_template.js +++ b/api/api/indices.exists_template.js @@ -106,6 +106,7 @@ function buildIndicesExistsTemplate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.exists_type.js b/api/api/indices.exists_type.js index c08fd8695..b33f1e856 100644 --- a/api/api/indices.exists_type.js +++ b/api/api/indices.exists_type.js @@ -124,6 +124,7 @@ function buildIndicesExistsType (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.flush.js b/api/api/indices.flush.js index e8e1aca59..6e39a31ed 100644 --- a/api/api/indices.flush.js +++ b/api/api/indices.flush.js @@ -110,6 +110,7 @@ function buildIndicesFlush (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.flush_synced.js b/api/api/indices.flush_synced.js index ec4f7086a..34ebe17d4 100644 --- a/api/api/indices.flush_synced.js +++ b/api/api/indices.flush_synced.js @@ -105,6 +105,7 @@ function buildIndicesFlushSynced (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.forcemerge.js b/api/api/indices.forcemerge.js index 3ee9383c9..19ee37db4 100644 --- a/api/api/indices.forcemerge.js +++ b/api/api/indices.forcemerge.js @@ -113,6 +113,7 @@ function buildIndicesForcemerge (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.freeze.js b/api/api/indices.freeze.js index deb10d22e..b88d62acc 100644 --- a/api/api/indices.freeze.js +++ b/api/api/indices.freeze.js @@ -108,6 +108,7 @@ function buildIndicesFreeze (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.get.js b/api/api/indices.get.js index 685665cc4..a662c5753 100644 --- a/api/api/indices.get.js +++ b/api/api/indices.get.js @@ -118,6 +118,7 @@ function buildIndicesGet (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.get_alias.js b/api/api/indices.get_alias.js index ce82cc7fb..27a406f36 100644 --- a/api/api/indices.get_alias.js +++ b/api/api/indices.get_alias.js @@ -112,6 +112,7 @@ function buildIndicesGetAlias (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.get_field_mapping.js b/api/api/indices.get_field_mapping.js index da0e264c5..fa211f636 100644 --- a/api/api/indices.get_field_mapping.js +++ b/api/api/indices.get_field_mapping.js @@ -122,6 +122,7 @@ function buildIndicesGetFieldMapping (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.get_mapping.js b/api/api/indices.get_mapping.js index 4130c2e4e..315e1c11e 100644 --- a/api/api/indices.get_mapping.js +++ b/api/api/indices.get_mapping.js @@ -118,6 +118,7 @@ function buildIndicesGetMapping (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.get_settings.js b/api/api/indices.get_settings.js index 887161848..6581cbaa6 100644 --- a/api/api/indices.get_settings.js +++ b/api/api/indices.get_settings.js @@ -121,6 +121,7 @@ function buildIndicesGetSettings (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.get_template.js b/api/api/indices.get_template.js index ac4702461..ab2848ca6 100644 --- a/api/api/indices.get_template.js +++ b/api/api/indices.get_template.js @@ -104,6 +104,7 @@ function buildIndicesGetTemplate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.get_upgrade.js b/api/api/indices.get_upgrade.js index 90e6f5eb0..fea41e2ac 100644 --- a/api/api/indices.get_upgrade.js +++ b/api/api/indices.get_upgrade.js @@ -105,6 +105,7 @@ function buildIndicesGetUpgrade (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.open.js b/api/api/indices.open.js index 76de5efd1..747c61525 100644 --- a/api/api/indices.open.js +++ b/api/api/indices.open.js @@ -115,6 +115,7 @@ function buildIndicesOpen (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.put_alias.js b/api/api/indices.put_alias.js index 2208b9008..9fc60c093 100644 --- a/api/api/indices.put_alias.js +++ b/api/api/indices.put_alias.js @@ -117,6 +117,7 @@ function buildIndicesPutAlias (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.put_mapping.js b/api/api/indices.put_mapping.js index a6dae7d40..41834d339 100644 --- a/api/api/indices.put_mapping.js +++ b/api/api/indices.put_mapping.js @@ -127,6 +127,7 @@ function buildIndicesPutMapping (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.put_settings.js b/api/api/indices.put_settings.js index 9d4ec22a8..19a7a0516 100644 --- a/api/api/indices.put_settings.js +++ b/api/api/indices.put_settings.js @@ -117,6 +117,7 @@ function buildIndicesPutSettings (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.put_template.js b/api/api/indices.put_template.js index 92f577446..565020d7e 100644 --- a/api/api/indices.put_template.js +++ b/api/api/indices.put_template.js @@ -111,6 +111,7 @@ function buildIndicesPutTemplate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.recovery.js b/api/api/indices.recovery.js index 3a5ba3f90..b5a3a6808 100644 --- a/api/api/indices.recovery.js +++ b/api/api/indices.recovery.js @@ -101,6 +101,7 @@ function buildIndicesRecovery (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.refresh.js b/api/api/indices.refresh.js index e73865227..d09c5d44e 100644 --- a/api/api/indices.refresh.js +++ b/api/api/indices.refresh.js @@ -105,6 +105,7 @@ function buildIndicesRefresh (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.rollover.js b/api/api/indices.rollover.js index 3713d8a74..80b3c2f0e 100644 --- a/api/api/indices.rollover.js +++ b/api/api/indices.rollover.js @@ -117,6 +117,7 @@ function buildIndicesRollover (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.segments.js b/api/api/indices.segments.js index 79d1d3f23..a91afea3d 100644 --- a/api/api/indices.segments.js +++ b/api/api/indices.segments.js @@ -107,6 +107,7 @@ function buildIndicesSegments (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.shard_stores.js b/api/api/indices.shard_stores.js index e0c03498a..b7c5048bd 100644 --- a/api/api/indices.shard_stores.js +++ b/api/api/indices.shard_stores.js @@ -107,6 +107,7 @@ function buildIndicesShardStores (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.shrink.js b/api/api/indices.shrink.js index 3b76d6de3..4b2cd1736 100644 --- a/api/api/indices.shrink.js +++ b/api/api/indices.shrink.js @@ -119,6 +119,7 @@ function buildIndicesShrink (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.split.js b/api/api/indices.split.js index 7e7b45d1f..f82c12775 100644 --- a/api/api/indices.split.js +++ b/api/api/indices.split.js @@ -119,6 +119,7 @@ function buildIndicesSplit (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.stats.js b/api/api/indices.stats.js index ce2467410..c3425f2a4 100644 --- a/api/api/indices.stats.js +++ b/api/api/indices.stats.js @@ -118,6 +118,7 @@ function buildIndicesStats (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.unfreeze.js b/api/api/indices.unfreeze.js index d9ef9d2ad..dd2e2e573 100644 --- a/api/api/indices.unfreeze.js +++ b/api/api/indices.unfreeze.js @@ -108,6 +108,7 @@ function buildIndicesUnfreeze (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.update_aliases.js b/api/api/indices.update_aliases.js index cb869edbd..d7a6fdfbb 100644 --- a/api/api/indices.update_aliases.js +++ b/api/api/indices.update_aliases.js @@ -97,6 +97,7 @@ function buildIndicesUpdateAliases (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.upgrade.js b/api/api/indices.upgrade.js index 88894487b..849a1e61e 100644 --- a/api/api/indices.upgrade.js +++ b/api/api/indices.upgrade.js @@ -111,6 +111,7 @@ function buildIndicesUpgrade (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/indices.validate_query.js b/api/api/indices.validate_query.js index 02b9d0786..ae2f60b04 100644 --- a/api/api/indices.validate_query.js +++ b/api/api/indices.validate_query.js @@ -130,6 +130,7 @@ function buildIndicesValidateQuery (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/info.js b/api/api/info.js index 5f8b99a46..4ba638970 100644 --- a/api/api/info.js +++ b/api/api/info.js @@ -91,6 +91,7 @@ function buildInfo (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ingest.delete_pipeline.js b/api/api/ingest.delete_pipeline.js index 73cf41fad..fc7e7d277 100644 --- a/api/api/ingest.delete_pipeline.js +++ b/api/api/ingest.delete_pipeline.js @@ -103,6 +103,7 @@ function buildIngestDeletePipeline (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ingest.get_pipeline.js b/api/api/ingest.get_pipeline.js index c5194f5d4..f723a5ede 100644 --- a/api/api/ingest.get_pipeline.js +++ b/api/api/ingest.get_pipeline.js @@ -99,6 +99,7 @@ function buildIngestGetPipeline (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ingest.processor_grok.js b/api/api/ingest.processor_grok.js index a74871868..68d479bc8 100644 --- a/api/api/ingest.processor_grok.js +++ b/api/api/ingest.processor_grok.js @@ -91,6 +91,7 @@ function buildIngestProcessorGrok (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ingest.put_pipeline.js b/api/api/ingest.put_pipeline.js index 457a43446..e8ad6dade 100644 --- a/api/api/ingest.put_pipeline.js +++ b/api/api/ingest.put_pipeline.js @@ -104,6 +104,7 @@ function buildIngestPutPipeline (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ingest.simulate.js b/api/api/ingest.simulate.js index 88646cb22..86a7ed6ab 100644 --- a/api/api/ingest.simulate.js +++ b/api/api/ingest.simulate.js @@ -99,6 +99,7 @@ function buildIngestSimulate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/mget.js b/api/api/mget.js index 7f145470f..9b824c8da 100644 --- a/api/api/mget.js +++ b/api/api/mget.js @@ -127,6 +127,7 @@ function buildMget (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.close_job.js b/api/api/ml.close_job.js index 8fefaab84..a002e4c28 100644 --- a/api/api/ml.close_job.js +++ b/api/api/ml.close_job.js @@ -93,6 +93,7 @@ function buildMlCloseJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.delete_calendar.js b/api/api/ml.delete_calendar.js index 81c9225ea..d4671be1d 100644 --- a/api/api/ml.delete_calendar.js +++ b/api/api/ml.delete_calendar.js @@ -93,6 +93,7 @@ function buildMlDeleteCalendar (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.delete_calendar_event.js b/api/api/ml.delete_calendar_event.js index b041a90ec..70fd61e2a 100644 --- a/api/api/ml.delete_calendar_event.js +++ b/api/api/ml.delete_calendar_event.js @@ -108,6 +108,7 @@ function buildMlDeleteCalendarEvent (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.delete_calendar_job.js b/api/api/ml.delete_calendar_job.js index 2be5f5fb7..ff6315180 100644 --- a/api/api/ml.delete_calendar_job.js +++ b/api/api/ml.delete_calendar_job.js @@ -108,6 +108,7 @@ function buildMlDeleteCalendarJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.delete_datafeed.js b/api/api/ml.delete_datafeed.js index ed60d1f23..ca4dff876 100644 --- a/api/api/ml.delete_datafeed.js +++ b/api/api/ml.delete_datafeed.js @@ -94,6 +94,7 @@ function buildMlDeleteDatafeed (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.delete_expired_data.js b/api/api/ml.delete_expired_data.js index 614ad1f44..d97d69d5e 100644 --- a/api/api/ml.delete_expired_data.js +++ b/api/api/ml.delete_expired_data.js @@ -86,6 +86,7 @@ function buildMlDeleteExpiredData (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.delete_filter.js b/api/api/ml.delete_filter.js index 0f2e705e2..29e92e9ef 100644 --- a/api/api/ml.delete_filter.js +++ b/api/api/ml.delete_filter.js @@ -93,6 +93,7 @@ function buildMlDeleteFilter (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.delete_forecast.js b/api/api/ml.delete_forecast.js index 0d7943e79..b51697d73 100644 --- a/api/api/ml.delete_forecast.js +++ b/api/api/ml.delete_forecast.js @@ -110,6 +110,7 @@ function buildMlDeleteForecast (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.delete_job.js b/api/api/ml.delete_job.js index cb167cf1e..052557d13 100644 --- a/api/api/ml.delete_job.js +++ b/api/api/ml.delete_job.js @@ -96,6 +96,7 @@ function buildMlDeleteJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.delete_model_snapshot.js b/api/api/ml.delete_model_snapshot.js index ffa300a1a..0cf2877b2 100644 --- a/api/api/ml.delete_model_snapshot.js +++ b/api/api/ml.delete_model_snapshot.js @@ -108,6 +108,7 @@ function buildMlDeleteModelSnapshot (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.find_file_structure.js b/api/api/ml.find_file_structure.js index 203794b29..c5a554fb4 100644 --- a/api/api/ml.find_file_structure.js +++ b/api/api/ml.find_file_structure.js @@ -119,6 +119,7 @@ function buildMlFindFileStructure (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.flush_job.js b/api/api/ml.flush_job.js index 1b230efe3..36e5bfd62 100644 --- a/api/api/ml.flush_job.js +++ b/api/api/ml.flush_job.js @@ -99,6 +99,7 @@ function buildMlFlushJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.forecast.js b/api/api/ml.forecast.js index edd250141..4e3292f69 100644 --- a/api/api/ml.forecast.js +++ b/api/api/ml.forecast.js @@ -96,6 +96,7 @@ function buildMlForecast (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.get_buckets.js b/api/api/ml.get_buckets.js index c96696282..2a2175b22 100644 --- a/api/api/ml.get_buckets.js +++ b/api/api/ml.get_buckets.js @@ -120,6 +120,7 @@ function buildMlGetBuckets (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.get_calendar_events.js b/api/api/ml.get_calendar_events.js index 28d45f003..bf0bcf57e 100644 --- a/api/api/ml.get_calendar_events.js +++ b/api/api/ml.get_calendar_events.js @@ -103,6 +103,7 @@ function buildMlGetCalendarEvents (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.get_calendars.js b/api/api/ml.get_calendars.js index 3c8e4ae09..6c3d27023 100644 --- a/api/api/ml.get_calendars.js +++ b/api/api/ml.get_calendars.js @@ -94,6 +94,7 @@ function buildMlGetCalendars (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.get_categories.js b/api/api/ml.get_categories.js index fc2b281ec..ed871db54 100644 --- a/api/api/ml.get_categories.js +++ b/api/api/ml.get_categories.js @@ -96,6 +96,7 @@ function buildMlGetCategories (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.get_datafeed_stats.js b/api/api/ml.get_datafeed_stats.js index 464989ada..178a52ab6 100644 --- a/api/api/ml.get_datafeed_stats.js +++ b/api/api/ml.get_datafeed_stats.js @@ -92,6 +92,7 @@ function buildMlGetDatafeedStats (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.get_datafeeds.js b/api/api/ml.get_datafeeds.js index a8e4402e5..581c58ddd 100644 --- a/api/api/ml.get_datafeeds.js +++ b/api/api/ml.get_datafeeds.js @@ -92,6 +92,7 @@ function buildMlGetDatafeeds (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.get_filters.js b/api/api/ml.get_filters.js index b671bfe3c..c8437d7e0 100644 --- a/api/api/ml.get_filters.js +++ b/api/api/ml.get_filters.js @@ -94,6 +94,7 @@ function buildMlGetFilters (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.get_influencers.js b/api/api/ml.get_influencers.js index 1ed056d00..91137204a 100644 --- a/api/api/ml.get_influencers.js +++ b/api/api/ml.get_influencers.js @@ -105,6 +105,7 @@ function buildMlGetInfluencers (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.get_job_stats.js b/api/api/ml.get_job_stats.js index dc220fc07..fff403791 100644 --- a/api/api/ml.get_job_stats.js +++ b/api/api/ml.get_job_stats.js @@ -92,6 +92,7 @@ function buildMlGetJobStats (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.get_jobs.js b/api/api/ml.get_jobs.js index 64d26e01a..f380ee13e 100644 --- a/api/api/ml.get_jobs.js +++ b/api/api/ml.get_jobs.js @@ -92,6 +92,7 @@ function buildMlGetJobs (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.get_model_snapshots.js b/api/api/ml.get_model_snapshots.js index baf9e4310..7a56d6ab6 100644 --- a/api/api/ml.get_model_snapshots.js +++ b/api/api/ml.get_model_snapshots.js @@ -112,6 +112,7 @@ function buildMlGetModelSnapshots (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.get_overall_buckets.js b/api/api/ml.get_overall_buckets.js index d47e3fa2f..f4b62e7c1 100644 --- a/api/api/ml.get_overall_buckets.js +++ b/api/api/ml.get_overall_buckets.js @@ -105,6 +105,7 @@ function buildMlGetOverallBuckets (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.get_records.js b/api/api/ml.get_records.js index fdf2c5057..a669f825f 100644 --- a/api/api/ml.get_records.js +++ b/api/api/ml.get_records.js @@ -105,6 +105,7 @@ function buildMlGetRecords (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.info.js b/api/api/ml.info.js index 860f1f2a4..0121cda08 100644 --- a/api/api/ml.info.js +++ b/api/api/ml.info.js @@ -78,6 +78,7 @@ function buildMlInfo (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.open_job.js b/api/api/ml.open_job.js index 6077b8532..db196ceaf 100644 --- a/api/api/ml.open_job.js +++ b/api/api/ml.open_job.js @@ -95,6 +95,7 @@ function buildMlOpenJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.post_calendar_events.js b/api/api/ml.post_calendar_events.js index 8d8bda98b..74cfa6469 100644 --- a/api/api/ml.post_calendar_events.js +++ b/api/api/ml.post_calendar_events.js @@ -94,6 +94,7 @@ function buildMlPostCalendarEvents (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.post_data.js b/api/api/ml.post_data.js index 6d131ed40..9199a03fb 100644 --- a/api/api/ml.post_data.js +++ b/api/api/ml.post_data.js @@ -98,6 +98,7 @@ function buildMlPostData (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.preview_datafeed.js b/api/api/ml.preview_datafeed.js index 8901a0ccb..45d172998 100644 --- a/api/api/ml.preview_datafeed.js +++ b/api/api/ml.preview_datafeed.js @@ -93,6 +93,7 @@ function buildMlPreviewDatafeed (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.put_calendar.js b/api/api/ml.put_calendar.js index 4a70cf521..0225bd77b 100644 --- a/api/api/ml.put_calendar.js +++ b/api/api/ml.put_calendar.js @@ -88,6 +88,7 @@ function buildMlPutCalendar (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.put_calendar_job.js b/api/api/ml.put_calendar_job.js index 17f7d3ca6..55b005f37 100644 --- a/api/api/ml.put_calendar_job.js +++ b/api/api/ml.put_calendar_job.js @@ -108,6 +108,7 @@ function buildMlPutCalendarJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.put_datafeed.js b/api/api/ml.put_datafeed.js index dae7e4811..0a7616390 100644 --- a/api/api/ml.put_datafeed.js +++ b/api/api/ml.put_datafeed.js @@ -94,6 +94,7 @@ function buildMlPutDatafeed (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.put_filter.js b/api/api/ml.put_filter.js index 9fe5e7967..c3dc6d5a7 100644 --- a/api/api/ml.put_filter.js +++ b/api/api/ml.put_filter.js @@ -94,6 +94,7 @@ function buildMlPutFilter (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.put_job.js b/api/api/ml.put_job.js index c75b38431..9a96b02f5 100644 --- a/api/api/ml.put_job.js +++ b/api/api/ml.put_job.js @@ -94,6 +94,7 @@ function buildMlPutJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.revert_model_snapshot.js b/api/api/ml.revert_model_snapshot.js index 9f9167741..1682f4012 100644 --- a/api/api/ml.revert_model_snapshot.js +++ b/api/api/ml.revert_model_snapshot.js @@ -104,6 +104,7 @@ function buildMlRevertModelSnapshot (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.start_datafeed.js b/api/api/ml.start_datafeed.js index 1ecaddc9d..0000dfd7f 100644 --- a/api/api/ml.start_datafeed.js +++ b/api/api/ml.start_datafeed.js @@ -93,6 +93,7 @@ function buildMlStartDatafeed (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.stop_datafeed.js b/api/api/ml.stop_datafeed.js index 2b88f2b66..81e72c478 100644 --- a/api/api/ml.stop_datafeed.js +++ b/api/api/ml.stop_datafeed.js @@ -93,6 +93,7 @@ function buildMlStopDatafeed (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.update_datafeed.js b/api/api/ml.update_datafeed.js index 0cd667d38..bf9a57b50 100644 --- a/api/api/ml.update_datafeed.js +++ b/api/api/ml.update_datafeed.js @@ -94,6 +94,7 @@ function buildMlUpdateDatafeed (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.update_filter.js b/api/api/ml.update_filter.js index ed8c87e4d..9dcd8c001 100644 --- a/api/api/ml.update_filter.js +++ b/api/api/ml.update_filter.js @@ -94,6 +94,7 @@ function buildMlUpdateFilter (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.update_job.js b/api/api/ml.update_job.js index 1c2eda031..862d23245 100644 --- a/api/api/ml.update_job.js +++ b/api/api/ml.update_job.js @@ -94,6 +94,7 @@ function buildMlUpdateJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.update_model_snapshot.js b/api/api/ml.update_model_snapshot.js index 6fc8943c2..7e88a3dd0 100644 --- a/api/api/ml.update_model_snapshot.js +++ b/api/api/ml.update_model_snapshot.js @@ -109,6 +109,7 @@ function buildMlUpdateModelSnapshot (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.validate.js b/api/api/ml.validate.js index b6fcae44d..47c896b70 100644 --- a/api/api/ml.validate.js +++ b/api/api/ml.validate.js @@ -87,6 +87,7 @@ function buildMlValidate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ml.validate_detector.js b/api/api/ml.validate_detector.js index 6829c5922..96713468d 100644 --- a/api/api/ml.validate_detector.js +++ b/api/api/ml.validate_detector.js @@ -87,6 +87,7 @@ function buildMlValidateDetector (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/monitoring.bulk.js b/api/api/monitoring.bulk.js index 53415e9ae..346856d5a 100644 --- a/api/api/monitoring.bulk.js +++ b/api/api/monitoring.bulk.js @@ -99,6 +99,7 @@ function buildMonitoringBulk (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/msearch.js b/api/api/msearch.js index 50b9d1ee7..a2e0f7789 100644 --- a/api/api/msearch.js +++ b/api/api/msearch.js @@ -126,6 +126,7 @@ function buildMsearch (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/msearch_template.js b/api/api/msearch_template.js index 70b51cb3b..a8456490d 100644 --- a/api/api/msearch_template.js +++ b/api/api/msearch_template.js @@ -120,6 +120,7 @@ function buildMsearchTemplate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/mtermvectors.js b/api/api/mtermvectors.js index aa52d2c05..b9953cc80 100644 --- a/api/api/mtermvectors.js +++ b/api/api/mtermvectors.js @@ -129,6 +129,7 @@ function buildMtermvectors (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/nodes.hot_threads.js b/api/api/nodes.hot_threads.js index 6d514706e..eee2e0f9b 100644 --- a/api/api/nodes.hot_threads.js +++ b/api/api/nodes.hot_threads.js @@ -115,6 +115,7 @@ function buildNodesHotThreads (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/nodes.info.js b/api/api/nodes.info.js index dce92830c..5f4b9233c 100644 --- a/api/api/nodes.info.js +++ b/api/api/nodes.info.js @@ -106,6 +106,7 @@ function buildNodesInfo (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/nodes.reload_secure_settings.js b/api/api/nodes.reload_secure_settings.js index 68ee34580..2acbc743c 100644 --- a/api/api/nodes.reload_secure_settings.js +++ b/api/api/nodes.reload_secure_settings.js @@ -98,6 +98,7 @@ function buildNodesReloadSecureSettings (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/nodes.stats.js b/api/api/nodes.stats.js index 1fd5e8de4..86cae3c29 100644 --- a/api/api/nodes.stats.js +++ b/api/api/nodes.stats.js @@ -125,6 +125,7 @@ function buildNodesStats (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/nodes.usage.js b/api/api/nodes.usage.js index d8fed1279..92d8fe319 100644 --- a/api/api/nodes.usage.js +++ b/api/api/nodes.usage.js @@ -103,6 +103,7 @@ function buildNodesUsage (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ping.js b/api/api/ping.js index 1c158919d..394ce04ec 100644 --- a/api/api/ping.js +++ b/api/api/ping.js @@ -91,6 +91,7 @@ function buildPing (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/put_script.js b/api/api/put_script.js index d2f42a925..f7e950890 100644 --- a/api/api/put_script.js +++ b/api/api/put_script.js @@ -119,6 +119,7 @@ function buildPutScript (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/rank_eval.js b/api/api/rank_eval.js index bbeb9d38d..1256d6e29 100644 --- a/api/api/rank_eval.js +++ b/api/api/rank_eval.js @@ -106,6 +106,7 @@ function buildRankEval (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/reindex.js b/api/api/reindex.js index 83fb25f16..aca2e2563 100644 --- a/api/api/reindex.js +++ b/api/api/reindex.js @@ -107,6 +107,7 @@ function buildReindex (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/reindex_rethrottle.js b/api/api/reindex_rethrottle.js index ffc4dffa9..bfefeec6d 100644 --- a/api/api/reindex_rethrottle.js +++ b/api/api/reindex_rethrottle.js @@ -107,6 +107,7 @@ function buildReindexRethrottle (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/render_search_template.js b/api/api/render_search_template.js index 19c34ffaf..9fd9196f4 100644 --- a/api/api/render_search_template.js +++ b/api/api/render_search_template.js @@ -89,6 +89,7 @@ function buildRenderSearchTemplate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/scripts_painless_execute.js b/api/api/scripts_painless_execute.js index d7306b551..aa3c0ca95 100644 --- a/api/api/scripts_painless_execute.js +++ b/api/api/scripts_painless_execute.js @@ -84,6 +84,7 @@ function buildScriptsPainlessExecute (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/scroll.js b/api/api/scroll.js index 466950dde..4d59409af 100644 --- a/api/api/scroll.js +++ b/api/api/scroll.js @@ -97,6 +97,7 @@ function buildScroll (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/search.js b/api/api/search.js index aa59a2310..1fa82d539 100644 --- a/api/api/search.js +++ b/api/api/search.js @@ -205,6 +205,7 @@ function buildSearch (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/search_shards.js b/api/api/search_shards.js index e87adddcf..70466082f 100644 --- a/api/api/search_shards.js +++ b/api/api/search_shards.js @@ -111,6 +111,7 @@ function buildSearchShards (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/search_template.js b/api/api/search_template.js index 06722fd98..d9e5fe3cd 100644 --- a/api/api/search_template.js +++ b/api/api/search_template.js @@ -139,6 +139,7 @@ function buildSearchTemplate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.authenticate.js b/api/api/security.authenticate.js index aa80e1c18..31b408f0b 100644 --- a/api/api/security.authenticate.js +++ b/api/api/security.authenticate.js @@ -86,6 +86,7 @@ function buildSecurityAuthenticate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.change_password.js b/api/api/security.change_password.js index 662f5470c..0c3112980 100644 --- a/api/api/security.change_password.js +++ b/api/api/security.change_password.js @@ -93,6 +93,7 @@ function buildSecurityChangePassword (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.clear_cached_realms.js b/api/api/security.clear_cached_realms.js index c837a1ba0..d511fb190 100644 --- a/api/api/security.clear_cached_realms.js +++ b/api/api/security.clear_cached_realms.js @@ -94,6 +94,7 @@ function buildSecurityClearCachedRealms (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.clear_cached_roles.js b/api/api/security.clear_cached_roles.js index d0f1898ad..beaca6ca9 100644 --- a/api/api/security.clear_cached_roles.js +++ b/api/api/security.clear_cached_roles.js @@ -93,6 +93,7 @@ function buildSecurityClearCachedRoles (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.delete_privileges.js b/api/api/security.delete_privileges.js index c62ae5d41..5e17e192d 100644 --- a/api/api/security.delete_privileges.js +++ b/api/api/security.delete_privileges.js @@ -109,6 +109,7 @@ function buildSecurityDeletePrivileges (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.delete_role.js b/api/api/security.delete_role.js index cb3a4464d..8c387ed19 100644 --- a/api/api/security.delete_role.js +++ b/api/api/security.delete_role.js @@ -94,6 +94,7 @@ function buildSecurityDeleteRole (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.delete_role_mapping.js b/api/api/security.delete_role_mapping.js index 6528203cf..f70b31eb1 100644 --- a/api/api/security.delete_role_mapping.js +++ b/api/api/security.delete_role_mapping.js @@ -94,6 +94,7 @@ function buildSecurityDeleteRoleMapping (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.delete_user.js b/api/api/security.delete_user.js index ca8ac498b..1af9f66e8 100644 --- a/api/api/security.delete_user.js +++ b/api/api/security.delete_user.js @@ -94,6 +94,7 @@ function buildSecurityDeleteUser (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.disable_user.js b/api/api/security.disable_user.js index e4a447521..5d2c2b79b 100644 --- a/api/api/security.disable_user.js +++ b/api/api/security.disable_user.js @@ -88,6 +88,7 @@ function buildSecurityDisableUser (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.enable_user.js b/api/api/security.enable_user.js index e3b12c29e..e2caf9e4c 100644 --- a/api/api/security.enable_user.js +++ b/api/api/security.enable_user.js @@ -88,6 +88,7 @@ function buildSecurityEnableUser (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.get_privileges.js b/api/api/security.get_privileges.js index 04e38fca8..5bd95cf1a 100644 --- a/api/api/security.get_privileges.js +++ b/api/api/security.get_privileges.js @@ -96,6 +96,7 @@ function buildSecurityGetPrivileges (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.get_role.js b/api/api/security.get_role.js index 2c05b4c24..694fbbce4 100644 --- a/api/api/security.get_role.js +++ b/api/api/security.get_role.js @@ -91,6 +91,7 @@ function buildSecurityGetRole (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.get_role_mapping.js b/api/api/security.get_role_mapping.js index 00b0b309e..77c8c8fc3 100644 --- a/api/api/security.get_role_mapping.js +++ b/api/api/security.get_role_mapping.js @@ -91,6 +91,7 @@ function buildSecurityGetRoleMapping (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.get_token.js b/api/api/security.get_token.js index 3ae6fb217..cb157a5b5 100644 --- a/api/api/security.get_token.js +++ b/api/api/security.get_token.js @@ -87,6 +87,7 @@ function buildSecurityGetToken (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.get_user.js b/api/api/security.get_user.js index 6b66fd5d7..b4812af04 100644 --- a/api/api/security.get_user.js +++ b/api/api/security.get_user.js @@ -91,6 +91,7 @@ function buildSecurityGetUser (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.get_user_privileges.js b/api/api/security.get_user_privileges.js index 8730db65f..5c05d70fe 100644 --- a/api/api/security.get_user_privileges.js +++ b/api/api/security.get_user_privileges.js @@ -86,6 +86,7 @@ function buildSecurityGetUserPrivileges (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.has_privileges.js b/api/api/security.has_privileges.js index 494bed435..e6ada91ca 100644 --- a/api/api/security.has_privileges.js +++ b/api/api/security.has_privileges.js @@ -92,6 +92,7 @@ function buildSecurityHasPrivileges (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.invalidate_token.js b/api/api/security.invalidate_token.js index 784137b73..ac37e92d2 100644 --- a/api/api/security.invalidate_token.js +++ b/api/api/security.invalidate_token.js @@ -87,6 +87,7 @@ function buildSecurityInvalidateToken (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.put_privileges.js b/api/api/security.put_privileges.js index 96bac17ba..bccdfff0e 100644 --- a/api/api/security.put_privileges.js +++ b/api/api/security.put_privileges.js @@ -88,6 +88,7 @@ function buildSecurityPutPrivileges (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.put_role.js b/api/api/security.put_role.js index e1f457617..4c7e20942 100644 --- a/api/api/security.put_role.js +++ b/api/api/security.put_role.js @@ -95,6 +95,7 @@ function buildSecurityPutRole (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.put_role_mapping.js b/api/api/security.put_role_mapping.js index 0000d9fea..a14e17e4c 100644 --- a/api/api/security.put_role_mapping.js +++ b/api/api/security.put_role_mapping.js @@ -95,6 +95,7 @@ function buildSecurityPutRoleMapping (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/security.put_user.js b/api/api/security.put_user.js index 1ac211dea..6912834d4 100644 --- a/api/api/security.put_user.js +++ b/api/api/security.put_user.js @@ -95,6 +95,7 @@ function buildSecurityPutUser (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/snapshot.create.js b/api/api/snapshot.create.js index 2566fc106..dd4da1a53 100644 --- a/api/api/snapshot.create.js +++ b/api/api/snapshot.create.js @@ -114,6 +114,7 @@ function buildSnapshotCreate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/snapshot.create_repository.js b/api/api/snapshot.create_repository.js index a6408a229..67469f4e1 100644 --- a/api/api/snapshot.create_repository.js +++ b/api/api/snapshot.create_repository.js @@ -106,6 +106,7 @@ function buildSnapshotCreateRepository (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/snapshot.delete.js b/api/api/snapshot.delete.js index 6032eb950..afcea559e 100644 --- a/api/api/snapshot.delete.js +++ b/api/api/snapshot.delete.js @@ -116,6 +116,7 @@ function buildSnapshotDelete (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/snapshot.delete_repository.js b/api/api/snapshot.delete_repository.js index 06282ccb8..31484d4ea 100644 --- a/api/api/snapshot.delete_repository.js +++ b/api/api/snapshot.delete_repository.js @@ -103,6 +103,7 @@ function buildSnapshotDeleteRepository (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/snapshot.get.js b/api/api/snapshot.get.js index 685a0dedc..5d8a11bd0 100644 --- a/api/api/snapshot.get.js +++ b/api/api/snapshot.get.js @@ -121,6 +121,7 @@ function buildSnapshotGet (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/snapshot.get_repository.js b/api/api/snapshot.get_repository.js index 5f836c6e5..9368aeb30 100644 --- a/api/api/snapshot.get_repository.js +++ b/api/api/snapshot.get_repository.js @@ -101,6 +101,7 @@ function buildSnapshotGetRepository (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/snapshot.restore.js b/api/api/snapshot.restore.js index 352059d9f..038c5333f 100644 --- a/api/api/snapshot.restore.js +++ b/api/api/snapshot.restore.js @@ -114,6 +114,7 @@ function buildSnapshotRestore (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/snapshot.status.js b/api/api/snapshot.status.js index 81281fcce..af4f8a732 100644 --- a/api/api/snapshot.status.js +++ b/api/api/snapshot.status.js @@ -113,6 +113,7 @@ function buildSnapshotStatus (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/snapshot.verify_repository.js b/api/api/snapshot.verify_repository.js index 81a171072..b7fc46044 100644 --- a/api/api/snapshot.verify_repository.js +++ b/api/api/snapshot.verify_repository.js @@ -103,6 +103,7 @@ function buildSnapshotVerifyRepository (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/ssl.certificates.js b/api/api/ssl.certificates.js index 5fd7432ff..f339cae72 100644 --- a/api/api/ssl.certificates.js +++ b/api/api/ssl.certificates.js @@ -86,6 +86,7 @@ function buildSslCertificates (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/tasks.cancel.js b/api/api/tasks.cancel.js index 95a4b488b..1370b5442 100644 --- a/api/api/tasks.cancel.js +++ b/api/api/tasks.cancel.js @@ -103,6 +103,7 @@ function buildTasksCancel (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/tasks.get.js b/api/api/tasks.get.js index d8088c3bc..2611e4841 100644 --- a/api/api/tasks.get.js +++ b/api/api/tasks.get.js @@ -103,6 +103,7 @@ function buildTasksGet (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/tasks.list.js b/api/api/tasks.list.js index a1b0ffacc..cd3d8576d 100644 --- a/api/api/tasks.list.js +++ b/api/api/tasks.list.js @@ -108,6 +108,7 @@ function buildTasksList (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/termvectors.js b/api/api/termvectors.js index 4b31b792f..39f5b7899 100644 --- a/api/api/termvectors.js +++ b/api/api/termvectors.js @@ -130,6 +130,7 @@ function buildTermvectors (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/update.js b/api/api/update.js index 859e476f2..a2890c25a 100644 --- a/api/api/update.js +++ b/api/api/update.js @@ -140,6 +140,7 @@ function buildUpdate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/update_by_query.js b/api/api/update_by_query.js index 95ca38b5f..dab1fc51d 100644 --- a/api/api/update_by_query.js +++ b/api/api/update_by_query.js @@ -190,6 +190,7 @@ function buildUpdateByQuery (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/update_by_query_rethrottle.js b/api/api/update_by_query_rethrottle.js index 64af0aede..5197c1d0f 100644 --- a/api/api/update_by_query_rethrottle.js +++ b/api/api/update_by_query_rethrottle.js @@ -107,6 +107,7 @@ function buildUpdateByQueryRethrottle (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.graph.explore.js b/api/api/xpack.graph.explore.js index 4025b0cd2..2db33d83c 100644 --- a/api/api/xpack.graph.explore.js +++ b/api/api/xpack.graph.explore.js @@ -96,6 +96,7 @@ function buildXpackGraphExplore (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.info.js b/api/api/xpack.info.js index 4f3f706a9..18de196f3 100644 --- a/api/api/xpack.info.js +++ b/api/api/xpack.info.js @@ -87,6 +87,7 @@ function buildXpackInfo (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.license.delete.js b/api/api/xpack.license.delete.js index 663db0779..4ac239693 100644 --- a/api/api/xpack.license.delete.js +++ b/api/api/xpack.license.delete.js @@ -86,6 +86,7 @@ function buildXpackLicenseDelete (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.license.get.js b/api/api/xpack.license.get.js index cbc2ce78c..2f0cd0afd 100644 --- a/api/api/xpack.license.get.js +++ b/api/api/xpack.license.get.js @@ -87,6 +87,7 @@ function buildXpackLicenseGet (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.license.get_basic_status.js b/api/api/xpack.license.get_basic_status.js index bb8290150..ed27c80fb 100644 --- a/api/api/xpack.license.get_basic_status.js +++ b/api/api/xpack.license.get_basic_status.js @@ -86,6 +86,7 @@ function buildXpackLicenseGetBasicStatus (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.license.get_trial_status.js b/api/api/xpack.license.get_trial_status.js index 4bea1caa6..710274f52 100644 --- a/api/api/xpack.license.get_trial_status.js +++ b/api/api/xpack.license.get_trial_status.js @@ -86,6 +86,7 @@ function buildXpackLicenseGetTrialStatus (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.license.post.js b/api/api/xpack.license.post.js index 5b1757e1c..ae2881179 100644 --- a/api/api/xpack.license.post.js +++ b/api/api/xpack.license.post.js @@ -80,6 +80,7 @@ function buildXpackLicensePost (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.license.post_start_basic.js b/api/api/xpack.license.post_start_basic.js index 0d13fdfdc..f7de0dd88 100644 --- a/api/api/xpack.license.post_start_basic.js +++ b/api/api/xpack.license.post_start_basic.js @@ -87,6 +87,7 @@ function buildXpackLicensePostStartBasic (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.license.post_start_trial.js b/api/api/xpack.license.post_start_trial.js index 6d7c2453b..8864567db 100644 --- a/api/api/xpack.license.post_start_trial.js +++ b/api/api/xpack.license.post_start_trial.js @@ -89,6 +89,7 @@ function buildXpackLicensePostStartTrial (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.migration.deprecations.js b/api/api/xpack.migration.deprecations.js index 3cc91e8ff..0321eeb46 100644 --- a/api/api/xpack.migration.deprecations.js +++ b/api/api/xpack.migration.deprecations.js @@ -91,6 +91,7 @@ function buildXpackMigrationDeprecations (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.migration.get_assistance.js b/api/api/xpack.migration.get_assistance.js index 632fe180d..467fbc2d7 100644 --- a/api/api/xpack.migration.get_assistance.js +++ b/api/api/xpack.migration.get_assistance.js @@ -90,6 +90,7 @@ function buildXpackMigrationGetAssistance (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.migration.upgrade.js b/api/api/xpack.migration.upgrade.js index 6d3225fc4..774f603a5 100644 --- a/api/api/xpack.migration.upgrade.js +++ b/api/api/xpack.migration.upgrade.js @@ -88,6 +88,7 @@ function buildXpackMigrationUpgrade (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.rollup.delete_job.js b/api/api/xpack.rollup.delete_job.js index f23b0025f..312723f7f 100644 --- a/api/api/xpack.rollup.delete_job.js +++ b/api/api/xpack.rollup.delete_job.js @@ -87,6 +87,7 @@ function buildXpackRollupDeleteJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.rollup.get_jobs.js b/api/api/xpack.rollup.get_jobs.js index 179f85d45..c7bc1f800 100644 --- a/api/api/xpack.rollup.get_jobs.js +++ b/api/api/xpack.rollup.get_jobs.js @@ -83,6 +83,7 @@ function buildXpackRollupGetJobs (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.rollup.get_rollup_caps.js b/api/api/xpack.rollup.get_rollup_caps.js index 59760de0b..7cb63d6ed 100644 --- a/api/api/xpack.rollup.get_rollup_caps.js +++ b/api/api/xpack.rollup.get_rollup_caps.js @@ -83,6 +83,7 @@ function buildXpackRollupGetRollupCaps (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.rollup.get_rollup_index_caps.js b/api/api/xpack.rollup.get_rollup_index_caps.js index 7e92d5c51..b8374ef76 100644 --- a/api/api/xpack.rollup.get_rollup_index_caps.js +++ b/api/api/xpack.rollup.get_rollup_index_caps.js @@ -87,6 +87,7 @@ function buildXpackRollupGetRollupIndexCaps (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.rollup.put_job.js b/api/api/xpack.rollup.put_job.js index c29e673df..fd76991d3 100644 --- a/api/api/xpack.rollup.put_job.js +++ b/api/api/xpack.rollup.put_job.js @@ -94,6 +94,7 @@ function buildXpackRollupPutJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.rollup.rollup_search.js b/api/api/xpack.rollup.rollup_search.js index 6f527492c..a05ae3919 100644 --- a/api/api/xpack.rollup.rollup_search.js +++ b/api/api/xpack.rollup.rollup_search.js @@ -111,6 +111,7 @@ function buildXpackRollupRollupSearch (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.rollup.start_job.js b/api/api/xpack.rollup.start_job.js index 347be84a4..a50a0e704 100644 --- a/api/api/xpack.rollup.start_job.js +++ b/api/api/xpack.rollup.start_job.js @@ -87,6 +87,7 @@ function buildXpackRollupStartJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.rollup.stop_job.js b/api/api/xpack.rollup.stop_job.js index fc61788e2..6eb6f016c 100644 --- a/api/api/xpack.rollup.stop_job.js +++ b/api/api/xpack.rollup.stop_job.js @@ -91,6 +91,7 @@ function buildXpackRollupStopJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.sql.clear_cursor.js b/api/api/xpack.sql.clear_cursor.js index 2dcda2aff..d89f4daea 100644 --- a/api/api/xpack.sql.clear_cursor.js +++ b/api/api/xpack.sql.clear_cursor.js @@ -87,6 +87,7 @@ function buildXpackSqlClearCursor (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.sql.query.js b/api/api/xpack.sql.query.js index 02af9e2b7..9fd287cb0 100644 --- a/api/api/xpack.sql.query.js +++ b/api/api/xpack.sql.query.js @@ -88,6 +88,7 @@ function buildXpackSqlQuery (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.sql.translate.js b/api/api/xpack.sql.translate.js index 5906ec135..13df0aa43 100644 --- a/api/api/xpack.sql.translate.js +++ b/api/api/xpack.sql.translate.js @@ -87,6 +87,7 @@ function buildXpackSqlTranslate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.usage.js b/api/api/xpack.usage.js index 6640c9b63..a1767e6b8 100644 --- a/api/api/xpack.usage.js +++ b/api/api/xpack.usage.js @@ -87,6 +87,7 @@ function buildXpackUsage (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.watcher.ack_watch.js b/api/api/xpack.watcher.ack_watch.js index 28c83b82b..01e663de3 100644 --- a/api/api/xpack.watcher.ack_watch.js +++ b/api/api/xpack.watcher.ack_watch.js @@ -106,6 +106,7 @@ function buildXpackWatcherAckWatch (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.watcher.activate_watch.js b/api/api/xpack.watcher.activate_watch.js index 9a4d50bc5..5141e58b9 100644 --- a/api/api/xpack.watcher.activate_watch.js +++ b/api/api/xpack.watcher.activate_watch.js @@ -93,6 +93,7 @@ function buildXpackWatcherActivateWatch (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.watcher.deactivate_watch.js b/api/api/xpack.watcher.deactivate_watch.js index db78019ec..99888de1c 100644 --- a/api/api/xpack.watcher.deactivate_watch.js +++ b/api/api/xpack.watcher.deactivate_watch.js @@ -93,6 +93,7 @@ function buildXpackWatcherDeactivateWatch (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.watcher.delete_watch.js b/api/api/xpack.watcher.delete_watch.js index 7aa38e077..021ffcdc3 100644 --- a/api/api/xpack.watcher.delete_watch.js +++ b/api/api/xpack.watcher.delete_watch.js @@ -93,6 +93,7 @@ function buildXpackWatcherDeleteWatch (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.watcher.execute_watch.js b/api/api/xpack.watcher.execute_watch.js index 833d495af..262f49e44 100644 --- a/api/api/xpack.watcher.execute_watch.js +++ b/api/api/xpack.watcher.execute_watch.js @@ -85,6 +85,7 @@ function buildXpackWatcherExecuteWatch (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.watcher.get_watch.js b/api/api/xpack.watcher.get_watch.js index 4122377a4..673f33209 100644 --- a/api/api/xpack.watcher.get_watch.js +++ b/api/api/xpack.watcher.get_watch.js @@ -93,6 +93,7 @@ function buildXpackWatcherGetWatch (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.watcher.put_watch.js b/api/api/xpack.watcher.put_watch.js index 7ccd85ebc..b6efd896f 100644 --- a/api/api/xpack.watcher.put_watch.js +++ b/api/api/xpack.watcher.put_watch.js @@ -91,6 +91,7 @@ function buildXpackWatcherPutWatch (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.watcher.start.js b/api/api/xpack.watcher.start.js index 343bab037..1f442629c 100644 --- a/api/api/xpack.watcher.start.js +++ b/api/api/xpack.watcher.start.js @@ -86,6 +86,7 @@ function buildXpackWatcherStart (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.watcher.stats.js b/api/api/xpack.watcher.stats.js index cc4f02325..37f507530 100644 --- a/api/api/xpack.watcher.stats.js +++ b/api/api/xpack.watcher.stats.js @@ -94,6 +94,7 @@ function buildXpackWatcherStats (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } diff --git a/api/api/xpack.watcher.stop.js b/api/api/xpack.watcher.stop.js index eeb2f2aac..b87b67102 100644 --- a/api/api/xpack.watcher.stop.js +++ b/api/api/xpack.watcher.stop.js @@ -86,6 +86,7 @@ function buildXpackWatcherStop (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + compression: options.compression || false, warnings } From e4669e656dc874b3ced957436627bd471b9a5772 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 12 Feb 2019 16:40:10 +0100 Subject: [PATCH 115/172] Handle compression for streams --- lib/Transport.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Transport.js b/lib/Transport.js index 3123ef0dd..94a1df69f 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -96,7 +96,11 @@ class Transport { headers['Content-Type'] = 'application/json' if (compression === 'gzip') { - params.body = intoStream(params.body).pipe(createGzip()) + if (isStream(params.body) === false) { + params.body = intoStream(params.body).pipe(createGzip()) + } else { + params.body = params.body.pipe(createGzip()) + } headers['Content-Encoding'] = compression } From 2dbf00e8217d2f1764b7a9936d499dab57a520c3 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 12 Feb 2019 16:40:19 +0100 Subject: [PATCH 116/172] Updated test --- test/unit/transport.test.js | 49 ++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index 3cc88c9ce..ad3b4c243 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -1789,7 +1789,54 @@ test('Compress request', t => { }) }) - test('Should throw on invalid compression value', t => { + t.test('gzip stream body', t => { + t.plan(4) + function handler (req, res) { + t.match(req.headers, { + 'content-type': 'application/json', + 'content-encoding': 'gzip' + }) + var json = '' + req + .pipe(createGunzip()) + .on('data', chunk => { json += chunk }) + .on('error', err => t.fail(err)) + .on('end', () => { + t.deepEqual(JSON.parse(json), { you_know: 'for search' }) + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ you_know: 'for search' })) + }) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ Connection }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'POST', + path: '/hello', + body: intoStream(JSON.stringify({ you_know: 'for search' })) + }, { + compression: 'gzip' + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { you_know: 'for search' }) + server.stop() + }) + }) + }) + + t.test('Should throw on invalid compression value', t => { t.plan(2) try { From d4b2d4676bd6be5ee3bae008fb9416a98626667d Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 12 Feb 2019 16:40:33 +0100 Subject: [PATCH 117/172] Added docs --- docs/breaking-changes.asciidoc | 45 +++++++ docs/configuration.asciidoc | 219 ++++++++++++++++++++++++++++++ docs/extend.asciidoc | 63 +++++++++ docs/index.asciidoc | 48 +++++++ docs/typescript.asciidoc | 59 +++++++++ docs/usage.asciidoc | 236 +++++++++++++++++++++++++++++++++ 6 files changed, 670 insertions(+) create mode 100644 docs/breaking-changes.asciidoc create mode 100644 docs/configuration.asciidoc create mode 100644 docs/extend.asciidoc create mode 100644 docs/index.asciidoc create mode 100644 docs/typescript.asciidoc create mode 100644 docs/usage.asciidoc diff --git a/docs/breaking-changes.asciidoc b/docs/breaking-changes.asciidoc new file mode 100644 index 000000000..b9c79bb61 --- /dev/null +++ b/docs/breaking-changes.asciidoc @@ -0,0 +1,45 @@ += Breaking changes coming from the old client + +If you were already using the previous version of this client, the one you used to install with `npm install elasticsearch`, you will encounter some breaking changes. + +*Don't worry!* + +Every breaking change was carefully weighted, and every breaking change has solid reasons to introduce it, furthermore the new codebase has been rewritten with modern JavaScript, and has been carefully designed to be easy to maintain. + +=== Breaking changes + +* Minimum supported version of Node.js is `v6`. + +* Everything has been rewritten using ES6 classes to help users extend more easily the defaults. + +* There is no more an integrated logger. The client now is an event emitter that emits the following events: `request`, `response`, and `error`. + +* The code is no longer shipped with all the versions of the API, but only the same major version of the package. + +* The internals are completely different, so if you used to tweak a lot with them, you will need to refactor your code, while the surface API should be almost the same. + +* No more browser support, for that will be built another module, `@elastic/elasticsearch-browser`. This module is intended for Node.js only. + +* The returned value of an API call will no longer be the `body`, `statusCode`, and `headers` for callbacks and just the `body` for promises. The new returned value will be a unique object containing the `body`, `statusCode`, `headers`, and `warnings`, for both callback and promises. With the `asStream` parameter you can get the original HTTP response stream if the case you need to pipe it to another response for a forwarding use case. + +* Errors: there is no longer a custom error class for every HTTP status code (such as `BadRequest` or `NotFound`), but there is a single `ResponseError` instead. +All the error classes have been renamed, and now all are suffixed with `Error` at the end. + +Errors that have been removed: +`RequestTypeError`, `Generic`, and all the status code specific errors. + +Errors that have been added: +`ConfigurationError` (in case of bad configurations) and `ResponseError`, which contains all the data you may need to handle the specific error, such as `statusCode`, `headers`, `body`, and `message`. + +All the new error classes also have well-defined types. + +Errors that has been renamed: + +** `RequestTimeout` (408 statusCode) => `TimeoutError` +** `ConnectionFault` => `ConnectionError` +** `NoConnections` => `NoLivingConnectionsError` +** `Serialization` => `SerializationError` +** `Serialization` => `DeserializationError` + +* You must specify the port number in the configuration + +* The plugins option has been removed, if you want to extend the client now you should use the client.extend API. +There is a clear distinction between the API related parameters and the client related configurations, the parameters `ignore`, `headers`, `requestTimeout` and `maxRetries` are no longer part of the API object, and you should specify them in a second option object. + +* The `transport.request` method will no longer accept the `query` key, but the `querystring` key instead (which can be a string or an object), furthermore, you need to send a bulk-like request, instead of the `body` key, you should use the `bulkBody` key. Also in this method, the client specific parameters should be passed as a second object. diff --git a/docs/configuration.asciidoc b/docs/configuration.asciidoc new file mode 100644 index 000000000..3e8bad483 --- /dev/null +++ b/docs/configuration.asciidoc @@ -0,0 +1,219 @@ += Client configuration + +The client is designed to be easily configured as you see fit for your needs, following you can see all the possible basic options that you can use to configure it. + +[source,js] +---- +const { Client } = require('@elastic/elasticsearch') + +const client = new Client({ + node: 'http://localhost:9200' + maxRetries: 5, + requestTimeout: 60000, + sniffOnStart: true +}) +---- + +== Basic options +[cols=2*] +|=== +|`node` or `nodes` +a|The Elasticsearch endpoint to use. + +It can be a single string or an array of strings: +[source,js] +---- +node: 'http://localhost:9200' +---- +Or it can be an object (or an array of objects) that represents the node +[source,js] +---- +node: { + url: new URL('http://localhost:9200'), + ssl: 'ssl options', + agent: 'http agent options', + id: 'custom node id', + headers: { 'custom': 'headers' } + roles: { + master: true, + data: true, + ingest: true, + ml: false + } +} +---- + +|`maxRetries` +|`number` - Max number of retries for each request. + +_Default:_ `3` + +|`requestTimeout` +|`number` - Max request timeout for each request. + +_Default:_ `30000` + +|`pingTimeout` +|`number` - Max ping request timeout for each request. + +_Default:_ `3000` + +|`sniffInterval` +|`number, boolean` - Perform a sniff operation every `n` milliseconds. + +_Default:_ `false` + +|`sniffOnStart` +|`boolean` - Perform a sniff once the client is started. + +_Default:_ `false` + +|`sniffEndpoint` +|`string` - Max request timeout for each request. + +_Default:_ `'_nodes/_all/http'` + +|`sniffOnConnectionFault` +|`boolean` - Perform a sniff on connection fault. + +_Default:_ `false` + +|`resurrectStrategy` +|`string` - Configure the node resurrection strategy. + +_Options:_ `'ping'`, `'optimistic'`, `'none'` + +_Default:_ `'ping'` + +|`suggestCompression` +|`boolean` - Adds `accept-encoding` header to every request. + +_Default:_ `false` + +|`compression` +|`string, boolean` - Enables gzip request body compression. + +_Options:_ `'gzip'`, `false` + +_Default:_ `false` + +|`ssl` +|`http.SecureContextOptions` - ssl https://nodejs.org/api/tls.html[configuraton]. + +_Default:_ `null` + +|`agent` +|`http.AgentOptions` - http agent https://nodejs.org/api/http.html#http_new_agent_options[options]. + +_Default:_ `null` + +|`nodeFilter` +a|`function` - Filters which node not to use for a request. + +_Default:_ +[source,js] +---- +function defaultNodeFilter (node) { + // avoid master only nodes + if (node.roles.master === true && + node.roles.data === false && + node.roles.ingest === false) { + return false + } + return true +} +---- + +|`nodeSelector` +a|`function` - custom selection strategy. + +_Options:_ `'round-robin'`, `'random'`, custom function + +_Default:_ `'round-robin'` + +_Custom function example:_ +[source,js] +---- +function nodeSelector (connections) { + const index = calculateIndex() + return connections[index] +} +---- +|=== + +== Advanced configuration +If you need to customize the client behavior heavily, you are in the right place! + +The client allows you to customize the following internals: + +* `Transport` class +* `ConnectionPool` class +* `Connection` class +* `Serializer` class + +=== `Transport` +This class is responsible to perform the request to Elasticsearch and handling errors, it also handle the sniffing. +[source,js] +---- +const { Client, Transport } = require('@elastic/elasticsearch') + +class MyTransport extends Transport { + request (params, options, callback) { + // your code + } +} + +const client = new Client({ + Transport: MyTransport +}) +---- + +Sometimes you just need to inject a little snippet of your code and then continue to use the usual client code, in such case, you should call `super.method`. +[source,js] +---- +class MyTransport extends Transport { + request (params, options, callback) { + // your code + super.request(params, options, callback) + } +} +---- + +=== `ConnectionPool` +This class is responsible for keeping in memory all the Elasticsearch Connection that we are using, there is a single Connection for every node. + +Moreover, the connection pool will handle the resurrection strategies and the updates of the pool. +[source,js] +---- +const { Client, ConnectionPool } = require('@elastic/elasticsearch') + +class MyConnectionPool extends ConnectionPool { + markAlive (connection) { + // your code + super.markAlive(connection) + } +} + +const client = new Client({ + ConnectionPool: MyConnectionPool +}) +---- + +=== `Connection` +This class represents a single Node, it holds every information we have on the node, such as roles, id, URL, custom headers and so on. The actual HTTP request is performed here, this means that if you want to swap the default HTTP client (Node.js core), you should override this class `request` method. +[source,js] +---- +const { Client, Connection } = require('@elastic/elasticsearch') + +class MyConnection extends Connection { + request (params, callback) { + // your code + } +} + +const client = new Client({ + Connection: MyConnection +}) +---- + +=== `Serializer` +This class is responsible of the serialization of every request, it offers the following methods: + +* `serialize(object: any): string;`, serializes request objects +* `deserialize(json: string): any;`, deserializes response strings +* `ndserialize(array: any[]): string;`, serializes bulk request objects +* `qserialize(object: any): string;`, serializes request query parameters + +[source,js] +---- +const { Client, Serializer } = require('@elastic/elasticsearch') + +class MySerializer extends Serializer { + serialize (object) { + // your code + } +} + +const client = new Client({ + Serializer: MySerializer +}) +---- \ No newline at end of file diff --git a/docs/extend.asciidoc b/docs/extend.asciidoc new file mode 100644 index 000000000..98c4390ca --- /dev/null +++ b/docs/extend.asciidoc @@ -0,0 +1,63 @@ += Extend the client + +Sometimes you need to reuse the same logic, or you want to build a custom API to allow you simplify your code. + +The easiest way to achieve that is by extending the client. + +NOTE: You can't override existing methods. + +[source,js] +---- +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ node: 'http://localhost:9200' }) + +client.extend('supersearch', ({ makeRequest, ConfigurationError }) => { + return function supersearch (params, options) { + const { + body, + index, + method, + ...querystring + } = params + + // params validation + if (body == null) { + throw new ConfigurationError('Missing required parameter: body') + } + + // build request object + const request = { + method: method || 'POST', + path: `/${encodeURIComponent(index)}/_search_`, + body, + querystring + } + + // build request options object + const requestOptions = { + ignore: options.ignore || null, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions) + } +}) + +client.extend('utility.index', ({ makeRequest }) => { + return function _index (params, options) { + // your code + } +}) + +client.extend('utility.delete', ({ makeRequest }) => { + return function _delete (params, options) { + // your code + } +}) + +client.supersearch(...) +client.utility.index(...) +client.utility.delete(...) +---- \ No newline at end of file diff --git a/docs/index.asciidoc b/docs/index.asciidoc new file mode 100644 index 000000000..352b06806 --- /dev/null +++ b/docs/index.asciidoc @@ -0,0 +1,48 @@ += @elastic/elasticsearch + +The official Node.js client for Elasticsearch. + +== Features +* One-to-one mapping with REST API. +* Generalized, pluggable architecture. +* Configurable, automatic discovery of cluster nodes. +* Persistent, Keep-Alive connections. +* Load balancing (with pluggable selection strategy) across all available nodes. + +== Install +[source,sh] +---- +npm install @elastic/elasticsearch +---- +By default the latest version of the module will be installed, which is the same version of the current release of Elasticsearch. + +If you need to work with older versions of Elasticsearch, you should install the same version of the client as well. + +For example, if you are using Elasticsearch `v6.5.4`, you will need the client `v6`, and you can easily do that with `npm install @elastic/elasticsearch@6`. + +== Usage +[source,js] +---- +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ node: 'http://localhost:9200' }) + +// promise API +const result = await client.search({ + index: 'my-index', + body: { foo: 'bar' } +}) + +// callback API +client.search({ + index: 'my-index', + body: { foo: 'bar' } +}, (err, result) => { + if (err) console.log(err) +}) +---- + +== Reference +* Client configuration +* Client usage +* API methods +* TypeScript support +* Extend the client +* Breaking changes from old client diff --git a/docs/typescript.asciidoc b/docs/typescript.asciidoc new file mode 100644 index 000000000..e3ed3875f --- /dev/null +++ b/docs/typescript.asciidoc @@ -0,0 +1,59 @@ += TypeScript support + +The client offers a first-class support for TypeScript, since it ships the type definitions for every exposed API. + +While the client offers tyoe definitions for Request parameters, Request bodies and responses are shipped with `any` because there is not an official spec that defines them, so we cannot make guarantees over them (but since they are shipped with `any`, you can easily override them with your own typing definitions). + +NOTE: If you are using TypeScript you will be required to use _snake_case_ style to define the API parameters instead of _camelCase_. + +== How to extend the provided typings? +Extend the provided typings is very straightforward, you should declare a custom `.d.ts` file and then write inside your type extensions, following there is an example of how do it. +[source,ts] +---- +declare module '@elastic/elasticsearch' { + export interface ShardsResponse { + total: number; + successful: number; + failed: number; + skipped: number; + } + + export interface Explanation { + value: number; + description: string; + details: Explanation[]; + } + + export interface SearchResponse { + took: number; + timed_out: boolean; + _scroll_id?: string; + _shards: ShardsResponse; + hits: { + total: number; + max_score: number; + hits: Array<{ + _index: string; + _type: string; + _id: string; + _score: number; + _source: T; + _version?: number; + _explanation?: Explanation; + fields?: any; + highlight?: any; + inner_hits?: any; + matched_queries?: string[]; + sort?: string[]; + }>; + }; + aggregations?: any; + } + + export interface MSearchResponse { + responses?: Array>; + } +} + +export {}; +---- diff --git a/docs/usage.asciidoc b/docs/usage.asciidoc new file mode 100644 index 000000000..733bc6e5c --- /dev/null +++ b/docs/usage.asciidoc @@ -0,0 +1,236 @@ += Usage + +Use the client is pretty straightforward, it supports all the public APIs of Elasticsearch, and every method exposes the same signature. + +[source,js] +---- +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ node: 'http://localhost:9200' }) + +// promise API +const result = await client.search({ + index: 'my-index', + body: { foo: 'bar' } +}) + +// callback API +client.search({ + index: 'my-index', + body: { foo: 'bar' } +}, (err, result) => { + if (err) console.log(err) +}) +---- + +The returned value of every API call is formed as follows: + +[source,ts] +---- +{ + body: object | boolean + statusCode: number + headers: object + warnings: [string] +} +---- + +The above valiue will be returned even if there is an error during the execution of the request, this means that you can safely use the https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment[destructuring assignment]. + +[source,js] +---- +// promise API +const { body } = await client.search({ + index: 'my-index', + body: { foo: 'bar' } +}) + +// callback API +client.search({ + index: 'my-index', + body: { foo: 'bar' } +}, (err, { body }) => { + if (err) console.log(err) +}) +---- + +=== Request specific options +If needed you can pass request specific options in a second object: +[source,js] +---- +// promise API +const result = await client.search({ + index: 'my-index', + body: { foo: 'bar' } +}, { + ignore: [404], + maxRetries: 3 +}) + +// calback API +client.search({ + index: 'my-index', + body: { foo: 'bar' } +}, { + ignore: [404], + maxRetries: 3 +}, (err, { body }) => { + if (err) console.log(err) +}) +---- +The supported request specific options are: +[cols=2*] +|=== +|`ignore` +|`[number]` -  HTTP status codes which should not be considered errors for this request. + +_Default:_ `null` + +|`requestTimeout` +|`number` - Max request timeout for the request, it overrides the client default. + +_Default:_ `30000` + +|`maxRetries` +|`number` - Max number of retries for the request, it overrides the client default. + +_Default:_ `3` + +|`compression` +|`string, boolean` - Enables body compression for the request. + +_Options:_ `false`, `'gzip'` + +_Default:_ `false` + +|`asStream` +|`boolean` - Instead of getting the parsed body back, you will get the raw Node.js stream of data. + +_Default:_ `false` + +|`headers` +|`object` - Custom headers for the request. + +_Default:_ `null` +|=== + +=== Error handling +The client exposes a variety of error objects, that you can use to enhance your error handling. + +You can find all the error objects inside the `errors` key in the client. + +[source,js] +---- +const { errors } = require('@elastic/elasticsearch') +console.log(errors) +---- + +Following you can find the errors exported by the client. +[cols=2*] +|=== +|`ElasticsearchClientErrors` +|Every error inherits from this class, it is the basic error generated by the client. + +|`TimeoutError` +|Generated when a request exceeds the `requestTimeout` option. + +|`ConnectionError` +|Generated when an error occurs during the reequest, it can be a connection error or a malformed stream of data. + +|`NoLivingConnectionsError` +|Generated in case of all connections present in the connection pool are dead. + +|`SerializationError` +|Generated if the serialization fails. + +|`DeserializationError` +|Generated if the deserialization fails. + +|`ConfigurationError` +|Generated if there is a malformed configuration or parameter. + +|`ResponseError` +|Generated when in case of a `4xx` or `5xx` response. +|=== + +=== Events +The client is an event emitter, this means that you can listen for its event and add additional logic to your code, without need to change the client internals or your normal usage. + +You can find the events names by access the `events` key of the client. + +[source,js] +---- +const { events } = require('@elastic/elasticsearch') +console.log(events) +---- + +The client emits the following events: +[cols=2*] +|=== +|`request` +a|Emitted before to send the actual request to Elasticsearch. +[source,js] +---- +client.on('request', (err, meta) => { + console.log(err, meta) +}) +---- +`meta` is an object that contains the following informations: + +* `connection`: the connection instance +* `request`: every parameter that will be sent to Elasticsearch +* `response`: inside this event it will be always `null`. +* `attempts`: how many times the clients has tried to execute this request +* `aborted`: boolean check that is true if the request has been aborted. + +|`response` +a|Emitted before to send the actual request to Elasticsearch. +[source,js] +---- +client.on('response', (err, meta) => { + console.log(err, meta) +}) +---- +`meta` is an object that contains the following informations: + +* `connection`: the connection instance +* `request`: every parameter that will be sent to Elasticsearch +* `response`: the Elasticsearch response. +* `attempts`: how many times the clients has tried to execute this request +* `aborted`: boolean check that is true if the request has been aborted. + +|`sniff` +a|Emitted before to send the actual request to Elasticsearch. +[source,js] +---- +client.on('sniff', (err, meta) => { + console.log(err, meta) +}) +---- +`meta` is an object that contains the following informations: + +* `hosts`: the list of nodes obtained from Elasticsearch +* `reason`: the reason why the sniff was triggered. + +|`resurrect` +a|Emitted before to send the actual request to Elasticsearch. +[source,js] +---- +client.on('resurrect', (err, meta) => { + console.log(err, meta) +}) +---- +`meta` is an object that contains the following informations: + +* `connection`: the connection the client is trying to revive +* `strategy`: the strategy the client is using for reviving the connection +* `isAlive`: boolean value + +|=== + +The event emitter functionality can be useful if you want to log every request, response and error that is happening during the use of the client. + +[source,js] +---- +const logger = require('my-logger')() +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ node: 'http://localhost:9200' }) + +client.on('response', (err, meta) => { + if (err) { + logger.error(err) + } else { + logger.info(meta) + } +}) +---- \ No newline at end of file From 8cd8dd3410f5132ac3d2fe3434a4d5c8986423d4 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 13 Feb 2019 07:51:39 +0100 Subject: [PATCH 118/172] Updated docs indentation and added more examples --- docs/breaking-changes.asciidoc | 126 +++++++++++++++++++++++++++++++-- docs/configuration.asciidoc | 68 +++++++++--------- docs/extend.asciidoc | 72 +++++++++---------- docs/usage.asciidoc | 18 ++--- 4 files changed, 201 insertions(+), 83 deletions(-) diff --git a/docs/breaking-changes.asciidoc b/docs/breaking-changes.asciidoc index b9c79bb61..e70228331 100644 --- a/docs/breaking-changes.asciidoc +++ b/docs/breaking-changes.asciidoc @@ -14,13 +14,43 @@ Every breaking change was carefully weighted, and every breaking change has soli * There is no more an integrated logger. The client now is an event emitter that emits the following events: `request`, `response`, and `error`. -* The code is no longer shipped with all the versions of the API, but only the same major version of the package. +* The code is no longer shipped with all the versions of the API, but only the same major version of the package, this means that if you are using Elasticsearch `v6`, you will be required to install `@elasticelasticsearc@6`, and so on. * The internals are completely different, so if you used to tweak a lot with them, you will need to refactor your code, while the surface API should be almost the same. * No more browser support, for that will be built another module, `@elastic/elasticsearch-browser`. This module is intended for Node.js only. -* The returned value of an API call will no longer be the `body`, `statusCode`, and `headers` for callbacks and just the `body` for promises. The new returned value will be a unique object containing the `body`, `statusCode`, `headers`, and `warnings`, for both callback and promises. With the `asStream` parameter you can get the original HTTP response stream if the case you need to pipe it to another response for a forwarding use case. +* The returned value of an API call will no longer be the `body`, `statusCode`, and `headers` for callbacks and just the `body` for promises. The new returned value will be a unique object containing the `body`, `statusCode`, `headers`, and `warnings`, for both callback and promises. + +With the `asStream` parameter you can get the original HTTP response stream if the case you need to pipe it to another response for a forwarding use case. +[source,js] +---- +// before +const body = await client.search({ + index: 'my-index', + body: { foo: 'bar' } +}) + +client.search({ + index: 'my-index', + body: { foo: 'bar' } +}, (err, body, statusCode, headers) => { + if (err) console.log(err) +}) + +// after +const { body, statusCode, headers, warnings } = await client.search({ + index: 'my-index', + body: { foo: 'bar' } +}) + +client.search({ + index: 'my-index', + body: { foo: 'bar' } +}, (err, { body, statusCode, headers, warnings }) => { + if (err) console.log(err) +}) +---- + * Errors: there is no longer a custom error class for every HTTP status code (such as `BadRequest` or `NotFound`), but there is a single `ResponseError` instead. All the error classes have been renamed, and now all are suffixed with `Error` at the end. + @@ -37,9 +67,97 @@ Errors that has been renamed: ** `Serialization` => `SerializationError` ** `Serialization` => `DeserializationError` -* You must specify the port number in the configuration +* You must specify the port number in the configuration. In the previous version you can specifiy the host and port in a variety of ways, with the new client there is only one via the `node` parameter. * The plugins option has been removed, if you want to extend the client now you should use the client.extend API. -There is a clear distinction between the API related parameters and the client related configurations, the parameters `ignore`, `headers`, `requestTimeout` and `maxRetries` are no longer part of the API object, and you should specify them in a second option object. +[source,js] +---- +// before +const { Client } = require('elasticsearch') +const client = new Client({ plugins: [...] }) + +// after +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ ... }) +client.extend(...) +---- + +* There is a clear distinction between the API related parameters and the client related configurations, the parameters `ignore`, `headers`, `requestTimeout` and `maxRetries` are no longer part of the API object, and you should specify them in a second option object. +[source,js] +---- +// before +const body = await client.search({ + index: 'my-index', + body: { foo: 'bar' }, + ignore: [404] +}) + +client.search({ + index: 'my-index', + body: { foo: 'bar' }, + ignore: [404] +}, (err, body, statusCode, headers) => { + if (err) console.log(err) +}) + +// after +const { body, statusCode, headers, warnings } = await client.search({ + index: 'my-index', + body: { foo: 'bar' } +}, { + ignore: [404] +}) + +client.search({ + index: 'my-index', + body: { foo: 'bar' } +}, { + ignore: [404] +}, (err, { body, statusCode, headers, warnings }) => { + if (err) console.log(err) +}) +---- * The `transport.request` method will no longer accept the `query` key, but the `querystring` key instead (which can be a string or an object), furthermore, you need to send a bulk-like request, instead of the `body` key, you should use the `bulkBody` key. Also in this method, the client specific parameters should be passed as a second object. +[source,js] +---- +// before +const body = await client.transport.request({ + method: 'GET', + path: '/my-index/_search', + body: { foo: 'bar' }, + query: { bar: 'baz' } + ignore: [404] +}) + +client.transport.request({ + method: 'GET', + path: '/my-index/_search', + body: { foo: 'bar' }, + query: { bar: 'baz' } + ignore: [404] +}, (err, body, statusCode, headers) => { + if (err) console.log(err) +}) + +// after +const { body, statusCode, headers, warnings } = await client.transport.request({ + method: 'GET', + path: '/my-index/_search', + body: { foo: 'bar' }, + querystring: { bar: 'baz' } +}, { + ignore: [404] +}) + +client.transport.request({ + method: 'GET', + path: '/my-index/_search', + body: { foo: 'bar' }, + querystring: { bar: 'baz' } +}, { + ignore: [404] +}, (err, { body, statusCode, headers, warnings }) => { + if (err) console.log(err) +}) +---- diff --git a/docs/configuration.asciidoc b/docs/configuration.asciidoc index 3e8bad483..5392cec24 100644 --- a/docs/configuration.asciidoc +++ b/docs/configuration.asciidoc @@ -7,10 +7,10 @@ The client is designed to be easily configured as you see fit for your needs, fo const { Client } = require('@elastic/elasticsearch') const client = new Client({ - node: 'http://localhost:9200' - maxRetries: 5, - requestTimeout: 60000, - sniffOnStart: true + node: 'http://localhost:9200' + maxRetries: 5, + requestTimeout: 60000, + sniffOnStart: true }) ---- @@ -28,17 +28,17 @@ Or it can be an object (or an array of objects) that represents the node [source,js] ---- node: { - url: new URL('http://localhost:9200'), - ssl: 'ssl options', - agent: 'http agent options', - id: 'custom node id', - headers: { 'custom': 'headers' } - roles: { - master: true, - data: true, - ingest: true, - ml: false - } + url: new URL('http://localhost:9200'), + ssl: 'ssl options', + agent: 'http agent options', + id: 'custom node id', + headers: { 'custom': 'headers' } + roles: { + master: true, + data: true, + ingest: true, + ml: false + } } ---- @@ -138,9 +138,9 @@ This class is responsible to perform the request to Elasticsearch and handling e const { Client, Transport } = require('@elastic/elasticsearch') class MyTransport extends Transport { - request (params, options, callback) { - // your code - } + request (params, options, callback) { + // your code + } } const client = new Client({ @@ -152,10 +152,10 @@ Sometimes you just need to inject a little snippet of your code and then continu [source,js] ---- class MyTransport extends Transport { - request (params, options, callback) { - // your code - super.request(params, options, callback) - } + request (params, options, callback) { + // your code + super.request(params, options, callback) + } } ---- @@ -167,10 +167,10 @@ Moreover, the connection pool will handle the resurrection strategies and the up const { Client, ConnectionPool } = require('@elastic/elasticsearch') class MyConnectionPool extends ConnectionPool { - markAlive (connection) { - // your code - super.markAlive(connection) - } + markAlive (connection) { + // your code + super.markAlive(connection) + } } const client = new Client({ @@ -185,13 +185,13 @@ This class represents a single Node, it holds every information we have on the n const { Client, Connection } = require('@elastic/elasticsearch') class MyConnection extends Connection { - request (params, callback) { - // your code - } + request (params, callback) { + // your code + } } const client = new Client({ - Connection: MyConnection + Connection: MyConnection }) ---- @@ -208,12 +208,12 @@ This class is responsible of the serialization of every request, it offers the f const { Client, Serializer } = require('@elastic/elasticsearch') class MySerializer extends Serializer { - serialize (object) { - // your code - } + serialize (object) { + // your code + } } const client = new Client({ - Serializer: MySerializer + Serializer: MySerializer }) ---- \ No newline at end of file diff --git a/docs/extend.asciidoc b/docs/extend.asciidoc index 98c4390ca..643dbb2b5 100644 --- a/docs/extend.asciidoc +++ b/docs/extend.asciidoc @@ -11,50 +11,50 @@ const { Client } = require('@elastic/elasticsearch') const client = new Client({ node: 'http://localhost:9200' }) client.extend('supersearch', ({ makeRequest, ConfigurationError }) => { - return function supersearch (params, options) { - const { - body, - index, - method, - ...querystring - } = params + return function supersearch (params, options) { + const { + body, + index, + method, + ...querystring + } = params - // params validation - if (body == null) { - throw new ConfigurationError('Missing required parameter: body') - } - - // build request object - const request = { - method: method || 'POST', - path: `/${encodeURIComponent(index)}/_search_`, - body, - querystring - } - - // build request options object - const requestOptions = { - ignore: options.ignore || null, - requestTimeout: options.requestTimeout || null, - maxRetries: options.maxRetries || null, - asStream: options.asStream || false, - headers: options.headers || null - } - - return makeRequest(request, requestOptions) + // params validation + if (body == null) { + throw new ConfigurationError('Missing required parameter: body') } + + // build request object + const request = { + method: method || 'POST', + path: `/${encodeURIComponent(index)}/_search_`, + body, + querystring + } + + // build request options object + const requestOptions = { + ignore: options.ignore || null, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions) + } }) client.extend('utility.index', ({ makeRequest }) => { - return function _index (params, options) { - // your code - } + return function _index (params, options) { + // your code + } }) client.extend('utility.delete', ({ makeRequest }) => { - return function _delete (params, options) { - // your code - } + return function _delete (params, options) { + // your code + } }) client.supersearch(...) diff --git a/docs/usage.asciidoc b/docs/usage.asciidoc index 733bc6e5c..15fbf5dc4 100644 --- a/docs/usage.asciidoc +++ b/docs/usage.asciidoc @@ -162,7 +162,7 @@ a|Emitted before to send the actual request to Elasticsearch. [source,js] ---- client.on('request', (err, meta) => { - console.log(err, meta) + console.log(err, meta) }) ---- `meta` is an object that contains the following informations: @@ -178,7 +178,7 @@ a|Emitted before to send the actual request to Elasticsearch. [source,js] ---- client.on('response', (err, meta) => { - console.log(err, meta) + console.log(err, meta) }) ---- `meta` is an object that contains the following informations: @@ -194,7 +194,7 @@ a|Emitted before to send the actual request to Elasticsearch. [source,js] ---- client.on('sniff', (err, meta) => { - console.log(err, meta) + console.log(err, meta) }) ---- `meta` is an object that contains the following informations: @@ -207,7 +207,7 @@ a|Emitted before to send the actual request to Elasticsearch. [source,js] ---- client.on('resurrect', (err, meta) => { - console.log(err, meta) + console.log(err, meta) }) ---- `meta` is an object that contains the following informations: @@ -227,10 +227,10 @@ const { Client } = require('@elastic/elasticsearch') const client = new Client({ node: 'http://localhost:9200' }) client.on('response', (err, meta) => { - if (err) { - logger.error(err) - } else { - logger.info(meta) - } + if (err) { + logger.error(err) + } else { + logger.info(meta) + } }) ---- \ No newline at end of file From 5a18409a6132c6dd86d0b553f637d61b73e5bddd Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 14 Feb 2019 07:57:16 +0100 Subject: [PATCH 119/172] Added documentation generator --- scripts/run.js | 37 +++++++-- scripts/utils/generateDocs.js | 142 ++++++++++++++++++++++++++++++++++ scripts/utils/index.js | 9 ++- 3 files changed, 180 insertions(+), 8 deletions(-) create mode 100644 scripts/utils/generateDocs.js diff --git a/scripts/run.js b/scripts/run.js index 92b63fb8b..016365f2c 100644 --- a/scripts/run.js +++ b/scripts/run.js @@ -7,7 +7,13 @@ const semver = require('semver') const ora = require('ora') const rimraf = require('rimraf') const standard = require('standard') -const { generate, cloneAndCheckout, genFactory, generateRequestTypes } = require('./utils') +const { + generate, + cloneAndCheckout, + genFactory, + generateRequestTypes, + generateDocs +} = require('./utils') start(minimist(process.argv.slice(2), { string: ['tag'] @@ -23,6 +29,7 @@ function start (opts) { const apiOutputFolder = join(packageFolder, 'api') const mainOutputFile = join(packageFolder, 'index.js') const typesOutputFile = join(packageFolder, 'generated.d.ts') + const docOutputFile = join(__dirname, '..', 'docs', 'reference.asciidoc') const requestParamsOutputFile = join(packageFolder, 'requestParams.d.ts') const allSpec = [] @@ -35,8 +42,11 @@ function start (opts) { return } - readdirSync(apiFolder).forEach(generateApiFile(apiFolder, log)) - readdirSync(xPackFolder).forEach(generateApiFile(xPackFolder, log)) + const apiFolderContents = readdirSync(apiFolder) + const xPackFolderContents = readdirSync(xPackFolder) + + apiFolderContents.forEach(generateApiFile(apiFolder, log)) + xPackFolderContents.forEach(generateApiFile(xPackFolder, log)) writeFileSync( requestParamsOutputFile, @@ -55,7 +65,21 @@ function start (opts) { types, { encoding: 'utf8' } ) - lintFiles(log) + + lintFiles(log, () => { + log.text = 'Generating documentation' + const allSpec = apiFolderContents.filter(f => f !== '_common.json') + .map(f => require(join(apiFolder, f))) + .concat(xPackFolderContents.map(f => require(join(xPackFolder, f)))) + writeFileSync( + docOutputFile, + generateDocs(require(join(apiFolder, '_common.json')), allSpec), + { encoding: 'utf8' } + ) + + log.succeed('Done!') + console.log('Remember to copy the generated types into the index.d.ts file') + }) }) function generateApiFile (apiFolder, log) { @@ -77,15 +101,14 @@ function start (opts) { } } - function lintFiles (log) { + function lintFiles (log, cb) { log.text = 'Linting...' const files = [join(packageFolder, '*.js'), join(apiOutputFolder, '*.js')] standard.lintFiles(files, { fix: true }, err => { if (err) { return log.fail(err.message) } - log.succeed('Done!') - console.log('Remember to copy the generated types into the index.d.ts file') + cb() }) } } diff --git a/scripts/utils/generateDocs.js b/scripts/utils/generateDocs.js new file mode 100644 index 000000000..48df3be4a --- /dev/null +++ b/scripts/utils/generateDocs.js @@ -0,0 +1,142 @@ +'use strict' + +const dedent = require('dedent') + +function generateDocs (common, spec) { + var doc = '= API Reference\n\n' + doc += commonParameters(common) + spec.forEach(s => { + doc += '\n' + generateApiDoc(s) + }) + return doc +} + +function commonParameters (spec) { + var doc = dedent` + === Common parameters + Parameters that are accepted by all API endpoints. + https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html + [cols=2*] + |===\n` + Object.keys(spec.params).forEach(key => { + const name = isSnakeCased(key) && key !== camelify(key) + ? '`' + key + '` or `' + camelify(key) + '`' + : '`' + key + '`' + + doc += dedent` + |${name} + |${'`' + spec.params[key].type + '`'} - ${spec.params[key].description}` + if (spec.params[key].default) { + doc += ` + + _Default:_ ${'`' + spec.params[key].default + '`'}` + } + doc += '\n\n' + }) + + doc += dedent` + |=== + ` + return doc +} + +function generateApiDoc (spec) { + const name = Object.keys(spec)[0] + const documentationUrl = spec[name].documentation + const params = [] + // url params + const urlParts = spec[name].url.parts + if (urlParts) { + Object.keys(urlParts).forEach(param => { + params.push({ + name: param, + type: getType(urlParts[param].type, urlParts[param].options), + description: urlParts[param].description, + default: urlParts[param].default + }) + }) + } + + // query params + const urlParams = spec[name].url.params + if (urlParams) { + Object.keys(urlParams).forEach(param => { + params.push({ + name: param, + type: getType(urlParams[param].type, urlParams[param].options), + description: urlParams[param].description, + default: urlParams[param].default + }) + }) + } + + // body params + const body = spec[name].body + if (body) { + params.push({ + name: 'body', + type: 'object', + description: body.description, + default: body.default + }) + } + + var doc = dedent` + === ${camelify(name)} + [source,js] + ---- + client.${camelify(name)}([params] [, options] [, callback]) + ---- + ${documentationUrl || ''} + [cols=2*] + |===` + + doc += '\n' + params.reduce((acc, val) => { + const name = isSnakeCased(val.name) && val.name !== camelify(val.name) + ? '`' + val.name + '` or `' + camelify(val.name) + '`' + : '`' + val.name + '`' + acc += dedent` + |${name} + |${'`' + val.type + '`'} - ${val.description}` + if (val.default) { + acc += ` + + _Default:_ ${'`' + val.default + '`'}` + } + return acc + '\n\n' + }, '') + + doc += dedent` + |=== + ` + return doc +} + +function getType (type, options) { + switch (type) { + case 'list': + return 'string, string[]' + case 'date': + case 'time': + case 'timeout': + return 'string' + case 'enum': + return options.map(k => `'${k}'`).join(', ') + case 'int': + case 'double': + case 'long': + return 'number' + default: + return type + } +} + +function camelify (str) { + return str[0] === '_' + ? '_' + str.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase()) + : str.replace(/_([a-z])/g, k => k[1].toUpperCase()) +} + +function isSnakeCased (str) { + return !!~str.indexOf('_') +} + +module.exports = generateDocs diff --git a/scripts/utils/index.js b/scripts/utils/index.js index 6993895f7..b76bf7586 100644 --- a/scripts/utils/index.js +++ b/scripts/utils/index.js @@ -4,5 +4,12 @@ const generate = require('./generate') const generateRequestTypes = require('./generateRequestTypes') const cloneAndCheckout = require('./clone-es') const genFactory = require('./genMain') +const generateDocs = require('./generateDocs') -module.exports = { generate, cloneAndCheckout, genFactory, generateRequestTypes } +module.exports = { + generate, + cloneAndCheckout, + genFactory, + generateRequestTypes, + generateDocs +} From 6d68d22e32ffaf55f9c8185c79f0ee2237b76d50 Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 14 Feb 2019 07:57:29 +0100 Subject: [PATCH 120/172] Added API reference --- docs/reference.asciidoc | 5973 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 5973 insertions(+) create mode 100644 docs/reference.asciidoc diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc new file mode 100644 index 000000000..0cbf273ca --- /dev/null +++ b/docs/reference.asciidoc @@ -0,0 +1,5973 @@ += API Reference + +=== Common parameters +Parameters that are accepted by all API endpoints. +https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html +[cols=2*] +|=== +|`pretty` +|`boolean` - Pretty format the returned JSON response. + +|`human` +|`boolean` - Return human readable values for statistics. + + _Default:_ `true` + +|`error_trace` or `errorTrace` +|`boolean` - Include the stack trace of returned errors. + +|`source` +|`string` - The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests. + +|`filter_path` or `filterPath` +|`list` - A comma-separated list of filters used to reduce the response. + +|=== +=== bulk +[source,js] +---- +client.bulk([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html +[cols=2*] +|=== +|`index` +|`string` - Default index for items which don't provide one + +|`type` +|`string` - Default document type for items which don't provide one + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + +|`refresh` +|`'true', 'false', 'wait_for'` - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + +|`routing` +|`string` - Specific routing value + +|`timeout` +|`string` - Explicit operation timeout + +|`type` +|`string` - Default document type for items which don't provide one + +|`_source` +|`string, string[]` - True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request + +|`_source_excludes` or `_sourceExcludes` +|`string, string[]` - Default list of fields to exclude from the returned _source field, can be overridden on each sub-request + +|`_source_includes` or `_sourceIncludes` +|`string, string[]` - Default list of fields to extract and return from the _source field, can be overridden on each sub-request + +|`pipeline` +|`string` - The pipeline id to preprocess incoming documents with + +|`body` +|`object` - The operation definition and data (action-data pairs), separated by newlines + +|=== +=== cat.aliases +[source,js] +---- +client.cat.aliases([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-alias.html +[cols=2*] +|=== +|`name` +|`string, string[]` - A comma-separated list of alias names to return + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string, string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string, string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== +=== cat.allocation +[source,js] +---- +client.cat.allocation([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-allocation.html +[cols=2*] +|=== +|`node_id` or `nodeId` +|`string, string[]` - A comma-separated list of node IDs or names to limit the returned information + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`bytes` +|`'b', 'k', 'kb', 'm', 'mb', 'g', 'gb', 't', 'tb', 'p', 'pb'` - The unit in which to display byte values + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string, string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string, string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== +=== cat.count +[source,js] +---- +client.cat.count([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-count.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names to limit the returned information + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string, string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string, string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== +=== cat.fielddata +[source,js] +---- +client.cat.fielddata([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-fielddata.html +[cols=2*] +|=== +|`fields` +|`string, string[]` - A comma-separated list of fields to return the fielddata size + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`bytes` +|`'b', 'k', 'kb', 'm', 'mb', 'g', 'gb', 't', 'tb', 'p', 'pb'` - The unit in which to display byte values + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string, string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string, string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|`fields` +|`string, string[]` - A comma-separated list of fields to return in the output + +|=== +=== cat.health +[source,js] +---- +client.cat.health([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-health.html +[cols=2*] +|=== +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string, string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string, string[]` - Comma-separated list of column names or column aliases to sort by + +|`ts` +|`boolean` - Set to false to disable timestamping + + _Default:_ `true` + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== +=== cat.help +[source,js] +---- +client.cat.help([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cat.html +[cols=2*] +|=== +|`help` +|`boolean` - Return help information + +|`s` +|`string, string[]` - Comma-separated list of column names or column aliases to sort by + +|=== +=== cat.indices +[source,js] +---- +client.cat.indices([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-indices.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names to limit the returned information + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`bytes` +|`'b', 'k', 'm', 'g'` - The unit in which to display byte values + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string, string[]` - Comma-separated list of column names to display + +|`health` +|`'green', 'yellow', 'red'` - A health status ("green", "yellow", or "red" to filter only indices matching the specified health status + +|`help` +|`boolean` - Return help information + +|`pri` +|`boolean` - Set to true to return stats only for primary shards + +|`s` +|`string, string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== +=== cat.master +[source,js] +---- +client.cat.master([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-master.html +[cols=2*] +|=== +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string, string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string, string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== +=== cat.nodeattrs +[source,js] +---- +client.cat.nodeattrs([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodeattrs.html +[cols=2*] +|=== +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string, string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string, string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== +=== cat.nodes +[source,js] +---- +client.cat.nodes([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodes.html +[cols=2*] +|=== +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`full_id` or `fullId` +|`boolean` - Return the full node ID instead of the shortened version (default: false) + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string, string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string, string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== +=== cat.pendingTasks +[source,js] +---- +client.cat.pendingTasks([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-pending-tasks.html +[cols=2*] +|=== +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string, string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string, string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== +=== cat.plugins +[source,js] +---- +client.cat.plugins([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-plugins.html +[cols=2*] +|=== +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string, string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string, string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== +=== cat.recovery +[source,js] +---- +client.cat.recovery([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-recovery.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names to limit the returned information + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`bytes` +|`'b', 'k', 'kb', 'm', 'mb', 'g', 'gb', 't', 'tb', 'p', 'pb'` - The unit in which to display byte values + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string, string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string, string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== +=== cat.repositories +[source,js] +---- +client.cat.repositories([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-repositories.html +[cols=2*] +|=== +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string, string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string, string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== +=== cat.segments +[source,js] +---- +client.cat.segments([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-segments.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names to limit the returned information + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`bytes` +|`'b', 'k', 'kb', 'm', 'mb', 'g', 'gb', 't', 'tb', 'p', 'pb'` - The unit in which to display byte values + +|`h` +|`string, string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string, string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== +=== cat.shards +[source,js] +---- +client.cat.shards([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-shards.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names to limit the returned information + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`bytes` +|`'b', 'k', 'kb', 'm', 'mb', 'g', 'gb', 't', 'tb', 'p', 'pb'` - The unit in which to display byte values + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string, string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string, string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== +=== cat.snapshots +[source,js] +---- +client.cat.snapshots([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-snapshots.html +[cols=2*] +|=== +|`repository` +|`string, string[]` - Name of repository from which to fetch the snapshot information + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Set to true to ignore unavailable snapshots + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string, string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string, string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== +=== cat.tasks +[source,js] +---- +client.cat.tasks([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html +[cols=2*] +|=== +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`node_id` or `nodeId` +|`string, string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +|`actions` +|`string, string[]` - A comma-separated list of actions that should be returned. Leave empty to return all. + +|`detailed` +|`boolean` - Return detailed task information (default: false) + +|`parent_task` or `parentTask` +|`number` - Return tasks with specified parent task id. Set to -1 to return all. + +|`h` +|`string, string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string, string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== +=== cat.templates +[source,js] +---- +client.cat.templates([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-templates.html +[cols=2*] +|=== +|`name` +|`string` - A pattern that returned template names must match + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string, string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string, string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== +=== cat.threadPool +[source,js] +---- +client.cat.threadPool([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-thread-pool.html +[cols=2*] +|=== +|`thread_pool_patterns` or `threadPoolPatterns` +|`string, string[]` - A comma-separated list of regular-expressions to filter the thread pools in the output + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`size` +|`'', 'k', 'm', 'g', 't', 'p'` - The multiplier in which to display values + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string, string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string, string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== +=== clearScroll +[source,js] +---- +client.clearScroll([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-scroll.html +[cols=2*] +|=== +|`scroll_id` or `scrollId` +|`string, string[]` - A comma-separated list of scroll IDs to clear + +|`body` +|`object` - A comma-separated list of scroll IDs to clear if none was specified via the scroll_id parameter + +|=== +=== cluster.allocationExplain +[source,js] +---- +client.cluster.allocationExplain([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-allocation-explain.html +[cols=2*] +|=== +|`include_yes_decisions` or `includeYesDecisions` +|`boolean` - Return 'YES' decisions in explanation (default: false) + +|`include_disk_info` or `includeDiskInfo` +|`boolean` - Return information about disk usage and shard sizes (default: false) + +|`body` +|`object` - The index, shard, and primary flag to explain. Empty means 'explain the first unassigned shard' + +|=== +=== cluster.getSettings +[source,js] +---- +client.cluster.getSettings([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html +[cols=2*] +|=== +|`flat_settings` or `flatSettings` +|`boolean` - Return settings in flat format (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`timeout` +|`string` - Explicit operation timeout + +|`include_defaults` or `includeDefaults` +|`boolean` - Whether to return all default clusters setting. + +|=== +=== cluster.health +[source,js] +---- +client.cluster.health([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-health.html +[cols=2*] +|=== +|`index` +|`string, string[]` - Limit the information returned to a specific index + +|`level` +|`'cluster', 'indices', 'shards'` - Specify the level of detail for returned information + + _Default:_ `cluster` + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`timeout` +|`string` - Explicit operation timeout + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Wait until the specified number of shards is active + +|`wait_for_nodes` or `waitForNodes` +|`string` - Wait until the specified number of nodes is available + +|`wait_for_events` or `waitForEvents` +|`'immediate', 'urgent', 'high', 'normal', 'low', 'languid'` - Wait until all currently queued events with the given priority are processed + +|`wait_for_no_relocating_shards` or `waitForNoRelocatingShards` +|`boolean` - Whether to wait until there are no relocating shards in the cluster + +|`wait_for_no_initializing_shards` or `waitForNoInitializingShards` +|`boolean` - Whether to wait until there are no initializing shards in the cluster + +|`wait_for_status` or `waitForStatus` +|`'green', 'yellow', 'red'` - Wait until cluster is in a specific state + +|=== +=== cluster.pendingTasks +[source,js] +---- +client.cluster.pendingTasks([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-pending.html +[cols=2*] +|=== +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|=== +=== cluster.putSettings +[source,js] +---- +client.cluster.putSettings([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html +[cols=2*] +|=== +|`flat_settings` or `flatSettings` +|`boolean` - Return settings in flat format (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`timeout` +|`string` - Explicit operation timeout + +|`body` +|`object` - The settings to be updated. Can be either `transient` or `persistent` (survives cluster restart). + +|=== +=== cluster.remoteInfo +[source,js] +---- +client.cluster.remoteInfo([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-remote-info.html +[cols=2*] +|=== +|=== +=== cluster.reroute +[source,js] +---- +client.cluster.reroute([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-reroute.html +[cols=2*] +|=== +|`dry_run` or `dryRun` +|`boolean` - Simulate the operation only and return the resulting state + +|`explain` +|`boolean` - Return an explanation of why the commands can or cannot be executed + +|`retry_failed` or `retryFailed` +|`boolean` - Retries allocation of shards that are blocked due to too many subsequent allocation failures + +|`metric` +|`string, string[]` - Limit the information returned to the specified metrics. Defaults to all but metadata + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`timeout` +|`string` - Explicit operation timeout + +|`body` +|`object` - The definition of `commands` to perform (`move`, `cancel`, `allocate`) + +|=== +=== cluster.state +[source,js] +---- +client.cluster.state([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-state.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + +|`metric` +|`string, string[]` - Limit the information returned to the specified metrics + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`flat_settings` or `flatSettings` +|`boolean` - Return settings in flat format (default: false) + +|`wait_for_metadata_version` or `waitForMetadataVersion` +|`number` - Wait for the metadata version to be equal or greater than the specified metadata version + +|`wait_for_timeout` or `waitForTimeout` +|`string` - The maximum time to wait for wait_for_metadata_version before timing out + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|=== +=== cluster.stats +[source,js] +---- +client.cluster.stats([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-stats.html +[cols=2*] +|=== +|`node_id` or `nodeId` +|`string, string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +|`flat_settings` or `flatSettings` +|`boolean` - Return settings in flat format (default: false) + +|`timeout` +|`string` - Explicit operation timeout + +|=== +=== count +[source,js] +---- +client.count([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/search-count.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of indices to restrict the results + +|`type` +|`string, string[]` - A comma-separated list of types to restrict the results + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`ignore_throttled` or `ignoreThrottled` +|`boolean` - Whether specified concrete, expanded or aliased indices should be ignored when throttled + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|`min_score` or `minScore` +|`number` - Include only documents with a specific `_score` value in the result + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`routing` +|`string, string[]` - A comma-separated list of specific routing values + +|`q` +|`string` - Query in the Lucene query string syntax + +|`analyzer` +|`string` - The analyzer to use for the query string + +|`analyze_wildcard` or `analyzeWildcard` +|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) + +|`default_operator` or `defaultOperator` +|`'AND', 'OR'` - The default operator for query string query (AND or OR) + + _Default:_ `OR` + +|`df` +|`string` - The field to use as default where no field prefix is given in the query string + +|`lenient` +|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + +|`terminate_after` or `terminateAfter` +|`number` - The maximum count for each shard, upon reaching which the query execution will terminate early + +|`body` +|`object` - A query to restrict the results specified with the Query DSL (optional) + +|=== +=== create +[source,js] +---- +client.create([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html +[cols=2*] +|=== +|`id` +|`string` - Document ID + +|`index` +|`string` - The name of the index + +|`type` +|`string` - The type of the document + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + +|`parent` +|`string` - ID of the parent document + +|`refresh` +|`'true', 'false', 'wait_for'` - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + +|`routing` +|`string` - Specific routing value + +|`timeout` +|`string` - Explicit operation timeout + +|`version` +|`number` - Explicit version number for concurrency control + +|`version_type` or `versionType` +|`'internal', 'external', 'external_gte', 'force'` - Specific version type + +|`pipeline` +|`string` - The pipeline id to preprocess incoming documents with + +|`body` +|`object` - The document + +|=== +=== delete +[source,js] +---- +client.delete([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete.html +[cols=2*] +|=== +|`id` +|`string` - The document ID + +|`index` +|`string` - The name of the index + +|`type` +|`string` - The type of the document + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + +|`parent` +|`string` - ID of parent document + +|`refresh` +|`'true', 'false', 'wait_for'` - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + +|`routing` +|`string` - Specific routing value + +|`timeout` +|`string` - Explicit operation timeout + +|`version` +|`number` - Explicit version number for concurrency control + +|`version_type` or `versionType` +|`'internal', 'external', 'external_gte', 'force'` - Specific version type + +|=== +=== deleteByQuery +[source,js] +---- +client.deleteByQuery([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`type` +|`string, string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types + +|`analyzer` +|`string` - The analyzer to use for the query string + +|`analyze_wildcard` or `analyzeWildcard` +|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) + +|`default_operator` or `defaultOperator` +|`'AND', 'OR'` - The default operator for query string query (AND or OR) + + _Default:_ `OR` + +|`df` +|`string` - The field to use as default where no field prefix is given in the query string + +|`from` +|`number` - Starting offset (default: 0) + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`conflicts` +|`'abort', 'proceed'` - What to do when the delete by query hits version conflicts? + + _Default:_ `abort` + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|`lenient` +|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`q` +|`string` - Query in the Lucene query string syntax + +|`routing` +|`string, string[]` - A comma-separated list of specific routing values + +|`scroll` +|`string` - Specify how long a consistent view of the index should be maintained for scrolled search + +|`search_type` or `searchType` +|`'query_then_fetch', 'dfs_query_then_fetch'` - Search operation type + +|`search_timeout` or `searchTimeout` +|`string` - Explicit timeout for each search request. Defaults to no timeout. + +|`size` +|`number` - Number of hits to return (default: 10) + +|`sort` +|`string, string[]` - A comma-separated list of : pairs + +|`_source` +|`string, string[]` - True or false to return the _source field or not, or a list of fields to return + +|`_source_excludes` or `_sourceExcludes` +|`string, string[]` - A list of fields to exclude from the returned _source field + +|`_source_includes` or `_sourceIncludes` +|`string, string[]` - A list of fields to extract and return from the _source field + +|`terminate_after` or `terminateAfter` +|`number` - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + +|`stats` +|`string, string[]` - Specific 'tag' of the request for logging and statistical purposes + +|`version` +|`boolean` - Specify whether to return document version as part of a hit + +|`request_cache` or `requestCache` +|`boolean` - Specify if request cache should be used for this request or not, defaults to index level setting + +|`refresh` +|`boolean` - Should the effected indexes be refreshed? + +|`timeout` +|`string` - Time each individual bulk request should wait for shards that are unavailable. + + _Default:_ `1m` + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + +|`scroll_size` or `scrollSize` +|`number` - Size on the scroll request powering the delete by query + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Should the request should block until the delete by query is complete. + + _Default:_ `true` + +|`requests_per_second` or `requestsPerSecond` +|`number` - The throttle for this request in sub-requests per second. -1 means no throttle. + +|`slices` +|`number` - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. + + _Default:_ `1` + +|`body` +|`object` - The search definition using the Query DSL + +|=== +=== deleteByQueryRethrottle +[source,js] +---- +client.deleteByQueryRethrottle([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html +[cols=2*] +|=== +|`task_id` or `taskId` +|`string` - The task id to rethrottle + +|`requests_per_second` or `requestsPerSecond` +|`number` - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. + +|=== +=== deleteScript +[source,js] +---- +client.deleteScript([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html +[cols=2*] +|=== +|`id` +|`string` - Script ID + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|=== +=== exists +[source,js] +---- +client.exists([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html +[cols=2*] +|=== +|`id` +|`string` - The document ID + +|`index` +|`string` - The name of the index + +|`type` +|`string` - The type of the document (use `_all` to fetch the first document matching the ID across all types) + +|`stored_fields` or `storedFields` +|`string, string[]` - A comma-separated list of stored fields to return in the response + +|`parent` +|`string` - The ID of the parent document + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`realtime` +|`boolean` - Specify whether to perform the operation in realtime or search mode + +|`refresh` +|`boolean` - Refresh the shard containing the document before performing the operation + +|`routing` +|`string` - Specific routing value + +|`_source` +|`string, string[]` - True or false to return the _source field or not, or a list of fields to return + +|`_source_excludes` or `_sourceExcludes` +|`string, string[]` - A list of fields to exclude from the returned _source field + +|`_source_includes` or `_sourceIncludes` +|`string, string[]` - A list of fields to extract and return from the _source field + +|`version` +|`number` - Explicit version number for concurrency control + +|`version_type` or `versionType` +|`'internal', 'external', 'external_gte', 'force'` - Specific version type + +|=== +=== existsSource +[source,js] +---- +client.existsSource([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html +[cols=2*] +|=== +|`id` +|`string` - The document ID + +|`index` +|`string` - The name of the index + +|`type` +|`string` - The type of the document; use `_all` to fetch the first document matching the ID across all types + +|`parent` +|`string` - The ID of the parent document + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`realtime` +|`boolean` - Specify whether to perform the operation in realtime or search mode + +|`refresh` +|`boolean` - Refresh the shard containing the document before performing the operation + +|`routing` +|`string` - Specific routing value + +|`_source` +|`string, string[]` - True or false to return the _source field or not, or a list of fields to return + +|`_source_excludes` or `_sourceExcludes` +|`string, string[]` - A list of fields to exclude from the returned _source field + +|`_source_includes` or `_sourceIncludes` +|`string, string[]` - A list of fields to extract and return from the _source field + +|`version` +|`number` - Explicit version number for concurrency control + +|`version_type` or `versionType` +|`'internal', 'external', 'external_gte', 'force'` - Specific version type + +|=== +=== explain +[source,js] +---- +client.explain([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/search-explain.html +[cols=2*] +|=== +|`id` +|`string` - The document ID + +|`index` +|`string` - The name of the index + +|`type` +|`string` - The type of the document + +|`analyze_wildcard` or `analyzeWildcard` +|`boolean` - Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false) + +|`analyzer` +|`string` - The analyzer for the query string query + +|`default_operator` or `defaultOperator` +|`'AND', 'OR'` - The default operator for query string query (AND or OR) + + _Default:_ `OR` + +|`df` +|`string` - The default field for query string query (default: _all) + +|`stored_fields` or `storedFields` +|`string, string[]` - A comma-separated list of stored fields to return in the response + +|`lenient` +|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + +|`parent` +|`string` - The ID of the parent document + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`q` +|`string` - Query in the Lucene query string syntax + +|`routing` +|`string` - Specific routing value + +|`_source` +|`string, string[]` - True or false to return the _source field or not, or a list of fields to return + +|`_source_excludes` or `_sourceExcludes` +|`string, string[]` - A list of fields to exclude from the returned _source field + +|`_source_includes` or `_sourceIncludes` +|`string, string[]` - A list of fields to extract and return from the _source field + +|`body` +|`object` - The query definition using the Query DSL + +|=== +=== fieldCaps +[source,js] +---- +client.fieldCaps([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + +|`fields` +|`string, string[]` - A comma-separated list of field names + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|=== +=== get +[source,js] +---- +client.get([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html +[cols=2*] +|=== +|`id` +|`string` - The document ID + +|`index` +|`string` - The name of the index + +|`type` +|`string` - The type of the document (use `_all` to fetch the first document matching the ID across all types) + +|`stored_fields` or `storedFields` +|`string, string[]` - A comma-separated list of stored fields to return in the response + +|`parent` +|`string` - The ID of the parent document + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`realtime` +|`boolean` - Specify whether to perform the operation in realtime or search mode + +|`refresh` +|`boolean` - Refresh the shard containing the document before performing the operation + +|`routing` +|`string` - Specific routing value + +|`_source` +|`string, string[]` - True or false to return the _source field or not, or a list of fields to return + +|`_source_excludes` or `_sourceExcludes` +|`string, string[]` - A list of fields to exclude from the returned _source field + +|`_source_includes` or `_sourceIncludes` +|`string, string[]` - A list of fields to extract and return from the _source field + +|`_source_exclude` or `_sourceExclude` +|`string, string[]` - A list of fields to exclude from the returned _source field + +|`_source_include` or `_sourceInclude` +|`string, string[]` - A list of fields to extract and return from the _source field + +|`version` +|`number` - Explicit version number for concurrency control + +|`version_type` or `versionType` +|`'internal', 'external', 'external_gte', 'force'` - Specific version type + +|=== +=== getScript +[source,js] +---- +client.getScript([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html +[cols=2*] +|=== +|`id` +|`string` - Script ID + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|=== +=== getSource +[source,js] +---- +client.getSource([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html +[cols=2*] +|=== +|`id` +|`string` - The document ID + +|`index` +|`string` - The name of the index + +|`type` +|`string` - The type of the document; use `_all` to fetch the first document matching the ID across all types + +|`parent` +|`string` - The ID of the parent document + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`realtime` +|`boolean` - Specify whether to perform the operation in realtime or search mode + +|`refresh` +|`boolean` - Refresh the shard containing the document before performing the operation + +|`routing` +|`string` - Specific routing value + +|`_source` +|`string, string[]` - True or false to return the _source field or not, or a list of fields to return + +|`_source_excludes` or `_sourceExcludes` +|`string, string[]` - A list of fields to exclude from the returned _source field + +|`_source_includes` or `_sourceIncludes` +|`string, string[]` - A list of fields to extract and return from the _source field + +|`version` +|`number` - Explicit version number for concurrency control + +|`version_type` or `versionType` +|`'internal', 'external', 'external_gte', 'force'` - Specific version type + +|=== +=== index +[source,js] +---- +client.index([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html +[cols=2*] +|=== +|`id` +|`string` - Document ID + +|`index` +|`string` - The name of the index + +|`type` +|`string` - The type of the document + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + +|`op_type` or `opType` +|`'index', 'create'` - Explicit operation type + + _Default:_ `index` + +|`parent` +|`string` - ID of the parent document + +|`refresh` +|`'true', 'false', 'wait_for'` - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + +|`routing` +|`string` - Specific routing value + +|`timeout` +|`string` - Explicit operation timeout + +|`version` +|`number` - Explicit version number for concurrency control + +|`version_type` or `versionType` +|`'internal', 'external', 'external_gte', 'force'` - Specific version type + +|`pipeline` +|`string` - The pipeline id to preprocess incoming documents with + +|`body` +|`object` - The document + +|=== +=== indices.analyze +[source,js] +---- +client.indices.analyze([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-analyze.html +[cols=2*] +|=== +|`index` +|`string` - The name of the index to scope the operation + +|`index` +|`string` - The name of the index to scope the operation + +|`body` +|`object` - Define analyzer/tokenizer parameters and the text on which the analysis should be performed + +|=== +=== indices.clearCache +[source,js] +---- +client.indices.clearCache([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clearcache.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index name to limit the operation + +|`fielddata` +|`boolean` - Clear field data + +|`fields` +|`string, string[]` - A comma-separated list of fields to clear when using the `fielddata` parameter (default: all) + +|`query` +|`boolean` - Clear query caches + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|`index` +|`string, string[]` - A comma-separated list of index name to limit the operation + +|`request` +|`boolean` - Clear request cache + +|=== +=== indices.close +[source,js] +---- +client.indices.close([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma separated list of indices to close + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|=== +=== indices.create +[source,js] +---- +client.indices.create([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-index.html +[cols=2*] +|=== +|`index` +|`string` - The name of the index + +|`include_type_name` or `includeTypeName` +|`string` - Whether a type should be expected in the body of the mappings. + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Set the number of active shards to wait for before the operation returns. + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`body` +|`object` - The configuration for the index (`settings` and `mappings`) + +|=== +=== indices.delete +[source,js] +---- +client.indices.delete([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-index.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of indices to delete; use `_all` or `*` string to delete all indices + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Ignore unavailable indexes (default: false) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Ignore if a wildcard expression resolves to no concrete indices (default: false) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether wildcard expressions should get expanded to open or closed indices (default: open) + + _Default:_ `open` + +|=== +=== indices.deleteAlias +[source,js] +---- +client.indices.deleteAlias([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names (supports wildcards); use `_all` for all indices + +|`name` +|`string, string[]` - A comma-separated list of aliases to delete (supports wildcards); use `_all` to delete all aliases for the specified indices. + +|`timeout` +|`string` - Explicit timestamp for the document + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|=== +=== indices.deleteTemplate +[source,js] +---- +client.indices.deleteTemplate([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html +[cols=2*] +|=== +|`name` +|`string` - The name of the template + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|=== +=== indices.exists +[source,js] +---- +client.indices.exists([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-exists.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Ignore unavailable indexes (default: false) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Ignore if a wildcard expression resolves to no concrete indices (default: false) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether wildcard expressions should get expanded to open or closed indices (default: open) + + _Default:_ `open` + +|`flat_settings` or `flatSettings` +|`boolean` - Return settings in flat format (default: false) + +|`include_defaults` or `includeDefaults` +|`boolean` - Whether to return all default setting for each of the indices. + +|=== +=== indices.existsAlias +[source,js] +---- +client.indices.existsAlias([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names to filter aliases + +|`name` +|`string, string[]` - A comma-separated list of alias names to return + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `all` + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|=== +=== indices.existsTemplate +[source,js] +---- +client.indices.existsTemplate([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html +[cols=2*] +|=== +|`name` +|`string, string[]` - The comma separated names of the index templates + +|`flat_settings` or `flatSettings` +|`boolean` - Return settings in flat format (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|=== +=== indices.existsType +[source,js] +---- +client.indices.existsType([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-types-exists.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names; use `_all` to check the types across all indices + +|`type` +|`string, string[]` - A comma-separated list of document types to check + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|=== +=== indices.flush +[source,js] +---- +client.indices.flush([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-flush.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names; use `_all` or empty string for all indices + +|`force` +|`boolean` - Whether a flush should be forced even if it is not necessarily needed ie. if no changes will be committed to the index. This is useful if transaction log IDs should be incremented even if no uncommitted changes are present. (This setting can be considered as internal) + +|`wait_if_ongoing` or `waitIfOngoing` +|`boolean` - If set to true the flush operation will block until the flush can be executed if another flush operation is already executing. The default is true. If set to false the flush will be skipped iff if another flush operation is already running. + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|=== +=== indices.flushSynced +[source,js] +---- +client.indices.flushSynced([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-synced-flush.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names; use `_all` or empty string for all indices + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|=== +=== indices.forcemerge +[source,js] +---- +client.indices.forcemerge([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-forcemerge.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + +|`flush` +|`boolean` - Specify whether the index should be flushed after performing the operation (default: true) + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|`max_num_segments` or `maxNumSegments` +|`number` - The number of segments the index should be merged into (default: dynamic) + +|`only_expunge_deletes` or `onlyExpungeDeletes` +|`boolean` - Specify whether the operation should only expunge deleted documents + +|=== +=== indices.get +[source,js] +---- +client.indices.get([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-index.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Ignore unavailable indexes (default: false) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Ignore if a wildcard expression resolves to no concrete indices (default: false) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether wildcard expressions should get expanded to open or closed indices (default: open) + + _Default:_ `open` + +|`flat_settings` or `flatSettings` +|`boolean` - Return settings in flat format (default: false) + +|`include_defaults` or `includeDefaults` +|`boolean` - Whether to return all default setting for each of the indices. + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|=== +=== indices.getAlias +[source,js] +---- +client.indices.getAlias([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names to filter aliases + +|`name` +|`string, string[]` - A comma-separated list of alias names to return + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `all` + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|=== +=== indices.getFieldMapping +[source,js] +---- +client.indices.getFieldMapping([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-field-mapping.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names + +|`type` +|`string, string[]` - A comma-separated list of document types + +|`fields` +|`string, string[]` - A comma-separated list of fields + +|`include_defaults` or `includeDefaults` +|`boolean` - Whether the default mapping values should be returned as well + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|=== +=== indices.getMapping +[source,js] +---- +client.indices.getMapping([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-mapping.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names + +|`type` +|`string, string[]` - A comma-separated list of document types + +|`include_type_name` or `includeTypeName` +|`string` - Whether to add the type name to the response + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|=== +=== indices.getSettings +[source,js] +---- +client.indices.getSettings([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-settings.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + +|`name` +|`string, string[]` - The name of the settings that should be included + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open,closed` + +|`flat_settings` or `flatSettings` +|`boolean` - Return settings in flat format (default: false) + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`include_defaults` or `includeDefaults` +|`boolean` - Whether to return all default setting for each of the indices. + +|=== +=== indices.getTemplate +[source,js] +---- +client.indices.getTemplate([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html +[cols=2*] +|=== +|`name` +|`string, string[]` - The comma separated names of the index templates + +|`flat_settings` or `flatSettings` +|`boolean` - Return settings in flat format (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|=== +=== indices.getUpgrade +[source,js] +---- +client.indices.getUpgrade([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-upgrade.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|=== +=== indices.open +[source,js] +---- +client.indices.open([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma separated list of indices to open + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `closed` + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of active shards to wait for before the operation returns. + +|=== +=== indices.putAlias +[source,js] +---- +client.indices.putAlias([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names the alias should point to (supports wildcards); use `_all` to perform the operation on all indices. + +|`name` +|`string` - The name of the alias to be created or updated + +|`timeout` +|`string` - Explicit timestamp for the document + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`body` +|`object` - The settings for the alias, such as `routing` or `filter` + +|=== +=== indices.putMapping +[source,js] +---- +client.indices.putMapping([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-put-mapping.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. + +|`type` +|`string` - The name of the document type + +|`include_type_name` or `includeTypeName` +|`string` - Whether a type should be expected in the body of the mappings. + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|`body` +|`object` - The mapping definition + +|=== +=== indices.putSettings +[source,js] +---- +client.indices.putSettings([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-update-settings.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`timeout` +|`string` - Explicit operation timeout + +|`preserve_existing` or `preserveExisting` +|`boolean` - Whether to update existing settings. If set to `true` existing settings on an index remain unchanged, the default is `false` + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|`flat_settings` or `flatSettings` +|`boolean` - Return settings in flat format (default: false) + +|`body` +|`object` - The index settings to be updated + +|=== +=== indices.putTemplate +[source,js] +---- +client.indices.putTemplate([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html +[cols=2*] +|=== +|`name` +|`string` - The name of the template + +|`order` +|`number` - The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers) + +|`create` +|`boolean` - Whether the index template should only be added if new or can also replace an existing one + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`flat_settings` or `flatSettings` +|`boolean` - Return settings in flat format (default: false) + +|`body` +|`object` - The template definition + +|=== +=== indices.recovery +[source,js] +---- +client.indices.recovery([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-recovery.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + +|`detailed` +|`boolean` - Whether to display detailed information about shard recovery + +|`active_only` or `activeOnly` +|`boolean` - Display only those recoveries that are currently on-going + +|=== +=== indices.refresh +[source,js] +---- +client.indices.refresh([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-refresh.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|=== +=== indices.rollover +[source,js] +---- +client.indices.rollover([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html +[cols=2*] +|=== +|`alias` +|`string` - The name of the alias to rollover + +|`new_index` or `newIndex` +|`string` - The name of the rollover index + +|`timeout` +|`string` - Explicit operation timeout + +|`dry_run` or `dryRun` +|`boolean` - If set to true the rollover action will only be validated but not actually performed even if a condition matches. The default is false + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Set the number of active shards to wait for on the newly created rollover index before the operation returns. + +|`body` +|`object` - The conditions that needs to be met for executing rollover + +|=== +=== indices.segments +[source,js] +---- +client.indices.segments([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-segments.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|`verbose` +|`boolean` - Includes detailed memory usage by Lucene. + +|=== +=== indices.shardStores +[source,js] +---- +client.indices.shardStores([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shards-stores.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + +|`status` +|`string, string[]` - A comma-separated list of statuses used to filter on shards to get store information for + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|=== +=== indices.shrink +[source,js] +---- +client.indices.shrink([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shrink-index.html +[cols=2*] +|=== +|`index` +|`string` - The name of the source index to shrink + +|`target` +|`string` - The name of the target index to shrink into + +|`copy_settings` or `copySettings` +|`boolean` - whether or not to copy settings from the source index (defaults to false) + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Set the number of active shards to wait for on the shrunken index before the operation returns. + +|`body` +|`object` - The configuration for the target index (`settings` and `aliases`) + +|=== +=== indices.split +[source,js] +---- +client.indices.split([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-split-index.html +[cols=2*] +|=== +|`index` +|`string` - The name of the source index to split + +|`target` +|`string` - The name of the target index to split into + +|`copy_settings` or `copySettings` +|`boolean` - whether or not to copy settings from the source index (defaults to false) + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Set the number of active shards to wait for on the shrunken index before the operation returns. + +|`body` +|`object` - The configuration for the target index (`settings` and `aliases`) + +|=== +=== indices.stats +[source,js] +---- +client.indices.stats([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-stats.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + +|`metric` +|`string, string[]` - Limit the information returned the specific metrics. + +|`completion_fields` or `completionFields` +|`string, string[]` - A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) + +|`fielddata_fields` or `fielddataFields` +|`string, string[]` - A comma-separated list of fields for `fielddata` index metric (supports wildcards) + +|`fields` +|`string, string[]` - A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) + +|`groups` +|`string, string[]` - A comma-separated list of search groups for `search` index metric + +|`level` +|`'cluster', 'indices', 'shards'` - Return stats aggregated at cluster, index or shard level + + _Default:_ `indices` + +|`types` +|`string, string[]` - A comma-separated list of document types for the `indexing` index metric + +|`include_segment_file_sizes` or `includeSegmentFileSizes` +|`boolean` - Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) + +|=== +=== indices.updateAliases +[source,js] +---- +client.indices.updateAliases([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html +[cols=2*] +|=== +|`timeout` +|`string` - Request timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`body` +|`object` - The definition of `actions` to perform + +|=== +=== indices.upgrade +[source,js] +---- +client.indices.upgrade([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-upgrade.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Specify whether the request should block until the all segments are upgraded (default: false) + +|`only_ancient_segments` or `onlyAncientSegments` +|`boolean` - If true, only ancient (an older Lucene major release) segments will be upgraded + +|=== +=== indices.validateQuery +[source,js] +---- +client.indices.validateQuery([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/search-validate.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names to restrict the operation; use `_all` or empty string to perform the operation on all indices + +|`type` +|`string, string[]` - A comma-separated list of document types to restrict the operation; leave empty to perform the operation on all types + +|`explain` +|`boolean` - Return detailed information about the error + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|`q` +|`string` - Query in the Lucene query string syntax + +|`analyzer` +|`string` - The analyzer to use for the query string + +|`analyze_wildcard` or `analyzeWildcard` +|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) + +|`default_operator` or `defaultOperator` +|`'AND', 'OR'` - The default operator for query string query (AND or OR) + + _Default:_ `OR` + +|`df` +|`string` - The field to use as default where no field prefix is given in the query string + +|`lenient` +|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + +|`rewrite` +|`boolean` - Provide a more detailed explanation showing the actual Lucene query that will be executed. + +|`all_shards` or `allShards` +|`boolean` - Execute validation on all shards instead of one random shard per index + +|`body` +|`object` - The query definition specified with the Query DSL + +|=== +=== info +[source,js] +---- +client.info([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/ +[cols=2*] +|=== +|=== +=== ingest.deletePipeline +[source,js] +---- +client.ingest.deletePipeline([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html +[cols=2*] +|=== +|`id` +|`string` - Pipeline ID + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`timeout` +|`string` - Explicit operation timeout + +|=== +=== ingest.getPipeline +[source,js] +---- +client.ingest.getPipeline([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html +[cols=2*] +|=== +|`id` +|`string` - Comma separated list of pipeline ids. Wildcards supported + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|=== +=== ingest.processorGrok +[source,js] +---- +client.ingest.processorGrok([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html +[cols=2*] +|=== +|=== +=== ingest.putPipeline +[source,js] +---- +client.ingest.putPipeline([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html +[cols=2*] +|=== +|`id` +|`string` - Pipeline ID + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`timeout` +|`string` - Explicit operation timeout + +|`body` +|`object` - The ingest definition + +|=== +=== ingest.simulate +[source,js] +---- +client.ingest.simulate([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html +[cols=2*] +|=== +|`id` +|`string` - Pipeline ID + +|`verbose` +|`boolean` - Verbose mode. Display data output for each processor in executed pipeline + +|`body` +|`object` - The simulate definition + +|=== +=== mget +[source,js] +---- +client.mget([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-get.html +[cols=2*] +|=== +|`index` +|`string` - The name of the index + +|`type` +|`string` - The type of the document + +|`stored_fields` or `storedFields` +|`string, string[]` - A comma-separated list of stored fields to return in the response + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`realtime` +|`boolean` - Specify whether to perform the operation in realtime or search mode + +|`refresh` +|`boolean` - Refresh the shard containing the document before performing the operation + +|`routing` +|`string` - Specific routing value + +|`_source` +|`string, string[]` - True or false to return the _source field or not, or a list of fields to return + +|`_source_excludes` or `_sourceExcludes` +|`string, string[]` - A list of fields to exclude from the returned _source field + +|`_source_includes` or `_sourceIncludes` +|`string, string[]` - A list of fields to extract and return from the _source field + +|`body` +|`object` - Document identifiers; can be either `docs` (containing full document information) or `ids` (when index and type is provided in the URL. + +|=== +=== msearch +[source,js] +---- +client.msearch([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/search-multi-search.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names to use as default + +|`type` +|`string, string[]` - A comma-separated list of document types to use as default + +|`search_type` or `searchType` +|`'query_then_fetch', 'query_and_fetch', 'dfs_query_then_fetch', 'dfs_query_and_fetch'` - Search operation type + +|`max_concurrent_searches` or `maxConcurrentSearches` +|`number` - Controls the maximum number of concurrent searches the multi search api will execute + +|`typed_keys` or `typedKeys` +|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + +|`pre_filter_shard_size` or `preFilterShardSize` +|`number` - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on it's rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. + + _Default:_ `128` + +|`max_concurrent_shard_requests` or `maxConcurrentShardRequests` +|`number` - The number of concurrent shard requests each sub search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + + _Default:_ `The default grows with the number of nodes in the cluster but is at most 256.` + +|`rest_total_hits_as_int` or `restTotalHitsAsInt` +|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response + +|`body` +|`object` - The request definitions (metadata-search request definition pairs), separated by newlines + +|=== +=== msearchTemplate +[source,js] +---- +client.msearchTemplate([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names to use as default + +|`type` +|`string, string[]` - A comma-separated list of document types to use as default + +|`search_type` or `searchType` +|`'query_then_fetch', 'query_and_fetch', 'dfs_query_then_fetch', 'dfs_query_and_fetch'` - Search operation type + +|`typed_keys` or `typedKeys` +|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + +|`max_concurrent_searches` or `maxConcurrentSearches` +|`number` - Controls the maximum number of concurrent searches the multi search api will execute + +|`rest_total_hits_as_int` or `restTotalHitsAsInt` +|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response + +|`body` +|`object` - The request definitions (metadata-search request definition pairs), separated by newlines + +|=== +=== mtermvectors +[source,js] +---- +client.mtermvectors([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-termvectors.html +[cols=2*] +|=== +|`index` +|`string` - The index in which the document resides. + +|`type` +|`string` - The type of the document. + +|`ids` +|`string, string[]` - A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body + +|`term_statistics` or `termStatistics` +|`boolean` - Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +|`field_statistics` or `fieldStatistics` +|`boolean` - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + + _Default:_ `true` + +|`fields` +|`string, string[]` - A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +|`offsets` +|`boolean` - Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + + _Default:_ `true` + +|`positions` +|`boolean` - Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + + _Default:_ `true` + +|`payloads` +|`boolean` - Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + + _Default:_ `true` + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body "params" or "docs". + +|`routing` +|`string` - Specific routing value. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +|`parent` +|`string` - Parent id of documents. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +|`realtime` +|`boolean` - Specifies if requests are real-time as opposed to near-real-time (default: true). + +|`version` +|`number` - Explicit version number for concurrency control + +|`version_type` or `versionType` +|`'internal', 'external', 'external_gte', 'force'` - Specific version type + +|`body` +|`object` - Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation. + +|=== +=== nodes.hotThreads +[source,js] +---- +client.nodes.hotThreads([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-hot-threads.html +[cols=2*] +|=== +|`node_id` or `nodeId` +|`string, string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +|`interval` +|`string` - The interval for the second sampling of threads + +|`snapshots` +|`number` - Number of samples of thread stacktrace (default: 10) + +|`threads` +|`number` - Specify the number of threads to provide information for (default: 3) + +|`ignore_idle_threads` or `ignoreIdleThreads` +|`boolean` - Don't show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue (default: true) + +|`type` +|`'cpu', 'wait', 'block'` - The type to sample (default: cpu) + +|`timeout` +|`string` - Explicit operation timeout + +|=== +=== nodes.info +[source,js] +---- +client.nodes.info([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-info.html +[cols=2*] +|=== +|`node_id` or `nodeId` +|`string, string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +|`metric` +|`string, string[]` - A comma-separated list of metrics you wish returned. Leave empty to return all. + +|`flat_settings` or `flatSettings` +|`boolean` - Return settings in flat format (default: false) + +|`timeout` +|`string` - Explicit operation timeout + +|=== +=== nodes.reloadSecureSettings +[source,js] +---- +client.nodes.reloadSecureSettings([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/master/secure-settings.html#reloadable-secure-settings +[cols=2*] +|=== +|`node_id` or `nodeId` +|`string, string[]` - A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes. + +|`timeout` +|`string` - Explicit operation timeout + +|=== +=== nodes.stats +[source,js] +---- +client.nodes.stats([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-stats.html +[cols=2*] +|=== +|`metric` +|`string, string[]` - Limit the information returned to the specified metrics + +|`index_metric` or `indexMetric` +|`string, string[]` - Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified. + +|`node_id` or `nodeId` +|`string, string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +|`completion_fields` or `completionFields` +|`string, string[]` - A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) + +|`fielddata_fields` or `fielddataFields` +|`string, string[]` - A comma-separated list of fields for `fielddata` index metric (supports wildcards) + +|`fields` +|`string, string[]` - A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) + +|`groups` +|`boolean` - A comma-separated list of search groups for `search` index metric + +|`level` +|`'indices', 'node', 'shards'` - Return indices stats aggregated at index, node or shard level + + _Default:_ `node` + +|`types` +|`string, string[]` - A comma-separated list of document types for the `indexing` index metric + +|`timeout` +|`string` - Explicit operation timeout + +|`include_segment_file_sizes` or `includeSegmentFileSizes` +|`boolean` - Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) + +|=== +=== nodes.usage +[source,js] +---- +client.nodes.usage([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html +[cols=2*] +|=== +|`metric` +|`string, string[]` - Limit the information returned to the specified metrics + +|`node_id` or `nodeId` +|`string, string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +|`timeout` +|`string` - Explicit operation timeout + +|=== +=== ping +[source,js] +---- +client.ping([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/ +[cols=2*] +|=== +|=== +=== putScript +[source,js] +---- +client.putScript([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html +[cols=2*] +|=== +|`id` +|`string` - Script ID + +|`context` +|`string` - Script context + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`context` +|`string` - Context name to compile script against + +|`body` +|`object` - The document + +|=== +=== rankEval +[source,js] +---- +client.rankEval([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/master/search-rank-eval.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|`body` +|`object` - The ranking evaluation search definition, including search requests, document ratings and ranking metric definition. + +|=== +=== reindex +[source,js] +---- +client.reindex([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html +[cols=2*] +|=== +|`refresh` +|`boolean` - Should the effected indexes be refreshed? + +|`timeout` +|`string` - Time each individual bulk request should wait for shards that are unavailable. + + _Default:_ `1m` + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Should the request should block until the reindex is complete. + + _Default:_ `true` + +|`requests_per_second` or `requestsPerSecond` +|`number` - The throttle to set on this request in sub-requests per second. -1 means no throttle. + +|`slices` +|`number` - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. + + _Default:_ `1` + +|`body` +|`object` - The search definition using the Query DSL and the prototype for the index request. + +|=== +=== reindexRethrottle +[source,js] +---- +client.reindexRethrottle([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html +[cols=2*] +|=== +|`task_id` or `taskId` +|`string` - The task id to rethrottle + +|`requests_per_second` or `requestsPerSecond` +|`number` - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. + +|=== +=== renderSearchTemplate +[source,js] +---- +client.renderSearchTemplate([params] [, options] [, callback]) +---- +http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-template.html +[cols=2*] +|=== +|`id` +|`string` - The id of the stored search template + +|`body` +|`object` - The search definition template and its params + +|=== +=== scriptsPainlessExecute +[source,js] +---- +client.scriptsPainlessExecute([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html +[cols=2*] +|=== +|`body` +|`object` - The script to execute + +|=== +=== scroll +[source,js] +---- +client.scroll([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-scroll.html +[cols=2*] +|=== +|`scroll_id` or `scrollId` +|`string` - The scroll ID + +|`scroll` +|`string` - Specify how long a consistent view of the index should be maintained for scrolled search + +|`scroll_id` or `scrollId` +|`string` - The scroll ID for scrolled search + +|`rest_total_hits_as_int` or `restTotalHitsAsInt` +|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response + +|`body` +|`object` - The scroll ID if not passed by URL or query parameter. + +|=== +=== search +[source,js] +---- +client.search([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`type` +|`string, string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types + +|`analyzer` +|`string` - The analyzer to use for the query string + +|`analyze_wildcard` or `analyzeWildcard` +|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) + +|`default_operator` or `defaultOperator` +|`'AND', 'OR'` - The default operator for query string query (AND or OR) + + _Default:_ `OR` + +|`df` +|`string` - The field to use as default where no field prefix is given in the query string + +|`explain` +|`boolean` - Specify whether to return detailed information about score computation as part of a hit + +|`stored_fields` or `storedFields` +|`string, string[]` - A comma-separated list of stored fields to return as part of a hit + +|`docvalue_fields` or `docvalueFields` +|`string, string[]` - A comma-separated list of fields to return as the docvalue representation of a field for each hit + +|`from` +|`number` - Starting offset (default: 0) + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`ignore_throttled` or `ignoreThrottled` +|`boolean` - Whether specified concrete, expanded or aliased indices should be ignored when throttled + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|`lenient` +|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`q` +|`string` - Query in the Lucene query string syntax + +|`routing` +|`string, string[]` - A comma-separated list of specific routing values + +|`scroll` +|`string` - Specify how long a consistent view of the index should be maintained for scrolled search + +|`search_type` or `searchType` +|`'query_then_fetch', 'dfs_query_then_fetch'` - Search operation type + +|`size` +|`number` - Number of hits to return (default: 10) + +|`sort` +|`string, string[]` - A comma-separated list of : pairs + +|`_source` +|`string, string[]` - True or false to return the _source field or not, or a list of fields to return + +|`_source_excludes` or `_sourceExcludes` +|`string, string[]` - A list of fields to exclude from the returned _source field + +|`_source_includes` or `_sourceIncludes` +|`string, string[]` - A list of fields to extract and return from the _source field + +|`terminate_after` or `terminateAfter` +|`number` - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + +|`stats` +|`string, string[]` - Specific 'tag' of the request for logging and statistical purposes + +|`suggest_field` or `suggestField` +|`string` - Specify which field to use for suggestions + +|`suggest_mode` or `suggestMode` +|`'missing', 'popular', 'always'` - Specify suggest mode + + _Default:_ `missing` + +|`suggest_size` or `suggestSize` +|`number` - How many suggestions to return in response + +|`suggest_text` or `suggestText` +|`string` - The source text for which the suggestions should be returned + +|`timeout` +|`string` - Explicit operation timeout + +|`track_scores` or `trackScores` +|`boolean` - Whether to calculate and return scores even if they are not used for sorting + +|`track_total_hits` or `trackTotalHits` +|`boolean` - Indicate if the number of documents that match the query should be tracked + +|`allow_partial_search_results` or `allowPartialSearchResults` +|`boolean` - Indicate if an error should be returned if there is a partial search failure or timeout + + _Default:_ `true` + +|`typed_keys` or `typedKeys` +|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + +|`version` +|`boolean` - Specify whether to return document version as part of a hit + +|`request_cache` or `requestCache` +|`boolean` - Specify if request cache should be used for this request or not, defaults to index level setting + +|`batched_reduce_size` or `batchedReduceSize` +|`number` - The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. + + _Default:_ `512` + +|`max_concurrent_shard_requests` or `maxConcurrentShardRequests` +|`number` - The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + + _Default:_ `The default is 5.` + +|`pre_filter_shard_size` or `preFilterShardSize` +|`number` - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on it's rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. + + _Default:_ `128` + +|`rest_total_hits_as_int` or `restTotalHitsAsInt` +|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response + +|`body` +|`object` - The search definition using the Query DSL + +|=== +=== searchShards +[source,js] +---- +client.searchShards([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/search-shards.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`routing` +|`string` - Specific routing value + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|=== +=== searchTemplate +[source,js] +---- +client.searchTemplate([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`type` +|`string, string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`ignore_throttled` or `ignoreThrottled` +|`boolean` - Whether specified concrete, expanded or aliased indices should be ignored when throttled + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`routing` +|`string, string[]` - A comma-separated list of specific routing values + +|`scroll` +|`string` - Specify how long a consistent view of the index should be maintained for scrolled search + +|`search_type` or `searchType` +|`'query_then_fetch', 'query_and_fetch', 'dfs_query_then_fetch', 'dfs_query_and_fetch'` - Search operation type + +|`explain` +|`boolean` - Specify whether to return detailed information about score computation as part of a hit + +|`profile` +|`boolean` - Specify whether to profile the query execution + +|`typed_keys` or `typedKeys` +|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + +|`rest_total_hits_as_int` or `restTotalHitsAsInt` +|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response + +|`body` +|`object` - The search definition template and its params + +|=== +=== snapshot.create +[source,js] +---- +client.snapshot.create([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html +[cols=2*] +|=== +|`repository` +|`string` - A repository name + +|`snapshot` +|`string` - A snapshot name + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Should this request wait until the operation has completed before returning + +|`body` +|`object` - The snapshot definition + +|=== +=== snapshot.createRepository +[source,js] +---- +client.snapshot.createRepository([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html +[cols=2*] +|=== +|`repository` +|`string` - A repository name + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`timeout` +|`string` - Explicit operation timeout + +|`verify` +|`boolean` - Whether to verify the repository after creation + +|`body` +|`object` - The repository definition + +|=== +=== snapshot.delete +[source,js] +---- +client.snapshot.delete([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html +[cols=2*] +|=== +|`repository` +|`string` - A repository name + +|`snapshot` +|`string` - A snapshot name + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|=== +=== snapshot.deleteRepository +[source,js] +---- +client.snapshot.deleteRepository([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html +[cols=2*] +|=== +|`repository` +|`string, string[]` - A comma-separated list of repository names + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`timeout` +|`string` - Explicit operation timeout + +|=== +=== snapshot.get +[source,js] +---- +client.snapshot.get([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html +[cols=2*] +|=== +|`repository` +|`string` - A repository name + +|`snapshot` +|`string, string[]` - A comma-separated list of snapshot names + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown + +|`verbose` +|`boolean` - Whether to show verbose snapshot info or only show the basic info found in the repository index blob + +|=== +=== snapshot.getRepository +[source,js] +---- +client.snapshot.getRepository([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html +[cols=2*] +|=== +|`repository` +|`string, string[]` - A comma-separated list of repository names + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|=== +=== snapshot.restore +[source,js] +---- +client.snapshot.restore([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html +[cols=2*] +|=== +|`repository` +|`string` - A repository name + +|`snapshot` +|`string` - A snapshot name + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Should this request wait until the operation has completed before returning + +|`body` +|`object` - Details of what to restore + +|=== +=== snapshot.status +[source,js] +---- +client.snapshot.status([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html +[cols=2*] +|=== +|`repository` +|`string` - A repository name + +|`snapshot` +|`string, string[]` - A comma-separated list of snapshot names + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown + +|=== +=== snapshot.verifyRepository +[source,js] +---- +client.snapshot.verifyRepository([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html +[cols=2*] +|=== +|`repository` +|`string` - A repository name + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`timeout` +|`string` - Explicit operation timeout + +|=== +=== tasks.cancel +[source,js] +---- +client.tasks.cancel([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html +[cols=2*] +|=== +|`task_id` or `taskId` +|`string` - Cancel the task with specified task id (node_id:task_number) + +|`nodes` +|`string, string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +|`actions` +|`string, string[]` - A comma-separated list of actions that should be cancelled. Leave empty to cancel all. + +|`parent_task_id` or `parentTaskId` +|`string` - Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all. + +|=== +=== tasks.get +[source,js] +---- +client.tasks.get([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html +[cols=2*] +|=== +|`task_id` or `taskId` +|`string` - Return the task with specified id (node_id:task_number) + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Wait for the matching tasks to complete (default: false) + +|`timeout` +|`string` - Explicit operation timeout + +|=== +=== tasks.list +[source,js] +---- +client.tasks.list([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html +[cols=2*] +|=== +|`nodes` +|`string, string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +|`actions` +|`string, string[]` - A comma-separated list of actions that should be returned. Leave empty to return all. + +|`detailed` +|`boolean` - Return detailed task information (default: false) + +|`parent_task_id` or `parentTaskId` +|`string` - Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all. + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Wait for the matching tasks to complete (default: false) + +|`group_by` or `groupBy` +|`'nodes', 'parents', 'none'` - Group tasks by nodes or parent/child relationships + + _Default:_ `nodes` + +|`timeout` +|`string` - Explicit operation timeout + +|=== +=== termvectors +[source,js] +---- +client.termvectors([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-termvectors.html +[cols=2*] +|=== +|`index` +|`string` - The index in which the document resides. + +|`type` +|`string` - The type of the document. + +|`id` +|`string` - The id of the document, when not specified a doc param should be supplied. + +|`term_statistics` or `termStatistics` +|`boolean` - Specifies if total term frequency and document frequency should be returned. + +|`field_statistics` or `fieldStatistics` +|`boolean` - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. + + _Default:_ `true` + +|`fields` +|`string, string[]` - A comma-separated list of fields to return. + +|`offsets` +|`boolean` - Specifies if term offsets should be returned. + + _Default:_ `true` + +|`positions` +|`boolean` - Specifies if term positions should be returned. + + _Default:_ `true` + +|`payloads` +|`boolean` - Specifies if term payloads should be returned. + + _Default:_ `true` + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random). + +|`routing` +|`string` - Specific routing value. + +|`parent` +|`string` - Parent id of documents. + +|`realtime` +|`boolean` - Specifies if request is real-time as opposed to near-real-time (default: true). + +|`version` +|`number` - Explicit version number for concurrency control + +|`version_type` or `versionType` +|`'internal', 'external', 'external_gte', 'force'` - Specific version type + +|`body` +|`object` - Define parameters and or supply a document to get termvectors for. See documentation. + +|=== +=== update +[source,js] +---- +client.update([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update.html +[cols=2*] +|=== +|`id` +|`string` - Document ID + +|`index` +|`string` - The name of the index + +|`type` +|`string` - The type of the document + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + +|`_source` +|`string, string[]` - True or false to return the _source field or not, or a list of fields to return + +|`_source_excludes` or `_sourceExcludes` +|`string, string[]` - A list of fields to exclude from the returned _source field + +|`_source_includes` or `_sourceIncludes` +|`string, string[]` - A list of fields to extract and return from the _source field + +|`lang` +|`string` - The script language (default: painless) + +|`parent` +|`string` - ID of the parent document. Is is only used for routing and when for the upsert request + +|`refresh` +|`'true', 'false', 'wait_for'` - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + +|`retry_on_conflict` or `retryOnConflict` +|`number` - Specify how many times should the operation be retried when a conflict occurs (default: 0) + +|`routing` +|`string` - Specific routing value + +|`timeout` +|`string` - Explicit operation timeout + +|`version` +|`number` - Explicit version number for concurrency control + +|`version_type` or `versionType` +|`'internal', 'force'` - Specific version type + +|`body` +|`object` - The request definition requires either `script` or partial `doc` + +|=== +=== updateByQuery +[source,js] +---- +client.updateByQuery([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`type` +|`string, string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types + +|`analyzer` +|`string` - The analyzer to use for the query string + +|`analyze_wildcard` or `analyzeWildcard` +|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) + +|`default_operator` or `defaultOperator` +|`'AND', 'OR'` - The default operator for query string query (AND or OR) + + _Default:_ `OR` + +|`df` +|`string` - The field to use as default where no field prefix is given in the query string + +|`from` +|`number` - Starting offset (default: 0) + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`conflicts` +|`'abort', 'proceed'` - What to do when the update by query hits version conflicts? + + _Default:_ `abort` + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|`lenient` +|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + +|`pipeline` +|`string` - Ingest pipeline to set on index requests made by this action. (default: none) + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`q` +|`string` - Query in the Lucene query string syntax + +|`routing` +|`string, string[]` - A comma-separated list of specific routing values + +|`scroll` +|`string` - Specify how long a consistent view of the index should be maintained for scrolled search + +|`search_type` or `searchType` +|`'query_then_fetch', 'dfs_query_then_fetch'` - Search operation type + +|`search_timeout` or `searchTimeout` +|`string` - Explicit timeout for each search request. Defaults to no timeout. + +|`size` +|`number` - Number of hits to return (default: 10) + +|`sort` +|`string, string[]` - A comma-separated list of : pairs + +|`_source` +|`string, string[]` - True or false to return the _source field or not, or a list of fields to return + +|`_source_excludes` or `_sourceExcludes` +|`string, string[]` - A list of fields to exclude from the returned _source field + +|`_source_includes` or `_sourceIncludes` +|`string, string[]` - A list of fields to extract and return from the _source field + +|`terminate_after` or `terminateAfter` +|`number` - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + +|`stats` +|`string, string[]` - Specific 'tag' of the request for logging and statistical purposes + +|`version` +|`boolean` - Specify whether to return document version as part of a hit + +|`version_type` or `versionType` +|`boolean` - Should the document increment the version number (internal) on hit or not (reindex) + +|`request_cache` or `requestCache` +|`boolean` - Specify if request cache should be used for this request or not, defaults to index level setting + +|`refresh` +|`boolean` - Should the effected indexes be refreshed? + +|`timeout` +|`string` - Time each individual bulk request should wait for shards that are unavailable. + + _Default:_ `1m` + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + +|`scroll_size` or `scrollSize` +|`number` - Size on the scroll request powering the update by query + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Should the request should block until the update by query operation is complete. + + _Default:_ `true` + +|`requests_per_second` or `requestsPerSecond` +|`number` - The throttle to set on this request in sub-requests per second. -1 means no throttle. + +|`slices` +|`number` - The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks. + + _Default:_ `1` + +|`body` +|`object` - The search definition using the Query DSL + +|=== +=== updateByQueryRethrottle +[source,js] +---- +client.updateByQueryRethrottle([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html +[cols=2*] +|=== +|`task_id` or `taskId` +|`string` - The task id to rethrottle + +|`requests_per_second` or `requestsPerSecond` +|`number` - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. + +|=== +=== ccr.deleteAutoFollowPattern +[source,js] +---- +client.ccr.deleteAutoFollowPattern([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html +[cols=2*] +|=== +|`name` +|`string` - The name of the auto follow pattern. + +|=== +=== ccr.follow +[source,js] +---- +client.ccr.follow([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html +[cols=2*] +|=== +|`index` +|`string` - The name of the follower index + +|`body` +|`object` - The name of the leader index and other optional ccr related parameters + +|=== +=== ccr.followStats +[source,js] +---- +client.ccr.followStats([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index patterns; use `_all` to perform the operation on all indices + +|=== +=== ccr.getAutoFollowPattern +[source,js] +---- +client.ccr.getAutoFollowPattern([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html +[cols=2*] +|=== +|`name` +|`string` - The name of the auto follow pattern. + +|=== +=== ccr.pauseFollow +[source,js] +---- +client.ccr.pauseFollow([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html +[cols=2*] +|=== +|`index` +|`string` - The name of the follower index that should pause following its leader index. + +|=== +=== ccr.putAutoFollowPattern +[source,js] +---- +client.ccr.putAutoFollowPattern([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html +[cols=2*] +|=== +|`name` +|`string` - The name of the auto follow pattern. + +|`body` +|`object` - The specification of the auto follow pattern + +|=== +=== ccr.resumeFollow +[source,js] +---- +client.ccr.resumeFollow([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-resume-follow.html +[cols=2*] +|=== +|`index` +|`string` - The name of the follow index to resume following. + +|`body` +|`object` - The name of the leader index and other optional ccr related parameters + +|=== +=== ccr.stats +[source,js] +---- +client.ccr.stats([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html +[cols=2*] +|=== +|=== +=== ccr.unfollow +[source,js] +---- +client.ccr.unfollow([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current +[cols=2*] +|=== +|`index` +|`string` - The name of the follower index that should be turned into a regular index. + +|=== +=== ilm.deleteLifecycle +[source,js] +---- +client.ilm.deleteLifecycle([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-delete-lifecycle.html +[cols=2*] +|=== +|`policy` +|`string` - The name of the index lifecycle policy + +|=== +=== ilm.explainLifecycle +[source,js] +---- +client.ilm.explainLifecycle([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-explain-lifecycle.html +[cols=2*] +|=== +|`index` +|`string` - The name of the index to explain + +|`human` +|`boolean` - Return data such as dates in a human readable format + + _Default:_ `false` + +|=== +=== ilm.getLifecycle +[source,js] +---- +client.ilm.getLifecycle([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-lifecycle.html +[cols=2*] +|=== +|`policy` +|`string` - The name of the index lifecycle policy + +|=== +=== ilm.getStatus +[source,js] +---- +client.ilm.getStatus([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-status.html +[cols=2*] +|=== +|=== +=== ilm.moveToStep +[source,js] +---- +client.ilm.moveToStep([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-move-to-step.html +[cols=2*] +|=== +|`index` +|`string` - The name of the index whose lifecycle step is to change + +|`body` +|`object` - The new lifecycle step to move to + +|=== +=== ilm.putLifecycle +[source,js] +---- +client.ilm.putLifecycle([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-put-lifecycle.html +[cols=2*] +|=== +|`policy` +|`string` - The name of the index lifecycle policy + +|`body` +|`object` - The lifecycle policy definition to register + +|=== +=== ilm.removePolicy +[source,js] +---- +client.ilm.removePolicy([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-remove-policy.html +[cols=2*] +|=== +|`index` +|`string` - The name of the index to remove policy on + +|=== +=== ilm.retry +[source,js] +---- +client.ilm.retry([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-retry-policy.html +[cols=2*] +|=== +|`index` +|`string` - The name of the indices (comma-separated) whose failed lifecycle step is to be retry + +|=== +=== ilm.start +[source,js] +---- +client.ilm.start([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-start.html +[cols=2*] +|=== +|=== +=== ilm.stop +[source,js] +---- +client.ilm.stop([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-stop.html +[cols=2*] +|=== +|=== +=== indices.freeze +[source,js] +---- +client.indices.freeze([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.html +[cols=2*] +|=== +|`index` +|`string` - The name of the index to freeze + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `closed` + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of active shards to wait for before the operation returns. + +|=== +=== indices.unfreeze +[source,js] +---- +client.indices.unfreeze([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.html +[cols=2*] +|=== +|`index` +|`string` - The name of the index to unfreeze + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `closed` + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of active shards to wait for before the operation returns. + +|=== +=== ml.closeJob +[source,js] +---- +client.ml.closeJob([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-close-job.html +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - The name of the job to close + +|`allow_no_jobs` or `allowNoJobs` +|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + +|`force` +|`boolean` - True if the job should be forcefully closed + +|`timeout` +|`string` - Controls the time to wait until a job has closed. Default to 30 minutes + +|=== +=== ml.deleteCalendar +[source,js] +---- +client.ml.deleteCalendar([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`calendar_id` or `calendarId` +|`string` - The ID of the calendar to delete + +|=== +=== ml.deleteCalendarEvent +[source,js] +---- +client.ml.deleteCalendarEvent([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`calendar_id` or `calendarId` +|`string` - The ID of the calendar to modify + +|`event_id` or `eventId` +|`string` - The ID of the event to remove from the calendar + +|=== +=== ml.deleteCalendarJob +[source,js] +---- +client.ml.deleteCalendarJob([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`calendar_id` or `calendarId` +|`string` - The ID of the calendar to modify + +|`job_id` or `jobId` +|`string` - The ID of the job to remove from the calendar + +|=== +=== ml.deleteDatafeed +[source,js] +---- +client.ml.deleteDatafeed([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html +[cols=2*] +|=== +|`datafeed_id` or `datafeedId` +|`string` - The ID of the datafeed to delete + +|`force` +|`boolean` - True if the datafeed should be forcefully deleted + +|=== +=== ml.deleteExpiredData +[source,js] +---- +client.ml.deleteExpiredData([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|=== +=== ml.deleteFilter +[source,js] +---- +client.ml.deleteFilter([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`filter_id` or `filterId` +|`string` - The ID of the filter to delete + +|=== +=== ml.deleteForecast +[source,js] +---- +client.ml.deleteForecast([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - The ID of the job from which to delete forecasts + +|`forecast_id` or `forecastId` +|`string` - The ID of the forecast to delete, can be comma delimited list. Leaving blank implies `_all` + +|`allow_no_forecasts` or `allowNoForecasts` +|`boolean` - Whether to ignore if `_all` matches no forecasts + +|`timeout` +|`string` - Controls the time to wait until the forecast(s) are deleted. Default to 30 seconds + +|=== +=== ml.deleteJob +[source,js] +---- +client.ml.deleteJob([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - The ID of the job to delete + +|`force` +|`boolean` - True if the job should be forcefully deleted + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Should this request wait until the operation has completed before returning + + _Default:_ `true` + +|=== +=== ml.deleteModelSnapshot +[source,js] +---- +client.ml.deleteModelSnapshot([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-snapshot.html +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - The ID of the job to fetch + +|`snapshot_id` or `snapshotId` +|`string` - The ID of the snapshot to delete + +|=== +=== ml.findFileStructure +[source,js] +---- +client.ml.findFileStructure([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-file-structure.html +[cols=2*] +|=== +|`lines_to_sample` or `linesToSample` +|`number` - How many lines of the file should be included in the analysis + + _Default:_ `1000` + +|`timeout` +|`string` - Timeout after which the analysis will be aborted + + _Default:_ `25s` + +|`charset` +|`string` - Optional parameter to specify the character set of the file + +|`format` +|`'ndjson', 'xml', 'delimited', 'semi_structured_text'` - Optional parameter to specify the high level file format + +|`has_header_row` or `hasHeaderRow` +|`boolean` - Optional parameter to specify whether a delimited file includes the column names in its first row + +|`column_names` or `columnNames` +|`string, string[]` - Optional parameter containing a comma separated list of the column names for a delimited file + +|`delimiter` +|`string` - Optional parameter to specify the delimiter character for a delimited file - must be a single character + +|`quote` +|`string` - Optional parameter to specify the quote character for a delimited file - must be a single character + +|`should_trim_fields` or `shouldTrimFields` +|`boolean` - Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them + +|`grok_pattern` or `grokPattern` +|`string` - Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file + +|`timestamp_field` or `timestampField` +|`string` - Optional parameter to specify the timestamp field in the file + +|`timestamp_format` or `timestampFormat` +|`string` - Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format + +|`explain` +|`boolean` - Whether to include a commentary on how the structure was derived + +|`body` +|`object` - The contents of the file to be analyzed + +|=== +=== ml.flushJob +[source,js] +---- +client.ml.flushJob([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-flush-job.html +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - The name of the job to flush + +|`calc_interim` or `calcInterim` +|`boolean` - Calculates interim results for the most recent bucket or all buckets within the latency period + +|`start` +|`string` - When used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results + +|`end` +|`string` - When used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results + +|`advance_time` or `advanceTime` +|`string` - Advances time to the given value generating results and updating the model for the advanced interval + +|`skip_time` or `skipTime` +|`string` - Skips time to the given value without generating results or updating the model for the skipped interval + +|`body` +|`object` - Flush parameters + +|=== +=== ml.forecast +[source,js] +---- +client.ml.forecast([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - The ID of the job to forecast for + +|`duration` +|`string` - The duration of the forecast + +|`expires_in` or `expiresIn` +|`string` - The time interval after which the forecast expires. Expired forecasts will be deleted at the first opportunity. + +|=== +=== ml.getBuckets +[source,js] +---- +client.ml.getBuckets([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-bucket.html +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - ID of the job to get bucket results from + +|`timestamp` +|`string` - The timestamp of the desired single bucket result + +|`expand` +|`boolean` - Include anomaly records + +|`exclude_interim` or `excludeInterim` +|`boolean` - Exclude interim results + +|`from` +|`number` - skips a number of buckets + +|`size` +|`number` - specifies a max number of buckets to get + +|`start` +|`string` - Start time filter for buckets + +|`end` +|`string` - End time filter for buckets + +|`anomaly_score` or `anomalyScore` +|`number` - Filter for the most anomalous buckets + +|`sort` +|`string` - Sort buckets by a particular field + +|`desc` +|`boolean` - Set the sort direction + +|`body` +|`object` - Bucket selection details if not provided in URI + +|=== +=== ml.getCalendarEvents +[source,js] +---- +client.ml.getCalendarEvents([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`calendar_id` or `calendarId` +|`string` - The ID of the calendar containing the events + +|`job_id` or `jobId` +|`string` - Get events for the job. When this option is used calendar_id must be '_all' + +|`start` +|`string` - Get events after this time + +|`end` +|`string` - Get events before this time + +|`from` +|`number` - Skips a number of events + +|`size` +|`number` - Specifies a max number of events to get + +|=== +=== ml.getCalendars +[source,js] +---- +client.ml.getCalendars([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`calendar_id` or `calendarId` +|`string` - The ID of the calendar to fetch + +|`from` +|`number` - skips a number of calendars + +|`size` +|`number` - specifies a max number of calendars to get + +|=== +=== ml.getCategories +[source,js] +---- +client.ml.getCategories([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-category.html +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - The name of the job + +|`category_id` or `categoryId` +|`number` - The identifier of the category definition of interest + +|`from` +|`number` - skips a number of categories + +|`size` +|`number` - specifies a max number of categories to get + +|`body` +|`object` - Category selection details if not provided in URI + +|=== +=== ml.getDatafeedStats +[source,js] +---- +client.ml.getDatafeedStats([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed-stats.html +[cols=2*] +|=== +|`datafeed_id` or `datafeedId` +|`string` - The ID of the datafeeds stats to fetch + +|`allow_no_datafeeds` or `allowNoDatafeeds` +|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + +|=== +=== ml.getDatafeeds +[source,js] +---- +client.ml.getDatafeeds([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed.html +[cols=2*] +|=== +|`datafeed_id` or `datafeedId` +|`string` - The ID of the datafeeds to fetch + +|`allow_no_datafeeds` or `allowNoDatafeeds` +|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + +|=== +=== ml.getFilters +[source,js] +---- +client.ml.getFilters([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`filter_id` or `filterId` +|`string` - The ID of the filter to fetch + +|`from` +|`number` - skips a number of filters + +|`size` +|`number` - specifies a max number of filters to get + +|=== +=== ml.getInfluencers +[source,js] +---- +client.ml.getInfluencers([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-influencer.html +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - undefined + +|`exclude_interim` or `excludeInterim` +|`boolean` - Exclude interim results + +|`from` +|`number` - skips a number of influencers + +|`size` +|`number` - specifies a max number of influencers to get + +|`start` +|`string` - start timestamp for the requested influencers + +|`end` +|`string` - end timestamp for the requested influencers + +|`influencer_score` or `influencerScore` +|`number` - influencer score threshold for the requested influencers + +|`sort` +|`string` - sort field for the requested influencers + +|`desc` +|`boolean` - whether the results should be sorted in decending order + +|`body` +|`object` - Influencer selection criteria + +|=== +=== ml.getJobStats +[source,js] +---- +client.ml.getJobStats([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-stats.html +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - The ID of the jobs stats to fetch + +|`allow_no_jobs` or `allowNoJobs` +|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + +|=== +=== ml.getJobs +[source,js] +---- +client.ml.getJobs([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job.html +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - The ID of the jobs to fetch + +|`allow_no_jobs` or `allowNoJobs` +|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + +|=== +=== ml.getModelSnapshots +[source,js] +---- +client.ml.getModelSnapshots([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-snapshot.html +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - The ID of the job to fetch + +|`snapshot_id` or `snapshotId` +|`string` - The ID of the snapshot to fetch + +|`from` +|`number` - Skips a number of documents + +|`size` +|`number` - The default number of documents returned in queries as a string. + +|`start` +|`string` - The filter 'start' query parameter + +|`end` +|`string` - The filter 'end' query parameter + +|`sort` +|`string` - Name of the field to sort on + +|`desc` +|`boolean` - True if the results should be sorted in descending order + +|`body` +|`object` - Model snapshot selection criteria + +|=== +=== ml.getOverallBuckets +[source,js] +---- +client.ml.getOverallBuckets([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-overall-buckets.html +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - The job IDs for which to calculate overall bucket results + +|`top_n` or `topN` +|`number` - The number of top job bucket scores to be used in the overall_score calculation + +|`bucket_span` or `bucketSpan` +|`string` - The span of the overall buckets. Defaults to the longest job bucket_span + +|`overall_score` or `overallScore` +|`number` - Returns overall buckets with overall scores higher than this value + +|`exclude_interim` or `excludeInterim` +|`boolean` - If true overall buckets that include interim buckets will be excluded + +|`start` +|`string` - Returns overall buckets with timestamps after this time + +|`end` +|`string` - Returns overall buckets with timestamps earlier than this time + +|`allow_no_jobs` or `allowNoJobs` +|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + +|`body` +|`object` - Overall bucket selection details if not provided in URI + +|=== +=== ml.getRecords +[source,js] +---- +client.ml.getRecords([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-record.html +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - undefined + +|`exclude_interim` or `excludeInterim` +|`boolean` - Exclude interim results + +|`from` +|`number` - skips a number of records + +|`size` +|`number` - specifies a max number of records to get + +|`start` +|`string` - Start time filter for records + +|`end` +|`string` - End time filter for records + +|`record_score` or `recordScore` +|`number` - undefined + +|`sort` +|`string` - Sort records by a particular field + +|`desc` +|`boolean` - Set the sort direction + +|`body` +|`object` - Record selection criteria + +|=== +=== ml.info +[source,js] +---- +client.ml.info([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|=== +=== ml.openJob +[source,js] +---- +client.ml.openJob([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - The ID of the job to open + +|`ignore_downtime` or `ignoreDowntime` +|`boolean` - Controls if gaps in data are treated as anomalous or as a maintenance window after a job re-start + +|`timeout` +|`string` - Controls the time to wait until a job has opened. Default to 30 minutes + +|=== +=== ml.postCalendarEvents +[source,js] +---- +client.ml.postCalendarEvents([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`calendar_id` or `calendarId` +|`string` - The ID of the calendar to modify + +|`body` +|`object` - A list of events + +|=== +=== ml.postData +[source,js] +---- +client.ml.postData([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-data.html +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - The name of the job receiving the data + +|`reset_start` or `resetStart` +|`string` - Optional parameter to specify the start of the bucket resetting range + +|`reset_end` or `resetEnd` +|`string` - Optional parameter to specify the end of the bucket resetting range + +|`body` +|`object` - The data to process + +|=== +=== ml.previewDatafeed +[source,js] +---- +client.ml.previewDatafeed([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html +[cols=2*] +|=== +|`datafeed_id` or `datafeedId` +|`string` - The ID of the datafeed to preview + +|=== +=== ml.putCalendar +[source,js] +---- +client.ml.putCalendar([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`calendar_id` or `calendarId` +|`string` - The ID of the calendar to create + +|`body` +|`object` - The calendar details + +|=== +=== ml.putCalendarJob +[source,js] +---- +client.ml.putCalendarJob([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`calendar_id` or `calendarId` +|`string` - The ID of the calendar to modify + +|`job_id` or `jobId` +|`string` - The ID of the job to add to the calendar + +|=== +=== ml.putDatafeed +[source,js] +---- +client.ml.putDatafeed([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-datafeed.html +[cols=2*] +|=== +|`datafeed_id` or `datafeedId` +|`string` - The ID of the datafeed to create + +|`body` +|`object` - The datafeed config + +|=== +=== ml.putFilter +[source,js] +---- +client.ml.putFilter([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`filter_id` or `filterId` +|`string` - The ID of the filter to create + +|`body` +|`object` - The filter details + +|=== +=== ml.putJob +[source,js] +---- +client.ml.putJob([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - The ID of the job to create + +|`body` +|`object` - The job + +|=== +=== ml.revertModelSnapshot +[source,js] +---- +client.ml.revertModelSnapshot([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-revert-snapshot.html +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - The ID of the job to fetch + +|`snapshot_id` or `snapshotId` +|`string` - The ID of the snapshot to revert to + +|`delete_intervening_results` or `deleteInterveningResults` +|`boolean` - Should we reset the results back to the time of the snapshot? + +|`body` +|`object` - Reversion options + +|=== +=== ml.startDatafeed +[source,js] +---- +client.ml.startDatafeed([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-start-datafeed.html +[cols=2*] +|=== +|`datafeed_id` or `datafeedId` +|`string` - The ID of the datafeed to start + +|`start` +|`string` - The start time from where the datafeed should begin + +|`end` +|`string` - The end time when the datafeed should stop. When not set, the datafeed continues in real time + +|`timeout` +|`string` - Controls the time to wait until a datafeed has started. Default to 20 seconds + +|`body` +|`object` - The start datafeed parameters + +|=== +=== ml.stopDatafeed +[source,js] +---- +client.ml.stopDatafeed([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-stop-datafeed.html +[cols=2*] +|=== +|`datafeed_id` or `datafeedId` +|`string` - The ID of the datafeed to stop + +|`allow_no_datafeeds` or `allowNoDatafeeds` +|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + +|`force` +|`boolean` - True if the datafeed should be forcefully stopped. + +|`timeout` +|`string` - Controls the time to wait until a datafeed has stopped. Default to 20 seconds + +|=== +=== ml.updateDatafeed +[source,js] +---- +client.ml.updateDatafeed([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-datafeed.html +[cols=2*] +|=== +|`datafeed_id` or `datafeedId` +|`string` - The ID of the datafeed to update + +|`body` +|`object` - The datafeed update settings + +|=== +=== ml.updateFilter +[source,js] +---- +client.ml.updateFilter([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`filter_id` or `filterId` +|`string` - The ID of the filter to update + +|`body` +|`object` - The filter update + +|=== +=== ml.updateJob +[source,js] +---- +client.ml.updateJob([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-job.html +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - The ID of the job to create + +|`body` +|`object` - The job update settings + +|=== +=== ml.updateModelSnapshot +[source,js] +---- +client.ml.updateModelSnapshot([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-snapshot.html +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - The ID of the job to fetch + +|`snapshot_id` or `snapshotId` +|`string` - The ID of the snapshot to update + +|`body` +|`object` - The model snapshot properties to update + +|=== +=== ml.validate +[source,js] +---- +client.ml.validate([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`body` +|`object` - The job config + +|=== +=== ml.validateDetector +[source,js] +---- +client.ml.validateDetector([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`body` +|`object` - The detector + +|=== +=== monitoring.bulk +[source,js] +---- +client.monitoring.bulk([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/monitoring/current/appendix-api-bulk.html +[cols=2*] +|=== +|`type` +|`string` - Default document type for items which don't provide one + +|`system_id` or `systemId` +|`string` - Identifier of the monitored system + +|`system_api_version` or `systemApiVersion` +|`string` - API Version of the monitored system + +|`interval` +|`string` - Collection interval (e.g., '10s' or '10000ms') of the payload + +|`body` +|`object` - The operation definition and data (action-data pairs), separated by newlines + +|=== +=== security.authenticate +[source,js] +---- +client.security.authenticate([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-authenticate.html +[cols=2*] +|=== +|=== +=== security.changePassword +[source,js] +---- +client.security.changePassword([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-change-password.html +[cols=2*] +|=== +|`username` +|`string` - The username of the user to change the password for + +|`refresh` +|`'true', 'false', 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + +|`body` +|`object` - the new password for the user + +|=== +=== security.clearCachedRealms +[source,js] +---- +client.security.clearCachedRealms([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-cache.html +[cols=2*] +|=== +|`realms` +|`string, string[]` - Comma-separated list of realms to clear + +|`usernames` +|`string, string[]` - Comma-separated list of usernames to clear from the cache + +|=== +=== security.clearCachedRoles +[source,js] +---- +client.security.clearCachedRoles([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-role-cache.html +[cols=2*] +|=== +|`name` +|`string, string[]` - Role name + +|=== +=== security.deletePrivileges +[source,js] +---- +client.security.deletePrivileges([params] [, options] [, callback]) +---- +TODO +[cols=2*] +|=== +|`application` +|`string` - Application name + +|`name` +|`string` - Privilege name + +|`refresh` +|`'true', 'false', 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + +|=== +=== security.deleteRole +[source,js] +---- +client.security.deleteRole([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role.html +[cols=2*] +|=== +|`name` +|`string` - Role name + +|`refresh` +|`'true', 'false', 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + +|=== +=== security.deleteRoleMapping +[source,js] +---- +client.security.deleteRoleMapping([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role-mapping.html +[cols=2*] +|=== +|`name` +|`string` - Role-mapping name + +|`refresh` +|`'true', 'false', 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + +|=== +=== security.deleteUser +[source,js] +---- +client.security.deleteUser([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-user.html +[cols=2*] +|=== +|`username` +|`string` - username + +|`refresh` +|`'true', 'false', 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + +|=== +=== security.disableUser +[source,js] +---- +client.security.disableUser([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-disable-user.html +[cols=2*] +|=== +|`username` +|`string` - The username of the user to disable + +|`refresh` +|`'true', 'false', 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + +|=== +=== security.enableUser +[source,js] +---- +client.security.enableUser([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-enable-user.html +[cols=2*] +|=== +|`username` +|`string` - The username of the user to enable + +|`refresh` +|`'true', 'false', 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + +|=== +=== security.getPrivileges +[source,js] +---- +client.security.getPrivileges([params] [, options] [, callback]) +---- +TODO +[cols=2*] +|=== +|`application` +|`string` - Application name + +|`name` +|`string` - Privilege name + +|=== +=== security.getRole +[source,js] +---- +client.security.getRole([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html +[cols=2*] +|=== +|`name` +|`string` - Role name + +|=== +=== security.getRoleMapping +[source,js] +---- +client.security.getRoleMapping([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role-mapping.html +[cols=2*] +|=== +|`name` +|`string` - Role-Mapping name + +|=== +=== security.getToken +[source,js] +---- +client.security.getToken([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html +[cols=2*] +|=== +|`body` +|`object` - The token request to get + +|=== +=== security.getUser +[source,js] +---- +client.security.getUser([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user.html +[cols=2*] +|=== +|`username` +|`string, string[]` - A comma-separated list of usernames + +|=== +=== security.getUserPrivileges +[source,js] +---- +client.security.getUserPrivileges([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-privileges.html +[cols=2*] +|=== +|=== +=== security.hasPrivileges +[source,js] +---- +client.security.hasPrivileges([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html +[cols=2*] +|=== +|`user` +|`string` - Username + +|`body` +|`object` - The privileges to test + +|=== +=== security.invalidateToken +[source,js] +---- +client.security.invalidateToken([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html +[cols=2*] +|=== +|`body` +|`object` - The token to invalidate + +|=== +=== security.putPrivileges +[source,js] +---- +client.security.putPrivileges([params] [, options] [, callback]) +---- +TODO +[cols=2*] +|=== +|`refresh` +|`'true', 'false', 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + +|`body` +|`object` - The privilege(s) to add + +|=== +=== security.putRole +[source,js] +---- +client.security.putRole([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html +[cols=2*] +|=== +|`name` +|`string` - Role name + +|`refresh` +|`'true', 'false', 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + +|`body` +|`object` - The role to add + +|=== +=== security.putRoleMapping +[source,js] +---- +client.security.putRoleMapping([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role-mapping.html +[cols=2*] +|=== +|`name` +|`string` - Role-mapping name + +|`refresh` +|`'true', 'false', 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + +|`body` +|`object` - The role to add + +|=== +=== security.putUser +[source,js] +---- +client.security.putUser([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html +[cols=2*] +|=== +|`username` +|`string` - The username of the User + +|`refresh` +|`'true', 'false', 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + +|`body` +|`object` - The user to add + +|=== +=== ssl.certificates +[source,js] +---- +client.ssl.certificates([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-ssl.html +[cols=2*] +|=== +|=== +=== xpack.graph.explore +[source,js] +---- +client.xpack.graph.explore([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/graph-explore-api.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`type` +|`string, string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types + +|`routing` +|`string` - Specific routing value + +|`timeout` +|`string` - Explicit operation timeout + +|`body` +|`object` - Graph Query DSL + +|=== +=== xpack.info +[source,js] +---- +client.xpack.info([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/info-api.html +[cols=2*] +|=== +|`categories` +|`string, string[]` - Comma-separated list of info categories. Can be any of: build, license, features + +|=== +=== xpack.license.delete +[source,js] +---- +client.xpack.license.delete([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/x-pack/current/license-management.html +[cols=2*] +|=== +|=== +=== xpack.license.get +[source,js] +---- +client.xpack.license.get([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/x-pack/current/license-management.html +[cols=2*] +|=== +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|=== +=== xpack.license.getBasicStatus +[source,js] +---- +client.xpack.license.getBasicStatus([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/x-pack/current/license-management.html +[cols=2*] +|=== +|=== +=== xpack.license.getTrialStatus +[source,js] +---- +client.xpack.license.getTrialStatus([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/x-pack/current/license-management.html +[cols=2*] +|=== +|=== +=== xpack.license.post +[source,js] +---- +client.xpack.license.post([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/x-pack/current/license-management.html +[cols=2*] +|=== +|`acknowledge` +|`boolean` - whether the user has acknowledged acknowledge messages (default: false) + +|`body` +|`object` - licenses to be installed + +|=== +=== xpack.license.postStartBasic +[source,js] +---- +client.xpack.license.postStartBasic([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/x-pack/current/license-management.html +[cols=2*] +|=== +|`acknowledge` +|`boolean` - whether the user has acknowledged acknowledge messages (default: false) + +|=== +=== xpack.license.postStartTrial +[source,js] +---- +client.xpack.license.postStartTrial([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/x-pack/current/license-management.html +[cols=2*] +|=== +|`type` +|`string` - The type of trial license to generate (default: "trial") + +|`acknowledge` +|`boolean` - whether the user has acknowledged acknowledge messages (default: false) + +|=== +=== xpack.migration.deprecations +[source,js] +---- +client.xpack.migration.deprecations([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html +[cols=2*] +|=== +|`index` +|`string` - Index pattern + +|=== +=== xpack.migration.getAssistance +[source,js] +---- +client.xpack.migration.getAssistance([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-assistance.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open', 'closed', 'none', 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + + _Default:_ `open` + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|=== +=== xpack.migration.upgrade +[source,js] +---- +client.xpack.migration.upgrade([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-upgrade.html +[cols=2*] +|=== +|`index` +|`string` - The name of the index + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Should the request block until the upgrade operation is completed + + _Default:_ `true` + +|=== +=== xpack.rollup.deleteJob +[source,js] +---- +client.xpack.rollup.deleteJob([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`id` +|`string` - The ID of the job to delete + +|=== +=== xpack.rollup.getJobs +[source,js] +---- +client.xpack.rollup.getJobs([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`id` +|`string` - The ID of the job(s) to fetch. Accepts glob patterns, or left blank for all jobs + +|=== +=== xpack.rollup.getRollupCaps +[source,js] +---- +client.xpack.rollup.getRollupCaps([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`id` +|`string` - The ID of the index to check rollup capabilities on, or left blank for all jobs + +|=== +=== xpack.rollup.getRollupIndexCaps +[source,js] +---- +client.xpack.rollup.getRollupIndexCaps([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`index` +|`string` - The rollup index or index pattern to obtain rollup capabilities from. + +|=== +=== xpack.rollup.putJob +[source,js] +---- +client.xpack.rollup.putJob([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`id` +|`string` - The ID of the job to create + +|`body` +|`object` - The job configuration + +|=== +=== xpack.rollup.rollupSearch +[source,js] +---- +client.xpack.rollup.rollupSearch([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`index` +|`string` - The index or index-pattern (containing rollup or regular data) that should be searched + +|`type` +|`string` - The doc type inside the index + +|`typed_keys` or `typedKeys` +|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + +|`rest_total_hits_as_int` or `restTotalHitsAsInt` +|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response + +|`body` +|`object` - The search request body + +|=== +=== xpack.rollup.startJob +[source,js] +---- +client.xpack.rollup.startJob([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`id` +|`string` - The ID of the job to start + +|=== +=== xpack.rollup.stopJob +[source,js] +---- +client.xpack.rollup.stopJob([params] [, options] [, callback]) +---- + +[cols=2*] +|=== +|`id` +|`string` - The ID of the job to stop + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - True if the API should block until the job has fully stopped, false if should be executed async. Defaults to false. + +|`timeout` +|`string` - Block for (at maximum) the specified duration while waiting for the job to stop. Defaults to 30s. + +|=== +=== xpack.sql.clearCursor +[source,js] +---- +client.xpack.sql.clearCursor([params] [, options] [, callback]) +---- +Clear SQL cursor +[cols=2*] +|=== +|`body` +|`object` - Specify the cursor value in the `cursor` element to clean the cursor. + +|=== +=== xpack.sql.query +[source,js] +---- +client.xpack.sql.query([params] [, options] [, callback]) +---- +Execute SQL +[cols=2*] +|=== +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`body` +|`object` - Use the `query` element to start a query. Use the `cursor` element to continue a query. + +|=== +=== xpack.sql.translate +[source,js] +---- +client.xpack.sql.translate([params] [, options] [, callback]) +---- +Translate SQL into Elasticsearch queries +[cols=2*] +|=== +|`body` +|`object` - Specify the query in the `query` element. + +|=== +=== xpack.usage +[source,js] +---- +client.xpack.usage([params] [, options] [, callback]) +---- +Retrieve information about xpack features usage +[cols=2*] +|=== +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for watch write operation + +|=== +=== xpack.watcher.ackWatch +[source,js] +---- +client.xpack.watcher.ackWatch([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-ack-watch.html +[cols=2*] +|=== +|`watch_id` or `watchId` +|`string` - Watch ID + +|`action_id` or `actionId` +|`string, string[]` - A comma-separated list of the action ids to be acked + +|=== +=== xpack.watcher.activateWatch +[source,js] +---- +client.xpack.watcher.activateWatch([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-activate-watch.html +[cols=2*] +|=== +|`watch_id` or `watchId` +|`string` - Watch ID + +|=== +=== xpack.watcher.deactivateWatch +[source,js] +---- +client.xpack.watcher.deactivateWatch([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-deactivate-watch.html +[cols=2*] +|=== +|`watch_id` or `watchId` +|`string` - Watch ID + +|=== +=== xpack.watcher.deleteWatch +[source,js] +---- +client.xpack.watcher.deleteWatch([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-delete-watch.html +[cols=2*] +|=== +|`id` +|`string` - Watch ID + +|=== +=== xpack.watcher.executeWatch +[source,js] +---- +client.xpack.watcher.executeWatch([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-execute-watch.html +[cols=2*] +|=== +|`id` +|`string` - Watch ID + +|`debug` +|`boolean` - indicates whether the watch should execute in debug mode + +|`body` +|`object` - Execution control + +|=== +=== xpack.watcher.getWatch +[source,js] +---- +client.xpack.watcher.getWatch([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-watch.html +[cols=2*] +|=== +|`id` +|`string` - Watch ID + +|=== +=== xpack.watcher.putWatch +[source,js] +---- +client.xpack.watcher.putWatch([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html +[cols=2*] +|=== +|`id` +|`string` - Watch ID + +|`active` +|`boolean` - Specify whether the watch is in/active by default + +|`version` +|`number` - Explicit version number for concurrency control + +|`body` +|`object` - The watch + +|=== +=== xpack.watcher.start +[source,js] +---- +client.xpack.watcher.start([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-start.html +[cols=2*] +|=== +|=== +=== xpack.watcher.stats +[source,js] +---- +client.xpack.watcher.stats([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stats.html +[cols=2*] +|=== +|`metric` +|`'_all', 'queued_watches', 'current_watches', 'pending_watches'` - Controls what additional stat metrics should be include in the response + +|`metric` +|`'_all', 'queued_watches', 'current_watches', 'pending_watches'` - Controls what additional stat metrics should be include in the response + +|`emit_stacktraces` or `emitStacktraces` +|`boolean` - Emits stack traces of currently running watches + +|=== +=== xpack.watcher.stop +[source,js] +---- +client.xpack.watcher.stop([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stop.html +[cols=2*] +|=== +|=== \ No newline at end of file From 9bbae42ccca8d56f6f1f3a23895a923500ed5c6a Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 14 Feb 2019 16:25:03 +0100 Subject: [PATCH 121/172] Docs: Fix typo and added a note --- docs/typescript.asciidoc | 2 +- docs/usage.asciidoc | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/typescript.asciidoc b/docs/typescript.asciidoc index e3ed3875f..94148a5cd 100644 --- a/docs/typescript.asciidoc +++ b/docs/typescript.asciidoc @@ -2,7 +2,7 @@ The client offers a first-class support for TypeScript, since it ships the type definitions for every exposed API. -While the client offers tyoe definitions for Request parameters, Request bodies and responses are shipped with `any` because there is not an official spec that defines them, so we cannot make guarantees over them (but since they are shipped with `any`, you can easily override them with your own typing definitions). +While the client offers type definitions for Request parameters, Request bodies and responses are shipped with `any` because there is not an official spec that defines them, so we cannot make guarantees over them (but since they are shipped with `any`, you can easily override them with your own typing definitions). NOTE: If you are using TypeScript you will be required to use _snake_case_ style to define the API parameters instead of _camelCase_. diff --git a/docs/usage.asciidoc b/docs/usage.asciidoc index 15fbf5dc4..fd7de728f 100644 --- a/docs/usage.asciidoc +++ b/docs/usage.asciidoc @@ -34,6 +34,8 @@ The returned value of every API call is formed as follows: } ---- +NOTE: The body will be a boolean value when using `HEAD` APIs. + The above valiue will be returned even if there is an error during the execution of the request, this means that you can safely use the https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment[destructuring assignment]. [source,js] From 1c2dbf6e765eb6fc578c0487877bb5924e698636 Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 14 Feb 2019 16:25:16 +0100 Subject: [PATCH 122/172] Added examples --- docs/examples/bulk.asciidoc | 58 +++++++++++++++++++ docs/examples/exists.asciidoc | 33 +++++++++++ docs/examples/get.asciidoc | 32 +++++++++++ docs/examples/scroll.asciidoc | 95 +++++++++++++++++++++++++++++++ docs/examples/search.asciidoc | 59 +++++++++++++++++++ docs/examples/typescript.asciidoc | 65 +++++++++++++++++++++ 6 files changed, 342 insertions(+) create mode 100644 docs/examples/bulk.asciidoc create mode 100644 docs/examples/exists.asciidoc create mode 100644 docs/examples/get.asciidoc create mode 100644 docs/examples/scroll.asciidoc create mode 100644 docs/examples/search.asciidoc create mode 100644 docs/examples/typescript.asciidoc diff --git a/docs/examples/bulk.asciidoc b/docs/examples/bulk.asciidoc new file mode 100644 index 000000000..93c5397c1 --- /dev/null +++ b/docs/examples/bulk.asciidoc @@ -0,0 +1,58 @@ += Bulk + +The `bulk` API makes it possible to perform many index/delete operations in a single API call. + +This can greatly increase the indexing speed. + +[source,js] +---- +'use strict' + +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ node: 'http://localhost:9200' }) + +async function run () { + await client.bulk({ + // here we are forcing an index refresh, + // otherwise we will not get any result + // in the consequent search + refresh: true, + body: [ + // operation to perform + { index: { _index: 'game-of-thrones' } }, + // the document to index + { + character: 'Ned Stark', + quote: 'Winter is coming.' + }, + + { index: { _index: 'game-of-thrones' } }, + { + character: 'Daenerys Targaryen', + quote: 'I am the blood of the dragon.' + }, + + { index: { _index: 'game-of-thrones' } }, + { + character: 'Tyrion Lannister', + quote: 'A mind needs books like a sword needs a whetstone.' + } + ] + }) + + // Let's search! + const { body } = await client.search({ + index: 'game-of-thrones', + body: { + query: { + match: { + quote: 'winter' + } + } + } + }) + + console.log(body.hits.hits) +} + +run().catch(console.log) +---- \ No newline at end of file diff --git a/docs/examples/exists.asciidoc b/docs/examples/exists.asciidoc new file mode 100644 index 000000000..4c64287a3 --- /dev/null +++ b/docs/examples/exists.asciidoc @@ -0,0 +1,33 @@ += Exists + +Check that the document `/game-of-thrones/1` exists. + +NOTE: Since this API uses the `HEAD` method, the body value will be boolean. + +[source,js] +--------- +'use strict' + +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ node: 'http://localhost:9200' }) + +async function run () { + await client.index({ + index: 'game-of-thrones', + id: '1', + body: { + character: 'Ned Stark', + quote: 'Winter is coming.' + } + }) + + const { body } = await client.exists({ + index: 'game-of-thrones', + id: 1 + }) + + console.log(body) // true +} + +run().catch(console.log) +--------- \ No newline at end of file diff --git a/docs/examples/get.asciidoc b/docs/examples/get.asciidoc new file mode 100644 index 000000000..b978bc8ce --- /dev/null +++ b/docs/examples/get.asciidoc @@ -0,0 +1,32 @@ += Get + +The get API allows to get a typed JSON document from the index based on its id. + +The following example gets a JSON document from an index called `game-of-thrones`, under a type called `_doc`, with id valued `'1'`. + +[source,js] +--------- +'use strict' + +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ node: 'http://localhost:9200' }) + +async function run () { + await client.index({ + index: 'game-of-thrones', + id: '1', + body: { + character: 'Ned Stark', + quote: 'Winter is coming.' + } + }) + + const { body } = await client.get({ + index: 'game-of-thrones', + id: '1' + }) + + console.log(body) +} + +run().catch(console.log) +--------- \ No newline at end of file diff --git a/docs/examples/scroll.asciidoc b/docs/examples/scroll.asciidoc new file mode 100644 index 000000000..eadddef55 --- /dev/null +++ b/docs/examples/scroll.asciidoc @@ -0,0 +1,95 @@ += Scroll + +While a search request returns a single “page” of results, the scroll API can be used to retrieve large numbers of results (or even all results) from a single search request, in much the same way as you would use a cursor on a traditional database. + +Scrolling is not intended for real time user requests, but rather for processing large amounts of data, e.g. in order to reindex the contents of one index into a new index with a different configuration. + +NOTE: The results that are returned from a scroll request reflect the state of the index at the time that the initial search request was made, like a snapshot in time. Subsequent changes to documents (index, update or delete) will only affect later search requests. + +In order to use scrolling, the initial search request should specify the scroll parameter in the query string, which tells Elasticsearch how long it should keep the “search context” alive. + +[source,js] +---- +'use strict' + +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ node: 'http://localhost:9200' }) + +async function run () { + const allQuotes = [] + const responseQueue = [] + + // Let's index some data! + await client.bulk({ + // here we are forcing an index refresh, + // otherwise we will not get any result + // in the consequent search + refresh: true, + body: [ + // operation to perform + { index: { _index: 'game-of-thrones' } }, + // the document to index + { + character: 'Ned Stark', + quote: 'Winter is coming.' + }, + + { index: { _index: 'game-of-thrones' } }, + { + character: 'Daenerys Targaryen', + quote: 'I am the blood of the dragon.' + }, + + { index: { _index: 'game-of-thrones' } }, + { + character: 'Tyrion Lannister', + quote: 'A mind needs books like a sword needs a whetstone.' + } + ] + }) + + // start things off by searching, setting a scroll timeout, and pushing + // our first response into the queue to be processed + const response = await client.search({ + index: 'game-of-thrones', + // keep the search results "scrollable" for 30 seconds + scroll: '30s', + // for the sake of this example, we will get only one result per search + size: 1, + // filter the source to only include the quote field + _source: ['quote'], + body: { + query: { + match_all: {} + } + } + }) + + responseQueue.push(response) + + while (responseQueue.length) { + const { body } = responseQueue.shift() + + // collect the titles from this response + body.hits.hits.forEach(function (hit) { + allQuotes.push(hit._source.quote) + }) + + // check to see if we have collected all of the quotes + if (body.hits.total.value === allQuotes.length) { + console.log('Every quote', allQuotes) + break + } + + // get the next response if there are more quotes to fetch + responseQueue.push( + await client.scroll({ + scrollId: body._scroll_id, + scroll: '30s' + }) + ) + } +} + +run().catch(console.log) +---- \ No newline at end of file diff --git a/docs/examples/search.asciidoc b/docs/examples/search.asciidoc new file mode 100644 index 000000000..794efc1e5 --- /dev/null +++ b/docs/examples/search.asciidoc @@ -0,0 +1,59 @@ += Search + +The `search` API allows you to execute a search query and get back search hits that match the query. + +The query can either be provided using a simple https://www.elastic.co/guide/en/elasticsearch/reference/6.6/search-uri-request.html[query string as a parameter], or using a https://www.elastic.co/guide/en/elasticsearch/reference/6.6/search-request-body.html[request body]. + +[source,js] +---- +'use strict' + +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ node: 'http://localhost:9200' }) + +async function run () { + // Let's start by indexing some data + await client.index({ + index: 'game-of-thrones', + body: { + character: 'Ned Stark', + quote: 'Winter is coming.' + } + }) + + await client.index({ + index: 'game-of-thrones', + body: { + character: 'Daenerys Targaryen', + quote: 'I am the blood of the dragon.' + } + }) + + await client.index({ + index: 'game-of-thrones', + // here we are forcing an index refresh, + // otherwise we will not get any result + // in the consequent search + refresh: true, + body: { + character: 'Tyrion Lannister', + quote: 'A mind needs books like a sword needs a whetstone.' + } + }) + + // Let's search! + const { body } = await client.search({ + index: 'game-of-thrones', + body: { + query: { + match: { + quote: 'winter' + } + } + } + }) + + console.log(body.hits.hits) +} + +run().catch(console.log) +---- \ No newline at end of file diff --git a/docs/examples/typescript.asciidoc b/docs/examples/typescript.asciidoc new file mode 100644 index 000000000..2591fdd7d --- /dev/null +++ b/docs/examples/typescript.asciidoc @@ -0,0 +1,65 @@ += Typescript + +The client offers a first-class support for TypeScript, since it ships the type definitions for every exposed API. + +NOTE: If you are using TypeScript you will be required to use _snake_case_ style to define the API parameters instead of _camelCase_. + +[source,ts] +---- +'use strict' + +import { Client, ApiResponse } from '@elastic/elasticsearch' +const client = new Client({ node: 'http://localhost:9200' }) + +async function run (): void { + // Let's start by indexing some data + await client.index({ + index: 'game-of-thrones', + body: { + character: 'Ned Stark', + quote: 'Winter is coming.' + } + }) + + await client.index({ + index: 'game-of-thrones', + body: { + character: 'Daenerys Targaryen', + quote: 'I am the blood of the dragon.' + } + }) + + await client.index({ + index: 'game-of-thrones', + // here we are forcing an index refresh, + // otherwise we will not get any result + // in the consequent search + refresh: true, + body: { + character: 'Tyrion Lannister', + quote: 'A mind needs books like a sword needs a whetstone.' + } + }) + + // Let's search! + client + .search({ + index: 'game-of-thrones', + body: { + query: { + match: { + quote: 'winter' + } + } + } + }) + .then((result: ApiResponse) => { + console.og(result.body.hits.hits) + }) + .catch((err: Error) => { + console.log(err) + }) +} + +run() +---- \ No newline at end of file From f704d4fcf39e1d0e6865ca6354383b8f5c105060 Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 14 Feb 2019 18:34:20 +0100 Subject: [PATCH 123/172] Added examples --- docs/examples/msearch.asciidoc | 51 ++++++++++++++++++++ docs/examples/scroll.asciidoc | 79 +++++++++++++++++++++++++++++++ docs/examples/suggest.asciidoc | 59 +++++++++++++++++++++++ docs/examples/typescript.asciidoc | 36 +++++++------- 4 files changed, 209 insertions(+), 16 deletions(-) create mode 100644 docs/examples/msearch.asciidoc create mode 100644 docs/examples/suggest.asciidoc diff --git a/docs/examples/msearch.asciidoc b/docs/examples/msearch.asciidoc new file mode 100644 index 000000000..f81cc0c04 --- /dev/null +++ b/docs/examples/msearch.asciidoc @@ -0,0 +1,51 @@ += MSearch + +The multi search API allows to execute several search requests within the same API. + +[source,js] +---- +'use strict' + +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ node: 'http://localhost:9200' }) + +async function run () { + await client.bulk({ + refresh: true, + body: [ + { index: { _index: 'game-of-thrones' } }, + { + character: 'Ned Stark', + quote: 'Winter is coming.' + }, + + { index: { _index: 'game-of-thrones' } }, + { + character: 'Daenerys Targaryen', + quote: 'I am the blood of the dragon.' + }, + + { index: { _index: 'game-of-thrones' } }, + { + character: 'Tyrion Lannister', + quote: 'A mind needs books like a sword needs a whetstone.' + } + ] + }) + + const { body } = await client.msearch({ + body: [ + { index: 'game-of-thrones' }, + { query: { match: { character: 'Daenerys' } } }, + + { index: 'game-of-thrones' }, + { query: { match: { character: 'Tyrion' } } } + ] + }) + + console.log(body.responses) +} + +run().catch(console.log) + +---- \ No newline at end of file diff --git a/docs/examples/scroll.asciidoc b/docs/examples/scroll.asciidoc index eadddef55..90ade2fb6 100644 --- a/docs/examples/scroll.asciidoc +++ b/docs/examples/scroll.asciidoc @@ -91,5 +91,84 @@ async function run () { } } +run().catch(console.log) +---- + +Another cool usage of the `scroll` API can be done with Node.js ≥ 10, by using async iteration! + +[source,js] +---- +'use strict' + +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ node: 'http://localhost:9200' }) + +// Scroll utility +async function * scrollSearch (params) { + var response = await client.search(params) + + while (true) { + const sourceHits = response.body.hits.hits + + if (sourceHits.length === 0) { + break + } + + for (const hit of sourceHits) { + yield hit + } + + if (!response.body._scroll_id) { + break + } + + response = await client.scroll({ + scrollId: response.body._scroll_id, + scroll: params.scroll + }) + } +} + +async function run () { + await client.bulk({ + refresh: true, + body: [ + { index: { _index: 'game-of-thrones' } }, + { + character: 'Ned Stark', + quote: 'Winter is coming.' + }, + + { index: { _index: 'game-of-thrones' } }, + { + character: 'Daenerys Targaryen', + quote: 'I am the blood of the dragon.' + }, + + { index: { _index: 'game-of-thrones' } }, + { + character: 'Tyrion Lannister', + quote: 'A mind needs books like a sword needs a whetstone.' + } + ] + }) + + const params = { + index: 'game-of-thrones', + scroll: '30s', + size: 1, + _source: ['quote'], + body: { + query: { + match_all: {} + } + } + } + + for await (const hit of scrollSearch(params)) { + console.log(hit._source) + } +} + run().catch(console.log) ---- \ No newline at end of file diff --git a/docs/examples/suggest.asciidoc b/docs/examples/suggest.asciidoc new file mode 100644 index 000000000..d691d8344 --- /dev/null +++ b/docs/examples/suggest.asciidoc @@ -0,0 +1,59 @@ += Suggest + +The suggest feature suggests similar looking terms based on a provided text by using a suggester. _Parts of the suggest feature are still under development._ + +The suggest request part is defined alongside the query part in a `search` request. + +If the query part is left out, only suggestions are returned. + +[source,js] +---- +'use strict' + +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ node: 'http://localhost:9200' }) + +async function run () { + await client.bulk({ + refresh: true, + body: [ + { index: { _index: 'game-of-thrones' } }, + { + character: 'Ned Stark', + quote: 'Winter is coming.' + }, + + { index: { _index: 'game-of-thrones' } }, + { + character: 'Daenerys Targaryen', + quote: 'I am the blood of the dragon.' + }, + + { index: { _index: 'game-of-thrones' } }, + { + character: 'Tyrion Lannister', + quote: 'A mind needs books like a sword needs a whetstone.' + } + ] + }) + + const { body } = await client.search({ + index: 'game-of-thrones', + body: { + query: { + match: { quote: 'witner' } + }, + suggest: { + gotsuggest: { + text: 'witner', + term: { field: 'quote' } + } + } + } + }) + + console.log(body) +} + +run().catch(console.log) + +---- \ No newline at end of file diff --git a/docs/examples/typescript.asciidoc b/docs/examples/typescript.asciidoc index 2591fdd7d..b3df28b74 100644 --- a/docs/examples/typescript.asciidoc +++ b/docs/examples/typescript.asciidoc @@ -8,28 +8,30 @@ NOTE: If you are using TypeScript you will be required to use _snake_case_ style ---- 'use strict' -import { Client, ApiResponse } from '@elastic/elasticsearch' +import { Client, ApiResponse, RequestParams } from '@elastic/elasticsearch' const client = new Client({ node: 'http://localhost:9200' }) async function run (): void { // Let's start by indexing some data - await client.index({ + const doc1: RequestParams.Index = { index: 'game-of-thrones', body: { character: 'Ned Stark', quote: 'Winter is coming.' } - }) + } + await client.index(doc1) - await client.index({ + const doc2: RequestParams.Index = { index: 'game-of-thrones', body: { character: 'Daenerys Targaryen', quote: 'I am the blood of the dragon.' } - }) + } + await client.index(doc2) - await client.index({ + const doc3: RequestParams.Index = { index: 'game-of-thrones', // here we are forcing an index refresh, // otherwise we will not get any result @@ -39,20 +41,22 @@ async function run (): void { character: 'Tyrion Lannister', quote: 'A mind needs books like a sword needs a whetstone.' } - }) + } + await client.index(doc3) // Let's search! - client - .search({ - index: 'game-of-thrones', - body: { - query: { - match: { - quote: 'winter' - } + const params: RequestParams.Search = { + index: 'game-of-thrones', + body: { + query: { + match: { + quote: 'winter' } } - }) + } + } + client + .search(params) .then((result: ApiResponse) => { console.og(result.body.hits.hits) }) From 96fe644eb20ca8538b24ea4c6d3cc32f745357c6 Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 15 Feb 2019 10:29:48 +0100 Subject: [PATCH 124/172] API generation --- api/api/ccr.follow.js | 5 +- api/api/ccr.follow_info.js | 106 ++++++++++++++++++++++ api/api/ccr.resume_follow.js | 6 -- api/api/create.js | 12 ++- api/api/delete.js | 6 ++ api/api/exists_source.js | 14 ++- api/api/get_source.js | 14 ++- api/api/index.js | 6 ++ api/api/indices.create.js | 2 +- api/api/indices.get.js | 3 + api/api/indices.get_field_mapping.js | 3 + api/api/indices.get_mapping.js | 2 +- api/api/indices.get_template.js | 3 + api/api/indices.put_mapping.js | 2 +- api/api/indices.put_template.js | 3 + api/api/indices.rollover.js | 3 + api/api/ml.close_job.js | 1 + api/api/ml.set_upgrade_mode.js | 116 ++++++++++++++++++++++++ api/api/msearch.js | 3 + api/api/msearch_template.js | 3 + api/api/search.js | 6 ++ api/api/search_template.js | 3 + api/api/security.create_api_key.js | 115 ++++++++++++++++++++++++ api/api/security.get_api_key.js | 120 +++++++++++++++++++++++++ api/api/security.invalidate_api_key.js | 114 +++++++++++++++++++++++ api/api/update.js | 11 +-- api/api/xpack.watcher.put_watch.js | 9 +- api/index.js | 10 +++ api/requestParams.d.ts | 61 +++++++++++-- 29 files changed, 712 insertions(+), 50 deletions(-) create mode 100644 api/api/ccr.follow_info.js create mode 100644 api/api/ml.set_upgrade_mode.js create mode 100644 api/api/security.create_api_key.js create mode 100644 api/api/security.get_api_key.js create mode 100644 api/api/security.invalidate_api_key.js diff --git a/api/api/ccr.follow.js b/api/api/ccr.follow.js index 8c7e1b803..61e1d0b6d 100644 --- a/api/api/ccr.follow.js +++ b/api/api/ccr.follow.js @@ -10,15 +10,16 @@ function buildCcrFollow (opts) { * Perform a [ccr.follow](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html) request * * @param {string} index - The name of the follower index + * @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before returning. Defaults to 0. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) * @param {object} body - The name of the leader index and other optional ccr related parameters */ const acceptedQuerystring = [ - + 'wait_for_active_shards' ] const snakeCase = { - + waitForActiveShards: 'wait_for_active_shards' } return function ccrFollow (params, options, callback) { diff --git a/api/api/ccr.follow_info.js b/api/api/ccr.follow_info.js new file mode 100644 index 000000000..13d9f35a8 --- /dev/null +++ b/api/api/ccr.follow_info.js @@ -0,0 +1,106 @@ +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildCcrFollowInfo (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ccr.follow_info](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-info.html) request + * + * @param {list} index - A comma-separated list of index patterns; use `_all` to perform the operation on all indices + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function ccrFollowInfo (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ccrFollowInfo(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), + result + ) + } + + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'info' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + compression: options.compression || false, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildCcrFollowInfo diff --git a/api/api/ccr.resume_follow.js b/api/api/ccr.resume_follow.js index 961947862..259462aca 100644 --- a/api/api/ccr.resume_follow.js +++ b/api/api/ccr.resume_follow.js @@ -48,12 +48,6 @@ function buildCcrResumeFollow (opts) { result ) } - if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) - } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { diff --git a/api/api/create.js b/api/api/create.js index 062e5c4c8..462407692 100644 --- a/api/api/create.js +++ b/api/api/create.js @@ -79,12 +79,6 @@ function buildCreate (opts) { result ) } - if (params['type'] == null) { - return callback( - new ConfigurationError('Missing required parameter: type'), - result - ) - } if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), @@ -128,7 +122,11 @@ function buildCreate (opts) { var path = '' - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_create' + if ((index) != null && (type) != null && (id) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_create' + } else { + path = '/' + encodeURIComponent(index) + '/' + '_create' + '/' + encodeURIComponent(id) + } // build request object const request = { diff --git a/api/api/delete.js b/api/api/delete.js index abef3c447..92afd3d0a 100644 --- a/api/api/delete.js +++ b/api/api/delete.js @@ -17,6 +17,8 @@ function buildDelete (opts) { * @param {enum} refresh - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. * @param {string} routing - Specific routing value * @param {time} timeout - Explicit operation timeout + * @param {number} if_seq_no - only perform the delete operation if the last operation that has changed the document has the specified sequence number + * @param {number} if_primary_term - only perform the delete operation if the last operation that has changed the document has the specified primary term * @param {number} version - Explicit version number for concurrency control * @param {enum} version_type - Specific version type */ @@ -27,6 +29,8 @@ function buildDelete (opts) { 'refresh', 'routing', 'timeout', + 'if_seq_no', + 'if_primary_term', 'version', 'version_type', 'pretty', @@ -38,6 +42,8 @@ function buildDelete (opts) { const snakeCase = { waitForActiveShards: 'wait_for_active_shards', + ifSeqNo: 'if_seq_no', + ifPrimaryTerm: 'if_primary_term', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' diff --git a/api/api/exists_source.js b/api/api/exists_source.js index afb2b531a..fdf9a0ce3 100644 --- a/api/api/exists_source.js +++ b/api/api/exists_source.js @@ -11,7 +11,7 @@ function buildExistsSource (opts) { * * @param {string} id - The document ID * @param {string} index - The name of the index - * @param {string} type - The type of the document; use `_all` to fetch the first document matching the ID across all types + * @param {string} type - The type of the document; deprecated and optional starting with 7.0 * @param {string} parent - The ID of the parent document * @param {string} preference - Specify the node or shard the operation should be performed on (default: random) * @param {boolean} realtime - Specify whether to perform the operation in realtime or search mode @@ -83,12 +83,6 @@ function buildExistsSource (opts) { result ) } - if (params['type'] == null) { - return callback( - new ConfigurationError('Missing required parameter: type'), - result - ) - } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), @@ -132,7 +126,11 @@ function buildExistsSource (opts) { var path = '' - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source' + if ((index) != null && (type) != null && (id) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source' + } else { + path = '/' + encodeURIComponent(index) + '/' + '_source' + '/' + encodeURIComponent(id) + } // build request object const request = { diff --git a/api/api/get_source.js b/api/api/get_source.js index 003667bbf..2578a0252 100644 --- a/api/api/get_source.js +++ b/api/api/get_source.js @@ -11,7 +11,7 @@ function buildGetSource (opts) { * * @param {string} id - The document ID * @param {string} index - The name of the index - * @param {string} type - The type of the document; use `_all` to fetch the first document matching the ID across all types + * @param {string} type - The type of the document; deprecated and optional starting with 7.0 * @param {string} parent - The ID of the parent document * @param {string} preference - Specify the node or shard the operation should be performed on (default: random) * @param {boolean} realtime - Specify whether to perform the operation in realtime or search mode @@ -83,12 +83,6 @@ function buildGetSource (opts) { result ) } - if (params['type'] == null) { - return callback( - new ConfigurationError('Missing required parameter: type'), - result - ) - } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), @@ -132,7 +126,11 @@ function buildGetSource (opts) { var path = '' - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source' + if ((index) != null && (type) != null && (id) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source' + } else { + path = '/' + encodeURIComponent(index) + '/' + '_source' + '/' + encodeURIComponent(id) + } // build request object const request = { diff --git a/api/api/index.js b/api/api/index.js index 09508b801..051977d18 100644 --- a/api/api/index.js +++ b/api/api/index.js @@ -20,6 +20,8 @@ function buildIndex (opts) { * @param {time} timeout - Explicit operation timeout * @param {number} version - Explicit version number for concurrency control * @param {enum} version_type - Specific version type + * @param {number} if_seq_no - only perform the index operation if the last operation that has changed the document has the specified sequence number + * @param {number} if_primary_term - only perform the index operation if the last operation that has changed the document has the specified primary term * @param {string} pipeline - The pipeline id to preprocess incoming documents with * @param {object} body - The document */ @@ -33,6 +35,8 @@ function buildIndex (opts) { 'timeout', 'version', 'version_type', + 'if_seq_no', + 'if_primary_term', 'pipeline', 'pretty', 'human', @@ -45,6 +49,8 @@ function buildIndex (opts) { waitForActiveShards: 'wait_for_active_shards', opType: 'op_type', versionType: 'version_type', + ifSeqNo: 'if_seq_no', + ifPrimaryTerm: 'if_primary_term', errorTrace: 'error_trace', filterPath: 'filter_path' } diff --git a/api/api/indices.create.js b/api/api/indices.create.js index a2ba5b0f8..24a05e698 100644 --- a/api/api/indices.create.js +++ b/api/api/indices.create.js @@ -10,7 +10,7 @@ function buildIndicesCreate (opts) { * Perform a [indices.create](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-index.html) request * * @param {string} index - The name of the index - * @param {string} include_type_name - Whether a type should be expected in the body of the mappings. + * @param {boolean} include_type_name - Whether a type should be expected in the body of the mappings. * @param {string} wait_for_active_shards - Set the number of active shards to wait for before the operation returns. * @param {time} timeout - Explicit operation timeout * @param {time} master_timeout - Specify timeout for connection to master diff --git a/api/api/indices.get.js b/api/api/indices.get.js index a662c5753..2c22c4fd9 100644 --- a/api/api/indices.get.js +++ b/api/api/indices.get.js @@ -10,6 +10,7 @@ function buildIndicesGet (opts) { * Perform a [indices.get](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-index.html) request * * @param {list} index - A comma-separated list of index names + * @param {boolean} include_type_name - Whether to add the type name to the response (default: false) * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) * @param {boolean} ignore_unavailable - Ignore unavailable indexes (default: false) * @param {boolean} allow_no_indices - Ignore if a wildcard expression resolves to no concrete indices (default: false) @@ -20,6 +21,7 @@ function buildIndicesGet (opts) { */ const acceptedQuerystring = [ + 'include_type_name', 'local', 'ignore_unavailable', 'allow_no_indices', @@ -35,6 +37,7 @@ function buildIndicesGet (opts) { ] const snakeCase = { + includeTypeName: 'include_type_name', ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', diff --git a/api/api/indices.get_field_mapping.js b/api/api/indices.get_field_mapping.js index fa211f636..fbf4a1498 100644 --- a/api/api/indices.get_field_mapping.js +++ b/api/api/indices.get_field_mapping.js @@ -12,6 +12,7 @@ function buildIndicesGetFieldMapping (opts) { * @param {list} index - A comma-separated list of index names * @param {list} type - A comma-separated list of document types * @param {list} fields - A comma-separated list of fields + * @param {boolean} include_type_name - Whether a type should be returned in the body of the mappings. * @param {boolean} include_defaults - Whether the default mapping values should be returned as well * @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) @@ -20,6 +21,7 @@ function buildIndicesGetFieldMapping (opts) { */ const acceptedQuerystring = [ + 'include_type_name', 'include_defaults', 'ignore_unavailable', 'allow_no_indices', @@ -33,6 +35,7 @@ function buildIndicesGetFieldMapping (opts) { ] const snakeCase = { + includeTypeName: 'include_type_name', includeDefaults: 'include_defaults', ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', diff --git a/api/api/indices.get_mapping.js b/api/api/indices.get_mapping.js index 315e1c11e..29946a529 100644 --- a/api/api/indices.get_mapping.js +++ b/api/api/indices.get_mapping.js @@ -11,7 +11,7 @@ function buildIndicesGetMapping (opts) { * * @param {list} index - A comma-separated list of index names * @param {list} type - A comma-separated list of document types - * @param {string} include_type_name - Whether to add the type name to the response + * @param {boolean} include_type_name - Whether to add the type name to the response (default: false) * @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. diff --git a/api/api/indices.get_template.js b/api/api/indices.get_template.js index ab2848ca6..9b439d659 100644 --- a/api/api/indices.get_template.js +++ b/api/api/indices.get_template.js @@ -10,12 +10,14 @@ function buildIndicesGetTemplate (opts) { * Perform a [indices.get_template](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html) request * * @param {list} name - The comma separated names of the index templates + * @param {boolean} include_type_name - Whether a type should be returned in the body of the mappings. * @param {boolean} flat_settings - Return settings in flat format (default: false) * @param {time} master_timeout - Explicit operation timeout for connection to master node * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) */ const acceptedQuerystring = [ + 'include_type_name', 'flat_settings', 'master_timeout', 'local', @@ -27,6 +29,7 @@ function buildIndicesGetTemplate (opts) { ] const snakeCase = { + includeTypeName: 'include_type_name', flatSettings: 'flat_settings', masterTimeout: 'master_timeout', errorTrace: 'error_trace', diff --git a/api/api/indices.put_mapping.js b/api/api/indices.put_mapping.js index 41834d339..d40e0efff 100644 --- a/api/api/indices.put_mapping.js +++ b/api/api/indices.put_mapping.js @@ -11,7 +11,7 @@ function buildIndicesPutMapping (opts) { * * @param {list} index - A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. * @param {string} type - The name of the document type - * @param {string} include_type_name - Whether a type should be expected in the body of the mappings. + * @param {boolean} include_type_name - Whether a type should be expected in the body of the mappings. * @param {time} timeout - Explicit operation timeout * @param {time} master_timeout - Specify timeout for connection to master * @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) diff --git a/api/api/indices.put_template.js b/api/api/indices.put_template.js index 565020d7e..11121db57 100644 --- a/api/api/indices.put_template.js +++ b/api/api/indices.put_template.js @@ -10,6 +10,7 @@ function buildIndicesPutTemplate (opts) { * Perform a [indices.put_template](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html) request * * @param {string} name - The name of the template + * @param {boolean} include_type_name - Whether a type should be returned in the body of the mappings. * @param {number} order - The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers) * @param {boolean} create - Whether the index template should only be added if new or can also replace an existing one * @param {time} timeout - Explicit operation timeout @@ -19,6 +20,7 @@ function buildIndicesPutTemplate (opts) { */ const acceptedQuerystring = [ + 'include_type_name', 'order', 'create', 'timeout', @@ -32,6 +34,7 @@ function buildIndicesPutTemplate (opts) { ] const snakeCase = { + includeTypeName: 'include_type_name', masterTimeout: 'master_timeout', flatSettings: 'flat_settings', errorTrace: 'error_trace', diff --git a/api/api/indices.rollover.js b/api/api/indices.rollover.js index 80b3c2f0e..7872cb241 100644 --- a/api/api/indices.rollover.js +++ b/api/api/indices.rollover.js @@ -11,6 +11,7 @@ function buildIndicesRollover (opts) { * * @param {string} alias - The name of the alias to rollover * @param {string} new_index - The name of the rollover index + * @param {boolean} include_type_name - Whether a type should be included in the body of the mappings. * @param {time} timeout - Explicit operation timeout * @param {boolean} dry_run - If set to true the rollover action will only be validated but not actually performed even if a condition matches. The default is false * @param {time} master_timeout - Specify timeout for connection to master @@ -19,6 +20,7 @@ function buildIndicesRollover (opts) { */ const acceptedQuerystring = [ + 'include_type_name', 'timeout', 'dry_run', 'master_timeout', @@ -31,6 +33,7 @@ function buildIndicesRollover (opts) { ] const snakeCase = { + includeTypeName: 'include_type_name', dryRun: 'dry_run', masterTimeout: 'master_timeout', waitForActiveShards: 'wait_for_active_shards', diff --git a/api/api/ml.close_job.js b/api/api/ml.close_job.js index a002e4c28..0d36e9ec2 100644 --- a/api/api/ml.close_job.js +++ b/api/api/ml.close_job.js @@ -13,6 +13,7 @@ function buildMlCloseJob (opts) { * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) * @param {boolean} force - True if the job should be forcefully closed * @param {time} timeout - Controls the time to wait until a job has closed. Default to 30 minutes + * @param {object} body - The URL params optionally sent in the body */ const acceptedQuerystring = [ diff --git a/api/api/ml.set_upgrade_mode.js b/api/api/ml.set_upgrade_mode.js new file mode 100644 index 000000000..d6a52ddab --- /dev/null +++ b/api/api/ml.set_upgrade_mode.js @@ -0,0 +1,116 @@ +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlSetUpgradeMode (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ml.set_upgrade_mode](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-set-upgrade-mode.html) request + * + * @param {boolean} enabled - Whether to enable upgrade_mode ML setting or not. Defaults to false. + * @param {time} timeout - Controls the time to wait before action times out. Defaults to 30 seconds + */ + + const acceptedQuerystring = [ + 'enabled', + 'timeout' + ] + + const snakeCase = { + + } + + return function mlSetUpgradeMode (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlSetUpgradeMode(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), + result + ) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'set_upgrade_mode' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + compression: options.compression || false, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlSetUpgradeMode diff --git a/api/api/msearch.js b/api/api/msearch.js index a2e0f7789..567ac6baa 100644 --- a/api/api/msearch.js +++ b/api/api/msearch.js @@ -17,6 +17,7 @@ function buildMsearch (opts) { * @param {number} pre_filter_shard_size - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on it's rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. * @param {number} max_concurrent_shard_requests - The number of concurrent shard requests each sub search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response + * @param {boolean} ccs_minimize_roundtrips - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution * @param {object} body - The request definitions (metadata-search request definition pairs), separated by newlines */ @@ -27,6 +28,7 @@ function buildMsearch (opts) { 'pre_filter_shard_size', 'max_concurrent_shard_requests', 'rest_total_hits_as_int', + 'ccs_minimize_roundtrips', 'pretty', 'human', 'error_trace', @@ -41,6 +43,7 @@ function buildMsearch (opts) { preFilterShardSize: 'pre_filter_shard_size', maxConcurrentShardRequests: 'max_concurrent_shard_requests', restTotalHitsAsInt: 'rest_total_hits_as_int', + ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', errorTrace: 'error_trace', filterPath: 'filter_path' } diff --git a/api/api/msearch_template.js b/api/api/msearch_template.js index a8456490d..7826e0b56 100644 --- a/api/api/msearch_template.js +++ b/api/api/msearch_template.js @@ -15,6 +15,7 @@ function buildMsearchTemplate (opts) { * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response * @param {number} max_concurrent_searches - Controls the maximum number of concurrent searches the multi search api will execute * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response + * @param {boolean} ccs_minimize_roundtrips - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution * @param {object} body - The request definitions (metadata-search request definition pairs), separated by newlines */ @@ -23,6 +24,7 @@ function buildMsearchTemplate (opts) { 'typed_keys', 'max_concurrent_searches', 'rest_total_hits_as_int', + 'ccs_minimize_roundtrips', 'pretty', 'human', 'error_trace', @@ -35,6 +37,7 @@ function buildMsearchTemplate (opts) { typedKeys: 'typed_keys', maxConcurrentSearches: 'max_concurrent_searches', restTotalHitsAsInt: 'rest_total_hits_as_int', + ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', errorTrace: 'error_trace', filterPath: 'filter_path' } diff --git a/api/api/search.js b/api/api/search.js index 1fa82d539..36f5dc088 100644 --- a/api/api/search.js +++ b/api/api/search.js @@ -13,6 +13,7 @@ function buildSearch (opts) { * @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types * @param {string} analyzer - The analyzer to use for the query string * @param {boolean} analyze_wildcard - Specify whether wildcard and prefix queries should be analyzed (default: false) + * @param {boolean} ccs_minimize_roundtrips - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution * @param {enum} default_operator - The default operator for query string query (AND or OR) * @param {string} df - The field to use as default where no field prefix is given in the query string * @param {boolean} explain - Specify whether to return detailed information about score computation as part of a hit @@ -46,6 +47,7 @@ function buildSearch (opts) { * @param {boolean} allow_partial_search_results - Indicate if an error should be returned if there is a partial search failure or timeout * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response * @param {boolean} version - Specify whether to return document version as part of a hit + * @param {boolean} seq_no_primary_term - Specify whether to return sequence number and primary term of the last modification of each hit * @param {boolean} request_cache - Specify if request cache should be used for this request or not, defaults to index level setting * @param {number} batched_reduce_size - The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. * @param {number} max_concurrent_shard_requests - The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests @@ -57,6 +59,7 @@ function buildSearch (opts) { const acceptedQuerystring = [ 'analyzer', 'analyze_wildcard', + 'ccs_minimize_roundtrips', 'default_operator', 'df', 'explain', @@ -90,6 +93,7 @@ function buildSearch (opts) { 'allow_partial_search_results', 'typed_keys', 'version', + 'seq_no_primary_term', 'request_cache', 'batched_reduce_size', 'max_concurrent_shard_requests', @@ -104,6 +108,7 @@ function buildSearch (opts) { const snakeCase = { analyzeWildcard: 'analyze_wildcard', + ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', defaultOperator: 'default_operator', storedFields: 'stored_fields', docvalueFields: 'docvalue_fields', @@ -123,6 +128,7 @@ function buildSearch (opts) { trackTotalHits: 'track_total_hits', allowPartialSearchResults: 'allow_partial_search_results', typedKeys: 'typed_keys', + seqNoPrimaryTerm: 'seq_no_primary_term', requestCache: 'request_cache', batchedReduceSize: 'batched_reduce_size', maxConcurrentShardRequests: 'max_concurrent_shard_requests', diff --git a/api/api/search_template.js b/api/api/search_template.js index d9e5fe3cd..757f33a5c 100644 --- a/api/api/search_template.js +++ b/api/api/search_template.js @@ -23,6 +23,7 @@ function buildSearchTemplate (opts) { * @param {boolean} profile - Specify whether to profile the query execution * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response + * @param {boolean} ccs_minimize_roundtrips - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution * @param {object} body - The search definition template and its params */ @@ -39,6 +40,7 @@ function buildSearchTemplate (opts) { 'profile', 'typed_keys', 'rest_total_hits_as_int', + 'ccs_minimize_roundtrips', 'pretty', 'human', 'error_trace', @@ -54,6 +56,7 @@ function buildSearchTemplate (opts) { searchType: 'search_type', typedKeys: 'typed_keys', restTotalHitsAsInt: 'rest_total_hits_as_int', + ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', errorTrace: 'error_trace', filterPath: 'filter_path' } diff --git a/api/api/security.create_api_key.js b/api/api/security.create_api_key.js new file mode 100644 index 000000000..40dbb3cac --- /dev/null +++ b/api/api/security.create_api_key.js @@ -0,0 +1,115 @@ +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityCreateApiKey (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [security.create_api_key](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html) request + * + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * @param {object} body - The api key request to create an API key + */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + + return function securityCreateApiKey (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityCreateApiKey(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), + result + ) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + 'api_key' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + compression: options.compression || false, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityCreateApiKey diff --git a/api/api/security.get_api_key.js b/api/api/security.get_api_key.js new file mode 100644 index 000000000..70356a786 --- /dev/null +++ b/api/api/security.get_api_key.js @@ -0,0 +1,120 @@ +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityGetApiKey (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [security.get_api_key](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-api-key.html) request + * + * @param {string} id - API key id of the API key to be retrieved + * @param {string} name - API key name of the API key to be retrieved + * @param {string} username - user name of the user who created this API key to be retrieved + * @param {string} realm_name - realm name of the user who created this API key to be retrieved + */ + + const acceptedQuerystring = [ + 'id', + 'name', + 'username', + 'realm_name' + ] + + const snakeCase = { + realmName: 'realm_name' + } + + return function securityGetApiKey (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityGetApiKey(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), + result + ) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + 'api_key' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + compression: options.compression || false, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityGetApiKey diff --git a/api/api/security.invalidate_api_key.js b/api/api/security.invalidate_api_key.js new file mode 100644 index 000000000..a6f9dcd69 --- /dev/null +++ b/api/api/security.invalidate_api_key.js @@ -0,0 +1,114 @@ +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityInvalidateApiKey (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [security.invalidate_api_key](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-api-key.html) request + * + * @param {object} body - The api key request to invalidate API key(s) + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function securityInvalidateApiKey (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityInvalidateApiKey(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['body'] == null) { + return callback( + new ConfigurationError('Missing required parameter: body'), + result + ) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), + result + ) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'DELETE' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + 'api_key' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + compression: options.compression || false, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityInvalidateApiKey diff --git a/api/api/update.js b/api/api/update.js index a2890c25a..bb46f7568 100644 --- a/api/api/update.js +++ b/api/api/update.js @@ -22,8 +22,8 @@ function buildUpdate (opts) { * @param {number} retry_on_conflict - Specify how many times should the operation be retried when a conflict occurs (default: 0) * @param {string} routing - Specific routing value * @param {time} timeout - Explicit operation timeout - * @param {number} version - Explicit version number for concurrency control - * @param {enum} version_type - Specific version type + * @param {number} if_seq_no - only perform the update operation if the last operation that has changed the document has the specified sequence number + * @param {number} if_primary_term - only perform the update operation if the last operation that has changed the document has the specified primary term * @param {object} body - The request definition requires either `script` or partial `doc` */ @@ -38,8 +38,8 @@ function buildUpdate (opts) { 'retry_on_conflict', 'routing', 'timeout', - 'version', - 'version_type', + 'if_seq_no', + 'if_primary_term', 'pretty', 'human', 'error_trace', @@ -52,7 +52,8 @@ function buildUpdate (opts) { _sourceExcludes: '_source_excludes', _sourceIncludes: '_source_includes', retryOnConflict: 'retry_on_conflict', - versionType: 'version_type', + ifSeqNo: 'if_seq_no', + ifPrimaryTerm: 'if_primary_term', errorTrace: 'error_trace', filterPath: 'filter_path' } diff --git a/api/api/xpack.watcher.put_watch.js b/api/api/xpack.watcher.put_watch.js index b6efd896f..e59d5de41 100644 --- a/api/api/xpack.watcher.put_watch.js +++ b/api/api/xpack.watcher.put_watch.js @@ -12,16 +12,21 @@ function buildXpackWatcherPutWatch (opts) { * @param {string} id - Watch ID * @param {boolean} active - Specify whether the watch is in/active by default * @param {number} version - Explicit version number for concurrency control + * @param {number} if_seq_no - only update the watch if the last operation that has changed the watch has the specified sequence number + * @param {number} if_primary_term - only update the watch if the last operation that has changed the watch has the specified primary term * @param {object} body - The watch */ const acceptedQuerystring = [ 'active', - 'version' + 'version', + 'if_seq_no', + 'if_primary_term' ] const snakeCase = { - + ifSeqNo: 'if_seq_no', + ifPrimaryTerm: 'if_primary_term' } return function xpackWatcherPutWatch (params, options, callback) { diff --git a/api/index.js b/api/index.js index 2993857b2..86c696dc9 100644 --- a/api/index.js +++ b/api/index.js @@ -37,6 +37,8 @@ function ESAPI (opts) { delete_auto_follow_pattern: lazyLoad('./api/ccr.delete_auto_follow_pattern.js', opts), deleteAutoFollowPattern: lazyLoad('./api/ccr.delete_auto_follow_pattern.js', opts), follow: lazyLoad('./api/ccr.follow.js', opts), + follow_info: lazyLoad('./api/ccr.follow_info.js', opts), + followInfo: lazyLoad('./api/ccr.follow_info.js', opts), follow_stats: lazyLoad('./api/ccr.follow_stats.js', opts), followStats: lazyLoad('./api/ccr.follow_stats.js', opts), get_auto_follow_pattern: lazyLoad('./api/ccr.get_auto_follow_pattern.js', opts), @@ -255,6 +257,8 @@ function ESAPI (opts) { putJob: lazyLoad('./api/ml.put_job.js', opts), revert_model_snapshot: lazyLoad('./api/ml.revert_model_snapshot.js', opts), revertModelSnapshot: lazyLoad('./api/ml.revert_model_snapshot.js', opts), + set_upgrade_mode: lazyLoad('./api/ml.set_upgrade_mode.js', opts), + setUpgradeMode: lazyLoad('./api/ml.set_upgrade_mode.js', opts), start_datafeed: lazyLoad('./api/ml.start_datafeed.js', opts), startDatafeed: lazyLoad('./api/ml.start_datafeed.js', opts), stop_datafeed: lazyLoad('./api/ml.stop_datafeed.js', opts), @@ -313,6 +317,8 @@ function ESAPI (opts) { clearCachedRealms: lazyLoad('./api/security.clear_cached_realms.js', opts), clear_cached_roles: lazyLoad('./api/security.clear_cached_roles.js', opts), clearCachedRoles: lazyLoad('./api/security.clear_cached_roles.js', opts), + create_api_key: lazyLoad('./api/security.create_api_key.js', opts), + createApiKey: lazyLoad('./api/security.create_api_key.js', opts), delete_privileges: lazyLoad('./api/security.delete_privileges.js', opts), deletePrivileges: lazyLoad('./api/security.delete_privileges.js', opts), delete_role: lazyLoad('./api/security.delete_role.js', opts), @@ -325,6 +331,8 @@ function ESAPI (opts) { disableUser: lazyLoad('./api/security.disable_user.js', opts), enable_user: lazyLoad('./api/security.enable_user.js', opts), enableUser: lazyLoad('./api/security.enable_user.js', opts), + get_api_key: lazyLoad('./api/security.get_api_key.js', opts), + getApiKey: lazyLoad('./api/security.get_api_key.js', opts), get_privileges: lazyLoad('./api/security.get_privileges.js', opts), getPrivileges: lazyLoad('./api/security.get_privileges.js', opts), get_role: lazyLoad('./api/security.get_role.js', opts), @@ -339,6 +347,8 @@ function ESAPI (opts) { getUserPrivileges: lazyLoad('./api/security.get_user_privileges.js', opts), has_privileges: lazyLoad('./api/security.has_privileges.js', opts), hasPrivileges: lazyLoad('./api/security.has_privileges.js', opts), + invalidate_api_key: lazyLoad('./api/security.invalidate_api_key.js', opts), + invalidateApiKey: lazyLoad('./api/security.invalidate_api_key.js', opts), invalidate_token: lazyLoad('./api/security.invalidate_token.js', opts), invalidateToken: lazyLoad('./api/security.invalidate_token.js', opts), put_privileges: lazyLoad('./api/security.put_privileges.js', opts), diff --git a/api/requestParams.d.ts b/api/requestParams.d.ts index 637bc48b1..c0865c021 100644 --- a/api/requestParams.d.ts +++ b/api/requestParams.d.ts @@ -337,7 +337,7 @@ export interface Count extends Generic { export interface Create extends Generic { id: string; index: string; - type: string; + type?: string; wait_for_active_shards?: string; parent?: string; refresh?: 'true' | 'false' | 'wait_for'; @@ -358,6 +358,8 @@ export interface Delete extends Generic { refresh?: 'true' | 'false' | 'wait_for'; routing?: string; timeout?: string; + if_seq_no?: number; + if_primary_term?: number; version?: number; version_type?: 'internal' | 'external' | 'external_gte' | 'force'; } @@ -431,7 +433,7 @@ export interface Exists extends Generic { export interface ExistsSource extends Generic { id: string; index: string; - type: string; + type?: string; parent?: string; preference?: string; realtime?: boolean; @@ -499,7 +501,7 @@ export interface GetScript extends Generic { export interface GetSource extends Generic { id: string; index: string; - type: string; + type?: string; parent?: string; preference?: string; realtime?: boolean; @@ -524,6 +526,8 @@ export interface Index extends Generic { timeout?: string; version?: number; version_type?: 'internal' | 'external' | 'external_gte' | 'force'; + if_seq_no?: number; + if_primary_term?: number; pipeline?: string; body: any; } @@ -555,7 +559,7 @@ export interface IndicesClose extends Generic { export interface IndicesCreate extends Generic { index: string; - include_type_name?: string; + include_type_name?: boolean; wait_for_active_shards?: string; timeout?: string; master_timeout?: string; @@ -647,6 +651,7 @@ export interface IndicesForcemerge extends Generic { export interface IndicesGet extends Generic { index: string | string[]; + include_type_name?: boolean; local?: boolean; ignore_unavailable?: boolean; allow_no_indices?: boolean; @@ -669,6 +674,7 @@ export interface IndicesGetFieldMapping extends Generic { index?: string | string[]; type?: string | string[]; fields: string | string[]; + include_type_name?: boolean; include_defaults?: boolean; ignore_unavailable?: boolean; allow_no_indices?: boolean; @@ -679,7 +685,7 @@ export interface IndicesGetFieldMapping extends Generic { export interface IndicesGetMapping extends Generic { index?: string | string[]; type?: string | string[]; - include_type_name?: string; + include_type_name?: boolean; ignore_unavailable?: boolean; allow_no_indices?: boolean; expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; @@ -701,6 +707,7 @@ export interface IndicesGetSettings extends Generic { export interface IndicesGetTemplate extends Generic { name?: string | string[]; + include_type_name?: boolean; flat_settings?: boolean; master_timeout?: string; local?: boolean; @@ -734,7 +741,7 @@ export interface IndicesPutAlias extends Generic { export interface IndicesPutMapping extends Generic { index?: string | string[]; type?: string; - include_type_name?: string; + include_type_name?: boolean; timeout?: string; master_timeout?: string; ignore_unavailable?: boolean; @@ -757,6 +764,7 @@ export interface IndicesPutSettings extends Generic { export interface IndicesPutTemplate extends Generic { name: string; + include_type_name?: boolean; order?: number; create?: boolean; timeout?: string; @@ -781,6 +789,7 @@ export interface IndicesRefresh extends Generic { export interface IndicesRollover extends Generic { alias: string; new_index?: string; + include_type_name?: boolean; timeout?: string; dry_run?: boolean; master_timeout?: string; @@ -922,6 +931,7 @@ export interface Msearch extends Generic { pre_filter_shard_size?: number; max_concurrent_shard_requests?: number; rest_total_hits_as_int?: boolean; + ccs_minimize_roundtrips?: boolean; body: any; } @@ -932,6 +942,7 @@ export interface MsearchTemplate extends Generic { typed_keys?: boolean; max_concurrent_searches?: number; rest_total_hits_as_int?: boolean; + ccs_minimize_roundtrips?: boolean; body: any; } @@ -1051,6 +1062,7 @@ export interface Search extends Generic { type?: string | string[]; analyzer?: string; analyze_wildcard?: boolean; + ccs_minimize_roundtrips?: boolean; default_operator?: 'AND' | 'OR'; df?: string; explain?: boolean; @@ -1084,6 +1096,7 @@ export interface Search extends Generic { allow_partial_search_results?: boolean; typed_keys?: boolean; version?: boolean; + seq_no_primary_term?: boolean; request_cache?: boolean; batched_reduce_size?: number; max_concurrent_shard_requests?: number; @@ -1117,6 +1130,7 @@ export interface SearchTemplate extends Generic { profile?: boolean; typed_keys?: boolean; rest_total_hits_as_int?: boolean; + ccs_minimize_roundtrips?: boolean; body: any; } @@ -1239,8 +1253,8 @@ export interface Update extends Generic { retry_on_conflict?: number; routing?: string; timeout?: string; - version?: number; - version_type?: 'internal' | 'force'; + if_seq_no?: number; + if_primary_term?: number; body: any; } @@ -1295,9 +1309,14 @@ export interface CcrDeleteAutoFollowPattern extends Generic { export interface CcrFollow extends Generic { index: string; + wait_for_active_shards?: string; body: any; } +export interface CcrFollowInfo extends Generic { + index?: string | string[]; +} + export interface CcrFollowStats extends Generic { index?: string | string[]; } @@ -1317,7 +1336,7 @@ export interface CcrPutAutoFollowPattern extends Generic { export interface CcrResumeFollow extends Generic { index: string; - body: any; + body?: any; } export interface CcrStats extends Generic { @@ -1392,6 +1411,7 @@ export interface MlCloseJob extends Generic { allow_no_jobs?: boolean; force?: boolean; timeout?: string; + body?: any; } export interface MlDeleteCalendar extends Generic { @@ -1642,6 +1662,11 @@ export interface MlRevertModelSnapshot extends Generic { body?: any; } +export interface MlSetUpgradeMode extends Generic { + enabled?: boolean; + timeout?: string; +} + export interface MlStartDatafeed extends Generic { datafeed_id: string; start?: string; @@ -1712,6 +1737,11 @@ export interface SecurityClearCachedRoles extends Generic { name: string | string[]; } +export interface SecurityCreateApiKey extends Generic { + refresh?: 'true' | 'false' | 'wait_for'; + body: any; +} + export interface SecurityDeletePrivileges extends Generic { application: string; name: string; @@ -1743,6 +1773,13 @@ export interface SecurityEnableUser extends Generic { refresh?: 'true' | 'false' | 'wait_for'; } +export interface SecurityGetApiKey extends Generic { + id?: string; + name?: string; + username?: string; + realm_name?: string; +} + export interface SecurityGetPrivileges extends Generic { application?: string; name?: string; @@ -1772,6 +1809,10 @@ export interface SecurityHasPrivileges extends Generic { body: any; } +export interface SecurityInvalidateApiKey extends Generic { + body: any; +} + export interface SecurityInvalidateToken extends Generic { body: any; } @@ -1944,6 +1985,8 @@ export interface XpackWatcherPutWatch extends Generic { id: string; active?: boolean; version?: number; + if_seq_no?: number; + if_primary_term?: number; body?: any; } From b4d6d036f5709cbd21087fed0c29162e2e32a8dd Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 15 Feb 2019 10:30:04 +0100 Subject: [PATCH 125/172] Updated typings --- index.d.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 4a511dbab..0dc7f7a11 100644 --- a/index.d.ts +++ b/index.d.ts @@ -43,10 +43,10 @@ interface ClientOptions { } declare class Client extends EventEmitter { + constructor(opts?: ClientOptions); connectionPool: ConnectionPool; transport: Transport; serializer: Serializer - constructor(opts?: ClientOptions); // TODO: update fn declaration extends(method: string, fn: any): void; close(callback?: Function): Promise | void; @@ -79,6 +79,8 @@ declare class Client extends EventEmitter { delete_auto_follow_pattern: ApiMethod deleteAutoFollowPattern: ApiMethod follow: ApiMethod + follow_info: ApiMethod + followInfo: ApiMethod follow_stats: ApiMethod followStats: ApiMethod get_auto_follow_pattern: ApiMethod @@ -297,6 +299,8 @@ declare class Client extends EventEmitter { putJob: ApiMethod revert_model_snapshot: ApiMethod revertModelSnapshot: ApiMethod + set_upgrade_mode: ApiMethod + setUpgradeMode: ApiMethod start_datafeed: ApiMethod startDatafeed: ApiMethod stop_datafeed: ApiMethod @@ -355,6 +359,8 @@ declare class Client extends EventEmitter { clearCachedRealms: ApiMethod clear_cached_roles: ApiMethod clearCachedRoles: ApiMethod + create_api_key: ApiMethod + createApiKey: ApiMethod delete_privileges: ApiMethod deletePrivileges: ApiMethod delete_role: ApiMethod @@ -367,6 +373,8 @@ declare class Client extends EventEmitter { disableUser: ApiMethod enable_user: ApiMethod enableUser: ApiMethod + get_api_key: ApiMethod + getApiKey: ApiMethod get_privileges: ApiMethod getPrivileges: ApiMethod get_role: ApiMethod @@ -381,6 +389,8 @@ declare class Client extends EventEmitter { getUserPrivileges: ApiMethod has_privileges: ApiMethod hasPrivileges: ApiMethod + invalidate_api_key: ApiMethod + invalidateApiKey: ApiMethod invalidate_token: ApiMethod invalidateToken: ApiMethod put_privileges: ApiMethod From e98b3d4e8999ca093cefe1f0e9896cb31a2acac2 Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 15 Feb 2019 10:44:20 +0100 Subject: [PATCH 126/172] Updated ci conf --- .ci/docker-compose.yml | 2 +- .ci/test-matrix.yml | 2 +- .travis.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.ci/docker-compose.yml b/.ci/docker-compose.yml index 17b4a4797..a9128c62e 100644 --- a/.ci/docker-compose.yml +++ b/.ci/docker-compose.yml @@ -20,7 +20,7 @@ services: depends_on: - elasticsearch elasticsearch: - image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-7.0.0-alpha2} + image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-7.0.0-beta1} volumes: - esvol:/tmp networks: diff --git a/.ci/test-matrix.yml b/.ci/test-matrix.yml index 78f9ccd21..a23cedf9e 100644 --- a/.ci/test-matrix.yml +++ b/.ci/test-matrix.yml @@ -1,6 +1,6 @@ --- ELASTICSEARCH_VERSION: -- 7.0.0-alpha2 +- 7.0.0-beta1 NODE_JS_VERSION: - 10 diff --git a/.travis.yml b/.travis.yml index a37514d99..352f8d694 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ node_js: env: global: - - ELASTICSEARCH_VERSION=7.0.0-alpha2 + - ELASTICSEARCH_VERSION=7.0.0-beta1 - QUIET=true before_install: From 51ac7591673395d707d6eec09f55746e72506e6b Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 15 Feb 2019 18:36:28 +0100 Subject: [PATCH 127/172] Updated docs --- docs/breaking-changes.asciidoc | 2 +- docs/examples/asStream.asciidoc | 96 ++++++++++++++ docs/examples/ignore.asciidoc | 55 ++++++++ docs/examples/msearch.asciidoc | 1 - docs/examples/transport.request.asciidoc | 58 +++++++++ docs/reference.asciidoc | 152 +++++++++++++++++++++-- 6 files changed, 353 insertions(+), 11 deletions(-) create mode 100644 docs/examples/asStream.asciidoc create mode 100644 docs/examples/ignore.asciidoc create mode 100644 docs/examples/transport.request.asciidoc diff --git a/docs/breaking-changes.asciidoc b/docs/breaking-changes.asciidoc index e70228331..37b98f416 100644 --- a/docs/breaking-changes.asciidoc +++ b/docs/breaking-changes.asciidoc @@ -2,7 +2,7 @@ If you were already using the previous version of this client, the one you used to install with `npm install elasticsearch`, you will encounter some breaking changes. -*Don't worry!* +==== Don't panic! Every breaking change was carefully weighted, and every breaking change has solid reasons to introduce it, furthermore the new codebase has been rewritten with modern JavaScript, and has been carefully designed to be easy to maintain. diff --git a/docs/examples/asStream.asciidoc b/docs/examples/asStream.asciidoc new file mode 100644 index 000000000..00929bab0 --- /dev/null +++ b/docs/examples/asStream.asciidoc @@ -0,0 +1,96 @@ +== asStream + +Instead of getting the parsed body back, you will get the raw Node.js stream of data. + +[source,js] +---- +'use strict' + +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ node: 'http://localhost:9200' }) + +async function run () { + await client.bulk({ + refresh: true, + body: [ + // operation to perform + { index: { _index: 'game-of-thrones' } }, + // the document to index + { + character: 'Ned Stark', + quote: 'Winter is coming.' + }, + + { index: { _index: 'game-of-thrones' } }, + { + character: 'Daenerys Targaryen', + quote: 'I am the blood of the dragon.' + }, + + { index: { _index: 'game-of-thrones' } }, + { + character: 'Tyrion Lannister', + quote: 'A mind needs books like a sword needs a whetstone.' + } + ] + }) + + // Let's search! + const { body } = await client.search({ + index: 'game-of-thrones', + body: { + query: { + match: { + quote: 'winter' + } + } + } + }, { + asStream: true + }) + + // stream async iteration, available in Node.js ≥ 10 + var payload = '' + body.setEncoding('utf8') + for await (const chunk of body) { + payload += chunk + } + console.log(JSON.parse(payload)) + + // classic stream callback style + var payload = '' + body.setEncoding('utf8') + body.on('data', chunk => { payload += chunk }) + body.on('error', console.log) + body.on('end', () => { + console.log(JSON.parse(payload)) + }) +} + +run().catch(console.log) +---- + +TIP: This can be useful if you need to pipe the Elasticsearch's response to a proxy, or send it directly to another source. + +[source,js] +---- +'use strict' + +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ node: 'http://localhost:9200' }) +const fastify = require('fastify')() + +fastify.post('/search/:index', async (req, reply) => { + const { body, statusCode, headers } = await client.search({ + index: req.params.index, + body: req.body + }, { + asStream: true + }) + + reply.code(statusCode).headers(headers) + return body +}) + +fastify.listen(3000) +---- \ No newline at end of file diff --git a/docs/examples/ignore.asciidoc b/docs/examples/ignore.asciidoc new file mode 100644 index 000000000..d4b5a9af1 --- /dev/null +++ b/docs/examples/ignore.asciidoc @@ -0,0 +1,55 @@ +== Ignore +HTTP status codes which should not be considered errors for this request. + +[source,js] +---- +'use strict' + +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ node: 'http://localhost:9200' }) + +async function run () { + await client.bulk({ + refresh: true, + body: [ + // operation to perform + { index: { _index: 'game-of-thrones' } }, + // the document to index + { + character: 'Ned Stark', + quote: 'Winter is coming.' + }, + + { index: { _index: 'game-of-thrones' } }, + { + character: 'Daenerys Targaryen', + quote: 'I am the blood of the dragon.' + }, + + { index: { _index: 'game-of-thrones' } }, + { + character: 'Tyrion Lannister', + quote: 'A mind needs books like a sword needs a whetstone.' + } + ] + }) + + // Let's search! + const { body } = await client.search({ + index: 'game-of-thrones', + body: { + query: { + match: { + quote: 'fire' + } + } + } + }, { + ignore: [404] + }) + + console.log(body) // ResponseError +} + +run().catch(console.log) +---- \ No newline at end of file diff --git a/docs/examples/msearch.asciidoc b/docs/examples/msearch.asciidoc index f81cc0c04..5915dc77d 100644 --- a/docs/examples/msearch.asciidoc +++ b/docs/examples/msearch.asciidoc @@ -47,5 +47,4 @@ async function run () { } run().catch(console.log) - ---- \ No newline at end of file diff --git a/docs/examples/transport.request.asciidoc b/docs/examples/transport.request.asciidoc new file mode 100644 index 000000000..f89514b50 --- /dev/null +++ b/docs/examples/transport.request.asciidoc @@ -0,0 +1,58 @@ += transport.request + +It can happen that you need to communicate with Elasticsearch by using an API that is not supported by the client, to mitigate this issue you can directly call `client.transport.request`, which is the internal utility that the client uses to communicate with Elasticsearch when you use an API method. + +NOTE: When using the `transport.request` method you must provide all the parameters needed to perform an HTTP call, such as `method`, `path`, `querystring`, and `body`. + + +TIP: If you find yourself use this method too often, take in consideration the use of `client.extend`, which will make your code look cleaner and easier to maintain. + +[source,js] +---- +'use strict' + +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ node: 'http://localhost:9200' }) + +async function run () { + await client.bulk({ + refresh: true, + body: [ + { index: { _index: 'game-of-thrones' } }, + { + character: 'Ned Stark', + quote: 'Winter is coming.' + }, + + { index: { _index: 'game-of-thrones' } }, + { + character: 'Daenerys Targaryen', + quote: 'I am the blood of the dragon.' + }, + + { index: { _index: 'game-of-thrones' } }, + { + character: 'Tyrion Lannister', + quote: 'A mind needs books like a sword needs a whetstone.' + } + ] + }) + + const { body } = await client.transport.request({ + method: 'POST', + path: '/game-of-thrones/_search', + body: { + query: { + match: { + quote: 'winter' + } + } + }, + querystring: {} + }) + + console.log(body) +} + +run().catch(console.log) +---- \ No newline at end of file diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc index 0cbf273ca..856b5885e 100644 --- a/docs/reference.asciidoc +++ b/docs/reference.asciidoc @@ -1088,6 +1088,12 @@ http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete.html |`timeout` |`string` - Explicit operation timeout +|`if_seq_no` or `ifSeqNo` +|`number` - only perform the delete operation if the last operation that has changed the document has the specified sequence number + +|`if_primary_term` or `ifPrimaryTerm` +|`number` - only perform the delete operation if the last operation that has changed the document has the specified primary term + |`version` |`number` - Explicit version number for concurrency control @@ -1314,7 +1320,7 @@ http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html |`string` - The name of the index |`type` -|`string` - The type of the document; use `_all` to fetch the first document matching the ID across all types +|`string` - The type of the document; deprecated and optional starting with 7.0 |`parent` |`string` - The ID of the parent document @@ -1520,7 +1526,7 @@ http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html |`string` - The name of the index |`type` -|`string` - The type of the document; use `_all` to fetch the first document matching the ID across all types +|`string` - The type of the document; deprecated and optional starting with 7.0 |`parent` |`string` - The ID of the parent document @@ -1595,6 +1601,12 @@ http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html |`version_type` or `versionType` |`'internal', 'external', 'external_gte', 'force'` - Specific version type +|`if_seq_no` or `ifSeqNo` +|`number` - only perform the index operation if the last operation that has changed the document has the specified sequence number + +|`if_primary_term` or `ifPrimaryTerm` +|`number` - only perform the index operation if the last operation that has changed the document has the specified primary term + |`pipeline` |`string` - The pipeline id to preprocess incoming documents with @@ -1697,7 +1709,7 @@ http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-ind |`string` - The name of the index |`include_type_name` or `includeTypeName` -|`string` - Whether a type should be expected in the body of the mappings. +|`boolean` - Whether a type should be expected in the body of the mappings. |`wait_for_active_shards` or `waitForActiveShards` |`string` - Set the number of active shards to wait for before the operation returns. @@ -1979,6 +1991,9 @@ http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-index. |`index` |`string, string[]` - A comma-separated list of index names +|`include_type_name` or `includeTypeName` +|`boolean` - Whether to add the type name to the response (default: false) + |`local` |`boolean` - Return local information, do not retrieve the state from master node (default: false) @@ -2047,6 +2062,9 @@ http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-field- |`fields` |`string, string[]` - A comma-separated list of fields +|`include_type_name` or `includeTypeName` +|`boolean` - Whether a type should be returned in the body of the mappings. + |`include_defaults` or `includeDefaults` |`boolean` - Whether the default mapping values should be returned as well @@ -2079,7 +2097,7 @@ http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-mappin |`string, string[]` - A comma-separated list of document types |`include_type_name` or `includeTypeName` -|`string` - Whether to add the type name to the response +|`boolean` - Whether to add the type name to the response (default: false) |`ignore_unavailable` or `ignoreUnavailable` |`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -2146,6 +2164,9 @@ http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates. |`name` |`string, string[]` - The comma separated names of the index templates +|`include_type_name` or `includeTypeName` +|`boolean` - Whether a type should be returned in the body of the mappings. + |`flat_settings` or `flatSettings` |`boolean` - Return settings in flat format (default: false) @@ -2248,7 +2269,7 @@ http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-put-mappin |`string` - The name of the document type |`include_type_name` or `includeTypeName` -|`string` - Whether a type should be expected in the body of the mappings. +|`boolean` - Whether a type should be expected in the body of the mappings. |`timeout` |`string` - Explicit operation timeout @@ -2318,6 +2339,9 @@ http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates. |`name` |`string` - The name of the template +|`include_type_name` or `includeTypeName` +|`boolean` - Whether a type should be returned in the body of the mappings. + |`order` |`number` - The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers) @@ -2391,6 +2415,9 @@ http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-i |`new_index` or `newIndex` |`string` - The name of the rollover index +|`include_type_name` or `includeTypeName` +|`boolean` - Whether a type should be included in the body of the mappings. + |`timeout` |`string` - Explicit operation timeout @@ -2822,6 +2849,10 @@ http://www.elastic.co/guide/en/elasticsearch/reference/master/search-multi-searc |`rest_total_hits_as_int` or `restTotalHitsAsInt` |`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response +|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` +|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + + _Default:_ `true` + |`body` |`object` - The request definitions (metadata-search request definition pairs), separated by newlines @@ -2852,6 +2883,10 @@ http://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-sear |`rest_total_hits_as_int` or `restTotalHitsAsInt` |`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response +|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` +|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + + _Default:_ `true` + |`body` |`object` - The request definitions (metadata-search request definition pairs), separated by newlines @@ -3224,6 +3259,10 @@ http://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html |`analyze_wildcard` or `analyzeWildcard` |`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) +|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` +|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + + _Default:_ `true` + |`default_operator` or `defaultOperator` |`'AND', 'OR'` - The default operator for query string query (AND or OR) + _Default:_ `OR` @@ -3327,6 +3366,9 @@ http://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html |`version` |`boolean` - Specify whether to return document version as part of a hit +|`seq_no_primary_term` or `seqNoPrimaryTerm` +|`boolean` - Specify whether to return sequence number and primary term of the last modification of each hit + |`request_cache` or `requestCache` |`boolean` - Specify if request cache should be used for this request or not, defaults to index level setting @@ -3431,6 +3473,10 @@ http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.h |`rest_total_hits_as_int` or `restTotalHitsAsInt` |`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response +|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` +|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + + _Default:_ `true` + |`body` |`object` - The search definition template and its params @@ -3802,11 +3848,11 @@ http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update.html |`timeout` |`string` - Explicit operation timeout -|`version` -|`number` - Explicit version number for concurrency control +|`if_seq_no` or `ifSeqNo` +|`number` - only perform the update operation if the last operation that has changed the document has the specified sequence number -|`version_type` or `versionType` -|`'internal', 'force'` - Specific version type +|`if_primary_term` or `ifPrimaryTerm` +|`number` - only perform the update operation if the last operation that has changed the document has the specified primary term |`body` |`object` - The request definition requires either `script` or partial `doc` @@ -3976,9 +4022,25 @@ https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.h |`index` |`string` - The name of the follower index +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of shard copies that must be active before returning. Defaults to 0. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + + _Default:_ `0` + |`body` |`object` - The name of the leader index and other optional ccr related parameters +|=== +=== ccr.followInfo +[source,js] +---- +client.ccr.followInfo([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-info.html +[cols=2*] +|=== +|`index` +|`string, string[]` - A comma-separated list of index patterns; use `_all` to perform the operation on all indices + |=== === ccr.followStats [source,js] @@ -4270,6 +4332,9 @@ http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-close-job.html |`timeout` |`string` - Controls the time to wait until a job has closed. Default to 30 minutes +|`body` +|`object` - The URL params optionally sent in the body + |=== === ml.deleteCalendar [source,js] @@ -5017,6 +5082,21 @@ http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-revert-snapsho |`body` |`object` - Reversion options +|=== +=== ml.setUpgradeMode +[source,js] +---- +client.ml.setUpgradeMode([params] [, options] [, callback]) +---- +http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-set-upgrade-mode.html +[cols=2*] +|=== +|`enabled` +|`boolean` - Whether to enable upgrade_mode ML setting or not. Defaults to false. + +|`timeout` +|`string` - Controls the time to wait before action times out. Defaults to 30 seconds + |=== === ml.startDatafeed [source,js] @@ -5227,6 +5307,21 @@ https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-cle |`name` |`string, string[]` - Role name +|=== +=== security.createApiKey +[source,js] +---- +client.security.createApiKey([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html +[cols=2*] +|=== +|`refresh` +|`'true', 'false', 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + +|`body` +|`object` - The api key request to create an API key + |=== === security.deletePrivileges [source,js] @@ -5320,6 +5415,27 @@ https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-ena |`refresh` |`'true', 'false', 'wait_for'` - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. +|=== +=== security.getApiKey +[source,js] +---- +client.security.getApiKey([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-api-key.html +[cols=2*] +|=== +|`id` +|`string` - API key id of the API key to be retrieved + +|`name` +|`string` - API key name of the API key to be retrieved + +|`username` +|`string` - user name of the user who created this API key to be retrieved + +|`realm_name` or `realmName` +|`string` - realm name of the user who created this API key to be retrieved + |=== === security.getPrivileges [source,js] @@ -5407,6 +5523,18 @@ https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has |`body` |`object` - The privileges to test +|=== +=== security.invalidateApiKey +[source,js] +---- +client.security.invalidateApiKey([params] [, options] [, callback]) +---- +https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-api-key.html +[cols=2*] +|=== +|`body` +|`object` - The api key request to invalidate API key(s) + |=== === security.invalidateToken [source,js] @@ -5931,6 +6059,12 @@ http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-w |`version` |`number` - Explicit version number for concurrency control +|`if_seq_no` or `ifSeqNo` +|`number` - only update the watch if the last operation that has changed the watch has the specified sequence number + +|`if_primary_term` or `ifPrimaryTerm` +|`number` - only update the watch if the last operation that has changed the watch has the specified primary term + |`body` |`object` - The watch From c5bd8c6e61ce1df2e330fd0b27d02860b9507204 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 18 Feb 2019 09:17:02 +0100 Subject: [PATCH 128/172] Updated .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 352f8d694..6a3a361a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ env: - QUIET=true before_install: - - wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz + - wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ELASTICSEARCH_VERSION}-linux-x86_64.tar.gz - tar -xzf elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz - ./elasticsearch-${ELASTICSEARCH_VERSION}/bin/elasticsearch -Enode.attr.testattr=test -Epath.repo=/tmp -Erepositories.url.allowed_urls='http://snapshot.*' &> /dev/null & From 7e5bbad5c2126b7d66b5b1935649fb11ec6de988 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 18 Feb 2019 09:52:36 +0100 Subject: [PATCH 129/172] Updated .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6a3a361a8..3eb76648b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ env: before_install: - wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ELASTICSEARCH_VERSION}-linux-x86_64.tar.gz - - tar -xzf elasticsearch-${ELASTICSEARCH_VERSION}.tar.gz + - tar -xzf elasticsearch-${ELASTICSEARCH_VERSION}-linux-x86_64.tar.gz - ./elasticsearch-${ELASTICSEARCH_VERSION}/bin/elasticsearch -Enode.attr.testattr=test -Epath.repo=/tmp -Erepositories.url.allowed_urls='http://snapshot.*' &> /dev/null & install: From 92c23232a7ec6d27780c0974f07bb2ba5e5d0fcc Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 18 Feb 2019 12:59:29 +0100 Subject: [PATCH 130/172] API generation --- api/api/create.js | 13 ------------- api/api/get_source.js | 13 ------------- 2 files changed, 26 deletions(-) diff --git a/api/api/create.js b/api/api/create.js index 462407692..727cc2f0a 100644 --- a/api/api/create.js +++ b/api/api/create.js @@ -86,19 +86,6 @@ function buildCreate (opts) { ) } - // check required url components - if (params['id'] != null && (params['type'] == null || params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: type, index'), - result - ) - } else if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { return callback( diff --git a/api/api/get_source.js b/api/api/get_source.js index 2578a0252..9a738e7e1 100644 --- a/api/api/get_source.js +++ b/api/api/get_source.js @@ -90,19 +90,6 @@ function buildGetSource (opts) { ) } - // check required url components - if (params['id'] != null && (params['type'] == null || params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: type, index'), - result - ) - } else if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { return callback( From 709ee6fa30ecb126045d88c9b6efcf49e360dbcf Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 18 Feb 2019 12:59:46 +0100 Subject: [PATCH 131/172] Updated scripts --- scripts/es-docker.sh | 2 +- scripts/utils/generate.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/es-docker.sh b/scripts/es-docker.sh index c77bd3c54..11a1302fd 100755 --- a/scripts/es-docker.sh +++ b/scripts/es-docker.sh @@ -7,7 +7,7 @@ exec docker run \ -e "repositories.url.allowed_urls=http://snapshot.*" \ -e "discovery.type=single-node" \ -p 9200:9200 \ - docker.elastic.co/elasticsearch/elasticsearch:7.0.0-alpha2 + docker.elastic.co/elasticsearch/elasticsearch:7.0.0-beta1 # docker.elastic.co/elasticsearch/elasticsearch:6.5.4 # -e "xpack.security.enabled=true" \ diff --git a/scripts/utils/generate.js b/scripts/utils/generate.js index e3531f7db..3ae60ef0f 100644 --- a/scripts/utils/generate.js +++ b/scripts/utils/generate.js @@ -9,9 +9,11 @@ const allowedMethods = { // list of apis that does not need any kind of validation // because of how the url is built or the `type` handling in ES7 const noPathValidation = [ + 'create', 'exists', 'explain', 'get', + 'get_source', 'indices.get_alias', 'indices.exists_alias', 'indices.get_field_mapping', From aa9f5b6d41339e775a1c7ce3e060ecb52581eba0 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 18 Feb 2019 13:00:43 +0100 Subject: [PATCH 132/172] Updated integration test runner --- test/integration/test-runner.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/test/integration/test-runner.js b/test/integration/test-runner.js index 8cfbc2c48..1c7fc4757 100644 --- a/test/integration/test-runner.js +++ b/test/integration/test-runner.js @@ -213,7 +213,7 @@ TestRunner.prototype.fillStashedValues = function (obj) { return obj function getStashedValues (str) { - return str + const arr = str // we split the string on the dots // handle the key with a dot inside that is not a part of the path .split(/(? 1 ? arr.join('.') : arr[0] } } @@ -351,7 +354,8 @@ TestRunner.prototype.exec = function (name, actions, q, done) { : delve(this.response, this.fillStashedValues(key)), key === '$body' ? action.match[key] - : this.fillStashedValues(action.match)[key] + : this.fillStashedValues(action.match)[key], + action.match ) done() }) @@ -463,10 +467,10 @@ TestRunner.prototype.is_false = function (val, msg) { * @param {any} the second value * @returns {TestRunner} */ -TestRunner.prototype.match = function (val1, val2) { +TestRunner.prototype.match = function (val1, val2, action) { // both values are objects if (typeof val1 === 'object' && typeof val2 === 'object') { - this.tap.strictDeepEqual(val1, val2) + this.tap.strictDeepEqual(val1, val2, action) // the first value is the body as string and the second a pattern string } else if ( typeof val1 === 'string' && typeof val2 === 'string' && @@ -482,10 +486,10 @@ TestRunner.prototype.match = function (val1, val2) { .replace(/\s/g, '') .slice(1, -1) // 'm' adds the support for multiline regex - this.tap.match(val1, new RegExp(regStr, 'm'), `should match pattern provided: ${val2}`) + this.tap.match(val1, new RegExp(regStr, 'm'), `should match pattern provided: ${val2}, action: ${JSON.stringify(action)}`) // everything else } else { - this.tap.strictEqual(val1, val2, `should be equal: ${val1} - ${val2}`) + this.tap.strictEqual(val1, val2, `should be equal: ${val1} - ${val2}, action: ${JSON.stringify(action)}`) } return this } From 404ebff8a814a5b9a253702e48a07a8a842c282b Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 19 Feb 2019 08:25:42 +0100 Subject: [PATCH 133/172] Updated .ci conf --- .ci/Dockerfile | 2 +- .ci/docker-compose.yml | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.ci/Dockerfile b/.ci/Dockerfile index 04ff3f55d..695addb3d 100644 --- a/.ci/Dockerfile +++ b/.ci/Dockerfile @@ -1,4 +1,4 @@ -ARG NODE_JS_VERSION=8 +ARG NODE_JS_VERSION=10 FROM node:${NODE_JS_VERSION} # Create app directory diff --git a/.ci/docker-compose.yml b/.ci/docker-compose.yml index a9128c62e..d8a3b6c38 100644 --- a/.ci/docker-compose.yml +++ b/.ci/docker-compose.yml @@ -1,12 +1,12 @@ version: '3.2' services: client: - image: docker.elastic.co/clients/elasticsearch-js:${NODE_JS_VERSION:-8} + image: docker.elastic.co/clients/elasticsearch-js:${NODE_JS_VERSION:-10} build: context: .. dockerfile: .ci/Dockerfile args: - NODE_JS_VERSION: ${NODE_JS_VERSION:-8} + NODE_JS_VERSION: ${NODE_JS_VERSION:-10} environment: - "TEST_ES_SERVER=http://elasticsearch:9200" volumes: @@ -27,12 +27,11 @@ services: - esnet environment: - path.repo=/tmp - - "repositories.url.allowed_urls=http://*" + - "repositories.url.allowed_urls=http://snapshot.*" - node.attr.testattr=test - bootstrap.memory_lock=false - # - "discovery.zen.ping.unicast.hosts=elasticsearch" - "discovery.type=single-node" - - "http.max_content_length=5mb" + - "ES_JAVA_OPTS=-Xms512m -Xmx512m" networks: esnet: volumes: From 59a84216b1fc67449fd82d09b694b346b587cf48 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 19 Feb 2019 08:26:55 +0100 Subject: [PATCH 134/172] Updated .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index f8274fc48..6ecf99af0 100644 --- a/.gitignore +++ b/.gitignore @@ -47,4 +47,6 @@ package-lock.json # elasticsearch repo or binary files elasticsearch* +# Generated typings, we don't commit them +# because we should copy them in the main .d.ts file api/generated.d.ts From 98e8bbd63d2fce9b07215ccd7a6108245e912129 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 19 Feb 2019 08:30:53 +0100 Subject: [PATCH 135/172] Added cloud option and disable dead/alive handling if there is only one node and sniffing is disabled --- index.d.ts | 5 +++++ index.js | 14 +++++++++++++- lib/ConnectionPool.d.ts | 1 + lib/ConnectionPool.js | 7 +++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 0dc7f7a11..dfcf930a1 100644 --- a/index.d.ts +++ b/index.d.ts @@ -40,6 +40,11 @@ interface ClientOptions { agent?: AgentOptions; nodeFilter?: nodeFilterFn; nodeSelector?: nodeSelectorFn | string; + cloud?: { + id: string; + username: string; + password: string; + } } declare class Client extends EventEmitter { diff --git a/index.js b/index.js index 1fc9aba54..daf209791 100644 --- a/index.js +++ b/index.js @@ -14,6 +14,15 @@ const buildApi = require('./api') class Client extends EventEmitter { constructor (opts = {}) { super() + if (opts.cloud) { + const { id, username, password } = opts.cloud + // the cloud id is `cluster-name:base64encodedurl` + // the url is a string divided by two '$', the first is the cloud url + // the second the elasticsearch instance, the third the kibana instance + const cloudUrls = Buffer.from(id.split(':')[1], 'base64').toString().split('$') + opts.node = `https://${username}:${password}@${cloudUrls[1]}.${cloudUrls[0]}` + } + if (!opts.node && !opts.nodes) { throw new ConfigurationError('Missing node(s) option') } @@ -56,7 +65,10 @@ class Client extends EventEmitter { nodeWeighter: options.nodeWeighter, nodeSelector: options.nodeSelector, Connection: options.Connection, - emit: this.emit.bind(this) + emit: this.emit.bind(this), + sniffEnabled: options.sniffInterval !== false || + options.sniffOnStart !== false || + options.sniffOnConnectionFault !== false }) // Add the connections before initialize the Transport diff --git a/lib/ConnectionPool.d.ts b/lib/ConnectionPool.d.ts index dd55540fd..8b14ced59 100644 --- a/lib/ConnectionPool.d.ts +++ b/lib/ConnectionPool.d.ts @@ -42,6 +42,7 @@ export default class ConnectionPool { dead: string[]; _ssl: SecureContextOptions | null; _agent: AgentOptions | null; + _sniffEnabled: boolean; resurrectTimeout: number; resurrectTimeoutCutoff: number; pingTimeout: number; diff --git a/lib/ConnectionPool.js b/lib/ConnectionPool.js index e4221a16b..f5e82f401 100644 --- a/lib/ConnectionPool.js +++ b/lib/ConnectionPool.js @@ -27,6 +27,7 @@ class ConnectionPool { this.nodeFilter = opts.nodeFilter || defaultNodeFilter this.Connection = opts.Connection this.emit = opts.emit || noop + this._sniffEnabled = opts.sniffEnabled || false if (typeof opts.nodeSelector === 'function') { this.nodeSelector = opts.nodeSelector @@ -50,10 +51,13 @@ class ConnectionPool { * Marks a connection as 'alive'. * If needed removes the connection from the dead list * and then resets the `deadCount`. + * If sniffing is not enabled and there is only + * one node, this method is a noop. * * @param {object} connection */ markAlive (connection) { + if (this._sniffEnabled === false && this.connections.size === 1) return const { id } = connection debug(`Marking as 'alive' connection '${id}'`) const index = this.dead.indexOf(id) @@ -67,10 +71,13 @@ class ConnectionPool { * Marks a connection as 'dead'. * If needed adds the connection to the dead list * and then increments the `deadCount`. + * If sniffing is not enabled and there is only + * one node, this method is a noop. * * @param {object} connection */ markDead (connection) { + if (this._sniffEnabled === false && this.connections.size === 1) return const { id } = connection debug(`Marking as 'dead' connection '${id}'`) if (this.dead.indexOf(id) === -1) { From bcf895294b11f484e0f417cd2c8d9f30bc83b66a Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 19 Feb 2019 08:31:09 +0100 Subject: [PATCH 136/172] Updated test --- test/integration/test-runner.js | 14 +++++++++++ test/unit/client.test.js | 27 +++++++++++++++++++++ test/unit/connection-pool.test.js | 40 ++++++++++++++++++++++++++----- 3 files changed, 75 insertions(+), 6 deletions(-) diff --git a/test/integration/test-runner.js b/test/integration/test-runner.js index 1c7fc4757..2f8fa0b97 100644 --- a/test/integration/test-runner.js +++ b/test/integration/test-runner.js @@ -53,6 +53,20 @@ TestRunner.prototype.cleanup = function (q, done) { }) }) + q.add((q, done) => { + this.client.snapshot.delete({ repository: '*', snapshot: '*' }, { ignore: 404 }, err => { + this.tap.error(err, 'should not error:snapshot.delete') + done() + }) + }) + + q.add((q, done) => { + this.client.snapshot.deleteRepository({ repository: '*' }, { ignore: 404 }, err => { + this.tap.error(err, 'should not error:snapshot.deleteRepository') + done() + }) + }) + done() } diff --git a/test/unit/client.test.js b/test/unit/client.test.js index ff895a740..45f928ece 100644 --- a/test/unit/client.test.js +++ b/test/unit/client.test.js @@ -496,3 +496,30 @@ test('Extend client APIs', t => { t.end() }) + +test('Elastic cloud config', t => { + t.plan(1) + const client = new Client({ + cloud: { + // 'localhost$abcd$efgh' + id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA==', + username: 'elastic', + password: 'changeme' + } + }) + + const pool = client.connectionPool + t.match(pool.connections.get('https://abcd.localhost/'), { + url: new URL('https://elastic:changeme@abcd.localhost'), + id: 'https://abcd.localhost/', + ssl: null, + deadCount: 0, + resurrectTimeout: 0, + roles: { + master: true, + data: true, + ingest: true, + ml: false + } + }) +}) diff --git a/test/unit/connection-pool.test.js b/test/unit/connection-pool.test.js index 734877d1f..0969e21a0 100644 --- a/test/unit/connection-pool.test.js +++ b/test/unit/connection-pool.test.js @@ -47,7 +47,7 @@ test('API', t => { }) t.test('markDead', t => { - const pool = new ConnectionPool({ Connection }) + const pool = new ConnectionPool({ Connection, sniffEnabled: true }) const href = 'http://localhost:9200/' var connection = pool.addConnection(href) pool.markDead(connection) @@ -73,7 +73,7 @@ test('API', t => { }) t.test('markAlive', t => { - const pool = new ConnectionPool({ Connection }) + const pool = new ConnectionPool({ Connection, sniffEnabled: true }) const href = 'http://localhost:9200/' var connection = pool.addConnection(href) pool.markDead(connection) @@ -92,7 +92,8 @@ test('API', t => { const pool = new ConnectionPool({ resurrectStrategy: 'ping', pingTimeout: 3000, - Connection: MockConnection + Connection: MockConnection, + sniffEnabled: true }) const href = 'http://localhost:9200/' var connection = pool.addConnection(href) @@ -112,7 +113,8 @@ test('API', t => { const pool = new ConnectionPool({ resurrectStrategy: 'ping', pingTimeout: 3000, - Connection: MockConnectionTimeout + Connection: MockConnectionTimeout, + sniffEnabled: true }) const href = 'http://localhost:9200/' var connection = pool.addConnection(href) @@ -134,7 +136,8 @@ test('API', t => { t.test('optimistic strategy', t => { const pool = new ConnectionPool({ resurrectStrategy: 'optimistic', - Connection + Connection, + sniffEnabled: true }) const href = 'http://localhost:9200/' var connection = pool.addConnection(href) @@ -153,7 +156,8 @@ test('API', t => { t.test('none strategy', t => { const pool = new ConnectionPool({ resurrectStrategy: 'none', - Connection + Connection, + sniffEnabled: true }) const href = 'http://localhost:9200/' var connection = pool.addConnection(href) @@ -567,3 +571,27 @@ test('Node filter', t => { t.end() }) + +test('Single node behavior', t => { + t.test('sniffing disabled (markDead and markAlive should be noop)', t => { + t.plan(2) + const pool = new ConnectionPool({ Connection, sniffEnabled: false }) + const conn = pool.addConnection('http://localhost:9200/') + pool.markDead(conn) + t.strictEqual(pool.dead.length, 0) + pool.markAlive(conn) + t.strictEqual(pool.dead.length, 0) + }) + + t.test('sniffing enabled (markDead and markAlive should work)', t => { + t.plan(2) + const pool = new ConnectionPool({ Connection, sniffEnabled: true }) + const conn = pool.addConnection('http://localhost:9200/') + pool.markDead(conn) + t.strictEqual(pool.dead.length, 1) + pool.markAlive(conn) + t.strictEqual(pool.dead.length, 0) + }) + + t.end() +}) From b10ec1fa70ba641f9c12cb7edaabfc4d2e465b1f Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 19 Feb 2019 08:32:25 +0100 Subject: [PATCH 137/172] Added .npmignore --- .npmignore | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .npmignore diff --git a/.npmignore b/.npmignore new file mode 100644 index 000000000..dfe6586dc --- /dev/null +++ b/.npmignore @@ -0,0 +1,66 @@ +# Logs +logs +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules +jspm_packages + +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history + +# mac files +.DS_Store + +# vim swap files +*.swp + +package-lock.json + +# elasticsearch repo or binary files +elasticsearch* + +# Generated typings, we don't commit them +# because we should copy them in the main .d.ts file +api/generated.d.ts + +# Ignore doc folder +docs + +# Ignore test folder +test + +# Ignore scripts folder +scripts + +# ci configuration +.ci +.travis.yml +certs From 7616e8843843db474499f08d91be9ccafc5a59de Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 19 Feb 2019 08:32:35 +0100 Subject: [PATCH 138/172] Updated docs --- docs/authentication.asciidoc | 65 ++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 docs/authentication.asciidoc diff --git a/docs/authentication.asciidoc b/docs/authentication.asciidoc new file mode 100644 index 000000000..5038508d4 --- /dev/null +++ b/docs/authentication.asciidoc @@ -0,0 +1,65 @@ += Authentication + +This document contains code snippets to show you how to connect to various Elasticsearch providers. + +== Basic Auth + +You can provide your credentials in the node(s) URL. + +[source,js] +---- +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ + node: 'https://username:password@localhost:9200' +}) +---- + +Or you can use the full node declaration. + +[source,js] +---- +const { URL } = require('url') +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ + node: { + url: new URL('https://username:password@localhost:9200'), + id: 'node-1', + ... + } +}) +---- + +== SSL configuration + +Without any additional configuration you can specify `https://` node urls, but the certificates used to sign these requests will not verified (`rejectUnauthorized: false`). To turn on certificate verification you must specify an `ssl` object either in the top level config or in each host config object and set `rejectUnauthorized: true`. The ssl config object can contain many of the same configuration options that https://nodejs.org/api/tls.html#tls_tls_connect_options_callback[tls.connect()] accepts. + +[source,js] +---- +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ + node: 'http://username:password@localhost:9200', + ssl: { + ca: fs.readFileSync('./cacert.pem'), + rejectUnauthorized: true + } +}) +---- + +== Elastic Cloud + +If you are using https://www.elastic.co/cloud[Elastic Cloud], the client offers a easy way to connect to it via the `cloud` option. + +You must pass the cloud id that you can find in the cloud console, then your username and password. + +NOTE: Do not enable sniffing when using Elastic Cloud, since the nodes are behind a load balancer, the Cloud will take care of everything. + +[source,js] +---- +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ + cloud: { + id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA==', + username: 'elastic', + password: 'changeme' + } +}) +---- \ No newline at end of file From 0915c8c613197ccb4624565225e575d0de9c76db Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 19 Feb 2019 09:33:25 +0100 Subject: [PATCH 139/172] Added force option to extend method --- index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index daf209791..051c88b91 100644 --- a/index.js +++ b/index.js @@ -99,7 +99,12 @@ class Client extends EventEmitter { }) } - extend (name, fn) { + extend (name, opts, fn) { + if (typeof opts === 'function') { + fn = opts + opts = {} + } + var [namespace, method] = name.split('.') if (method == null) { method = namespace @@ -107,7 +112,7 @@ class Client extends EventEmitter { } if (namespace != null) { - if (this[namespace] != null && this[namespace][method] != null) { + if (this[namespace] != null && this[namespace][method] != null && opts.force !== true) { throw new Error(`The method "${method}" already exists on namespace "${namespace}"`) } @@ -118,7 +123,7 @@ class Client extends EventEmitter { ConfigurationError }) } else { - if (this[method] != null) { + if (this[method] != null && opts.force !== true) { throw new Error(`The method "${method}" already exists`) } From 665ea3999d547289686806d36f7317c269e3c0ca Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 19 Feb 2019 09:33:59 +0100 Subject: [PATCH 140/172] Updated types --- index.d.ts | 39 ++++++++++++++++++++++++++++++++------- lib/Transport.d.ts | 16 +++++++++++++--- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/index.d.ts b/index.d.ts index dfcf930a1..40926e816 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2,11 +2,18 @@ import { EventEmitter } from 'events'; import { SecureContextOptions } from 'tls'; -import Transport, { ApiResponse, EventMeta, SniffMeta, RequestOptions } from './lib/Transport'; +import Transport, { + ApiResponse, + EventMeta, + SniffMeta, + TransportRequestParams, + TransportRequestOptions +} from './lib/Transport'; import Connection, { AgentOptions } from './lib/Connection'; import ConnectionPool, { nodeSelectorFn, nodeFilterFn, ResurrectMeta } from './lib/ConnectionPool'; import Serializer from './lib/Serializer'; -import * as RequestParams from './api/requestParams' +import * as RequestParams from './api/requestParams'; +import * as errors from './lib/errors'; declare type anyObject = { [key: string]: any; @@ -16,9 +23,27 @@ declare type callbackFn = (err: Error | null, result: ApiResponse) => void; interface ApiMethod { (callback?: callbackFn): any; (params: T, callback?: callbackFn): any; - (params: T, options: RequestOptions, callback?: callbackFn): any; + (params: T, options: TransportRequestOptions, callback?: callbackFn): any; } +// Extend API +interface ClientExtendsCallbackOptions { + ConfigurationError: errors.ConfigurationError, + makeRequest(params: TransportRequestParams, options?: TransportRequestOptions): Promise | void; + result: { + body: null, + statusCode: null, + headers: null, + warnings: null + } +} +declare type extendsCallback = (options: ClientExtendsCallbackOptions) => any; +interface ClientExtends { + (method: string, fn: extendsCallback): void; + (method: string, opts: { force: boolean }, fn: extendsCallback): void; +} +// /Extend API + interface ClientOptions { node?: string | string[]; nodes?: string | string[]; @@ -51,9 +76,8 @@ declare class Client extends EventEmitter { constructor(opts?: ClientOptions); connectionPool: ConnectionPool; transport: Transport; - serializer: Serializer - // TODO: update fn declaration - extends(method: string, fn: any): void; + serializer: Serializer; + extend: ClientExtends; close(callback?: Function): Promise | void; bulk: ApiMethod cat: { @@ -525,5 +549,6 @@ export { EventMeta, SniffMeta, ResurrectMeta, - RequestParams + RequestParams, + ClientExtendsCallbackOptions }; diff --git a/lib/Transport.d.ts b/lib/Transport.d.ts index b9ecc7355..718377fc1 100644 --- a/lib/Transport.d.ts +++ b/lib/Transport.d.ts @@ -43,12 +43,22 @@ declare type anyObject = { [key: string]: any; }; -export interface RequestOptions { - ignore?: number | number[]; +export interface TransportRequestParams { + method: string; + path: string; + body?: anyObject, + bulkBody?: anyObject, + querystring: anyObject +} + +export interface TransportRequestOptions { + ignore?: [number]; requestTimeout?: number | string; maxRetries?: number; asStream?: boolean; headers?: anyObject; + compression?: string; + warnings?: [string]; } export default class Transport { @@ -72,7 +82,7 @@ export default class Transport { _nextSniff: number; _isSniffing: boolean; constructor(opts: TransportOptions); - request(params: any, options: RequestOptions, callback: (err: Error | null, result: ApiResponse) => void): any; + request(params: TransportRequestParams, options: TransportRequestOptions, callback: (err: Error | null, result: ApiResponse) => void): any; getConnection(): Connection | null; sniff(callback?: (...args: any[]) => void): void; } From a8f861c4d4e9fa129fcd3dcfa3d3613d68629d2c Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 19 Feb 2019 09:34:14 +0100 Subject: [PATCH 141/172] Updated test --- test/types/index.ts | 23 ++++++++++++++++++++++- test/unit/client.test.js | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/test/types/index.ts b/test/types/index.ts index 17e6669a3..ad1d026cd 100644 --- a/test/types/index.ts +++ b/test/types/index.ts @@ -6,9 +6,12 @@ import { EventMeta, SniffMeta, ResurrectMeta, - events + events, + ClientExtendsCallbackOptions } from '../../index' +import { TransportRequestParams, TransportRequestOptions } from '../../lib/Transport' + const client = new Client({ node: 'http://localhost:9200' }) client.on(events.REQUEST, (err: Error | null, meta: EventMeta) => {}) @@ -65,3 +68,21 @@ client.index({ }) .then((result: ApiResponse) => {}) .catch((err: Error) => {}) + +// extend client +client.extend('namespace.method', (options: ClientExtendsCallbackOptions) => { + return function (params: any) { + const requestParams: TransportRequestParams = { + method: 'GET', + path: '/', + querystring: {} + } + + const requestOptions: TransportRequestOptions = { + ignore: [404], + maxRetries: 5 + } + + return options.makeRequest(requestParams, requestOptions) + } +}) diff --git a/test/unit/client.test.js b/test/unit/client.test.js index 45f928ece..8cdd9f3f8 100644 --- a/test/unit/client.test.js +++ b/test/unit/client.test.js @@ -429,6 +429,28 @@ test('Extend client APIs', t => { } }) + t.test('Can override an existing method with { force: true }', t => { + t.plan(1) + + const client = new Client({ node: 'http://localhost:9200' }) + try { + client.extend('index', { force: true }, () => t.pass('Called')) + } catch (err) { + t.fail('Should not throw') + } + }) + + t.test('Can override an existing namespace and method with { force: true }', t => { + t.plan(1) + + const client = new Client({ node: 'http://localhost:9200' }) + try { + client.extend('indices.delete', { force: true }, () => t.pass('Called')) + } catch (err) { + t.fail('Should not throw') + } + }) + t.test('Should call the transport.request method', t => { t.plan(2) From 8fd0d49a0377e25124a43a8f8a19cc939f6c90b7 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 19 Feb 2019 09:34:23 +0100 Subject: [PATCH 142/172] Updated docs --- docs/extend.asciidoc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/extend.asciidoc b/docs/extend.asciidoc index 643dbb2b5..c80c8bd3f 100644 --- a/docs/extend.asciidoc +++ b/docs/extend.asciidoc @@ -3,7 +3,7 @@ Sometimes you need to reuse the same logic, or you want to build a custom API to allow you simplify your code. + The easiest way to achieve that is by extending the client. -NOTE: You can't override existing methods. +NOTE: If you want to override existing methods, you should specify the `{ force: true }` option. [source,js] ---- @@ -57,6 +57,12 @@ client.extend('utility.delete', ({ makeRequest }) => { } }) +client.extend('indices.delete', { force: true }, ({ makeRequest }) => { + return function _delete (params, options) { + // your code + } +}) + client.supersearch(...) client.utility.index(...) client.utility.delete(...) From 36627e66dab2a2fa7af8d8c7f44ca74a73e6e157 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 19 Feb 2019 10:38:21 +0100 Subject: [PATCH 143/172] Bumped v0.1.0-alpha.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7ca20297d..081e3e0da 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "main": "index.js", "types": "index.d.ts", "homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html", - "version": "0.1.0-alpha.6", + "version": "0.1.0-alpha.7", "keywords": [ "elasticsearch", "elastic", From f01ccf0ff3c4ccd02aeaf464a329a6f3d24308c9 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 19 Feb 2019 11:12:02 +0100 Subject: [PATCH 144/172] Fix syntax --- docs/breaking-changes.asciidoc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/breaking-changes.asciidoc b/docs/breaking-changes.asciidoc index 37b98f416..5669b0cbd 100644 --- a/docs/breaking-changes.asciidoc +++ b/docs/breaking-changes.asciidoc @@ -2,7 +2,7 @@ If you were already using the previous version of this client, the one you used to install with `npm install elasticsearch`, you will encounter some breaking changes. -==== Don't panic! +=== Don't panic! Every breaking change was carefully weighted, and every breaking change has solid reasons to introduce it, furthermore the new codebase has been rewritten with modern JavaScript, and has been carefully designed to be easy to maintain. @@ -22,6 +22,7 @@ Every breaking change was carefully weighted, and every breaking change has soli * The returned value of an API call will no longer be the `body`, `statusCode`, and `headers` for callbacks and just the `body` for promises. The new returned value will be a unique object containing the `body`, `statusCode`, `headers`, and `warnings`, for both callback and promises. + With the `asStream` parameter you can get the original HTTP response stream if the case you need to pipe it to another response for a forwarding use case. + [source,js] ---- // before @@ -70,6 +71,7 @@ Errors that has been renamed: * You must specify the port number in the configuration. In the previous version you can specifiy the host and port in a variety of ways, with the new client there is only one via the `node` parameter. * The plugins option has been removed, if you want to extend the client now you should use the client.extend API. + [source,js] ---- // before @@ -83,6 +85,7 @@ client.extend(...) ---- * There is a clear distinction between the API related parameters and the client related configurations, the parameters `ignore`, `headers`, `requestTimeout` and `maxRetries` are no longer part of the API object, and you should specify them in a second option object. + [source,js] ---- // before @@ -119,6 +122,7 @@ client.search({ ---- * The `transport.request` method will no longer accept the `query` key, but the `querystring` key instead (which can be a string or an object), furthermore, you need to send a bulk-like request, instead of the `body` key, you should use the `bulkBody` key. Also in this method, the client specific parameters should be passed as a second object. + [source,js] ---- // before From 8ff4cdc50695df09aaa554a0375261217d40a06e Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 19 Feb 2019 12:34:08 +0100 Subject: [PATCH 145/172] Updated docs --- docs/breaking-changes.asciidoc | 120 +++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) diff --git a/docs/breaking-changes.asciidoc b/docs/breaking-changes.asciidoc index 5669b0cbd..1663eedbf 100644 --- a/docs/breaking-changes.asciidoc +++ b/docs/breaking-changes.asciidoc @@ -165,3 +165,123 @@ client.transport.request({ if (err) console.log(err) }) ---- + +=== Talk is cheap. Show me the code. + +Following you will find a snippet of code with the old client, followed by the same code logic, but with the new client. + +[source,js] +---- +const { Client, errors } = require('elasticsearch') +const client = new Client({ + host: 'http://localhost:9200', + plugins: [utility] +}) + +async function run () { + try { + const body = await client.search({ + index: 'game-of-thrones', + body: { + query: { + match: { quote: 'winter' } + } + } + ignore: [404] + }) + console.log(body) + } catch (err) { + if (err instanceof errors.BadRequest) { + console.log('Bad request') + } else { + console.log(err) + } + } +} + +function utility (Client, config, components) { + const ca = components.clientAction.factory + Client.prototype.utility = components.clientAction.namespaceFactory() + const utility = Client.prototype.utility.prototype + + utility.index = ca({ + params: { + refresh: { + type: 'enum', + options: [ + 'true', + 'false', + 'wait_for', + '' + ] + }, + }, + urls: [ + { + fmt: '/<%=index%>/_doc', + req: { + index: { + type: 'string', + required: true + } + } + } + ], + needBody: true, + method: 'POST' + }) +}) +---- + +And now with the new client. + +[source,js] +---- +const { Client, errors } = require('@elastic/elasticsearch') +// NOTE: `host` has been renamed to `node`, +// and `plugins` is no longer supported +const client = new Client({ node: 'http://localhost:9200' }) + +async function run () { + try { + // NOTE: we are using the destructuring assignment + const { body } = await client.search({ + index: 'game-of-thrones', + body: { + query: { + match: { quote: 'winter' } + } + } + // NOTE: `ignore` now is in a separated object + }, { + ignore: [404] + }) + console.log(body) + } catch (err) { + // NOTE: we are checking the `statusCode` property + if (err.statusCode === 400) { + console.log('Bad request') + } else { + console.log(err) + } + } +} + +// NOTE: we can still extend the client, but with a different API. +// This new API is a little bit more verbose, since you must write +// your own validations, but it's way more flexible. +client.extend('utility.index', ({ makeRequest, ConfigurationError }) => { + return function utilityIndex (params, options) { + const { body, index, ...querystring } = params + if (body == null) throw new ConfigurationError('Missing body') + if (index == null) throw new ConfigurationError('Missing index') + const requestParams = { + method: 'POST', + path: `/${index}/_doc`, + body: body, + querystring + } + return makeRequest(requestParams, options) + } +}) +---- From e9cc0324c23031d0afc9876845e25d7e325ba142 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 19 Feb 2019 13:59:27 +0100 Subject: [PATCH 146/172] Updated scripts --- scripts/es-docker.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/es-docker.sh b/scripts/es-docker.sh index 11a1302fd..d09be3e26 100755 --- a/scripts/es-docker.sh +++ b/scripts/es-docker.sh @@ -8,7 +8,4 @@ exec docker run \ -e "discovery.type=single-node" \ -p 9200:9200 \ docker.elastic.co/elasticsearch/elasticsearch:7.0.0-beta1 - # docker.elastic.co/elasticsearch/elasticsearch:6.5.4 - -# -e "xpack.security.enabled=true" \ -# -e "ELASTIC_PASSWORD=passw0rd" \ + # docker.elastic.co/elasticsearch/elasticsearch:6.6.0 From 974bf0a819c3c5c0a955f66b618f7599f4231465 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 20 Feb 2019 12:43:06 +0100 Subject: [PATCH 147/172] Added global headers option --- index.js | 4 +++- lib/Transport.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 051c88b91..783ceeafc 100644 --- a/index.js +++ b/index.js @@ -50,6 +50,7 @@ class Client extends EventEmitter { compression: false, ssl: null, agent: null, + headers: {}, nodeFilter: null, nodeWeighter: null, nodeSelector: 'round-robin' @@ -85,7 +86,8 @@ class Client extends EventEmitter { sniffOnConnectionFault: options.sniffOnConnectionFault, sniffEndpoint: options.sniffEndpoint, suggestCompression: options.suggestCompression, - compression: options.compression + compression: options.compression, + headers: options.headers }) const apis = buildApi({ diff --git a/lib/Transport.js b/lib/Transport.js index 94a1df69f..6dafb3574 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -27,6 +27,7 @@ class Transport { this.requestTimeout = toMs(opts.requestTimeout) this.suggestCompression = opts.suggestCompression === true this.compression = opts.compression || false + this.headers = opts.headers || {} this.sniffInterval = opts.sniffInterval this.sniffOnConnectionFault = opts.sniffOnConnectionFault this.sniffEndpoint = opts.sniffEndpoint @@ -82,7 +83,8 @@ class Transport { return callback(new NoLivingConnectionsError('There are not living connections'), result) } - const headers = options.headers || {} + // TODO: make this assignment FAST + const headers = Object.assign({}, this.headers, options.headers) // handle json body if (params.body != null) { From 66e8d6147689ca4fe52611d2d6012675e3ef68b7 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 20 Feb 2019 12:43:15 +0100 Subject: [PATCH 148/172] Updated test --- test/unit/transport.test.js | 119 ++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index ad3b4c243..8fba614d1 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -1859,3 +1859,122 @@ test('Compress request', t => { t.end() }) + +test('Headers configuration', t => { + t.test('Global option', t => { + t.plan(3) + function handler (req, res) { + t.match(req.headers, { 'x-foo': 'bar' }) + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ Connection }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false, + headers: { + 'x-foo': 'bar' + } + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + server.stop() + }) + }) + }) + + t.test('Global option and custom option', t => { + t.plan(3) + function handler (req, res) { + t.match(req.headers, { + 'x-foo': 'bar', + 'x-baz': 'faz' + }) + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ Connection }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false, + headers: { + 'x-foo': 'bar' + } + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, { + headers: { 'x-baz': 'faz' } + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + server.stop() + }) + }) + }) + + t.test('Custom options should override global option', t => { + t.plan(3) + function handler (req, res) { + t.match(req.headers, { 'x-foo': 'faz' }) + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ Connection }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false, + headers: { + 'x-foo': 'bar' + } + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, { + headers: { 'x-foo': 'faz' } + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + server.stop() + }) + }) + }) + + t.end() +}) From 5b856cd4c283bf7b17690841650aa97542b7d04f Mon Sep 17 00:00:00 2001 From: Tomas Della Vedova Date: Thu, 21 Feb 2019 12:48:49 +0100 Subject: [PATCH 149/172] Child client support (#768) With this pr we introduce the `client.child` API, which returns a new client instance that shares the connection pool with the parent client. This feature can be handy if you need to have multiple client instances with different configurations, but with a shared connection pool. Example: ```js const { Client } = require('@elastic/elasticsearch') const client = new Client({ node: 'http://localhost:9200' }) const child = client.child({ headers: { 'x-foo': 'bar' }, requestTimeout: 1000 }) client.info(console.log) child.info(console.log) ``` **Open questions:** * Currently, the event emitter is shared between the parent and the child(ren), is it ok? * Currently, if you extend the parent client, the child client will have the same extensions, while if the child client adds an extension, the parent client will not be extended. Is it ok? **Caveats:** * You can override _any_ option except for the connection pool specific options (`ssl`, `agent`, `pingTimeout`, `Connection`, and `resurrectStrategy`). * You can't specify a new `Connection` class. * If you call `close` in any of the parent/child clients, every client will be closed. _Note: the `nodeFilter` and `nodeSelector` options are now `Transport` options and no longer `ConnectionPool` options._ --- docs/child.asciidoc | 23 ++++ index.d.ts | 8 +- index.js | 44 ++++++- lib/ConnectionPool.d.ts | 13 +- lib/ConnectionPool.js | 41 +------ lib/Transport.d.ts | 11 ++ lib/Transport.js | 42 ++++++- test/unit/child.test.js | 194 ++++++++++++++++++++++++++++++ test/unit/connection-pool.test.js | 62 ++-------- test/unit/selectors.test.js | 2 +- test/unit/transport.test.js | 33 +++++ 11 files changed, 357 insertions(+), 116 deletions(-) create mode 100644 docs/child.asciidoc create mode 100644 test/unit/child.test.js diff --git a/docs/child.asciidoc b/docs/child.asciidoc new file mode 100644 index 000000000..74ba23185 --- /dev/null +++ b/docs/child.asciidoc @@ -0,0 +1,23 @@ += Creating a child client + +There are some use cases where you may need multiple instances of the client. You can easily do that by calling `new Client()` as many times as you need, but you will lose all the benefits of using one single client, such as the long living connections and the connection pool handling. + +To avoid this problem the client offers a `child` API, which returns a new client instance that shares the connection pool with the parent client. + + +NOTE: The event emitter is shared between the parent and the child(ren), and if you extend the parent client, the child client will have the same extensions, while if the child client adds an extension, the parent client will not be extended. + +You can pass to the `child` every client option you would pass to a normal client, but the connection pool specific options (`ssl`, `agent`, `pingTimeout`, `Connection`, and `resurrectStrategy`). + +CAUTION: If you call `close` in any of the parent/child clients, every client will be closed. + +[source,js] +---- +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ node: 'http://localhost:9200' }) +const child = client.child({ + headers: { 'x-foo': 'bar' }, + requestTimeout: 1000 +}) + +client.info(console.log) +child.info(console.log) +---- diff --git a/index.d.ts b/index.d.ts index 40926e816..4b31d159a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -7,10 +7,12 @@ import Transport, { EventMeta, SniffMeta, TransportRequestParams, - TransportRequestOptions + TransportRequestOptions, + nodeFilterFn, + nodeSelectorFn } from './lib/Transport'; import Connection, { AgentOptions } from './lib/Connection'; -import ConnectionPool, { nodeSelectorFn, nodeFilterFn, ResurrectMeta } from './lib/ConnectionPool'; +import ConnectionPool, { ResurrectMeta } from './lib/ConnectionPool'; import Serializer from './lib/Serializer'; import * as RequestParams from './api/requestParams'; import * as errors from './lib/errors'; @@ -65,6 +67,7 @@ interface ClientOptions { agent?: AgentOptions; nodeFilter?: nodeFilterFn; nodeSelector?: nodeSelectorFn | string; + headers?: anyObject; cloud?: { id: string; username: string; @@ -78,6 +81,7 @@ declare class Client extends EventEmitter { transport: Transport; serializer: Serializer; extend: ClientExtends; + child(opts?: ClientOptions): Client; close(callback?: Function): Promise | void; bulk: ApiMethod cat: { diff --git a/index.js b/index.js index 783ceeafc..4769ff93c 100644 --- a/index.js +++ b/index.js @@ -9,6 +9,10 @@ const Serializer = require('./lib/Serializer') const errors = require('./lib/errors') const { ConfigurationError } = errors +const kInitialOptions = Symbol('elasticsearchjs-initial-options') +const kChild = Symbol('elasticsearchjs-child') +const kExtensions = Symbol('elasticsearchjs-extensions') + const buildApi = require('./api') class Client extends EventEmitter { @@ -52,19 +56,18 @@ class Client extends EventEmitter { agent: null, headers: {}, nodeFilter: null, - nodeWeighter: null, nodeSelector: 'round-robin' }, opts) + this[kInitialOptions] = options + this[kExtensions] = [] + this.serializer = new options.Serializer() this.connectionPool = new options.ConnectionPool({ pingTimeout: options.pingTimeout, resurrectStrategy: options.resurrectStrategy, ssl: options.ssl, agent: options.agent, - nodeFilter: options.nodeFilter, - nodeWeighter: options.nodeWeighter, - nodeSelector: options.nodeSelector, Connection: options.Connection, emit: this.emit.bind(this), sniffEnabled: options.sniffInterval !== false || @@ -73,7 +76,9 @@ class Client extends EventEmitter { }) // Add the connections before initialize the Transport - this.connectionPool.addConnection(options.node || options.nodes) + if (opts[kChild] !== true) { + this.connectionPool.addConnection(options.node || options.nodes) + } this.transport = new options.Transport({ emit: this.emit.bind(this), @@ -87,7 +92,9 @@ class Client extends EventEmitter { sniffEndpoint: options.sniffEndpoint, suggestCompression: options.suggestCompression, compression: options.compression, - headers: options.headers + headers: options.headers, + nodeFilter: options.nodeFilter, + nodeSelector: options.nodeSelector }) const apis = buildApi({ @@ -135,6 +142,31 @@ class Client extends EventEmitter { ConfigurationError }) } + + this[kExtensions].push({ name, opts, fn }) + } + + child (opts) { + // Merge the new options with the initial ones + const initialOptions = Object.assign({}, this[kInitialOptions], opts) + // Tell to the client that we are creating a child client + initialOptions[kChild] = true + + const client = new Client(initialOptions) + // Reuse the same connection pool + client.connectionPool = this.connectionPool + client.transport.connectionPool = this.connectionPool + // Share event listener + const emitter = this.emit.bind(this) + client.emit = emitter + client.connectionPool.emit = emitter + client.transport.emit = emitter + client.on = this.on.bind(this) + // Add parent extensions + this[kExtensions].forEach(({ name, opts, fn }) => { + client.extend(name, opts, fn) + }) + return client } close (callback) { diff --git a/lib/ConnectionPool.d.ts b/lib/ConnectionPool.d.ts index 8b14ced59..a98cb6677 100644 --- a/lib/ConnectionPool.d.ts +++ b/lib/ConnectionPool.d.ts @@ -2,14 +2,7 @@ import { SecureContextOptions } from 'tls'; import Connection, { AgentOptions } from './Connection'; - -export interface nodeSelectorFn { - (connections: Connection[]): Connection; -} - -export interface nodeFilterFn { - (connection: Connection): boolean; -} +import { nodeFilterFn, nodeSelectorFn } from './Transport'; interface ConnectionPoolOptions { ssl?: SecureContextOptions; @@ -17,8 +10,6 @@ interface ConnectionPoolOptions { pingTimeout?: number; Connection: typeof Connection; resurrectStrategy?: string; - nodeFilter?: nodeFilterFn; - nodeSelector?: string | nodeSelectorFn; } export interface getConnectionOptions { @@ -46,8 +37,6 @@ export default class ConnectionPool { resurrectTimeout: number; resurrectTimeoutCutoff: number; pingTimeout: number; - nodeFilter: nodeFilterFn; - nodeSelector: nodeSelectorFn; Connection: typeof Connection; resurrectStrategy: number; constructor(opts?: ConnectionPoolOptions); diff --git a/lib/ConnectionPool.js b/lib/ConnectionPool.js index f5e82f401..7cdb89b5c 100644 --- a/lib/ConnectionPool.js +++ b/lib/ConnectionPool.js @@ -24,21 +24,10 @@ class ConnectionPool { // the timeout doesn't increase this.resurrectTimeoutCutoff = 5 this.pingTimeout = opts.pingTimeout - this.nodeFilter = opts.nodeFilter || defaultNodeFilter this.Connection = opts.Connection this.emit = opts.emit || noop this._sniffEnabled = opts.sniffEnabled || false - if (typeof opts.nodeSelector === 'function') { - this.nodeSelector = opts.nodeSelector - } else if (opts.nodeSelector === 'round-robin') { - this.nodeSelector = roundRobinSelector() - } else if (opts.nodeSelector === 'random') { - this.nodeSelector = randomSelector - } else { - this.nodeSelector = roundRobinSelector() - } - const resurrectStrategy = opts.resurrectStrategy || 'ping' this.resurrectStrategy = ConnectionPool.resurrectStrategies[resurrectStrategy] assert( @@ -174,8 +163,8 @@ class ConnectionPool { * @returns {object|null} connection */ getConnection (opts = {}) { - const filter = opts.filter || this.nodeFilter - const selector = opts.selector || this.nodeSelector + const filter = opts.filter || (() => true) + const selector = opts.selector || (c => c[0]) // TODO: can we cache this? const connections = [] @@ -381,30 +370,4 @@ ConnectionPool.resurrectStrategies = { // .sort((a, b) => a[0] - b[0]) // .map(a => a[1]) -function defaultNodeFilter (node) { - // avoid master only nodes - if (node.roles.master === true && - node.roles.data === false && - node.roles.ingest === false) { - return false - } - return true -} - -function roundRobinSelector () { - var current = -1 - return function _roundRobinSelector (connections) { - if (++current >= connections.length) { - current = 0 - } - return connections[current] - } -} - -function randomSelector (connections) { - const index = Math.floor(Math.random() * connections.length) - return connections[index] -} - module.exports = ConnectionPool -module.exports.internals = { defaultNodeFilter, roundRobinSelector, randomSelector } diff --git a/lib/Transport.d.ts b/lib/Transport.d.ts index 718377fc1..9a9730127 100644 --- a/lib/Transport.d.ts +++ b/lib/Transport.d.ts @@ -2,6 +2,14 @@ import ConnectionPool from './ConnectionPool'; import Connection from './Connection'; import Serializer from './Serializer'; +export interface nodeSelectorFn { + (connections: Connection[]): Connection; +} + +export interface nodeFilterFn { + (connection: Connection): boolean; +} + declare type noopFn = (...args: any[]) => void; declare type emitFn = (event: string | symbol, ...args: any[]) => boolean; @@ -17,6 +25,9 @@ interface TransportOptions { sniffOnConnectionFault: boolean; sniffEndpoint: string; sniffOnStart: boolean; + nodeFilter?: nodeFilterFn; + nodeSelector?: string | nodeSelectorFn; + headers?: anyObject; } export interface ApiResponse { diff --git a/lib/Transport.js b/lib/Transport.js index 6dafb3574..f16907bec 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -32,6 +32,17 @@ class Transport { this.sniffOnConnectionFault = opts.sniffOnConnectionFault this.sniffEndpoint = opts.sniffEndpoint + this.nodeFilter = opts.nodeFilter || defaultNodeFilter + if (typeof opts.nodeSelector === 'function') { + this.nodeSelector = opts.nodeSelector + } else if (opts.nodeSelector === 'round-robin') { + this.nodeSelector = roundRobinSelector() + } else if (opts.nodeSelector === 'random') { + this.nodeSelector = randomSelector + } else { + this.nodeSelector = roundRobinSelector() + } + this._sniffEnabled = typeof this.sniffInterval === 'number' this._nextSniff = this._sniffEnabled ? (Date.now() + this.sniffInterval) : 0 this._isSniffing = false @@ -275,7 +286,10 @@ class Transport { this.sniff(Transport.sniffReasons.SNIFF_INTERVAL) } this.connectionPool.resurrect(now) - return this.connectionPool.getConnection() + return this.connectionPool.getConnection({ + filter: this.nodeFilter, + selector: this.nodeSelector + }) } sniff (reason = Transport.sniffReasons.DEFAULT, callback = noop) { @@ -340,4 +354,30 @@ function isStream (obj) { return typeof obj.pipe === 'function' } +function defaultNodeFilter (node) { + // avoid master only nodes + if (node.roles.master === true && + node.roles.data === false && + node.roles.ingest === false) { + return false + } + return true +} + +function roundRobinSelector () { + var current = -1 + return function _roundRobinSelector (connections) { + if (++current >= connections.length) { + current = 0 + } + return connections[current] + } +} + +function randomSelector (connections) { + const index = Math.floor(Math.random() * connections.length) + return connections[index] +} + module.exports = Transport +module.exports.internals = { defaultNodeFilter, roundRobinSelector, randomSelector } diff --git a/test/unit/child.test.js b/test/unit/child.test.js new file mode 100644 index 000000000..5e8405de3 --- /dev/null +++ b/test/unit/child.test.js @@ -0,0 +1,194 @@ +'use strict' + +const { test } = require('tap') +const { Client, errors } = require('../../index') +const { + buildServer, + connection: { MockConnection } +} = require('../utils') + +test('Should create a child client (headers check)', t => { + t.plan(4) + + var count = 0 + function handler (req, res) { + if (count++ === 0) { + t.match(req.headers, { 'x-foo': 'bar' }) + } else { + t.match(req.headers, { 'x-baz': 'faz' }) + } + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const client = new Client({ + node: `http://localhost:${port}`, + headers: { 'x-foo': 'bar' } + }) + const child = client.child({ + headers: { 'x-baz': 'faz' } + }) + + client.info((err, res) => { + t.error(err) + child.info((err, res) => { + t.error(err) + server.stop() + }) + }) + }) +}) + +test('Should create a child client (timeout check)', t => { + t.plan(2) + + function handler (req, res) { + setTimeout(() => { + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + }, 50) + } + + buildServer(handler, ({ port }, server) => { + const client = new Client({ node: `http://localhost:${port}` }) + const child = client.child({ requestTimeout: 25, maxRetries: 0 }) + + client.info((err, res) => { + t.error(err) + child.info((err, res) => { + t.true(err instanceof errors.TimeoutError) + server.stop() + }) + }) + }) +}) + +test('Client extensions', t => { + t.test('One level', t => { + t.plan(1) + + const client = new Client({ node: 'http://localhost:9200' }) + client.extend('utility.index', () => { + return () => t.ok('called') + }) + + const child = client.child() + child.utility.index() + }) + + t.test('Two levels', t => { + t.plan(2) + + const client = new Client({ node: 'http://localhost:9200' }) + client.extend('utility.index', () => { + return () => t.ok('called') + }) + + const child = client.child() + child.extend('utility.search', () => { + return () => t.ok('called') + }) + + const grandchild = child.child() + grandchild.utility.index() + grandchild.utility.search() + }) + + t.test('The child should not extend the parent', t => { + t.plan(1) + + const client = new Client({ node: 'http://localhost:9200' }) + const child = client.child() + + child.extend('utility.index', () => { + return () => t.fail('Should not be called') + }) + + try { + client.utility.index() + } catch (err) { + t.ok(err) + } + }) + + t.end() +}) + +test('Should share the event emitter', t => { + t.test('One level', t => { + t.plan(2) + + const client = new Client({ + node: 'http://localhost:9200', + Connection: MockConnection + }) + const child = client.child() + + client.on('response', (err, meta) => { + t.error(err) + }) + + child.info((err, res) => { + t.error(err) + }) + }) + + t.test('Two levels', t => { + t.plan(2) + + const client = new Client({ + node: 'http://localhost:9200', + Connection: MockConnection + }) + const child = client.child() + const grandchild = child.child() + + client.on('response', (err, meta) => { + t.error(err) + }) + + grandchild.info((err, res) => { + t.error(err) + }) + }) + + t.test('Child listener - one level', t => { + t.plan(2) + + const client = new Client({ + node: 'http://localhost:9200', + Connection: MockConnection + }) + const child = client.child() + + child.on('response', (err, meta) => { + t.error(err) + }) + + child.info((err, res) => { + t.error(err) + }) + }) + + t.test('Child listener - two levels', t => { + t.plan(2) + + const client = new Client({ + node: 'http://localhost:9200', + Connection: MockConnection + }) + const child = client.child() + const grandchild = child.child() + + child.on('response', (err, meta) => { + t.error(err) + }) + + grandchild.info((err, res) => { + t.error(err) + }) + }) + + t.end() +}) diff --git a/test/unit/connection-pool.test.js b/test/unit/connection-pool.test.js index 0969e21a0..534d9fc5e 100644 --- a/test/unit/connection-pool.test.js +++ b/test/unit/connection-pool.test.js @@ -4,6 +4,7 @@ const { test } = require('tap') const { URL } = require('url') const ConnectionPool = require('../../lib/ConnectionPool') const Connection = require('../../lib/Connection') +const { defaultNodeFilter, roundRobinSelector } = require('../../lib/Transport').internals const { connection: { MockConnection, MockConnectionTimeout } } = require('../utils') test('API', t => { @@ -227,22 +228,6 @@ test('API', t => { pool.getConnection({ filter }) }) - t.test('filter as ConnectionPool option', t => { - t.plan(3) - - const href1 = 'http://localhost:9200/' - const href2 = 'http://localhost:9200/other' - const pool = new ConnectionPool({ - Connection, - nodeFilter: node => { - t.ok('called') - return true - } - }) - pool.addConnection([href1, href2]) - t.strictEqual(pool.getConnection().id, href1) - }) - t.end() }) @@ -498,27 +483,16 @@ test('API', t => { test('Node selector', t => { t.test('round-robin', t => { t.plan(1) - const pool = new ConnectionPool({ Connection, nodeSelector: 'round-robin' }) + const pool = new ConnectionPool({ Connection }) pool.addConnection('http://localhost:9200/') - t.true(pool.getConnection() instanceof Connection) + t.true(pool.getConnection({ selector: roundRobinSelector() }) instanceof Connection) }) t.test('random', t => { t.plan(1) - const pool = new ConnectionPool({ Connection, nodeSelector: 'random' }) + const pool = new ConnectionPool({ Connection }) pool.addConnection('http://localhost:9200/') - t.true(pool.getConnection() instanceof Connection) - }) - - t.test('custom function', t => { - t.plan(2) - const nodeSelector = connections => { - t.ok('called') - return connections[0] - } - const pool = new ConnectionPool({ Connection, nodeSelector }) - pool.addConnection('http://localhost:9200/') - t.true(pool.getConnection() instanceof Connection) + t.true(pool.getConnection({ selector: roundRobinSelector() }) instanceof Connection) }) t.end() @@ -529,7 +503,7 @@ test('Node filter', t => { t.plan(1) const pool = new ConnectionPool({ Connection }) pool.addConnection({ url: new URL('http://localhost:9200/') }) - t.true(pool.getConnection() instanceof Connection) + t.true(pool.getConnection({ filter: defaultNodeFilter }) instanceof Connection) }) t.test('Should filter master only nodes', t => { @@ -544,29 +518,7 @@ test('Node filter', t => { ml: false } }) - t.strictEqual(pool.getConnection(), null) - }) - - t.test('custom', t => { - t.plan(2) - const nodeFilter = node => { - t.ok('called') - return true - } - const pool = new ConnectionPool({ Connection, nodeFilter }) - pool.addConnection({ url: new URL('http://localhost:9200/') }) - t.true(pool.getConnection() instanceof Connection) - }) - - t.test('custom (filter)', t => { - t.plan(2) - const nodeFilter = node => { - t.ok('called') - return false - } - const pool = new ConnectionPool({ Connection, nodeFilter }) - pool.addConnection({ url: new URL('http://localhost:9200/') }) - t.strictEqual(pool.getConnection(), null) + t.strictEqual(pool.getConnection({ filter: defaultNodeFilter }), null) }) t.end() diff --git a/test/unit/selectors.test.js b/test/unit/selectors.test.js index 4ce57b581..cde2d52a5 100644 --- a/test/unit/selectors.test.js +++ b/test/unit/selectors.test.js @@ -1,7 +1,7 @@ 'use strict' const { test } = require('tap') -const { roundRobinSelector, randomSelector } = require('../../lib/ConnectionPool').internals +const { roundRobinSelector, randomSelector } = require('../../lib/Transport').internals test('RoundRobinSelector', t => { const selector = roundRobinSelector() diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index 8fba614d1..6fe920c49 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -1978,3 +1978,36 @@ test('Headers configuration', t => { t.end() }) + +test('nodeFilter and nodeSelector', t => { + t.plan(4) + + const pool = new ConnectionPool({ Connection: MockConnection }) + pool.addConnection('http://localhost:9200') + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false, + nodeFilter: () => { + t.ok('called') + return true + }, + nodeSelector: conns => { + t.ok('called') + return conns[0] + } + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + }) +}) From 7e318cb334a4d6f7587342f4f4bf3d8bd5d175fa Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 21 Feb 2019 15:39:01 +0100 Subject: [PATCH 150/172] Enable compression for both request and response when using Elastic Cloud --- index.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.js b/index.js index 4769ff93c..cb40ce0c1 100644 --- a/index.js +++ b/index.js @@ -25,6 +25,12 @@ class Client extends EventEmitter { // the second the elasticsearch instance, the third the kibana instance const cloudUrls = Buffer.from(id.split(':')[1], 'base64').toString().split('$') opts.node = `https://${username}:${password}@${cloudUrls[1]}.${cloudUrls[0]}` + + // Cloud has better performances with compression enabled + // see https://github.com/elastic/elasticsearch-py/pull/704. + // So unless the user specifies otherwise, we enable compression. + if (opts.compression == null) opts.compression = 'gzip' + if (opts.suggestCompression == null) opts.suggestCompression = true } if (!opts.node && !opts.nodes) { From d9b2a969d61a525a676ce074d760b4935781c683 Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 21 Feb 2019 15:39:10 +0100 Subject: [PATCH 151/172] Updated test --- test/unit/client.test.js | 66 +++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/test/unit/client.test.js b/test/unit/client.test.js index 8cdd9f3f8..a997856cd 100644 --- a/test/unit/client.test.js +++ b/test/unit/client.test.js @@ -520,28 +520,52 @@ test('Extend client APIs', t => { }) test('Elastic cloud config', t => { - t.plan(1) - const client = new Client({ - cloud: { - // 'localhost$abcd$efgh' - id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA==', - username: 'elastic', - password: 'changeme' - } + t.test('Basic', t => { + t.plan(3) + const client = new Client({ + cloud: { + // 'localhost$abcd$efgh' + id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA==', + username: 'elastic', + password: 'changeme' + } + }) + + const pool = client.connectionPool + t.match(pool.connections.get('https://abcd.localhost/'), { + url: new URL('https://elastic:changeme@abcd.localhost'), + id: 'https://abcd.localhost/', + ssl: null, + deadCount: 0, + resurrectTimeout: 0, + roles: { + master: true, + data: true, + ingest: true, + ml: false + } + }) + + t.strictEqual(client.transport.compression, 'gzip') + t.strictEqual(client.transport.suggestCompression, true) }) - const pool = client.connectionPool - t.match(pool.connections.get('https://abcd.localhost/'), { - url: new URL('https://elastic:changeme@abcd.localhost'), - id: 'https://abcd.localhost/', - ssl: null, - deadCount: 0, - resurrectTimeout: 0, - roles: { - master: true, - data: true, - ingest: true, - ml: false - } + t.test('Override compression options', t => { + t.plan(2) + const client = new Client({ + cloud: { + // 'localhost$abcd$efgh' + id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA==', + username: 'elastic', + password: 'changeme' + }, + compression: false, + suggestCompression: false + }) + + t.strictEqual(client.transport.compression, false) + t.strictEqual(client.transport.suggestCompression, false) }) + + t.end() }) From a56327058b8d307fc7fa21eb600ade269d1d8645 Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 21 Feb 2019 15:39:15 +0100 Subject: [PATCH 152/172] Updated docs --- docs/authentication.asciidoc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/authentication.asciidoc b/docs/authentication.asciidoc index 5038508d4..f1a8ff823 100644 --- a/docs/authentication.asciidoc +++ b/docs/authentication.asciidoc @@ -48,9 +48,12 @@ const client = new Client({ == Elastic Cloud If you are using https://www.elastic.co/cloud[Elastic Cloud], the client offers a easy way to connect to it via the `cloud` option. + -You must pass the cloud id that you can find in the cloud console, then your username and password. +You must pass the Cloud ID that you can find in the cloud console, then your username and password. -NOTE: Do not enable sniffing when using Elastic Cloud, since the nodes are behind a load balancer, the Cloud will take care of everything. +NOTE: When connecting to Elastic Cloud, the client will automatically enable both request and response compression by default, since it yields significant throughput improvements. + +You can still disable the compression with `{ compression: false, suggestCompression: false }`. + +IMPORTANT: Do not enable sniffing when using Elastic Cloud, since the nodes are behind a load balancer, Elastic Cloud will take care of everything for you. [source,js] ---- From 8398ae2f4b77dd9cb1fea56e4923c5e2beac0595 Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 28 Feb 2019 10:57:42 +0100 Subject: [PATCH 153/172] Updated Elastic Cloud config --- index.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index cb40ce0c1..ce6a09ce3 100644 --- a/index.js +++ b/index.js @@ -31,18 +31,17 @@ class Client extends EventEmitter { // So unless the user specifies otherwise, we enable compression. if (opts.compression == null) opts.compression = 'gzip' if (opts.suggestCompression == null) opts.suggestCompression = true + if (opts.ssl == null || + (opts.ssl && opts.ssl.secureProtocol == null)) { + opts.ssl = opts.ssl || {} + opts.ssl.secureProtocol = 'TLSv1_2_method' + } } if (!opts.node && !opts.nodes) { throw new ConfigurationError('Missing node(s) option') } - if (opts.log === true) { - this.on('request', console.log) - this.on('response', console.log) - this.on('error', console.log) - } - const options = Object.assign({}, { Connection, ConnectionPool, From fe3c48e83e2258e6e9d4339be8236e6b522a44ed Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 28 Feb 2019 10:57:48 +0100 Subject: [PATCH 154/172] Updated test --- test/unit/client.test.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/unit/client.test.js b/test/unit/client.test.js index a997856cd..83512a775 100644 --- a/test/unit/client.test.js +++ b/test/unit/client.test.js @@ -521,7 +521,7 @@ test('Extend client APIs', t => { test('Elastic cloud config', t => { t.test('Basic', t => { - t.plan(3) + t.plan(4) const client = new Client({ cloud: { // 'localhost$abcd$efgh' @@ -535,7 +535,7 @@ test('Elastic cloud config', t => { t.match(pool.connections.get('https://abcd.localhost/'), { url: new URL('https://elastic:changeme@abcd.localhost'), id: 'https://abcd.localhost/', - ssl: null, + ssl: { secureProtocol: 'TLSv1_2_method' }, deadCount: 0, resurrectTimeout: 0, roles: { @@ -548,10 +548,11 @@ test('Elastic cloud config', t => { t.strictEqual(client.transport.compression, 'gzip') t.strictEqual(client.transport.suggestCompression, true) + t.deepEqual(pool._ssl, { secureProtocol: 'TLSv1_2_method' }) }) - t.test('Override compression options', t => { - t.plan(2) + t.test('Override default options', t => { + t.plan(3) const client = new Client({ cloud: { // 'localhost$abcd$efgh' @@ -560,11 +561,15 @@ test('Elastic cloud config', t => { password: 'changeme' }, compression: false, - suggestCompression: false + suggestCompression: false, + ssl: { + secureProtocol: 'TLSv1_1_method' + } }) t.strictEqual(client.transport.compression, false) t.strictEqual(client.transport.suggestCompression, false) + t.deepEqual(client.connectionPool._ssl, { secureProtocol: 'TLSv1_1_method' }) }) t.end() From 945fe1f605d9f85c0705745a8744ed228f0ae1d0 Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 28 Feb 2019 10:57:59 +0100 Subject: [PATCH 155/172] Updated docs --- docs/authentication.asciidoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/authentication.asciidoc b/docs/authentication.asciidoc index f1a8ff823..8a69cb404 100644 --- a/docs/authentication.asciidoc +++ b/docs/authentication.asciidoc @@ -51,7 +51,8 @@ If you are using https://www.elastic.co/cloud[Elastic Cloud], the client offers You must pass the Cloud ID that you can find in the cloud console, then your username and password. NOTE: When connecting to Elastic Cloud, the client will automatically enable both request and response compression by default, since it yields significant throughput improvements. + -You can still disable the compression with `{ compression: false, suggestCompression: false }`. +Moreover, the client will also set the ssl option `secureProtocol` to `TLSv1_2_method` unless specified otherwise. +You can still override this option by configuring them. IMPORTANT: Do not enable sniffing when using Elastic Cloud, since the nodes are behind a load balancer, Elastic Cloud will take care of everything for you. From 36163f48224dabb9bc394821709bcd016b921aed Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 28 Feb 2019 16:08:14 +0100 Subject: [PATCH 156/172] Use a safe default for keep alive maxSockets (#770) --- lib/Connection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Connection.js b/lib/Connection.js index a916f00d1..9b8971056 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -29,7 +29,7 @@ class Connection { const agentOptions = Object.assign({}, { keepAlive: true, keepAliveMsecs: 1000, - maxSockets: Infinity, + maxSockets: 256, maxFreeSockets: 256 }, opts.agent) this._agent = this.url.protocol === 'http:' From ed3cca0fe6c17620ab1b5717e8da52428cefe34d Mon Sep 17 00:00:00 2001 From: Tomas Della Vedova Date: Fri, 1 Mar 2019 08:42:56 +0100 Subject: [PATCH 157/172] Platinum integration test (#772) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🎉 --- .ci/certs/ca.crt | 20 +++ .ci/certs/testnode.crt | 19 +++ .ci/certs/testnode.key | 27 ++++ .ci/docker-compose.yml | 68 +++++++- .ci/run-tests | 4 +- api/api/ml.delete_calendar_event.js | 2 +- api/api/ml.delete_calendar_job.js | 2 +- api/api/ml.delete_forecast.js | 2 +- api/api/ml.delete_model_snapshot.js | 2 +- api/api/ml.find_file_structure.js | 2 +- api/api/ml.get_buckets.js | 2 +- api/api/ml.get_model_snapshots.js | 2 +- api/api/ml.put_calendar_job.js | 2 +- api/api/ml.revert_model_snapshot.js | 2 +- api/api/ml.update_model_snapshot.js | 2 +- api/api/security.get_privileges.js | 8 +- api/api/xpack.watcher.ack_watch.js | 2 +- lib/Transport.js | 4 +- package.json | 2 +- scripts/es-docker-platinum.sh | 32 ++++ scripts/utils/generate.js | 3 +- test/integration/helper.js | 64 ++++++++ test/integration/index.js | 126 +++++++++++---- test/integration/test-runner.js | 242 +++++++++++++++++++++++++--- 24 files changed, 563 insertions(+), 78 deletions(-) create mode 100755 .ci/certs/ca.crt create mode 100755 .ci/certs/testnode.crt create mode 100755 .ci/certs/testnode.key create mode 100755 scripts/es-docker-platinum.sh create mode 100644 test/integration/helper.js diff --git a/.ci/certs/ca.crt b/.ci/certs/ca.crt new file mode 100755 index 000000000..6402874d5 --- /dev/null +++ b/.ci/certs/ca.crt @@ -0,0 +1,20 @@ +-----BEGIN CERTIFICATE----- +MIIDSTCCAjGgAwIBAgIUIwN+0zglsexRKwE1RGHvlCcmrdwwDQYJKoZIhvcNAQEL +BQAwNDEyMDAGA1UEAxMpRWxhc3RpYyBDZXJ0aWZpY2F0ZSBUb29sIEF1dG9nZW5l +cmF0ZWQgQ0EwHhcNMTkwMjEzMDcyMjQwWhcNMjIwMjEyMDcyMjQwWjA0MTIwMAYD +VQQDEylFbGFzdGljIENlcnRpZmljYXRlIFRvb2wgQXV0b2dlbmVyYXRlZCBDQTCC +ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANILs0JO0e7x29zeVx21qalK +XKdX+AMlGJPH75wWO/Jq6YHtxt1wYIg762krOBXfG6JsFSOIwIv5VrzGGRGjSPt9 +OXQyXrDDiQvsBT3rpzLNdDs7KMl2tZswwv7w9ujgud0cYnS1MOpn81rfPc73DvMg +xuhplofDx6fn3++PjVRU2FNiIVWyEoaxRjCeGPMBubKZYaYbQA6vYM4Z+ByG727B +AyAER3t7xmvYti/EoO2hv2HQk5zgcj/Oq3AJKhnt8LH8fnfm3TnYNM1htvXqhN05 +vsvhvm2PHfnA5qLlSr/3W0aI/U/PqfsFDCgyRV097sMIaKkmavb0Ue7aQ7lgtp0C +AwEAAaNTMFEwHQYDVR0OBBYEFDRKlCMowWR1rwxE0d1lTEQe5O71MB8GA1UdIwQY +MBaAFDRKlCMowWR1rwxE0d1lTEQe5O71MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZI +hvcNAQELBQADggEBAKbCJ95EBpeuvF70KEt6QU70k/SH1NRvM9YzKryV0D975Jvu +HOSm9HgSTULeAUFZIa4oYyf3QUfVoI+2T/aQrfXA3gfrJWsHURkyNmiHOFAbYHqi +xA6i249G2GTEjc1+le/M2N2CcDKAmurW6vSGK4upXQbPd6KmnhHREX74zkWjnOa+ ++tibbSSOCT4Tmja2DbBxAPuivU9IB1g/hIUmbYQqKffQrBJA0658tz6w63a/Q7xN +pCvvbSgiMZ6qcVIcJkBT2IooYie+ax45pQECHthgIUcQAzfmIfqlU0Qfl8rDgAmn +0c1o6HQjKGU2aVGgSRuaaiHaSZjbPIZVS51sOoI= +-----END CERTIFICATE----- diff --git a/.ci/certs/testnode.crt b/.ci/certs/testnode.crt new file mode 100755 index 000000000..ff3bcb37f --- /dev/null +++ b/.ci/certs/testnode.crt @@ -0,0 +1,19 @@ +-----BEGIN CERTIFICATE----- +MIIDIjCCAgqgAwIBAgIUI4QU6jA1dYSCbdIA6oAb2TBEluowDQYJKoZIhvcNAQEL +BQAwNDEyMDAGA1UEAxMpRWxhc3RpYyBDZXJ0aWZpY2F0ZSBUb29sIEF1dG9nZW5l +cmF0ZWQgQ0EwHhcNMTkwMjEzMDcyMzEzWhcNMjIwMjEyMDcyMzEzWjATMREwDwYD +VQQDEwhpbnN0YW5jZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJeT +yOy6EAScZxrULKjHePciiz38grivCrhFFV+dThaRCcl3DhDzb9Eny5q5iEw3WvLQ +Rqmf01jncNIhaocTt66VqveXaMubbE8O0LcG6e4kpFO+JtnVF8JTARTc+ux/1uD6 +hO1VG/HItM7WQrQxh4hfB2u1AX2YQtoqEtXXEC+UHWfl4QzuzXjBnKCkO/L9/6Tf +yNFQWXxKnIiTs8Xm9sEhhSCBJPlLTQu+MX4vR2Uwj5XZmflDUr+ZTenl9qYxL6b3 +SWhh/qEl4GAj1+tS7ZZOxE0237mUh3IIFYSWSaMm8K2m/BYHkLNWL5B1dMic0lsv +osSoYrQuCef4HQMCitsCAwEAAaNNMEswHQYDVR0OBBYEFFMg4l1GLW8lYbwASY+r +YeWYRzIiMB8GA1UdIwQYMBaAFDRKlCMowWR1rwxE0d1lTEQe5O71MAkGA1UdEwQC +MAAwDQYJKoZIhvcNAQELBQADggEBAEQrgh1xALpumQTzsjxFRGque/vlKTgRs5Kh +xtgapr6wjIbdq7dagee+4yNOKzS5lGVXCgwrJlHESv9qY0uumT/33vK2uduJ7NAd +fR2ZzyBnhMX+mkYhmGrGYCTUMUIwOIQYa4Evis4W+LHmCIDG03l7gLHfdIBe9VMO +pDZum8f6ng0MM49s8/rXODNYKw8kFyUhnfChqMi/2yggb1uUIfKlJJIchkgYjE13 +zuC+fjo029Pq1jeMIdxugLf/7I/8NiW1Yj9aCXevUXG1qzHFEuKAinBXYOZO/vWS +LaEqOhwrzNynwgGpYAr7Rfgv4AflltYIIav4PZT03P7fbyAAf8s= +-----END CERTIFICATE----- diff --git a/.ci/certs/testnode.key b/.ci/certs/testnode.key new file mode 100755 index 000000000..c35b4bc83 --- /dev/null +++ b/.ci/certs/testnode.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpQIBAAKCAQEAl5PI7LoQBJxnGtQsqMd49yKLPfyCuK8KuEUVX51OFpEJyXcO +EPNv0SfLmrmITDda8tBGqZ/TWOdw0iFqhxO3rpWq95doy5tsTw7Qtwbp7iSkU74m +2dUXwlMBFNz67H/W4PqE7VUb8ci0ztZCtDGHiF8Ha7UBfZhC2ioS1dcQL5QdZ+Xh +DO7NeMGcoKQ78v3/pN/I0VBZfEqciJOzxeb2wSGFIIEk+UtNC74xfi9HZTCPldmZ ++UNSv5lN6eX2pjEvpvdJaGH+oSXgYCPX61Ltlk7ETTbfuZSHcggVhJZJoybwrab8 +FgeQs1YvkHV0yJzSWy+ixKhitC4J5/gdAwKK2wIDAQABAoIBAQCRFTJna/xy/WUu +59FLR4qAOj8++JgCwACpue4oU7/vl6nffSYokWoAr2+RzG4qTX2vFi3cpA8+dGCn +sLZvTi8tWzKGxBTZdg2oakzaMzLr74SeZ052iCGyrZJGbvF6Ny7srr1XEXSq6+os +ZCb6pMHOhO7saBdiKMAsY8MdjTl/33AduuE6ztqv+L92xTr2g4QlbT1KvWlEgppU +k4Gy7zdETkPBTSH/17ZwyGJoJICIAhbL4IpmOM4dPIg8nFkVPPpy6p0z4uGjtgnK +nreZ2EKMzCafBaHn7A77gpi0OrQdl6pe0fsGqv/323YjCJPbwwl5TsoNq44DzwiX +3M7XiVJxAoGBAOCne56vdN4uZmCgLVGT2JSUNVPOu4bfjrxWH6cslzrPT2Zhp3lO +M4axZ3gmcervV252YEZXntXDHHCSfrECllRN1WFD63XmyQ/CkhuvZkkeRHfzL1TE +EdqHOTqs4sRETZ7+RITFC81DZQkWWOKeyXMjyPBqd7RnThQHijB1c8Y5AoGBAKy6 +CVKBx+zz5crVD0tz4UhOmz1wRNN0CL0l+FXRuFSgbzMIvwpfiqe25crgeLHe2M2/ +TogdWbjZ2nUZQTzoRsSkQ6cKHpj+G/gWurp/UcHHXFVwgLSPF7c3KHDtiYq7Vqw0 +bvmhM03LI6+ZIPRV7hLBr7WP7UmpAiREMF7tTnmzAoGBAIkx3w3WywFQxtblmyeB +qbd7F2IaE23XoxyjX+tBEQ4qQqwcoSE0v8TXHIBEwjceeX+NLVhn9ClJYVniLRq+ +oL3VVqVyzB4RleJZCc98e3PV1yyFx/b1Uo3pHOsXX9lKeTjKwV9v0rhFGzPEgP3M +yOvXA8TG0FnM6OLUg/D6GX0JAoGAMuHS4TVOGeV3ahr9mHKYiN5vKNgrzka+VEod +L9rJ/FQOrfADpyCiDen5I5ygsXU+VM3oanyK88NpcVlxOGoMft0M+OYoQVWKE7lO +ZKYhBX6fGqQ7pfUJPXXIOgwfmni5fZ0sm+j63g3bg10OsiumKGxaQJgXhL1+3gQg +Y7ZwibUCgYEAlZoFFvkMLjpOSaHk1z5ZZnt19X0QUIultBwkumSqMPm+Ks7+uDrx +thGUCoz4ecr/ci4bIUY7mB+zfAbqnBOMxreJqCRbAIuRypo1IlWkTp8DywoDOfMW +NfzjVmzJ7EJu44nGmVAi1jw4Pbseivvi1ujMCoPgaE8I1uSh144bwN8= +-----END RSA PRIVATE KEY----- diff --git a/.ci/docker-compose.yml b/.ci/docker-compose.yml index d8a3b6c38..ba8b0538e 100644 --- a/.ci/docker-compose.yml +++ b/.ci/docker-compose.yml @@ -1,6 +1,6 @@ version: '3.2' services: - client: + client-oss: image: docker.elastic.co/clients/elasticsearch-js:${NODE_JS_VERSION:-10} build: context: .. @@ -8,7 +8,7 @@ services: args: NODE_JS_VERSION: ${NODE_JS_VERSION:-10} environment: - - "TEST_ES_SERVER=http://elasticsearch:9200" + - "TEST_ES_SERVER=http://elasticsearch-oss:9200" volumes: - ..:/usr/src/app # This will mount the node_modules directory @@ -16,15 +16,17 @@ services: - /usr/src/app/node_modules - esvol:/tmp networks: - - esnet + - esnet-oss depends_on: - - elasticsearch - elasticsearch: + - elasticsearch-oss + + elasticsearch-oss: image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-7.0.0-beta1} + - elasticsearch volumes: - esvol:/tmp networks: - - esnet + - esnet-oss environment: - path.repo=/tmp - "repositories.url.allowed_urls=http://snapshot.*" @@ -32,7 +34,59 @@ services: - bootstrap.memory_lock=false - "discovery.type=single-node" - "ES_JAVA_OPTS=-Xms512m -Xmx512m" + + client-platinum: + image: docker.elastic.co/clients/elasticsearch-js:${NODE_JS_VERSION:-10} + build: + context: .. + dockerfile: .ci/Dockerfile + args: + NODE_JS_VERSION: ${NODE_JS_VERSION:-10} + environment: + - "TEST_ES_SERVER=https://elastic:changeme@elasticsearch-platinum:9200" + volumes: + - ..:/usr/src/app + # This will mount the node_modules directory + # to the host machine using the buildtime directory. + - /usr/src/app/node_modules + - esvol:/tmp + networks: + - esnet-platinum + depends_on: + - elasticsearch-platinum + + elasticsearch-platinum: + image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-7.0.0-beta1} + ports: + - "9200:9200" + networks: + - esnet-platinum + environment: + - "node.attr.testattr=test" + - "path.repo=/tmp" + - "repositories.url.allowed_urls=http://snapshot.*" + - "discovery.type=single-node" + - "ES_JAVA_OPTS=-Xms1g -Xmx1g" + - "ELASTIC_PASSWORD=changeme" + - "xpack.security.enabled=true" + - "xpack.license.self_generated.type=trial" + - "xpack.security.http.ssl.enabled=true" + - "xpack.security.http.ssl.verification_mode=certificate" + - "xpack.security.http.ssl.key=certs/testnode.key" + - "xpack.security.http.ssl.certificate=certs/testnode.crt" + - "xpack.security.http.ssl.certificate_authorities=certs/ca.crt" + - "xpack.security.transport.ssl.enabled=true" + - "xpack.security.transport.ssl.key=certs/testnode.key" + - "xpack.security.transport.ssl.certificate=certs/testnode.crt" + - "xpack.security.transport.ssl.certificate_authorities=certs/ca.crt" + volumes: + - "./certs/testnode.crt:/usr/share/elasticsearch/config/certs/testnode.crt" + - "./certs/testnode.key:/usr/share/elasticsearch/config/certs/testnode.key" + - "./certs/ca.crt:/usr/share/elasticsearch/config/certs/ca.crt" + networks: - esnet: + # we need two networks otherwise the two ES instances will join each other + esnet-oss: + esnet-platinum: volumes: esvol: diff --git a/.ci/run-tests b/.ci/run-tests index e0deadb62..cccda74c3 100755 --- a/.ci/run-tests +++ b/.ci/run-tests @@ -10,4 +10,6 @@ # - $NODE_JS_VERSION # -ELASTICSEARCH_VERSION=${ELASTICSEARCH_VERSION} NODE_JS_VERSION=${NODE_JS_VERSION} docker-compose -f .ci/docker-compose.yml run client +ELASTICSEARCH_VERSION=${ELASTICSEARCH_VERSION} NODE_JS_VERSION=${NODE_JS_VERSION} docker-compose -f .ci/docker-compose.yml run client-oss + +ELASTICSEARCH_VERSION=${ELASTICSEARCH_VERSION} NODE_JS_VERSION=${NODE_JS_VERSION} docker-compose -f .ci/docker-compose.yml run client-platinum diff --git a/api/api/ml.delete_calendar_event.js b/api/api/ml.delete_calendar_event.js index 70fd61e2a..a8b7b8e4c 100644 --- a/api/api/ml.delete_calendar_event.js +++ b/api/api/ml.delete_calendar_event.js @@ -62,7 +62,7 @@ function buildMlDeleteCalendarEvent (opts) { } // check required url components - if ((params['event_id'] != null || params['eventId'] != null) && ((params['calendar_id'] == null || params['calendarId']))) { + if ((params['event_id'] != null || params['eventId'] != null) && ((params['calendar_id'] == null && params['calendarId'] == null))) { return callback( new ConfigurationError('Missing required parameter of the url: calendar_id'), result diff --git a/api/api/ml.delete_calendar_job.js b/api/api/ml.delete_calendar_job.js index ff6315180..ea412b9b4 100644 --- a/api/api/ml.delete_calendar_job.js +++ b/api/api/ml.delete_calendar_job.js @@ -62,7 +62,7 @@ function buildMlDeleteCalendarJob (opts) { } // check required url components - if ((params['job_id'] != null || params['jobId'] != null) && ((params['calendar_id'] == null || params['calendarId']))) { + if ((params['job_id'] != null || params['jobId'] != null) && ((params['calendar_id'] == null && params['calendarId'] == null))) { return callback( new ConfigurationError('Missing required parameter of the url: calendar_id'), result diff --git a/api/api/ml.delete_forecast.js b/api/api/ml.delete_forecast.js index b51697d73..d07337780 100644 --- a/api/api/ml.delete_forecast.js +++ b/api/api/ml.delete_forecast.js @@ -60,7 +60,7 @@ function buildMlDeleteForecast (opts) { } // check required url components - if ((params['forecast_id'] != null || params['forecastId'] != null) && ((params['job_id'] == null || params['jobId']))) { + if ((params['forecast_id'] != null || params['forecastId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { return callback( new ConfigurationError('Missing required parameter of the url: job_id'), result diff --git a/api/api/ml.delete_model_snapshot.js b/api/api/ml.delete_model_snapshot.js index 0cf2877b2..e77f38f36 100644 --- a/api/api/ml.delete_model_snapshot.js +++ b/api/api/ml.delete_model_snapshot.js @@ -62,7 +62,7 @@ function buildMlDeleteModelSnapshot (opts) { } // check required url components - if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null || params['jobId']))) { + if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { return callback( new ConfigurationError('Missing required parameter of the url: job_id'), result diff --git a/api/api/ml.find_file_structure.js b/api/api/ml.find_file_structure.js index c5a554fb4..7463010ad 100644 --- a/api/api/ml.find_file_structure.js +++ b/api/api/ml.find_file_structure.js @@ -109,7 +109,7 @@ function buildMlFindFileStructure (opts) { const request = { method, path, - body: body || '', + bulkBody: body, querystring } diff --git a/api/api/ml.get_buckets.js b/api/api/ml.get_buckets.js index 2a2175b22..81223c004 100644 --- a/api/api/ml.get_buckets.js +++ b/api/api/ml.get_buckets.js @@ -70,7 +70,7 @@ function buildMlGetBuckets (opts) { } // check required url components - if (params['timestamp'] != null && ((params['job_id'] == null || params['jobId']))) { + if (params['timestamp'] != null && ((params['job_id'] == null && params['jobId'] == null))) { return callback( new ConfigurationError('Missing required parameter of the url: job_id'), result diff --git a/api/api/ml.get_model_snapshots.js b/api/api/ml.get_model_snapshots.js index 7a56d6ab6..8c1d74dd1 100644 --- a/api/api/ml.get_model_snapshots.js +++ b/api/api/ml.get_model_snapshots.js @@ -62,7 +62,7 @@ function buildMlGetModelSnapshots (opts) { } // check required url components - if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null || params['jobId']))) { + if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { return callback( new ConfigurationError('Missing required parameter of the url: job_id'), result diff --git a/api/api/ml.put_calendar_job.js b/api/api/ml.put_calendar_job.js index 55b005f37..f3ad75956 100644 --- a/api/api/ml.put_calendar_job.js +++ b/api/api/ml.put_calendar_job.js @@ -62,7 +62,7 @@ function buildMlPutCalendarJob (opts) { } // check required url components - if ((params['job_id'] != null || params['jobId'] != null) && ((params['calendar_id'] == null || params['calendarId']))) { + if ((params['job_id'] != null || params['jobId'] != null) && ((params['calendar_id'] == null && params['calendarId'] == null))) { return callback( new ConfigurationError('Missing required parameter of the url: calendar_id'), result diff --git a/api/api/ml.revert_model_snapshot.js b/api/api/ml.revert_model_snapshot.js index 1682f4012..6f34bb7d3 100644 --- a/api/api/ml.revert_model_snapshot.js +++ b/api/api/ml.revert_model_snapshot.js @@ -58,7 +58,7 @@ function buildMlRevertModelSnapshot (opts) { } // check required url components - if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null || params['jobId']))) { + if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { return callback( new ConfigurationError('Missing required parameter of the url: job_id'), result diff --git a/api/api/ml.update_model_snapshot.js b/api/api/ml.update_model_snapshot.js index 7e88a3dd0..c495099a1 100644 --- a/api/api/ml.update_model_snapshot.js +++ b/api/api/ml.update_model_snapshot.js @@ -63,7 +63,7 @@ function buildMlUpdateModelSnapshot (opts) { } // check required url components - if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null || params['jobId']))) { + if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { return callback( new ConfigurationError('Missing required parameter of the url: job_id'), result diff --git a/api/api/security.get_privileges.js b/api/api/security.get_privileges.js index 5bd95cf1a..2e67a3e3a 100644 --- a/api/api/security.get_privileges.js +++ b/api/api/security.get_privileges.js @@ -80,7 +80,13 @@ function buildSecurityGetPrivileges (opts) { var path = '' - path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(application) + '/' + encodeURIComponent(name) + if (application && name) { + path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(application) + '/' + encodeURIComponent(name) + } else if (application) { + path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(application) + } else { + path = '/' + '_security' + '/' + 'privilege' + } // build request object const request = { diff --git a/api/api/xpack.watcher.ack_watch.js b/api/api/xpack.watcher.ack_watch.js index 01e663de3..3bd1233d9 100644 --- a/api/api/xpack.watcher.ack_watch.js +++ b/api/api/xpack.watcher.ack_watch.js @@ -56,7 +56,7 @@ function buildXpackWatcherAckWatch (opts) { } // check required url components - if ((params['action_id'] != null || params['actionId'] != null) && ((params['watch_id'] == null || params['watchId']))) { + if ((params['action_id'] != null || params['actionId'] != null) && ((params['watch_id'] == null && params['watchId'] == null))) { return callback( new ConfigurationError('Missing required parameter of the url: watch_id'), result diff --git a/lib/Transport.js b/lib/Transport.js index f16907bec..47a111110 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -106,7 +106,7 @@ class Transport { return callback(err, result) } } - headers['Content-Type'] = 'application/json' + headers['Content-Type'] = headers['Content-Type'] || 'application/json' if (compression === 'gzip') { if (isStream(params.body) === false) { @@ -131,7 +131,7 @@ class Transport { } else { params.body = params.bulkBody } - headers['Content-Type'] = 'application/x-ndjson' + headers['Content-Type'] = headers['Content-Type'] || 'application/x-ndjson' if (isStream(params.body) === false) { headers['Content-Length'] = '' + Buffer.byteLength(params.body) } diff --git a/package.json b/package.json index 081e3e0da..5f362c916 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "lint:fix": "standard --fix", "generate": "node scripts/run.js", "elasticsearch": "./scripts/es-docker.sh", - "ci": "./scripts/wait-cluster.sh && npm test && npm run test:integration" + "ci": "npm test && npm run test:integration" }, "author": { "name": "Tomas Della Vedova", diff --git a/scripts/es-docker-platinum.sh b/scripts/es-docker-platinum.sh new file mode 100755 index 000000000..8ab34962a --- /dev/null +++ b/scripts/es-docker-platinum.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +repo=$(pwd) +testnodecrt="/.ci/certs/testnode.crt" +testnodekey="/.ci/certs/testnode.key" +cacrt="/.ci/certs/ca.crt" + +exec docker run \ + --rm \ + -e "node.attr.testattr=test" \ + -e "path.repo=/tmp" \ + -e "repositories.url.allowed_urls=http://snapshot.*" \ + -e "discovery.type=single-node" \ + -e "ES_JAVA_OPTS=-Xms1g -Xmx1g" \ + -e "ELASTIC_PASSWORD=changeme" \ + -e "xpack.security.enabled=true" \ + -e "xpack.license.self_generated.type=trial" \ + -e "xpack.security.http.ssl.enabled=true" \ + -e "xpack.security.http.ssl.verification_mode=certificate" \ + -e "xpack.security.http.ssl.key=certs/testnode.key" \ + -e "xpack.security.http.ssl.certificate=certs/testnode.crt" \ + -e "xpack.security.http.ssl.certificate_authorities=certs/ca.crt" \ + -e "xpack.security.transport.ssl.enabled=true" \ + -e "xpack.security.transport.ssl.key=certs/testnode.key" \ + -e "xpack.security.transport.ssl.certificate=certs/testnode.crt" \ + -e "xpack.security.transport.ssl.certificate_authorities=certs/ca.crt" \ + -v "$repo$testnodecrt:/usr/share/elasticsearch/config/certs/testnode.crt" \ + -v "$repo$testnodekey:/usr/share/elasticsearch/config/certs/testnode.key" \ + -v "$repo$cacrt:/usr/share/elasticsearch/config/certs/ca.crt" \ + -p 9200:9200 \ + docker.elastic.co/elasticsearch/elasticsearch:7.0.0-beta1 + # docker.elastic.co/elasticsearch/elasticsearch:6.6.0 diff --git a/scripts/utils/generate.js b/scripts/utils/generate.js index 3ae60ef0f..0ee925ab6 100644 --- a/scripts/utils/generate.js +++ b/scripts/utils/generate.js @@ -34,6 +34,7 @@ const ndjsonApi = [ 'bulk', 'msearch', 'msearch_template', + 'ml.find_file_structure', 'monitoring.bulk' ] @@ -448,7 +449,7 @@ function genUrlValidation (paths, api) { if (chunks[i] === camelCased) { code += `params['${chunks[i]}'] == null${i === len - 1 ? '' : ' || '}` } else { - code += `(params['${chunks[i]}'] == null || params['${camelCased}'])${i === len - 1 ? '' : ' || '}` + code += `(params['${chunks[i]}'] == null && params['${camelCased}'] == null)${i === len - 1 ? '' : ' || '}` } } code += `)) { diff --git a/test/integration/helper.js b/test/integration/helper.js new file mode 100644 index 000000000..8d4479744 --- /dev/null +++ b/test/integration/helper.js @@ -0,0 +1,64 @@ +'use strict' + +const esDefaultRoles = [ + 'apm_system', + 'apm_user', + 'beats_admin', + 'beats_system', + 'code_admin', + 'code_user', + 'ingest_admin', + 'kibana_dashboard_only_user', + 'kibana_system', + 'kibana_user', + 'logstash_admin', + 'logstash_system', + 'machine_learning_admin', + 'machine_learning_user', + 'monitoring_user', + 'remote_monitoring_agent', + 'remote_monitoring_collector', + 'reporting_user', + 'rollup_admin', + 'rollup_user', + 'snapshot_user', + 'superuser', + 'transport_client', + 'watcher_admin', + 'watcher_user' +] + +const esDefaultUsers = [ + 'apm_system', + 'beats_system', + 'elastic', + 'logstash_system', + 'kibana', + 'remote_monitoring_user' +] + +function runInParallel (client, operation, options) { + if (options.length === 0) return Promise.resolve() + const operations = options.map(opts => { + const api = delve(client, operation).bind(client) + return api(opts) + }) + + return Promise.all(operations) +} + +// code from https://github.com/developit/dlv +// needed to support an edge case: `a\.b` +// where `a.b` is a single field: { 'a.b': true } +function delve (obj, key, def, p) { + p = 0 + // handle the key with a dot inside that is not a part of the path + // and removes the backslashes from the key + key = key.split + ? key.split(/(? k.replace(/\\/g, '')) + : key.replace(/\\/g, '') + while (obj && p < key.length) obj = obj[key[p++]] + return (obj === undefined || p < key.length) ? def : obj +} + +module.exports = { runInParallel, esDefaultRoles, esDefaultUsers, delve } diff --git a/test/integration/index.js b/test/integration/index.js index e3625a8f6..5f136413e 100644 --- a/test/integration/index.js +++ b/test/integration/index.js @@ -6,7 +6,6 @@ const { join, sep } = require('path') const yaml = require('js-yaml') const Git = require('simple-git') const ora = require('ora') -const minimist = require('minimist') const tap = require('tap') const { Client } = require('../../index') const TestRunner = require('./test-runner') @@ -14,7 +13,7 @@ const TestRunner = require('./test-runner') const esRepo = 'https://github.com/elastic/elasticsearch.git' const esFolder = join(__dirname, '..', '..', 'elasticsearch') const yamlFolder = join(esFolder, 'rest-api-spec', 'src', 'main', 'resources', 'rest-api-spec', 'test') -// const xPackYamlFolder = join(esFolder, 'x-pack', 'plugin', 'src', 'test', 'resources', 'rest-api-spec', 'test') +const xPackYamlFolder = join(esFolder, 'x-pack', 'plugin', 'src', 'test', 'resources', 'rest-api-spec', 'test') const customSkips = [ // skipping because we are booting ES with `discovery.type=single-node` // and this test will fail because of this configuration @@ -23,6 +22,31 @@ const customSkips = [ // which triggers a retry and the node to be marked as dead 'search.aggregation/240_max_buckets.yml' ] +const platinumBlackList = { + // file path: test name + 'cat.aliases/10_basic.yml': 'Empty cluster', + 'index/10_with_id.yml': 'Index with ID', + 'indices.get_alias/10_basic.yml': 'Get alias against closed indices', + 'indices.get_alias/20_empty.yml': 'Check empty aliases when getting all aliases via /_alias', + // https://github.com/elastic/elasticsearch/pull/39400 + 'ml/jobs_crud.yml': 'Test put job with id that is already taken', + // TODO: investigate why this is failing + 'monitoring/bulk/10_basic.yml': '*', + 'monitoring/bulk/20_privileges.yml': '*', + 'license/20_put_license.yml': '*', + 'snapshot/10_basic.yml': '*', + // the body is correct, but the regex is failing + 'sql/sql.yml': 'Getting textual representation', + // we are setting two certificates in the docker config + 'ssl/10_basic.yml': '*', + // docker issue? + 'watcher/execute_watch/60_http_input.yml': '*', + // the checks are correct, but for some reason the test is failing on js side + // I bet is because the backslashes in the rg + 'watcher/execute_watch/70_invalid.yml': '*', + 'watcher/put_watch/10_basic.yml': '*', + 'xpack/15_basic.yml': '*' +} function Runner (opts) { if (!(this instanceof Runner)) { @@ -32,14 +56,39 @@ function Runner (opts) { assert(opts.node, 'Missing base node') this.bailout = opts.bailout - this.client = new Client({ node: opts.node }) + const options = { node: opts.node } + if (opts.isPlatinum) { + options.ssl = { + // NOTE: this path works only if we run + // the suite with npm scripts + ca: readFileSync('.ci/certs/ca.crt', 'utf8'), + rejectUnauthorized: false + } + } + this.client = new Client(options) this.log = ora('Loading yaml suite').start() } +Runner.prototype.waitCluster = function (callback, times = 0) { + this.log.text = 'Waiting for ElasticSearch' + this.client.cluster.health( + { waitForStatus: 'green', timeout: '50s' }, + (err, res) => { + if (++times < 10) { + setTimeout(() => { + this.waitCluster(callback, times) + }, 5000) + } else { + callback(err) + } + } + ) +} + /** * Runs the test suite */ -Runner.prototype.start = function () { +Runner.prototype.start = function (opts) { const parse = this.parse.bind(this) const client = this.client @@ -53,36 +102,36 @@ Runner.prototype.start = function () { // console.log() // }) - // Get the build hash of Elasticsearch - client.info((err, { body }) => { + this.waitCluster(err => { if (err) { this.log.fail(err.message) process.exit(1) } - const { number: version, build_hash: sha } = body.version + // Get the build hash of Elasticsearch + client.info((err, { body }) => { + if (err) { + this.log.fail(err.message) + process.exit(1) + } + const { number: version, build_hash: sha } = body.version - // Set the repository to the given sha and run the test suite - this.withSHA(sha, () => { - this.log.succeed('Done!') - runTest.call(this, version) + // Set the repository to the given sha and run the test suite + this.withSHA(sha, () => { + this.log.succeed(`Testing ${opts.isPlatinum ? 'platinum' : 'oss'} api...`) + runTest.call(this, version) + }) }) - - // client.xpack.license.postStartTrial({ acknowledge: true }, (err, { body }) => { - // if (err) { - // this.log.fail(err.message) - // return - // } - // }) }) function runTest (version) { const files = [] .concat(getAllFiles(yamlFolder)) - // .concat(getAllFiles(xPackYamlFolder)) + .concat(opts.isPlatinum ? getAllFiles(xPackYamlFolder) : []) .filter(t => !/(README|TODO)/g.test(t)) files.forEach(runTestFile.bind(this)) function runTestFile (file) { + // if (!file.endsWith('watcher/execute_watch/70_invalid.yml')) return for (var i = 0; i < customSkips.length; i++) { if (file.endsWith(customSkips[i])) return } @@ -94,7 +143,7 @@ Runner.prototype.start = function () { // every document is separated by '---', so we split on the separator // and then we remove the empty strings, finally we parse them const tests = data - .split('---') + .split('\n---\n') .map(s => s.trim()) .filter(Boolean) .map(parse) @@ -111,9 +160,26 @@ Runner.prototype.start = function () { tests.forEach(test => { const name = Object.keys(test)[0] if (name === 'setup' || name === 'teardown') return + // should skip the test inside `platinumBlackList` + // if we are testing the platinum apis + if (opts.isPlatinum) { + const list = Object.keys(platinumBlackList) + for (i = 0; i < list.length; i++) { + if (file.endsWith(list[i]) && (name === platinumBlackList[list[i]] || platinumBlackList[list[i]] === '*')) { + const testName = file.slice(file.indexOf(`${sep}elasticsearch${sep}`)) + ' / ' + name + tap.skip(`Skipping test ${testName} because is blacklisted in the platinum test`) + return + } + } + } // create a subtest for the specific folder + test file + test name tap1.test(name, { jobs: 1, bail: this.bailout }, tap2 => { - const testRunner = TestRunner({ client, version, tap: tap2 }) + const testRunner = TestRunner({ + client, + version, + tap: tap2, + isPlatinum: file.includes('x-pack') + }) testRunner.run(setupTest, test[name], teardownTest, () => tap2.end()) }) }) @@ -245,19 +311,13 @@ Runner.prototype.createFolder = function (name) { } if (require.main === module) { - const opts = minimist(process.argv.slice(2), { - string: ['node', 'version'], - boolean: ['bailout'], - default: { - // node: 'http://elastic:passw0rd@localhost:9200', - node: process.env.TEST_ES_SERVER || 'http://localhost:9200', - version: '7.0', - bailout: false - } - }) - + const url = process.env.TEST_ES_SERVER || 'http://localhost:9200' + const opts = { + node: url, + isPlatinum: url.indexOf('@') > -1 + } const runner = Runner(opts) - runner.start() + runner.start(opts) } const getAllFiles = dir => diff --git a/test/integration/test-runner.js b/test/integration/test-runner.js index 2f8fa0b97..231fcd803 100644 --- a/test/integration/test-runner.js +++ b/test/integration/test-runner.js @@ -3,15 +3,20 @@ const t = require('tap') const semver = require('semver') const workq = require('workq') +const helper = require('./helper') const { ConfigurationError } = require('../../lib/errors') +const { delve } = helper + const supportedFeatures = [ 'gtelte', 'regex', 'benchmark', 'stash_in_path', 'groovy_scripting', - 'headers' + 'headers', + 'transform_and_set', + 'catch_unauthorized' ] function TestRunner (opts) { @@ -25,6 +30,7 @@ function TestRunner (opts) { this.response = null this.stash = new Map() this.tap = opts.tap || t + this.isPlatinum = opts.isPlatinum this.q = opts.q || workq() } @@ -55,14 +61,148 @@ TestRunner.prototype.cleanup = function (q, done) { q.add((q, done) => { this.client.snapshot.delete({ repository: '*', snapshot: '*' }, { ignore: 404 }, err => { - this.tap.error(err, 'should not error:snapshot.delete') + this.tap.error(err, 'should not error: snapshot.delete') done() }) }) q.add((q, done) => { this.client.snapshot.deleteRepository({ repository: '*' }, { ignore: 404 }, err => { - this.tap.error(err, 'should not error:snapshot.deleteRepository') + this.tap.error(err, 'should not error: snapshot.deleteRepository') + done() + }) + }) + + done() +} + +/** + * Runs some additional API calls to prepare ES for the Platinum test, + * This set of calls should be executed before the final clenup. + * @param {queue} + * @param {function} done + */ +TestRunner.prototype.cleanupPlatinum = function (q, done) { + this.tap.comment('Platinum Cleanup') + + q.add((q, done) => { + this.client.security.getRole((err, { body }) => { + this.tap.error(err, 'should not error: security.getRole') + const roles = Object.keys(body).filter(n => helper.esDefaultRoles.indexOf(n) === -1) + helper.runInParallel( + this.client, 'security.deleteRole', + roles.map(r => ({ name: r, refresh: 'wait_for' })) + ) + .then(() => done()) + .catch(err => this.tap.error(err, 'should not error: security.deleteRole')) + }) + }) + + q.add((q, done) => { + this.client.security.getUser((err, { body }) => { + this.tap.error(err, 'should not error: security.getUser') + const users = Object.keys(body).filter(n => helper.esDefaultUsers.indexOf(n) === -1) + helper.runInParallel( + this.client, 'security.deleteUser', + users.map(r => ({ username: r, refresh: 'wait_for' })) + ) + .then(() => done()) + .catch(err => this.tap.error(err, 'should not error: security.deleteUser')) + }) + }) + + q.add((q, done) => { + this.client.security.getPrivileges((err, { body }) => { + this.tap.error(err, 'should not error: security.getPrivileges') + const privileges = [] + Object.keys(body).forEach(app => { + Object.keys(body[app]).forEach(priv => { + privileges.push({ + name: body[app][priv].name, + application: body[app][priv].application, + refresh: 'wait_for' + }) + }) + }) + helper.runInParallel(this.client, 'security.deletePrivileges', privileges) + .then(() => done()) + .catch(err => this.tap.error(err, 'should not error: security.deletePrivileges')) + }) + }) + + q.add((q, done) => { + this.client.ml.stopDatafeed({ datafeedId: '*', force: true }, err => { + this.tap.error(err, 'should not error: ml.stopDatafeed') + this.client.ml.getDatafeeds({ datafeedId: '*' }, (err, { body }) => { + this.tap.error(err, 'should error: not ml.getDatafeeds') + const feeds = body.datafeeds.map(f => f.datafeed_id) + helper.runInParallel( + this.client, 'ml.deleteDatafeed', + feeds.map(f => ({ datafeedId: f })) + ) + .then(() => done()) + .catch(err => this.tap.error(err, 'should not error: ml.deleteDatafeed')) + }) + }) + }) + + q.add((q, done) => { + this.client.ml.closeJob({ jobId: '*', force: true }, err => { + this.tap.error(err, 'should not error: ml.closeJob') + this.client.ml.getJobs({ jobId: '*' }, (err, { body }) => { + this.tap.error(err, 'should not error: ml.getJobs') + const jobs = body.jobs.map(j => j.job_id) + helper.runInParallel( + this.client, 'ml.deleteJob', + jobs.map(j => ({ jobId: j, waitForCompletion: true, force: true })) + ) + .then(() => done()) + .catch(err => this.tap.error(err, 'should not error: ml.deleteJob')) + }) + }) + }) + + q.add((q, done) => { + this.client.xpack.rollup.getJobs({ id: '_all' }, (err, { body }) => { + this.tap.error(err, 'should not error: rollup.getJobs') + const jobs = body.jobs.map(j => j.config.id) + helper.runInParallel( + this.client, 'xpack.rollup.stopJob', + jobs.map(j => ({ id: j, waitForCompletion: true })) + ) + .then(() => helper.runInParallel( + this.client, 'xpack.rollup.deleteJob', + jobs.map(j => ({ id: j })) + )) + .then(() => done()) + .catch(err => this.tap.error(err, 'should not error: rollup.stopJob/deleteJob')) + }) + }) + + q.add((q, done) => { + this.client.tasks.list((err, { body }) => { + this.tap.error(err, 'should not error: tasks.list') + const tasks = Object.keys(body.nodes) + .reduce((acc, node) => { + const { tasks } = body.nodes[node] + Object.keys(tasks).forEach(id => { + if (tasks[id].cancellable) acc.push(id) + }) + return acc + }, []) + + helper.runInParallel( + this.client, 'tasks.cancel', + tasks.map(id => ({ taskId: id })) + ) + .then(() => done()) + .catch(err => this.tap.error(err, 'should not error: tasks.cancel')) + }) + }) + + q.add((q, done) => { + this.client.indices.delete({ index: '.ml-*' }, { ignore: 404 }, err => { + this.tap.error(err, 'should not error: indices.delete (ml indices)') done() }) }) @@ -77,7 +217,7 @@ TestRunner.prototype.cleanup = function (q, done) { * - the actual test * - teardown * - cleanup - * Internally uses a queue to guarantee the order of the test sections. +* Internally uses a queue to guarantee the order of the test sections. * @param {object} setup (null if not needed) * @param {object} test * @oaram {object} teardown (null if not needed) @@ -92,6 +232,20 @@ TestRunner.prototype.run = function (setup, test, teardown, end) { return end() } + if (this.isPlatinum) { + this.tap.comment('Creating x-pack user') + // Some platinum test requires this user + this.q.add((q, done) => { + this.client.security.putUser({ + username: 'x_pack_rest_user', + body: { password: 'x-pack-test-password', roles: ['superuser'] } + }, (err, { body }) => { + this.tap.error(err, 'should not error: security.putUser') + done() + }) + }) + } + if (setup) { this.q.add((q, done) => { this.exec('Setup', setup, q, done) @@ -108,6 +262,12 @@ TestRunner.prototype.run = function (setup, test, teardown, end) { }) } + if (this.isPlatinum) { + this.q.add((q, done) => { + this.cleanupPlatinum(q, done) + }) + } + this.q.add((q, done) => { this.cleanup(q, done) }) @@ -211,11 +371,33 @@ TestRunner.prototype.fillStashedValues = function (obj) { // iterate every key of the object for (const key in obj) { const val = obj[key] + // if the key value is a string, and the string includes '${' + // that we must update the content of '${...}'. + // eg: 'Basic ${auth}' we search the stahed value 'auth' + // and the resulting value will be 'Basic valueOfAuth' + if (typeof val === 'string' && val.includes('${')) { + const start = val.indexOf('${') + const end = val.indexOf('}', val.indexOf('${')) + const stashedKey = val.slice(start + 2, end) + const stashed = this.stash.get(stashedKey) + obj[key] = val.slice(0, start) + stashed + val.slice(end + 1) + continue + } + // handle json strings, eg: '{"hello":"$world"}' + if (typeof val === 'string' && val.includes('"$')) { + const start = val.indexOf('"$') + const end = val.indexOf('"', start + 1) + const stashedKey = val.slice(start + 2, end) + const stashed = '"' + this.stash.get(stashedKey) + '"' + obj[key] = val.slice(0, start) + stashed + val.slice(end + 1) + continue + } // if the key value is a string, and the string includes '$' // we run the "update value" code if (typeof val === 'string' && val.includes('$')) { // update the key value obj[key] = getStashedValues.call(this, val) + continue } // go deep in the object @@ -261,6 +443,26 @@ TestRunner.prototype.set = function (key, name) { return this } +/** + * Applies a given transformation and stashes the result. + * @param {string} the name to identify the stashed value + * @param {string} the transformation function as string + * @returns {TestRunner} + */ +TestRunner.prototype.transform_and_set = function (name, transform) { + if (/base64EncodeCredentials/.test(transform)) { + const [user, password] = transform + .slice(transform.indexOf('(') + 1, -1) + .replace(/ /g, '') + .split(',') + const userAndPassword = `${delve(this.response, user)}:${delve(this.response, password)}` + this.stash.set(name, Buffer.from(userAndPassword).toString('base64')) + } else { + throw new Error(`Unknown transform: '${transform}'`) + } + return this +} + /** * Runs a client command * @param {object} the action to perform @@ -353,7 +555,15 @@ TestRunner.prototype.exec = function (name, actions, q, done) { if (action.set) { q.add((q, done) => { const key = Object.keys(action.set)[0] - this.set(key, action.set[key]) + this.set(this.fillStashedValues(key), action.set[key]) + done() + }) + } + + if (action.transform_and_set) { + q.add((q, done) => { + const key = Object.keys(action.transform_and_set)[0] + this.transform_and_set(key, action.transform_and_set[key]) done() }) } @@ -423,8 +633,12 @@ TestRunner.prototype.exec = function (name, actions, q, done) { q.add((q, done) => { const key = Object.keys(action.length)[0] this.length( - delve(this.response, this.fillStashedValues(key)), - this.fillStashedValues(action.length)[key] + key === '$body' || key === '' + ? this.response + : delve(this.response, this.fillStashedValues(key)), + key === '$body' + ? action.length[key] + : this.fillStashedValues(action.length)[key] ) done() }) @@ -694,20 +908,6 @@ function getSkip (arr) { return null } -// code from https://github.com/developit/dlv -// needed to support an edge case: `a\.b` -// where `a.b` is a single field: { 'a.b': true } -function delve (obj, key, def, p) { - p = 0 - // handle the key with a dot inside that is not a part of the path - // and removes the backslashes from the key - key = key.split - ? key.split(/(? k.replace(/\\/g, '')) - : key.replace(/\\/g, '') - while (obj && p < key.length) obj = obj[key[p++]] - return (obj === undefined || p < key.length) ? def : obj -} - // Gets two *maybe* numbers and returns two valida numbers // it throws if one or both are not a valid number // the returned value is an array with the new values From f175f83d34ea83cb4e4d8b897e29c89c5d49de3e Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 1 Mar 2019 09:02:31 +0100 Subject: [PATCH 158/172] Workaround for keepAlive false --- lib/Connection.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Connection.js b/lib/Connection.js index 9b8971056..1f30c9f0b 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -26,10 +26,13 @@ class Connection { throw new ConfigurationError(`Invalid protocol: '${this.url.protocol}'`) } + // Probably there is a bug in Node Core + // see https://github.com/nodejs/node/issues/26357 + const keepAliveFalse = opts.agent && opts.agent.keepAlive === false const agentOptions = Object.assign({}, { keepAlive: true, keepAliveMsecs: 1000, - maxSockets: 256, + maxSockets: keepAliveFalse ? Infinity : 256, maxFreeSockets: 256 }, opts.agent) this._agent = this.url.protocol === 'http:' From 4f02fd550946a83a5e0ea0ebb1379418292ac01c Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 1 Mar 2019 14:56:09 +0100 Subject: [PATCH 159/172] Bumped v0.1.0-beta.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5f362c916..a4c1043f2 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "main": "index.js", "types": "index.d.ts", "homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html", - "version": "0.1.0-alpha.7", + "version": "0.1.0-beta.1", "keywords": [ "elasticsearch", "elastic", From cae38e6b2bfe03d771f23925a14923dcdb7282fe Mon Sep 17 00:00:00 2001 From: Tomas Della Vedova Date: Fri, 8 Mar 2019 07:47:24 +0100 Subject: [PATCH 160/172] License (#773) - Added license header - Added license checker - Fixed tap --- api/api/bulk.js | 19 +++++++++ api/api/cat.aliases.js | 19 +++++++++ api/api/cat.allocation.js | 19 +++++++++ api/api/cat.count.js | 19 +++++++++ api/api/cat.fielddata.js | 19 +++++++++ api/api/cat.health.js | 19 +++++++++ api/api/cat.help.js | 19 +++++++++ api/api/cat.indices.js | 19 +++++++++ api/api/cat.master.js | 19 +++++++++ api/api/cat.nodeattrs.js | 19 +++++++++ api/api/cat.nodes.js | 19 +++++++++ api/api/cat.pending_tasks.js | 19 +++++++++ api/api/cat.plugins.js | 19 +++++++++ api/api/cat.recovery.js | 19 +++++++++ api/api/cat.repositories.js | 19 +++++++++ api/api/cat.segments.js | 19 +++++++++ api/api/cat.shards.js | 19 +++++++++ api/api/cat.snapshots.js | 19 +++++++++ api/api/cat.tasks.js | 19 +++++++++ api/api/cat.templates.js | 19 +++++++++ api/api/cat.thread_pool.js | 19 +++++++++ api/api/ccr.delete_auto_follow_pattern.js | 19 +++++++++ api/api/ccr.follow.js | 19 +++++++++ api/api/ccr.follow_info.js | 19 +++++++++ api/api/ccr.follow_stats.js | 19 +++++++++ api/api/ccr.get_auto_follow_pattern.js | 19 +++++++++ api/api/ccr.pause_follow.js | 19 +++++++++ api/api/ccr.put_auto_follow_pattern.js | 19 +++++++++ api/api/ccr.resume_follow.js | 19 +++++++++ api/api/ccr.stats.js | 19 +++++++++ api/api/ccr.unfollow.js | 19 +++++++++ api/api/clear_scroll.js | 19 +++++++++ api/api/cluster.allocation_explain.js | 19 +++++++++ api/api/cluster.get_settings.js | 19 +++++++++ api/api/cluster.health.js | 19 +++++++++ api/api/cluster.pending_tasks.js | 19 +++++++++ api/api/cluster.put_settings.js | 19 +++++++++ api/api/cluster.remote_info.js | 19 +++++++++ api/api/cluster.reroute.js | 19 +++++++++ api/api/cluster.state.js | 19 +++++++++ api/api/cluster.stats.js | 19 +++++++++ api/api/count.js | 19 +++++++++ api/api/create.js | 19 +++++++++ api/api/delete.js | 19 +++++++++ api/api/delete_by_query.js | 19 +++++++++ api/api/delete_by_query_rethrottle.js | 19 +++++++++ api/api/delete_script.js | 19 +++++++++ api/api/exists.js | 19 +++++++++ api/api/exists_source.js | 19 +++++++++ api/api/explain.js | 19 +++++++++ api/api/field_caps.js | 19 +++++++++ api/api/get.js | 19 +++++++++ api/api/get_script.js | 19 +++++++++ api/api/get_source.js | 19 +++++++++ api/api/ilm.delete_lifecycle.js | 19 +++++++++ api/api/ilm.explain_lifecycle.js | 19 +++++++++ api/api/ilm.get_lifecycle.js | 19 +++++++++ api/api/ilm.get_status.js | 19 +++++++++ api/api/ilm.move_to_step.js | 19 +++++++++ api/api/ilm.put_lifecycle.js | 19 +++++++++ api/api/ilm.remove_policy.js | 19 +++++++++ api/api/ilm.retry.js | 19 +++++++++ api/api/ilm.start.js | 19 +++++++++ api/api/ilm.stop.js | 19 +++++++++ api/api/index.js | 19 +++++++++ api/api/indices.analyze.js | 19 +++++++++ api/api/indices.clear_cache.js | 19 +++++++++ api/api/indices.close.js | 19 +++++++++ api/api/indices.create.js | 19 +++++++++ api/api/indices.delete.js | 19 +++++++++ api/api/indices.delete_alias.js | 19 +++++++++ api/api/indices.delete_template.js | 19 +++++++++ api/api/indices.exists.js | 19 +++++++++ api/api/indices.exists_alias.js | 19 +++++++++ api/api/indices.exists_template.js | 19 +++++++++ api/api/indices.exists_type.js | 19 +++++++++ api/api/indices.flush.js | 19 +++++++++ api/api/indices.flush_synced.js | 19 +++++++++ api/api/indices.forcemerge.js | 19 +++++++++ api/api/indices.freeze.js | 19 +++++++++ api/api/indices.get.js | 19 +++++++++ api/api/indices.get_alias.js | 19 +++++++++ api/api/indices.get_field_mapping.js | 19 +++++++++ api/api/indices.get_mapping.js | 19 +++++++++ api/api/indices.get_settings.js | 19 +++++++++ api/api/indices.get_template.js | 19 +++++++++ api/api/indices.get_upgrade.js | 19 +++++++++ api/api/indices.open.js | 19 +++++++++ api/api/indices.put_alias.js | 19 +++++++++ api/api/indices.put_mapping.js | 19 +++++++++ api/api/indices.put_settings.js | 19 +++++++++ api/api/indices.put_template.js | 19 +++++++++ api/api/indices.recovery.js | 19 +++++++++ api/api/indices.refresh.js | 19 +++++++++ api/api/indices.rollover.js | 19 +++++++++ api/api/indices.segments.js | 19 +++++++++ api/api/indices.shard_stores.js | 19 +++++++++ api/api/indices.shrink.js | 19 +++++++++ api/api/indices.split.js | 19 +++++++++ api/api/indices.stats.js | 19 +++++++++ api/api/indices.unfreeze.js | 19 +++++++++ api/api/indices.update_aliases.js | 19 +++++++++ api/api/indices.upgrade.js | 19 +++++++++ api/api/indices.validate_query.js | 19 +++++++++ api/api/info.js | 19 +++++++++ api/api/ingest.delete_pipeline.js | 19 +++++++++ api/api/ingest.get_pipeline.js | 19 +++++++++ api/api/ingest.processor_grok.js | 19 +++++++++ api/api/ingest.put_pipeline.js | 19 +++++++++ api/api/ingest.simulate.js | 19 +++++++++ api/api/mget.js | 19 +++++++++ api/api/ml.close_job.js | 19 +++++++++ api/api/ml.delete_calendar.js | 19 +++++++++ api/api/ml.delete_calendar_event.js | 19 +++++++++ api/api/ml.delete_calendar_job.js | 19 +++++++++ api/api/ml.delete_datafeed.js | 19 +++++++++ api/api/ml.delete_expired_data.js | 19 +++++++++ api/api/ml.delete_filter.js | 19 +++++++++ api/api/ml.delete_forecast.js | 19 +++++++++ api/api/ml.delete_job.js | 19 +++++++++ api/api/ml.delete_model_snapshot.js | 19 +++++++++ api/api/ml.find_file_structure.js | 19 +++++++++ api/api/ml.flush_job.js | 19 +++++++++ api/api/ml.forecast.js | 19 +++++++++ api/api/ml.get_buckets.js | 19 +++++++++ api/api/ml.get_calendar_events.js | 19 +++++++++ api/api/ml.get_calendars.js | 19 +++++++++ api/api/ml.get_categories.js | 19 +++++++++ api/api/ml.get_datafeed_stats.js | 19 +++++++++ api/api/ml.get_datafeeds.js | 19 +++++++++ api/api/ml.get_filters.js | 19 +++++++++ api/api/ml.get_influencers.js | 19 +++++++++ api/api/ml.get_job_stats.js | 19 +++++++++ api/api/ml.get_jobs.js | 19 +++++++++ api/api/ml.get_model_snapshots.js | 19 +++++++++ api/api/ml.get_overall_buckets.js | 19 +++++++++ api/api/ml.get_records.js | 19 +++++++++ api/api/ml.info.js | 19 +++++++++ api/api/ml.open_job.js | 19 +++++++++ api/api/ml.post_calendar_events.js | 19 +++++++++ api/api/ml.post_data.js | 19 +++++++++ api/api/ml.preview_datafeed.js | 19 +++++++++ api/api/ml.put_calendar.js | 19 +++++++++ api/api/ml.put_calendar_job.js | 19 +++++++++ api/api/ml.put_datafeed.js | 19 +++++++++ api/api/ml.put_filter.js | 19 +++++++++ api/api/ml.put_job.js | 19 +++++++++ api/api/ml.revert_model_snapshot.js | 19 +++++++++ api/api/ml.set_upgrade_mode.js | 19 +++++++++ api/api/ml.start_datafeed.js | 19 +++++++++ api/api/ml.stop_datafeed.js | 19 +++++++++ api/api/ml.update_datafeed.js | 19 +++++++++ api/api/ml.update_filter.js | 19 +++++++++ api/api/ml.update_job.js | 19 +++++++++ api/api/ml.update_model_snapshot.js | 19 +++++++++ api/api/ml.validate.js | 19 +++++++++ api/api/ml.validate_detector.js | 19 +++++++++ api/api/monitoring.bulk.js | 19 +++++++++ api/api/msearch.js | 19 +++++++++ api/api/msearch_template.js | 19 +++++++++ api/api/mtermvectors.js | 19 +++++++++ api/api/nodes.hot_threads.js | 19 +++++++++ api/api/nodes.info.js | 19 +++++++++ api/api/nodes.reload_secure_settings.js | 19 +++++++++ api/api/nodes.stats.js | 19 +++++++++ api/api/nodes.usage.js | 19 +++++++++ api/api/ping.js | 19 +++++++++ api/api/put_script.js | 19 +++++++++ api/api/rank_eval.js | 19 +++++++++ api/api/reindex.js | 19 +++++++++ api/api/reindex_rethrottle.js | 19 +++++++++ api/api/render_search_template.js | 19 +++++++++ api/api/scripts_painless_execute.js | 19 +++++++++ api/api/scroll.js | 19 +++++++++ api/api/search.js | 19 +++++++++ api/api/search_shards.js | 19 +++++++++ api/api/search_template.js | 19 +++++++++ api/api/security.authenticate.js | 19 +++++++++ api/api/security.change_password.js | 19 +++++++++ api/api/security.clear_cached_realms.js | 19 +++++++++ api/api/security.clear_cached_roles.js | 19 +++++++++ api/api/security.create_api_key.js | 19 +++++++++ api/api/security.delete_privileges.js | 19 +++++++++ api/api/security.delete_role.js | 19 +++++++++ api/api/security.delete_role_mapping.js | 19 +++++++++ api/api/security.delete_user.js | 19 +++++++++ api/api/security.disable_user.js | 19 +++++++++ api/api/security.enable_user.js | 19 +++++++++ api/api/security.get_api_key.js | 19 +++++++++ api/api/security.get_privileges.js | 19 +++++++++ api/api/security.get_role.js | 19 +++++++++ api/api/security.get_role_mapping.js | 19 +++++++++ api/api/security.get_token.js | 19 +++++++++ api/api/security.get_user.js | 19 +++++++++ api/api/security.get_user_privileges.js | 19 +++++++++ api/api/security.has_privileges.js | 19 +++++++++ api/api/security.invalidate_api_key.js | 19 +++++++++ api/api/security.invalidate_token.js | 19 +++++++++ api/api/security.put_privileges.js | 19 +++++++++ api/api/security.put_role.js | 19 +++++++++ api/api/security.put_role_mapping.js | 19 +++++++++ api/api/security.put_user.js | 19 +++++++++ api/api/snapshot.create.js | 19 +++++++++ api/api/snapshot.create_repository.js | 19 +++++++++ api/api/snapshot.delete.js | 19 +++++++++ api/api/snapshot.delete_repository.js | 19 +++++++++ api/api/snapshot.get.js | 19 +++++++++ api/api/snapshot.get_repository.js | 19 +++++++++ api/api/snapshot.restore.js | 19 +++++++++ api/api/snapshot.status.js | 19 +++++++++ api/api/snapshot.verify_repository.js | 19 +++++++++ api/api/ssl.certificates.js | 19 +++++++++ api/api/tasks.cancel.js | 19 +++++++++ api/api/tasks.get.js | 19 +++++++++ api/api/tasks.list.js | 19 +++++++++ api/api/termvectors.js | 19 +++++++++ api/api/update.js | 19 +++++++++ api/api/update_by_query.js | 19 +++++++++ api/api/update_by_query_rethrottle.js | 19 +++++++++ api/api/xpack.graph.explore.js | 19 +++++++++ api/api/xpack.info.js | 19 +++++++++ api/api/xpack.license.delete.js | 19 +++++++++ api/api/xpack.license.get.js | 19 +++++++++ api/api/xpack.license.get_basic_status.js | 19 +++++++++ api/api/xpack.license.get_trial_status.js | 19 +++++++++ api/api/xpack.license.post.js | 19 +++++++++ api/api/xpack.license.post_start_basic.js | 19 +++++++++ api/api/xpack.license.post_start_trial.js | 19 +++++++++ api/api/xpack.migration.deprecations.js | 19 +++++++++ api/api/xpack.migration.get_assistance.js | 19 +++++++++ api/api/xpack.migration.upgrade.js | 19 +++++++++ api/api/xpack.rollup.delete_job.js | 19 +++++++++ api/api/xpack.rollup.get_jobs.js | 19 +++++++++ api/api/xpack.rollup.get_rollup_caps.js | 19 +++++++++ api/api/xpack.rollup.get_rollup_index_caps.js | 19 +++++++++ api/api/xpack.rollup.put_job.js | 19 +++++++++ api/api/xpack.rollup.rollup_search.js | 19 +++++++++ api/api/xpack.rollup.start_job.js | 19 +++++++++ api/api/xpack.rollup.stop_job.js | 19 +++++++++ api/api/xpack.sql.clear_cursor.js | 19 +++++++++ api/api/xpack.sql.query.js | 19 +++++++++ api/api/xpack.sql.translate.js | 19 +++++++++ api/api/xpack.usage.js | 19 +++++++++ api/api/xpack.watcher.ack_watch.js | 19 +++++++++ api/api/xpack.watcher.activate_watch.js | 19 +++++++++ api/api/xpack.watcher.deactivate_watch.js | 19 +++++++++ api/api/xpack.watcher.delete_watch.js | 19 +++++++++ api/api/xpack.watcher.execute_watch.js | 19 +++++++++ api/api/xpack.watcher.get_watch.js | 19 +++++++++ api/api/xpack.watcher.put_watch.js | 19 +++++++++ api/api/xpack.watcher.start.js | 19 +++++++++ api/api/xpack.watcher.stats.js | 19 +++++++++ api/api/xpack.watcher.stop.js | 19 +++++++++ api/index.js | 19 +++++++++ api/requestParams.d.ts | 19 +++++++++ index.d.ts | 19 +++++++++ index.js | 19 +++++++++ lib/Connection.d.ts | 19 +++++++++ lib/Connection.js | 19 +++++++++ lib/ConnectionPool.d.ts | 19 +++++++++ lib/ConnectionPool.js | 19 +++++++++ lib/Serializer.d.ts | 19 +++++++++ lib/Serializer.js | 19 +++++++++ lib/Transport.d.ts | 19 +++++++++ lib/Transport.js | 19 +++++++++ lib/errors.d.ts | 19 +++++++++ lib/errors.js | 19 +++++++++ package.json | 8 ++-- scripts/run.js | 19 +++++++++ scripts/utils/clone-es.js | 19 +++++++++ scripts/utils/genMain.js | 38 ++++++++++++++++++ scripts/utils/generate.js | 38 ++++++++++++++++++ scripts/utils/generateDocs.js | 19 +++++++++ scripts/utils/generateRequestTypes.js | 40 ++++++++++++++++++- scripts/utils/index.js | 19 +++++++++ test/behavior/resurrect.test.js | 19 +++++++++ test/behavior/sniff.test.js | 19 +++++++++ test/integration/helper.js | 19 +++++++++ test/integration/index.js | 19 +++++++++ test/integration/test-runner.js | 19 +++++++++ test/types/index.ts | 19 +++++++++ test/unit/api-async.js | 19 +++++++++ test/unit/api.test.js | 19 +++++++++ test/unit/child.test.js | 19 +++++++++ test/unit/client.test.js | 19 +++++++++ test/unit/connection-pool.test.js | 19 +++++++++ test/unit/connection.test.js | 19 +++++++++ test/unit/events.test.js | 19 +++++++++ test/unit/selectors.test.js | 19 +++++++++ test/unit/serializer.test.js | 19 +++++++++ test/unit/transport.test.js | 19 +++++++++ test/utils/MockConnection.js | 19 +++++++++ test/utils/buildCluster.js | 19 +++++++++ test/utils/buildServer.js | 19 +++++++++ test/utils/index.js | 19 +++++++++ 295 files changed, 5649 insertions(+), 4 deletions(-) diff --git a/api/api/bulk.js b/api/api/bulk.js index 3932fdacb..99eac7efc 100644 --- a/api/api/bulk.js +++ b/api/api/bulk.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cat.aliases.js b/api/api/cat.aliases.js index 6f41c6ee2..90a8b9b6c 100644 --- a/api/api/cat.aliases.js +++ b/api/api/cat.aliases.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cat.allocation.js b/api/api/cat.allocation.js index 59760e42f..d7011ee9a 100644 --- a/api/api/cat.allocation.js +++ b/api/api/cat.allocation.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cat.count.js b/api/api/cat.count.js index 8e74ef322..847b8952f 100644 --- a/api/api/cat.count.js +++ b/api/api/cat.count.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cat.fielddata.js b/api/api/cat.fielddata.js index 99a130b78..39237bb99 100644 --- a/api/api/cat.fielddata.js +++ b/api/api/cat.fielddata.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cat.health.js b/api/api/cat.health.js index 883ea5ad1..a1fd09f95 100644 --- a/api/api/cat.health.js +++ b/api/api/cat.health.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cat.help.js b/api/api/cat.help.js index 052d7388f..86303fccf 100644 --- a/api/api/cat.help.js +++ b/api/api/cat.help.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cat.indices.js b/api/api/cat.indices.js index 6b6f8d082..fe29696f7 100644 --- a/api/api/cat.indices.js +++ b/api/api/cat.indices.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cat.master.js b/api/api/cat.master.js index afc29f2a2..e675085ca 100644 --- a/api/api/cat.master.js +++ b/api/api/cat.master.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cat.nodeattrs.js b/api/api/cat.nodeattrs.js index 5b9a3399d..066ee65fa 100644 --- a/api/api/cat.nodeattrs.js +++ b/api/api/cat.nodeattrs.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cat.nodes.js b/api/api/cat.nodes.js index 24682d26b..da0b693e1 100644 --- a/api/api/cat.nodes.js +++ b/api/api/cat.nodes.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cat.pending_tasks.js b/api/api/cat.pending_tasks.js index 3c5270872..44793c3e0 100644 --- a/api/api/cat.pending_tasks.js +++ b/api/api/cat.pending_tasks.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cat.plugins.js b/api/api/cat.plugins.js index 073373b53..ed91b68ce 100644 --- a/api/api/cat.plugins.js +++ b/api/api/cat.plugins.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cat.recovery.js b/api/api/cat.recovery.js index 52f7f142c..d002b1784 100644 --- a/api/api/cat.recovery.js +++ b/api/api/cat.recovery.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cat.repositories.js b/api/api/cat.repositories.js index d463091c7..c0d8cdd5e 100644 --- a/api/api/cat.repositories.js +++ b/api/api/cat.repositories.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cat.segments.js b/api/api/cat.segments.js index 20e2e896d..c3166bd7c 100644 --- a/api/api/cat.segments.js +++ b/api/api/cat.segments.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cat.shards.js b/api/api/cat.shards.js index 0aac452e1..649b07600 100644 --- a/api/api/cat.shards.js +++ b/api/api/cat.shards.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cat.snapshots.js b/api/api/cat.snapshots.js index 03b0f8fa6..bb966bf42 100644 --- a/api/api/cat.snapshots.js +++ b/api/api/cat.snapshots.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cat.tasks.js b/api/api/cat.tasks.js index b830de190..a01bbf89a 100644 --- a/api/api/cat.tasks.js +++ b/api/api/cat.tasks.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cat.templates.js b/api/api/cat.templates.js index cef9c6d6c..e78d0aa2f 100644 --- a/api/api/cat.templates.js +++ b/api/api/cat.templates.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cat.thread_pool.js b/api/api/cat.thread_pool.js index 24c684f39..1781e66da 100644 --- a/api/api/cat.thread_pool.js +++ b/api/api/cat.thread_pool.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ccr.delete_auto_follow_pattern.js b/api/api/ccr.delete_auto_follow_pattern.js index cefe3edbb..bbb484897 100644 --- a/api/api/ccr.delete_auto_follow_pattern.js +++ b/api/api/ccr.delete_auto_follow_pattern.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ccr.follow.js b/api/api/ccr.follow.js index 61e1d0b6d..6a7194f88 100644 --- a/api/api/ccr.follow.js +++ b/api/api/ccr.follow.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ccr.follow_info.js b/api/api/ccr.follow_info.js index 13d9f35a8..405600f7e 100644 --- a/api/api/ccr.follow_info.js +++ b/api/api/ccr.follow_info.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ccr.follow_stats.js b/api/api/ccr.follow_stats.js index 9c7f354dd..9da5104e4 100644 --- a/api/api/ccr.follow_stats.js +++ b/api/api/ccr.follow_stats.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ccr.get_auto_follow_pattern.js b/api/api/ccr.get_auto_follow_pattern.js index 1cd71c63f..2ff0087ad 100644 --- a/api/api/ccr.get_auto_follow_pattern.js +++ b/api/api/ccr.get_auto_follow_pattern.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ccr.pause_follow.js b/api/api/ccr.pause_follow.js index 926a3cf99..4b411bb07 100644 --- a/api/api/ccr.pause_follow.js +++ b/api/api/ccr.pause_follow.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ccr.put_auto_follow_pattern.js b/api/api/ccr.put_auto_follow_pattern.js index fb7f5fa28..aabd05699 100644 --- a/api/api/ccr.put_auto_follow_pattern.js +++ b/api/api/ccr.put_auto_follow_pattern.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ccr.resume_follow.js b/api/api/ccr.resume_follow.js index 259462aca..5c77febe9 100644 --- a/api/api/ccr.resume_follow.js +++ b/api/api/ccr.resume_follow.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ccr.stats.js b/api/api/ccr.stats.js index 7f7671702..c8564820a 100644 --- a/api/api/ccr.stats.js +++ b/api/api/ccr.stats.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ccr.unfollow.js b/api/api/ccr.unfollow.js index 6b8eb217b..340dbd97c 100644 --- a/api/api/ccr.unfollow.js +++ b/api/api/ccr.unfollow.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/clear_scroll.js b/api/api/clear_scroll.js index b104cb77f..da2f9f712 100644 --- a/api/api/clear_scroll.js +++ b/api/api/clear_scroll.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cluster.allocation_explain.js b/api/api/cluster.allocation_explain.js index b89da709d..527c10806 100644 --- a/api/api/cluster.allocation_explain.js +++ b/api/api/cluster.allocation_explain.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cluster.get_settings.js b/api/api/cluster.get_settings.js index efb8ac131..9c8bef4e6 100644 --- a/api/api/cluster.get_settings.js +++ b/api/api/cluster.get_settings.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cluster.health.js b/api/api/cluster.health.js index 679042f82..687b0ac7c 100644 --- a/api/api/cluster.health.js +++ b/api/api/cluster.health.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cluster.pending_tasks.js b/api/api/cluster.pending_tasks.js index ade3f4bd7..b9ef45a6e 100644 --- a/api/api/cluster.pending_tasks.js +++ b/api/api/cluster.pending_tasks.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cluster.put_settings.js b/api/api/cluster.put_settings.js index 234e8f6f8..256c4e291 100644 --- a/api/api/cluster.put_settings.js +++ b/api/api/cluster.put_settings.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cluster.remote_info.js b/api/api/cluster.remote_info.js index 370a2e49d..c30698370 100644 --- a/api/api/cluster.remote_info.js +++ b/api/api/cluster.remote_info.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cluster.reroute.js b/api/api/cluster.reroute.js index a93448f43..7ee098d41 100644 --- a/api/api/cluster.reroute.js +++ b/api/api/cluster.reroute.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cluster.state.js b/api/api/cluster.state.js index 4e8a510dc..3e63f2b57 100644 --- a/api/api/cluster.state.js +++ b/api/api/cluster.state.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/cluster.stats.js b/api/api/cluster.stats.js index abc9e133f..2c35519a9 100644 --- a/api/api/cluster.stats.js +++ b/api/api/cluster.stats.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/count.js b/api/api/count.js index ac8ab264d..5cba924c2 100644 --- a/api/api/count.js +++ b/api/api/count.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/create.js b/api/api/create.js index 727cc2f0a..15047c9bc 100644 --- a/api/api/create.js +++ b/api/api/create.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/delete.js b/api/api/delete.js index 92afd3d0a..f19ea699c 100644 --- a/api/api/delete.js +++ b/api/api/delete.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/delete_by_query.js b/api/api/delete_by_query.js index 3b787ad70..8ee94a0ea 100644 --- a/api/api/delete_by_query.js +++ b/api/api/delete_by_query.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/delete_by_query_rethrottle.js b/api/api/delete_by_query_rethrottle.js index 4e952fea8..b85f8ce49 100644 --- a/api/api/delete_by_query_rethrottle.js +++ b/api/api/delete_by_query_rethrottle.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/delete_script.js b/api/api/delete_script.js index 36477947b..53e126116 100644 --- a/api/api/delete_script.js +++ b/api/api/delete_script.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/exists.js b/api/api/exists.js index c4c5d8172..42a614052 100644 --- a/api/api/exists.js +++ b/api/api/exists.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/exists_source.js b/api/api/exists_source.js index fdf9a0ce3..e41c6bd03 100644 --- a/api/api/exists_source.js +++ b/api/api/exists_source.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/explain.js b/api/api/explain.js index dca065aae..a99f97bdb 100644 --- a/api/api/explain.js +++ b/api/api/explain.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/field_caps.js b/api/api/field_caps.js index 872bb18dd..29e4d12f5 100644 --- a/api/api/field_caps.js +++ b/api/api/field_caps.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/get.js b/api/api/get.js index f179f8459..632db9a58 100644 --- a/api/api/get.js +++ b/api/api/get.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/get_script.js b/api/api/get_script.js index e54467593..d128ca89e 100644 --- a/api/api/get_script.js +++ b/api/api/get_script.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/get_source.js b/api/api/get_source.js index 9a738e7e1..376441dd6 100644 --- a/api/api/get_source.js +++ b/api/api/get_source.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ilm.delete_lifecycle.js b/api/api/ilm.delete_lifecycle.js index 7e7c06e81..181d51ee5 100644 --- a/api/api/ilm.delete_lifecycle.js +++ b/api/api/ilm.delete_lifecycle.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ilm.explain_lifecycle.js b/api/api/ilm.explain_lifecycle.js index a50de9700..34c645f8d 100644 --- a/api/api/ilm.explain_lifecycle.js +++ b/api/api/ilm.explain_lifecycle.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ilm.get_lifecycle.js b/api/api/ilm.get_lifecycle.js index 8e9368741..8d95641e0 100644 --- a/api/api/ilm.get_lifecycle.js +++ b/api/api/ilm.get_lifecycle.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ilm.get_status.js b/api/api/ilm.get_status.js index 42dfec166..1e413b795 100644 --- a/api/api/ilm.get_status.js +++ b/api/api/ilm.get_status.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ilm.move_to_step.js b/api/api/ilm.move_to_step.js index 32be9e2a8..1e8ce0fd2 100644 --- a/api/api/ilm.move_to_step.js +++ b/api/api/ilm.move_to_step.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ilm.put_lifecycle.js b/api/api/ilm.put_lifecycle.js index e0d2352ec..eaa4090fd 100644 --- a/api/api/ilm.put_lifecycle.js +++ b/api/api/ilm.put_lifecycle.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ilm.remove_policy.js b/api/api/ilm.remove_policy.js index 0fba4e140..243ed1b9c 100644 --- a/api/api/ilm.remove_policy.js +++ b/api/api/ilm.remove_policy.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ilm.retry.js b/api/api/ilm.retry.js index 60e3ea0af..14eaea055 100644 --- a/api/api/ilm.retry.js +++ b/api/api/ilm.retry.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ilm.start.js b/api/api/ilm.start.js index 549350117..50eeecfc6 100644 --- a/api/api/ilm.start.js +++ b/api/api/ilm.start.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ilm.stop.js b/api/api/ilm.stop.js index f92de4797..946ef8a13 100644 --- a/api/api/ilm.stop.js +++ b/api/api/ilm.stop.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/index.js b/api/api/index.js index 051977d18..99d742324 100644 --- a/api/api/index.js +++ b/api/api/index.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.analyze.js b/api/api/indices.analyze.js index 206fbf71b..b922171ee 100644 --- a/api/api/indices.analyze.js +++ b/api/api/indices.analyze.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.clear_cache.js b/api/api/indices.clear_cache.js index e95ec5ecb..f3d17a8c0 100644 --- a/api/api/indices.clear_cache.js +++ b/api/api/indices.clear_cache.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.close.js b/api/api/indices.close.js index e78974573..855814b75 100644 --- a/api/api/indices.close.js +++ b/api/api/indices.close.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.create.js b/api/api/indices.create.js index 24a05e698..e22a3ff3f 100644 --- a/api/api/indices.create.js +++ b/api/api/indices.create.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.delete.js b/api/api/indices.delete.js index 7058d9340..f9da306fb 100644 --- a/api/api/indices.delete.js +++ b/api/api/indices.delete.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.delete_alias.js b/api/api/indices.delete_alias.js index fba43ea21..c4f043368 100644 --- a/api/api/indices.delete_alias.js +++ b/api/api/indices.delete_alias.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.delete_template.js b/api/api/indices.delete_template.js index 4362e1f0e..0c4d351dc 100644 --- a/api/api/indices.delete_template.js +++ b/api/api/indices.delete_template.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.exists.js b/api/api/indices.exists.js index 65f34e8d6..e92b1eb63 100644 --- a/api/api/indices.exists.js +++ b/api/api/indices.exists.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.exists_alias.js b/api/api/indices.exists_alias.js index c423cf9aa..cb76b7dd6 100644 --- a/api/api/indices.exists_alias.js +++ b/api/api/indices.exists_alias.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.exists_template.js b/api/api/indices.exists_template.js index a22944510..6de62dc57 100644 --- a/api/api/indices.exists_template.js +++ b/api/api/indices.exists_template.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.exists_type.js b/api/api/indices.exists_type.js index b33f1e856..c36e59af2 100644 --- a/api/api/indices.exists_type.js +++ b/api/api/indices.exists_type.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.flush.js b/api/api/indices.flush.js index 6e39a31ed..a50c12ec0 100644 --- a/api/api/indices.flush.js +++ b/api/api/indices.flush.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.flush_synced.js b/api/api/indices.flush_synced.js index 34ebe17d4..838f7d6ad 100644 --- a/api/api/indices.flush_synced.js +++ b/api/api/indices.flush_synced.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.forcemerge.js b/api/api/indices.forcemerge.js index 19ee37db4..ec60e5376 100644 --- a/api/api/indices.forcemerge.js +++ b/api/api/indices.forcemerge.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.freeze.js b/api/api/indices.freeze.js index b88d62acc..2017ff35d 100644 --- a/api/api/indices.freeze.js +++ b/api/api/indices.freeze.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.get.js b/api/api/indices.get.js index 2c22c4fd9..01ffba1b9 100644 --- a/api/api/indices.get.js +++ b/api/api/indices.get.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.get_alias.js b/api/api/indices.get_alias.js index 27a406f36..a19719224 100644 --- a/api/api/indices.get_alias.js +++ b/api/api/indices.get_alias.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.get_field_mapping.js b/api/api/indices.get_field_mapping.js index fbf4a1498..ef9ada9a2 100644 --- a/api/api/indices.get_field_mapping.js +++ b/api/api/indices.get_field_mapping.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.get_mapping.js b/api/api/indices.get_mapping.js index 29946a529..dbee4ed06 100644 --- a/api/api/indices.get_mapping.js +++ b/api/api/indices.get_mapping.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.get_settings.js b/api/api/indices.get_settings.js index 6581cbaa6..b52171127 100644 --- a/api/api/indices.get_settings.js +++ b/api/api/indices.get_settings.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.get_template.js b/api/api/indices.get_template.js index 9b439d659..144e913e6 100644 --- a/api/api/indices.get_template.js +++ b/api/api/indices.get_template.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.get_upgrade.js b/api/api/indices.get_upgrade.js index fea41e2ac..a452ad1bb 100644 --- a/api/api/indices.get_upgrade.js +++ b/api/api/indices.get_upgrade.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.open.js b/api/api/indices.open.js index 747c61525..e57a4bbca 100644 --- a/api/api/indices.open.js +++ b/api/api/indices.open.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.put_alias.js b/api/api/indices.put_alias.js index 9fc60c093..8a5b4f9da 100644 --- a/api/api/indices.put_alias.js +++ b/api/api/indices.put_alias.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.put_mapping.js b/api/api/indices.put_mapping.js index d40e0efff..1c6e59893 100644 --- a/api/api/indices.put_mapping.js +++ b/api/api/indices.put_mapping.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.put_settings.js b/api/api/indices.put_settings.js index 19a7a0516..a98dea7f4 100644 --- a/api/api/indices.put_settings.js +++ b/api/api/indices.put_settings.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.put_template.js b/api/api/indices.put_template.js index 11121db57..0c82f6ef8 100644 --- a/api/api/indices.put_template.js +++ b/api/api/indices.put_template.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.recovery.js b/api/api/indices.recovery.js index b5a3a6808..2cae29bbf 100644 --- a/api/api/indices.recovery.js +++ b/api/api/indices.recovery.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.refresh.js b/api/api/indices.refresh.js index d09c5d44e..5f136a12d 100644 --- a/api/api/indices.refresh.js +++ b/api/api/indices.refresh.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.rollover.js b/api/api/indices.rollover.js index 7872cb241..4e8dbd7ea 100644 --- a/api/api/indices.rollover.js +++ b/api/api/indices.rollover.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.segments.js b/api/api/indices.segments.js index a91afea3d..706df722c 100644 --- a/api/api/indices.segments.js +++ b/api/api/indices.segments.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.shard_stores.js b/api/api/indices.shard_stores.js index b7c5048bd..12a04e792 100644 --- a/api/api/indices.shard_stores.js +++ b/api/api/indices.shard_stores.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.shrink.js b/api/api/indices.shrink.js index 4b2cd1736..ff001b6c5 100644 --- a/api/api/indices.shrink.js +++ b/api/api/indices.shrink.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.split.js b/api/api/indices.split.js index f82c12775..fc023cdd2 100644 --- a/api/api/indices.split.js +++ b/api/api/indices.split.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.stats.js b/api/api/indices.stats.js index c3425f2a4..a199b3cdf 100644 --- a/api/api/indices.stats.js +++ b/api/api/indices.stats.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.unfreeze.js b/api/api/indices.unfreeze.js index dd2e2e573..cb2caca29 100644 --- a/api/api/indices.unfreeze.js +++ b/api/api/indices.unfreeze.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.update_aliases.js b/api/api/indices.update_aliases.js index d7a6fdfbb..f5fb51d99 100644 --- a/api/api/indices.update_aliases.js +++ b/api/api/indices.update_aliases.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.upgrade.js b/api/api/indices.upgrade.js index 849a1e61e..f2c1b3bcb 100644 --- a/api/api/indices.upgrade.js +++ b/api/api/indices.upgrade.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/indices.validate_query.js b/api/api/indices.validate_query.js index ae2f60b04..16197340b 100644 --- a/api/api/indices.validate_query.js +++ b/api/api/indices.validate_query.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/info.js b/api/api/info.js index 4ba638970..6a9eea357 100644 --- a/api/api/info.js +++ b/api/api/info.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ingest.delete_pipeline.js b/api/api/ingest.delete_pipeline.js index fc7e7d277..8bda91d4b 100644 --- a/api/api/ingest.delete_pipeline.js +++ b/api/api/ingest.delete_pipeline.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ingest.get_pipeline.js b/api/api/ingest.get_pipeline.js index f723a5ede..3a087b52e 100644 --- a/api/api/ingest.get_pipeline.js +++ b/api/api/ingest.get_pipeline.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ingest.processor_grok.js b/api/api/ingest.processor_grok.js index 68d479bc8..ac3e50156 100644 --- a/api/api/ingest.processor_grok.js +++ b/api/api/ingest.processor_grok.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ingest.put_pipeline.js b/api/api/ingest.put_pipeline.js index e8ad6dade..124995cea 100644 --- a/api/api/ingest.put_pipeline.js +++ b/api/api/ingest.put_pipeline.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ingest.simulate.js b/api/api/ingest.simulate.js index 86a7ed6ab..3f84a53c3 100644 --- a/api/api/ingest.simulate.js +++ b/api/api/ingest.simulate.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/mget.js b/api/api/mget.js index 9b824c8da..7f723bf27 100644 --- a/api/api/mget.js +++ b/api/api/mget.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.close_job.js b/api/api/ml.close_job.js index 0d36e9ec2..9074eba30 100644 --- a/api/api/ml.close_job.js +++ b/api/api/ml.close_job.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.delete_calendar.js b/api/api/ml.delete_calendar.js index d4671be1d..4a8a37d8b 100644 --- a/api/api/ml.delete_calendar.js +++ b/api/api/ml.delete_calendar.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.delete_calendar_event.js b/api/api/ml.delete_calendar_event.js index a8b7b8e4c..b7df3155f 100644 --- a/api/api/ml.delete_calendar_event.js +++ b/api/api/ml.delete_calendar_event.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.delete_calendar_job.js b/api/api/ml.delete_calendar_job.js index ea412b9b4..f21d9ac6a 100644 --- a/api/api/ml.delete_calendar_job.js +++ b/api/api/ml.delete_calendar_job.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.delete_datafeed.js b/api/api/ml.delete_datafeed.js index ca4dff876..54a45a41a 100644 --- a/api/api/ml.delete_datafeed.js +++ b/api/api/ml.delete_datafeed.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.delete_expired_data.js b/api/api/ml.delete_expired_data.js index d97d69d5e..0542e14c8 100644 --- a/api/api/ml.delete_expired_data.js +++ b/api/api/ml.delete_expired_data.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.delete_filter.js b/api/api/ml.delete_filter.js index 29e92e9ef..6a5de9739 100644 --- a/api/api/ml.delete_filter.js +++ b/api/api/ml.delete_filter.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.delete_forecast.js b/api/api/ml.delete_forecast.js index d07337780..9f198e4b5 100644 --- a/api/api/ml.delete_forecast.js +++ b/api/api/ml.delete_forecast.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.delete_job.js b/api/api/ml.delete_job.js index 052557d13..eaadee6a9 100644 --- a/api/api/ml.delete_job.js +++ b/api/api/ml.delete_job.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.delete_model_snapshot.js b/api/api/ml.delete_model_snapshot.js index e77f38f36..4cf55a783 100644 --- a/api/api/ml.delete_model_snapshot.js +++ b/api/api/ml.delete_model_snapshot.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.find_file_structure.js b/api/api/ml.find_file_structure.js index 7463010ad..7ffdeea43 100644 --- a/api/api/ml.find_file_structure.js +++ b/api/api/ml.find_file_structure.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.flush_job.js b/api/api/ml.flush_job.js index 36e5bfd62..82a25e63f 100644 --- a/api/api/ml.flush_job.js +++ b/api/api/ml.flush_job.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.forecast.js b/api/api/ml.forecast.js index 4e3292f69..2a85d6098 100644 --- a/api/api/ml.forecast.js +++ b/api/api/ml.forecast.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.get_buckets.js b/api/api/ml.get_buckets.js index 81223c004..c366ce6ba 100644 --- a/api/api/ml.get_buckets.js +++ b/api/api/ml.get_buckets.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.get_calendar_events.js b/api/api/ml.get_calendar_events.js index bf0bcf57e..5fd1ce5e8 100644 --- a/api/api/ml.get_calendar_events.js +++ b/api/api/ml.get_calendar_events.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.get_calendars.js b/api/api/ml.get_calendars.js index 6c3d27023..f1495d808 100644 --- a/api/api/ml.get_calendars.js +++ b/api/api/ml.get_calendars.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.get_categories.js b/api/api/ml.get_categories.js index ed871db54..7a4962025 100644 --- a/api/api/ml.get_categories.js +++ b/api/api/ml.get_categories.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.get_datafeed_stats.js b/api/api/ml.get_datafeed_stats.js index 178a52ab6..ed8f750e2 100644 --- a/api/api/ml.get_datafeed_stats.js +++ b/api/api/ml.get_datafeed_stats.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.get_datafeeds.js b/api/api/ml.get_datafeeds.js index 581c58ddd..222ebec71 100644 --- a/api/api/ml.get_datafeeds.js +++ b/api/api/ml.get_datafeeds.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.get_filters.js b/api/api/ml.get_filters.js index c8437d7e0..cc312e6dc 100644 --- a/api/api/ml.get_filters.js +++ b/api/api/ml.get_filters.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.get_influencers.js b/api/api/ml.get_influencers.js index 91137204a..9dcf9b4db 100644 --- a/api/api/ml.get_influencers.js +++ b/api/api/ml.get_influencers.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.get_job_stats.js b/api/api/ml.get_job_stats.js index fff403791..7f7d269ce 100644 --- a/api/api/ml.get_job_stats.js +++ b/api/api/ml.get_job_stats.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.get_jobs.js b/api/api/ml.get_jobs.js index f380ee13e..045fb72a6 100644 --- a/api/api/ml.get_jobs.js +++ b/api/api/ml.get_jobs.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.get_model_snapshots.js b/api/api/ml.get_model_snapshots.js index 8c1d74dd1..0c47346c9 100644 --- a/api/api/ml.get_model_snapshots.js +++ b/api/api/ml.get_model_snapshots.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.get_overall_buckets.js b/api/api/ml.get_overall_buckets.js index f4b62e7c1..c6a2ec4b5 100644 --- a/api/api/ml.get_overall_buckets.js +++ b/api/api/ml.get_overall_buckets.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.get_records.js b/api/api/ml.get_records.js index a669f825f..fd1608283 100644 --- a/api/api/ml.get_records.js +++ b/api/api/ml.get_records.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.info.js b/api/api/ml.info.js index 0121cda08..db91bad09 100644 --- a/api/api/ml.info.js +++ b/api/api/ml.info.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.open_job.js b/api/api/ml.open_job.js index db196ceaf..b3ea5cf40 100644 --- a/api/api/ml.open_job.js +++ b/api/api/ml.open_job.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.post_calendar_events.js b/api/api/ml.post_calendar_events.js index 74cfa6469..58fea906c 100644 --- a/api/api/ml.post_calendar_events.js +++ b/api/api/ml.post_calendar_events.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.post_data.js b/api/api/ml.post_data.js index 9199a03fb..bde273e14 100644 --- a/api/api/ml.post_data.js +++ b/api/api/ml.post_data.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.preview_datafeed.js b/api/api/ml.preview_datafeed.js index 45d172998..90fb528e3 100644 --- a/api/api/ml.preview_datafeed.js +++ b/api/api/ml.preview_datafeed.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.put_calendar.js b/api/api/ml.put_calendar.js index 0225bd77b..c3a7a716b 100644 --- a/api/api/ml.put_calendar.js +++ b/api/api/ml.put_calendar.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.put_calendar_job.js b/api/api/ml.put_calendar_job.js index f3ad75956..41000c788 100644 --- a/api/api/ml.put_calendar_job.js +++ b/api/api/ml.put_calendar_job.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.put_datafeed.js b/api/api/ml.put_datafeed.js index 0a7616390..cb61c97bd 100644 --- a/api/api/ml.put_datafeed.js +++ b/api/api/ml.put_datafeed.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.put_filter.js b/api/api/ml.put_filter.js index c3dc6d5a7..e2b4a71f5 100644 --- a/api/api/ml.put_filter.js +++ b/api/api/ml.put_filter.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.put_job.js b/api/api/ml.put_job.js index 9a96b02f5..8d1a546f1 100644 --- a/api/api/ml.put_job.js +++ b/api/api/ml.put_job.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.revert_model_snapshot.js b/api/api/ml.revert_model_snapshot.js index 6f34bb7d3..4a0266db9 100644 --- a/api/api/ml.revert_model_snapshot.js +++ b/api/api/ml.revert_model_snapshot.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.set_upgrade_mode.js b/api/api/ml.set_upgrade_mode.js index d6a52ddab..52895ccf5 100644 --- a/api/api/ml.set_upgrade_mode.js +++ b/api/api/ml.set_upgrade_mode.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.start_datafeed.js b/api/api/ml.start_datafeed.js index 0000dfd7f..2bd084273 100644 --- a/api/api/ml.start_datafeed.js +++ b/api/api/ml.start_datafeed.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.stop_datafeed.js b/api/api/ml.stop_datafeed.js index 81e72c478..981a41836 100644 --- a/api/api/ml.stop_datafeed.js +++ b/api/api/ml.stop_datafeed.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.update_datafeed.js b/api/api/ml.update_datafeed.js index bf9a57b50..9fb428ef5 100644 --- a/api/api/ml.update_datafeed.js +++ b/api/api/ml.update_datafeed.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.update_filter.js b/api/api/ml.update_filter.js index 9dcd8c001..c6c894cc5 100644 --- a/api/api/ml.update_filter.js +++ b/api/api/ml.update_filter.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.update_job.js b/api/api/ml.update_job.js index 862d23245..34567cf42 100644 --- a/api/api/ml.update_job.js +++ b/api/api/ml.update_job.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.update_model_snapshot.js b/api/api/ml.update_model_snapshot.js index c495099a1..938efb3d8 100644 --- a/api/api/ml.update_model_snapshot.js +++ b/api/api/ml.update_model_snapshot.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.validate.js b/api/api/ml.validate.js index 47c896b70..ab3767300 100644 --- a/api/api/ml.validate.js +++ b/api/api/ml.validate.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ml.validate_detector.js b/api/api/ml.validate_detector.js index 96713468d..9041daa51 100644 --- a/api/api/ml.validate_detector.js +++ b/api/api/ml.validate_detector.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/monitoring.bulk.js b/api/api/monitoring.bulk.js index 346856d5a..12b969770 100644 --- a/api/api/monitoring.bulk.js +++ b/api/api/monitoring.bulk.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/msearch.js b/api/api/msearch.js index 567ac6baa..7c9e7572b 100644 --- a/api/api/msearch.js +++ b/api/api/msearch.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/msearch_template.js b/api/api/msearch_template.js index 7826e0b56..d5cf00668 100644 --- a/api/api/msearch_template.js +++ b/api/api/msearch_template.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/mtermvectors.js b/api/api/mtermvectors.js index b9953cc80..fe88cb988 100644 --- a/api/api/mtermvectors.js +++ b/api/api/mtermvectors.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/nodes.hot_threads.js b/api/api/nodes.hot_threads.js index eee2e0f9b..44bd8dc3a 100644 --- a/api/api/nodes.hot_threads.js +++ b/api/api/nodes.hot_threads.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/nodes.info.js b/api/api/nodes.info.js index 5f4b9233c..b4ef6b8e1 100644 --- a/api/api/nodes.info.js +++ b/api/api/nodes.info.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/nodes.reload_secure_settings.js b/api/api/nodes.reload_secure_settings.js index 2acbc743c..dc185a7c9 100644 --- a/api/api/nodes.reload_secure_settings.js +++ b/api/api/nodes.reload_secure_settings.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/nodes.stats.js b/api/api/nodes.stats.js index 86cae3c29..0ca0ac3af 100644 --- a/api/api/nodes.stats.js +++ b/api/api/nodes.stats.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/nodes.usage.js b/api/api/nodes.usage.js index 92d8fe319..a7edd6912 100644 --- a/api/api/nodes.usage.js +++ b/api/api/nodes.usage.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ping.js b/api/api/ping.js index 394ce04ec..92e3f970b 100644 --- a/api/api/ping.js +++ b/api/api/ping.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/put_script.js b/api/api/put_script.js index f7e950890..db75d91cf 100644 --- a/api/api/put_script.js +++ b/api/api/put_script.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/rank_eval.js b/api/api/rank_eval.js index 1256d6e29..e92f7e316 100644 --- a/api/api/rank_eval.js +++ b/api/api/rank_eval.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/reindex.js b/api/api/reindex.js index aca2e2563..357f98875 100644 --- a/api/api/reindex.js +++ b/api/api/reindex.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/reindex_rethrottle.js b/api/api/reindex_rethrottle.js index bfefeec6d..44e14ffcf 100644 --- a/api/api/reindex_rethrottle.js +++ b/api/api/reindex_rethrottle.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/render_search_template.js b/api/api/render_search_template.js index 9fd9196f4..f3404c6b4 100644 --- a/api/api/render_search_template.js +++ b/api/api/render_search_template.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/scripts_painless_execute.js b/api/api/scripts_painless_execute.js index aa3c0ca95..bed28d199 100644 --- a/api/api/scripts_painless_execute.js +++ b/api/api/scripts_painless_execute.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/scroll.js b/api/api/scroll.js index 4d59409af..a0df2513c 100644 --- a/api/api/scroll.js +++ b/api/api/scroll.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/search.js b/api/api/search.js index 36f5dc088..fc74cb5e9 100644 --- a/api/api/search.js +++ b/api/api/search.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/search_shards.js b/api/api/search_shards.js index 70466082f..dd0b89496 100644 --- a/api/api/search_shards.js +++ b/api/api/search_shards.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/search_template.js b/api/api/search_template.js index 757f33a5c..f1b90ac28 100644 --- a/api/api/search_template.js +++ b/api/api/search_template.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.authenticate.js b/api/api/security.authenticate.js index 31b408f0b..d83a8967e 100644 --- a/api/api/security.authenticate.js +++ b/api/api/security.authenticate.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.change_password.js b/api/api/security.change_password.js index 0c3112980..053b3ddaa 100644 --- a/api/api/security.change_password.js +++ b/api/api/security.change_password.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.clear_cached_realms.js b/api/api/security.clear_cached_realms.js index d511fb190..97e40cea6 100644 --- a/api/api/security.clear_cached_realms.js +++ b/api/api/security.clear_cached_realms.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.clear_cached_roles.js b/api/api/security.clear_cached_roles.js index beaca6ca9..efa455423 100644 --- a/api/api/security.clear_cached_roles.js +++ b/api/api/security.clear_cached_roles.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.create_api_key.js b/api/api/security.create_api_key.js index 40dbb3cac..d6d928716 100644 --- a/api/api/security.create_api_key.js +++ b/api/api/security.create_api_key.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.delete_privileges.js b/api/api/security.delete_privileges.js index 5e17e192d..53dd69bb1 100644 --- a/api/api/security.delete_privileges.js +++ b/api/api/security.delete_privileges.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.delete_role.js b/api/api/security.delete_role.js index 8c387ed19..5cb9a7856 100644 --- a/api/api/security.delete_role.js +++ b/api/api/security.delete_role.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.delete_role_mapping.js b/api/api/security.delete_role_mapping.js index f70b31eb1..4139ef209 100644 --- a/api/api/security.delete_role_mapping.js +++ b/api/api/security.delete_role_mapping.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.delete_user.js b/api/api/security.delete_user.js index 1af9f66e8..521c45e02 100644 --- a/api/api/security.delete_user.js +++ b/api/api/security.delete_user.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.disable_user.js b/api/api/security.disable_user.js index 5d2c2b79b..b1099099c 100644 --- a/api/api/security.disable_user.js +++ b/api/api/security.disable_user.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.enable_user.js b/api/api/security.enable_user.js index e2caf9e4c..ff070099d 100644 --- a/api/api/security.enable_user.js +++ b/api/api/security.enable_user.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.get_api_key.js b/api/api/security.get_api_key.js index 70356a786..0bfc2d550 100644 --- a/api/api/security.get_api_key.js +++ b/api/api/security.get_api_key.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.get_privileges.js b/api/api/security.get_privileges.js index 2e67a3e3a..78e2be06a 100644 --- a/api/api/security.get_privileges.js +++ b/api/api/security.get_privileges.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.get_role.js b/api/api/security.get_role.js index 694fbbce4..c652efd1f 100644 --- a/api/api/security.get_role.js +++ b/api/api/security.get_role.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.get_role_mapping.js b/api/api/security.get_role_mapping.js index 77c8c8fc3..93652ab6a 100644 --- a/api/api/security.get_role_mapping.js +++ b/api/api/security.get_role_mapping.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.get_token.js b/api/api/security.get_token.js index cb157a5b5..41620b779 100644 --- a/api/api/security.get_token.js +++ b/api/api/security.get_token.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.get_user.js b/api/api/security.get_user.js index b4812af04..23bfca1f2 100644 --- a/api/api/security.get_user.js +++ b/api/api/security.get_user.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.get_user_privileges.js b/api/api/security.get_user_privileges.js index 5c05d70fe..560e07538 100644 --- a/api/api/security.get_user_privileges.js +++ b/api/api/security.get_user_privileges.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.has_privileges.js b/api/api/security.has_privileges.js index e6ada91ca..893604cc8 100644 --- a/api/api/security.has_privileges.js +++ b/api/api/security.has_privileges.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.invalidate_api_key.js b/api/api/security.invalidate_api_key.js index a6f9dcd69..75428192b 100644 --- a/api/api/security.invalidate_api_key.js +++ b/api/api/security.invalidate_api_key.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.invalidate_token.js b/api/api/security.invalidate_token.js index ac37e92d2..31e29f31a 100644 --- a/api/api/security.invalidate_token.js +++ b/api/api/security.invalidate_token.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.put_privileges.js b/api/api/security.put_privileges.js index bccdfff0e..52d46d3c7 100644 --- a/api/api/security.put_privileges.js +++ b/api/api/security.put_privileges.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.put_role.js b/api/api/security.put_role.js index 4c7e20942..c4f284eb2 100644 --- a/api/api/security.put_role.js +++ b/api/api/security.put_role.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.put_role_mapping.js b/api/api/security.put_role_mapping.js index a14e17e4c..452bbe29a 100644 --- a/api/api/security.put_role_mapping.js +++ b/api/api/security.put_role_mapping.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/security.put_user.js b/api/api/security.put_user.js index 6912834d4..f47652fc4 100644 --- a/api/api/security.put_user.js +++ b/api/api/security.put_user.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/snapshot.create.js b/api/api/snapshot.create.js index dd4da1a53..e76b8414a 100644 --- a/api/api/snapshot.create.js +++ b/api/api/snapshot.create.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/snapshot.create_repository.js b/api/api/snapshot.create_repository.js index 67469f4e1..8cca44291 100644 --- a/api/api/snapshot.create_repository.js +++ b/api/api/snapshot.create_repository.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/snapshot.delete.js b/api/api/snapshot.delete.js index afcea559e..751501653 100644 --- a/api/api/snapshot.delete.js +++ b/api/api/snapshot.delete.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/snapshot.delete_repository.js b/api/api/snapshot.delete_repository.js index 31484d4ea..09edaa681 100644 --- a/api/api/snapshot.delete_repository.js +++ b/api/api/snapshot.delete_repository.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/snapshot.get.js b/api/api/snapshot.get.js index 5d8a11bd0..e30b56ba5 100644 --- a/api/api/snapshot.get.js +++ b/api/api/snapshot.get.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/snapshot.get_repository.js b/api/api/snapshot.get_repository.js index 9368aeb30..473f293ed 100644 --- a/api/api/snapshot.get_repository.js +++ b/api/api/snapshot.get_repository.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/snapshot.restore.js b/api/api/snapshot.restore.js index 038c5333f..fb2e74995 100644 --- a/api/api/snapshot.restore.js +++ b/api/api/snapshot.restore.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/snapshot.status.js b/api/api/snapshot.status.js index af4f8a732..6480c6760 100644 --- a/api/api/snapshot.status.js +++ b/api/api/snapshot.status.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/snapshot.verify_repository.js b/api/api/snapshot.verify_repository.js index b7fc46044..08bc473c9 100644 --- a/api/api/snapshot.verify_repository.js +++ b/api/api/snapshot.verify_repository.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/ssl.certificates.js b/api/api/ssl.certificates.js index f339cae72..75b371557 100644 --- a/api/api/ssl.certificates.js +++ b/api/api/ssl.certificates.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/tasks.cancel.js b/api/api/tasks.cancel.js index 1370b5442..c333e0d36 100644 --- a/api/api/tasks.cancel.js +++ b/api/api/tasks.cancel.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/tasks.get.js b/api/api/tasks.get.js index 2611e4841..416a64cf6 100644 --- a/api/api/tasks.get.js +++ b/api/api/tasks.get.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/tasks.list.js b/api/api/tasks.list.js index cd3d8576d..1683df6f0 100644 --- a/api/api/tasks.list.js +++ b/api/api/tasks.list.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/termvectors.js b/api/api/termvectors.js index 39f5b7899..d4c822286 100644 --- a/api/api/termvectors.js +++ b/api/api/termvectors.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/update.js b/api/api/update.js index bb46f7568..997fb167f 100644 --- a/api/api/update.js +++ b/api/api/update.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/update_by_query.js b/api/api/update_by_query.js index dab1fc51d..6c31f79c6 100644 --- a/api/api/update_by_query.js +++ b/api/api/update_by_query.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/update_by_query_rethrottle.js b/api/api/update_by_query_rethrottle.js index 5197c1d0f..48bdffa57 100644 --- a/api/api/update_by_query_rethrottle.js +++ b/api/api/update_by_query_rethrottle.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.graph.explore.js b/api/api/xpack.graph.explore.js index 2db33d83c..823e7f232 100644 --- a/api/api/xpack.graph.explore.js +++ b/api/api/xpack.graph.explore.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.info.js b/api/api/xpack.info.js index 18de196f3..c4db3ea38 100644 --- a/api/api/xpack.info.js +++ b/api/api/xpack.info.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.license.delete.js b/api/api/xpack.license.delete.js index 4ac239693..f60e1546e 100644 --- a/api/api/xpack.license.delete.js +++ b/api/api/xpack.license.delete.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.license.get.js b/api/api/xpack.license.get.js index 2f0cd0afd..c2f887c29 100644 --- a/api/api/xpack.license.get.js +++ b/api/api/xpack.license.get.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.license.get_basic_status.js b/api/api/xpack.license.get_basic_status.js index ed27c80fb..9dc5ee6ec 100644 --- a/api/api/xpack.license.get_basic_status.js +++ b/api/api/xpack.license.get_basic_status.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.license.get_trial_status.js b/api/api/xpack.license.get_trial_status.js index 710274f52..3b5d68145 100644 --- a/api/api/xpack.license.get_trial_status.js +++ b/api/api/xpack.license.get_trial_status.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.license.post.js b/api/api/xpack.license.post.js index ae2881179..5539a9131 100644 --- a/api/api/xpack.license.post.js +++ b/api/api/xpack.license.post.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.license.post_start_basic.js b/api/api/xpack.license.post_start_basic.js index f7de0dd88..10af70ddd 100644 --- a/api/api/xpack.license.post_start_basic.js +++ b/api/api/xpack.license.post_start_basic.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.license.post_start_trial.js b/api/api/xpack.license.post_start_trial.js index 8864567db..7d7d6eb96 100644 --- a/api/api/xpack.license.post_start_trial.js +++ b/api/api/xpack.license.post_start_trial.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.migration.deprecations.js b/api/api/xpack.migration.deprecations.js index 0321eeb46..0eaab511e 100644 --- a/api/api/xpack.migration.deprecations.js +++ b/api/api/xpack.migration.deprecations.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.migration.get_assistance.js b/api/api/xpack.migration.get_assistance.js index 467fbc2d7..cfd98bdae 100644 --- a/api/api/xpack.migration.get_assistance.js +++ b/api/api/xpack.migration.get_assistance.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.migration.upgrade.js b/api/api/xpack.migration.upgrade.js index 774f603a5..e86a8fc50 100644 --- a/api/api/xpack.migration.upgrade.js +++ b/api/api/xpack.migration.upgrade.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.rollup.delete_job.js b/api/api/xpack.rollup.delete_job.js index 312723f7f..e80e0f24a 100644 --- a/api/api/xpack.rollup.delete_job.js +++ b/api/api/xpack.rollup.delete_job.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.rollup.get_jobs.js b/api/api/xpack.rollup.get_jobs.js index c7bc1f800..6162d7dbd 100644 --- a/api/api/xpack.rollup.get_jobs.js +++ b/api/api/xpack.rollup.get_jobs.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.rollup.get_rollup_caps.js b/api/api/xpack.rollup.get_rollup_caps.js index 7cb63d6ed..ce8fd7b8d 100644 --- a/api/api/xpack.rollup.get_rollup_caps.js +++ b/api/api/xpack.rollup.get_rollup_caps.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.rollup.get_rollup_index_caps.js b/api/api/xpack.rollup.get_rollup_index_caps.js index b8374ef76..75c68f601 100644 --- a/api/api/xpack.rollup.get_rollup_index_caps.js +++ b/api/api/xpack.rollup.get_rollup_index_caps.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.rollup.put_job.js b/api/api/xpack.rollup.put_job.js index fd76991d3..b4b36b414 100644 --- a/api/api/xpack.rollup.put_job.js +++ b/api/api/xpack.rollup.put_job.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.rollup.rollup_search.js b/api/api/xpack.rollup.rollup_search.js index a05ae3919..0b8ef2969 100644 --- a/api/api/xpack.rollup.rollup_search.js +++ b/api/api/xpack.rollup.rollup_search.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.rollup.start_job.js b/api/api/xpack.rollup.start_job.js index a50a0e704..763acadf4 100644 --- a/api/api/xpack.rollup.start_job.js +++ b/api/api/xpack.rollup.start_job.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.rollup.stop_job.js b/api/api/xpack.rollup.stop_job.js index 6eb6f016c..ac1f503b3 100644 --- a/api/api/xpack.rollup.stop_job.js +++ b/api/api/xpack.rollup.stop_job.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.sql.clear_cursor.js b/api/api/xpack.sql.clear_cursor.js index d89f4daea..26d64e8a1 100644 --- a/api/api/xpack.sql.clear_cursor.js +++ b/api/api/xpack.sql.clear_cursor.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.sql.query.js b/api/api/xpack.sql.query.js index 9fd287cb0..bb5d2e381 100644 --- a/api/api/xpack.sql.query.js +++ b/api/api/xpack.sql.query.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.sql.translate.js b/api/api/xpack.sql.translate.js index 13df0aa43..aadec40f7 100644 --- a/api/api/xpack.sql.translate.js +++ b/api/api/xpack.sql.translate.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.usage.js b/api/api/xpack.usage.js index a1767e6b8..fd612f4f2 100644 --- a/api/api/xpack.usage.js +++ b/api/api/xpack.usage.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.watcher.ack_watch.js b/api/api/xpack.watcher.ack_watch.js index 3bd1233d9..367fc0fa9 100644 --- a/api/api/xpack.watcher.ack_watch.js +++ b/api/api/xpack.watcher.ack_watch.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.watcher.activate_watch.js b/api/api/xpack.watcher.activate_watch.js index 5141e58b9..16b7547ad 100644 --- a/api/api/xpack.watcher.activate_watch.js +++ b/api/api/xpack.watcher.activate_watch.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.watcher.deactivate_watch.js b/api/api/xpack.watcher.deactivate_watch.js index 99888de1c..6881f2017 100644 --- a/api/api/xpack.watcher.deactivate_watch.js +++ b/api/api/xpack.watcher.deactivate_watch.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.watcher.delete_watch.js b/api/api/xpack.watcher.delete_watch.js index 021ffcdc3..aa7b84653 100644 --- a/api/api/xpack.watcher.delete_watch.js +++ b/api/api/xpack.watcher.delete_watch.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.watcher.execute_watch.js b/api/api/xpack.watcher.execute_watch.js index 262f49e44..25469dc54 100644 --- a/api/api/xpack.watcher.execute_watch.js +++ b/api/api/xpack.watcher.execute_watch.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.watcher.get_watch.js b/api/api/xpack.watcher.get_watch.js index 673f33209..d2a90ba0c 100644 --- a/api/api/xpack.watcher.get_watch.js +++ b/api/api/xpack.watcher.get_watch.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.watcher.put_watch.js b/api/api/xpack.watcher.put_watch.js index e59d5de41..0b8ec0e0f 100644 --- a/api/api/xpack.watcher.put_watch.js +++ b/api/api/xpack.watcher.put_watch.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.watcher.start.js b/api/api/xpack.watcher.start.js index 1f442629c..0891bcfcd 100644 --- a/api/api/xpack.watcher.start.js +++ b/api/api/xpack.watcher.start.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.watcher.stats.js b/api/api/xpack.watcher.stats.js index 37f507530..847e10ef6 100644 --- a/api/api/xpack.watcher.stats.js +++ b/api/api/xpack.watcher.stats.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/api/xpack.watcher.stop.js b/api/api/xpack.watcher.stop.js index b87b67102..77c5d11d2 100644 --- a/api/api/xpack.watcher.stop.js +++ b/api/api/xpack.watcher.stop.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/api/index.js b/api/index.js index 86c696dc9..ca997bffa 100644 --- a/api/index.js +++ b/api/index.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const assert = require('assert') diff --git a/api/requestParams.d.ts b/api/requestParams.d.ts index c0865c021..755fddf88 100644 --- a/api/requestParams.d.ts +++ b/api/requestParams.d.ts @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + export interface Generic { method?: string; ignore?: number | number[]; diff --git a/index.d.ts b/index.d.ts index 4b31d159a..2a4de4d01 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /// import { EventEmitter } from 'events'; diff --git a/index.js b/index.js index ce6a09ce3..27a77a9ac 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const { EventEmitter } = require('events') diff --git a/lib/Connection.d.ts b/lib/Connection.d.ts index 469bb473b..21c701789 100644 --- a/lib/Connection.d.ts +++ b/lib/Connection.d.ts @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /// import { URL } from 'url'; diff --git a/lib/Connection.js b/lib/Connection.js index 1f30c9f0b..22e570edd 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const assert = require('assert') diff --git a/lib/ConnectionPool.d.ts b/lib/ConnectionPool.d.ts index a98cb6677..340a5cca6 100644 --- a/lib/ConnectionPool.d.ts +++ b/lib/ConnectionPool.d.ts @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + /// import { SecureContextOptions } from 'tls'; diff --git a/lib/ConnectionPool.js b/lib/ConnectionPool.js index 7cdb89b5c..9e74dcb62 100644 --- a/lib/ConnectionPool.js +++ b/lib/ConnectionPool.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const assert = require('assert') diff --git a/lib/Serializer.d.ts b/lib/Serializer.d.ts index 542081d2c..bf8453ab3 100644 --- a/lib/Serializer.d.ts +++ b/lib/Serializer.d.ts @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + export default class Serializer { serialize(object: any): string; deserialize(json: string): any; diff --git a/lib/Serializer.js b/lib/Serializer.js index 5bb84adfb..6b96b956e 100644 --- a/lib/Serializer.js +++ b/lib/Serializer.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const { stringify } = require('querystring') diff --git a/lib/Transport.d.ts b/lib/Transport.d.ts index 9a9730127..34db13e84 100644 --- a/lib/Transport.d.ts +++ b/lib/Transport.d.ts @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + import ConnectionPool from './ConnectionPool'; import Connection from './Connection'; import Serializer from './Serializer'; diff --git a/lib/Transport.js b/lib/Transport.js index 47a111110..0e45581c0 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const debug = require('debug')('elasticsearch') diff --git a/lib/errors.d.ts b/lib/errors.d.ts index 9bd88ae1c..b76f6fad0 100644 --- a/lib/errors.d.ts +++ b/lib/errors.d.ts @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + export declare class TimeoutError extends Error { name: string; message: string; diff --git a/lib/errors.js b/lib/errors.js index 585ec6996..b611c47a5 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' class ElasticsearchClientError extends Error { diff --git a/package.json b/package.json index a4c1043f2..ecce252e7 100644 --- a/package.json +++ b/package.json @@ -19,14 +19,15 @@ "test": "npm run lint && npm run test:unit && npm run test:behavior && npm run test:types", "test:unit": "tap test/unit/*.test.js -J -t 300", "test:behavior": "tap test/behavior/*.test.js -J -t 300", - "test:integration": "tap test/integration/index.js -T --harmony", + "test:integration": "tap test/integration/index.js -T --harmony --no-esm", "test:types": "tsc --project ./test/types/tsconfig.json", "test:benchmarks": "nanobench test/benchmarks/*.bench.js", "lint": "standard", "lint:fix": "standard --fix", "generate": "node scripts/run.js", "elasticsearch": "./scripts/es-docker.sh", - "ci": "npm test && npm run test:integration" + "ci": "npm run license-checker && npm test && npm run test:integration", + "license-checker": "license-checker --production --onlyAllow='MIT;Apache-2.0;Apache1.1;ISC;BSD-3-Clause;BSD-2-Clause'" }, "author": { "name": "Tomas Della Vedova", @@ -40,6 +41,7 @@ "@types/node": "^10.12.24", "deepmerge": "^3.1.0", "js-yaml": "^3.12.1", + "license-checker": "^25.0.1", "lolex": "^3.1.0", "minimist": "^1.2.0", "nanobench": "github:delvedor/nanobench#repetitions", @@ -49,7 +51,7 @@ "simple-git": "^1.107.0", "standard": "^12.0.1", "stoppable": "^1.1.0", - "tap": "^12.5.2", + "tap": "^12.6.0", "typescript": "^3.3.3", "workq": "^2.1.0" }, diff --git a/scripts/run.js b/scripts/run.js index 016365f2c..23839c175 100644 --- a/scripts/run.js +++ b/scripts/run.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const { join } = require('path') diff --git a/scripts/utils/clone-es.js b/scripts/utils/clone-es.js index ad4ec69e6..7889541c3 100644 --- a/scripts/utils/clone-es.js +++ b/scripts/utils/clone-es.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const { accessSync, mkdirSync } = require('fs') diff --git a/scripts/utils/genMain.js b/scripts/utils/genMain.js index f7bc2358b..070ba6c00 100644 --- a/scripts/utils/genMain.js +++ b/scripts/utils/genMain.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const { readdirSync } = require('fs') @@ -74,6 +93,25 @@ function genFactory (folder) { .replace(/,/g, '') const fn = dedent` + /* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const assert = require('assert') diff --git a/scripts/utils/generate.js b/scripts/utils/generate.js index 0ee925ab6..29cb4ec31 100644 --- a/scripts/utils/generate.js +++ b/scripts/utils/generate.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const dedent = require('dedent') @@ -163,6 +182,25 @@ function generate (spec, common) { `.trim() // always call trim to avoid newlines const fn = dedent` + /* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' /* eslint camelcase: 0 */ diff --git a/scripts/utils/generateDocs.js b/scripts/utils/generateDocs.js index 48df3be4a..b0f34f3f5 100644 --- a/scripts/utils/generateDocs.js +++ b/scripts/utils/generateDocs.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const dedent = require('dedent') diff --git a/scripts/utils/generateRequestTypes.js b/scripts/utils/generateRequestTypes.js index 092bdf99d..e457e7e0b 100644 --- a/scripts/utils/generateRequestTypes.js +++ b/scripts/utils/generateRequestTypes.js @@ -1,7 +1,45 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' function generate (api) { - var types = `export interface Generic { + var types = `/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +export interface Generic { method?: string; ignore?: number | number[]; filter_path?: string | string[]; diff --git a/scripts/utils/index.js b/scripts/utils/index.js index b76bf7586..51169910b 100644 --- a/scripts/utils/index.js +++ b/scripts/utils/index.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const generate = require('./generate') diff --git a/test/behavior/resurrect.test.js b/test/behavior/resurrect.test.js index 2a1c412d0..a57be54e3 100644 --- a/test/behavior/resurrect.test.js +++ b/test/behavior/resurrect.test.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const { test } = require('tap') diff --git a/test/behavior/sniff.test.js b/test/behavior/sniff.test.js index bf0a7b386..b88c91e83 100644 --- a/test/behavior/sniff.test.js +++ b/test/behavior/sniff.test.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const { test } = require('tap') diff --git a/test/integration/helper.js b/test/integration/helper.js index 8d4479744..7c9822698 100644 --- a/test/integration/helper.js +++ b/test/integration/helper.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const esDefaultRoles = [ diff --git a/test/integration/index.js b/test/integration/index.js index 5f136413e..b217675ee 100644 --- a/test/integration/index.js +++ b/test/integration/index.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const assert = require('assert') diff --git a/test/integration/test-runner.js b/test/integration/test-runner.js index 231fcd803..63ca22085 100644 --- a/test/integration/test-runner.js +++ b/test/integration/test-runner.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const t = require('tap') diff --git a/test/types/index.ts b/test/types/index.ts index ad1d026cd..51ece57b5 100644 --- a/test/types/index.ts +++ b/test/types/index.ts @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' import { diff --git a/test/unit/api-async.js b/test/unit/api-async.js index dbfa7ea7f..92aa7d9c3 100644 --- a/test/unit/api-async.js +++ b/test/unit/api-async.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const { Client } = require('../../index') diff --git a/test/unit/api.test.js b/test/unit/api.test.js index 2a6b0eedc..61cc49a01 100644 --- a/test/unit/api.test.js +++ b/test/unit/api.test.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const { test } = require('tap') diff --git a/test/unit/child.test.js b/test/unit/child.test.js index 5e8405de3..2e8ea1554 100644 --- a/test/unit/child.test.js +++ b/test/unit/child.test.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const { test } = require('tap') diff --git a/test/unit/client.test.js b/test/unit/client.test.js index 83512a775..d92f765b6 100644 --- a/test/unit/client.test.js +++ b/test/unit/client.test.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const { test } = require('tap') diff --git a/test/unit/connection-pool.test.js b/test/unit/connection-pool.test.js index 534d9fc5e..9a5b502b4 100644 --- a/test/unit/connection-pool.test.js +++ b/test/unit/connection-pool.test.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const { test } = require('tap') diff --git a/test/unit/connection.test.js b/test/unit/connection.test.js index 92d6c6921..1a07ccf45 100644 --- a/test/unit/connection.test.js +++ b/test/unit/connection.test.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const { test } = require('tap') diff --git a/test/unit/events.test.js b/test/unit/events.test.js index 56c7d24a2..0d314a6e6 100644 --- a/test/unit/events.test.js +++ b/test/unit/events.test.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const { test } = require('tap') diff --git a/test/unit/selectors.test.js b/test/unit/selectors.test.js index cde2d52a5..8985f90fe 100644 --- a/test/unit/selectors.test.js +++ b/test/unit/selectors.test.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const { test } = require('tap') diff --git a/test/unit/serializer.test.js b/test/unit/serializer.test.js index 369b94ca9..cce887e7a 100644 --- a/test/unit/serializer.test.js +++ b/test/unit/serializer.test.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const { test } = require('tap') diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index 6fe920c49..7b15c72cc 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const { test } = require('tap') diff --git a/test/utils/MockConnection.js b/test/utils/MockConnection.js index 6e751b897..938bfd47a 100644 --- a/test/utils/MockConnection.js +++ b/test/utils/MockConnection.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const { Connection } = require('../../index') diff --git a/test/utils/buildCluster.js b/test/utils/buildCluster.js index 13c208f9f..a781f32cc 100644 --- a/test/utils/buildCluster.js +++ b/test/utils/buildCluster.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const debug = require('debug')('elasticsearch-test') diff --git a/test/utils/buildServer.js b/test/utils/buildServer.js index 235195594..28f7509be 100644 --- a/test/utils/buildServer.js +++ b/test/utils/buildServer.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const debug = require('debug')('elasticsearch-test') diff --git a/test/utils/index.js b/test/utils/index.js index 0aa7c6a17..e36ea2290 100644 --- a/test/utils/index.js +++ b/test/utils/index.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + 'use strict' const buildServer = require('./buildServer') From 46df19fd7d065f5e3c2be781c7fe81d70c20b6a2 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 11 Mar 2019 17:12:31 +0100 Subject: [PATCH 161/172] Updated types --- index.d.ts | 10 ++++----- lib/ConnectionPool.d.ts | 2 +- lib/Transport.d.ts | 34 +++++++++++++++++-------------- lib/errors.d.ts | 45 ++++++++++++++++++++++++----------------- 4 files changed, 50 insertions(+), 41 deletions(-) diff --git a/index.d.ts b/index.d.ts index 2a4de4d01..dd7a4244f 100644 --- a/index.d.ts +++ b/index.d.ts @@ -23,15 +23,14 @@ import { EventEmitter } from 'events'; import { SecureContextOptions } from 'tls'; import Transport, { ApiResponse, - EventMeta, - SniffMeta, + RequestEvent, TransportRequestParams, TransportRequestOptions, nodeFilterFn, nodeSelectorFn } from './lib/Transport'; import Connection, { AgentOptions } from './lib/Connection'; -import ConnectionPool, { ResurrectMeta } from './lib/ConnectionPool'; +import ConnectionPool, { ResurrectEvent } from './lib/ConnectionPool'; import Serializer from './lib/Serializer'; import * as RequestParams from './api/requestParams'; import * as errors from './lib/errors'; @@ -569,9 +568,8 @@ export { Serializer, events, ApiResponse, - EventMeta, - SniffMeta, - ResurrectMeta, + RequestEvent, + ResurrectEvent, RequestParams, ClientExtendsCallbackOptions }; diff --git a/lib/ConnectionPool.d.ts b/lib/ConnectionPool.d.ts index 340a5cca6..0dbbded05 100644 --- a/lib/ConnectionPool.d.ts +++ b/lib/ConnectionPool.d.ts @@ -36,7 +36,7 @@ export interface getConnectionOptions { selector?: nodeSelectorFn; } -export interface ResurrectMeta { +export interface ResurrectEvent { strategy: string; isAlive: boolean; connection: Connection; diff --git a/lib/Transport.d.ts b/lib/Transport.d.ts index 34db13e84..8037ae2f9 100644 --- a/lib/Transport.d.ts +++ b/lib/Transport.d.ts @@ -49,25 +49,29 @@ interface TransportOptions { headers?: anyObject; } -export interface ApiResponse { +export interface RequestEvent { body: any; statusCode: number | null; - headers: any; - warnings: any[] | null; + headers: anyObject | null; + warnings: string[] | null; + meta: { + request: { + params: TransportRequestParams; + options: TransportRequestOptions; + }; + connection: Connection; + attempts: number; + aborted: boolean; + sniff?: { + hosts: any[]; + reason: string; + }; + }; } -export interface EventMeta { - connection: Connection; - request: any; - response: ApiResponse; - attempts: number; - aborted: boolean; -} - -export interface SniffMeta { - hosts: any[]; - reason: string; -} +// ApiResponse and RequestEvent are the same thing +// we are doing this for have more clear names +export interface ApiResponse extends RequestEvent {} declare type anyObject = { [key: string]: any; diff --git a/lib/errors.d.ts b/lib/errors.d.ts index b76f6fad0..68b215725 100644 --- a/lib/errors.d.ts +++ b/lib/errors.d.ts @@ -17,51 +17,58 @@ * under the License. */ -export declare class TimeoutError extends Error { +import { ApiResponse } from './Transport' + +export declare class ElasticsearchClientError extends Error { name: string; message: string; - request: any; - constructor(message: string, request: any); } -export declare class ConnectionError extends Error { +export declare class TimeoutError extends ElasticsearchClientError { name: string; message: string; - request: any; - constructor(message: string, request: any); + meta: ApiResponse; + constructor(message: string, meta: ApiResponse); } -export declare class NoLivingConnectionsError extends Error { +export declare class ConnectionError extends ElasticsearchClientError { + name: string; + message: string; + meta: ApiResponse; + constructor(message: string, meta: ApiResponse); +} + +export declare class NoLivingConnectionsError extends ElasticsearchClientError { + name: string; + message: string; + meta: ApiResponse; + constructor(message: string, meta: ApiResponse); +} + +export declare class SerializationError extends ElasticsearchClientError { name: string; message: string; constructor(message: string); } -export declare class SerializationError extends Error { +export declare class DeserializationError extends ElasticsearchClientError { name: string; message: string; constructor(message: string); } -export declare class DeserializationError extends Error { +export declare class ConfigurationError extends ElasticsearchClientError { name: string; message: string; constructor(message: string); } -export declare class ConfigurationError extends Error { - name: string; - message: string; - constructor(message: string); -} - -export declare class ResponseError extends Error { +export declare class ResponseError extends ElasticsearchClientError { name: string; message: string; + meta: ApiResponse; body: any; statusCode: number; headers: any; - constructor({ body, statusCode, headers }: { - [key: string]: any; - }); + constructor(meta: ApiResponse); } From c990ed43d421238caf661c221d0bedc7e5de02b8 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 11 Mar 2019 17:12:53 +0100 Subject: [PATCH 162/172] Updated test --- test/behavior/sniff.test.js | 16 ++-- test/types/index.ts | 16 ++-- test/unit/errors.test.js | 93 ++++++++++++++++++++++ test/unit/events.test.js | 151 +++++++++++++++++++++++++----------- 4 files changed, 218 insertions(+), 58 deletions(-) create mode 100644 test/unit/errors.test.js diff --git a/test/behavior/sniff.test.js b/test/behavior/sniff.test.js index b88c91e83..c76709b49 100644 --- a/test/behavior/sniff.test.js +++ b/test/behavior/sniff.test.js @@ -43,9 +43,12 @@ test('Should update the connection pool', t => { }) t.strictEqual(client.connectionPool.connections.size, 1) - client.on(events.SNIFF, (err, { reason }) => { + client.on(events.SNIFF, (err, request) => { t.error(err) - t.strictEqual(reason, Transport.sniffReasons.DEFAULT) + t.strictEqual( + request.meta.sniff.reason, + Transport.sniffReasons.DEFAULT + ) }) // run the sniffer @@ -100,8 +103,9 @@ test('Sniff interval', t => { }) // this event will be triggered by api calls - client.on(events.SNIFF, (err, { hosts, reason }) => { + client.on(events.SNIFF, (err, request) => { t.error(err) + const { hosts, reason } = request.meta.sniff t.strictEqual( client.connectionPool.connections.size, hosts.length @@ -135,8 +139,9 @@ test('Sniff on start', t => { sniffOnStart: true }) - client.on(events.SNIFF, (err, { hosts, reason }) => { + client.on(events.SNIFF, (err, request) => { t.error(err) + const { hosts, reason } = request.meta.sniff t.strictEqual( client.connectionPool.connections.size, hosts.length @@ -207,8 +212,9 @@ test('Sniff on connection fault', t => { t.strictEqual(client.connectionPool.connections.size, 2) // this event will be triggered by the connection fault - client.on(events.SNIFF, (err, { hosts, reason }) => { + client.on(events.SNIFF, (err, request) => { t.error(err) + const { hosts, reason } = request.meta.sniff t.strictEqual( client.connectionPool.connections.size, hosts.length diff --git a/test/types/index.ts b/test/types/index.ts index 51ece57b5..fd1260bab 100644 --- a/test/types/index.ts +++ b/test/types/index.ts @@ -22,9 +22,8 @@ import { Client, ApiResponse, - EventMeta, - SniffMeta, - ResurrectMeta, + RequestEvent, + ResurrectEvent, events, ClientExtendsCallbackOptions } from '../../index' @@ -33,10 +32,13 @@ import { TransportRequestParams, TransportRequestOptions } from '../../lib/Trans const client = new Client({ node: 'http://localhost:9200' }) -client.on(events.REQUEST, (err: Error | null, meta: EventMeta) => {}) -client.on(events.RESPONSE, (err: Error | null, meta: EventMeta) => {}) -client.on(events.SNIFF, (err: Error | null, meta: SniffMeta) => {}) -client.on(events.RESURRECT, (err: Error | null, meta: ResurrectMeta) => {}) +client.on(events.RESPONSE, (err: Error | null, request: RequestEvent) => { + if (err) console.log(err) + const { body, statusCode } = request + const { params } = request.meta.request + console.log(params, body, statusCode) +}) +client.on(events.RESURRECT, (err: Error | null, meta: ResurrectEvent) => {}) // Callbacks client.info((err: Error | null, result: ApiResponse) => {}) diff --git a/test/unit/errors.test.js b/test/unit/errors.test.js new file mode 100644 index 000000000..213194cff --- /dev/null +++ b/test/unit/errors.test.js @@ -0,0 +1,93 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +const { test } = require('tap') +const { errors } = require('../../index') + +test('ElasticsearchClientError', t => { + const err = new errors.ElasticsearchClientError() + t.true(err instanceof Error) + t.end() +}) + +test('TimeoutError', t => { + const err = new errors.TimeoutError() + t.true(err instanceof Error) + t.true(err instanceof errors.ElasticsearchClientError) + t.true(err.hasOwnProperty('meta')) + t.end() +}) + +test('ConnectionError', t => { + const err = new errors.ConnectionError() + t.true(err instanceof Error) + t.true(err instanceof errors.ElasticsearchClientError) + t.true(err.hasOwnProperty('meta')) + t.end() +}) + +test('NoLivingConnectionsError', t => { + const err = new errors.NoLivingConnectionsError() + t.true(err instanceof Error) + t.true(err instanceof errors.ElasticsearchClientError) + t.true(err.hasOwnProperty('meta')) + t.end() +}) + +test('SerializationError', t => { + const err = new errors.SerializationError() + t.true(err instanceof Error) + t.true(err instanceof errors.ElasticsearchClientError) + t.false(err.hasOwnProperty('meta')) + t.end() +}) + +test('DeserializationError', t => { + const err = new errors.DeserializationError() + t.true(err instanceof Error) + t.true(err instanceof errors.ElasticsearchClientError) + t.false(err.hasOwnProperty('meta')) + t.end() +}) + +test('ConfigurationError', t => { + const err = new errors.ConfigurationError() + t.true(err instanceof Error) + t.true(err instanceof errors.ElasticsearchClientError) + t.false(err.hasOwnProperty('meta')) + t.end() +}) + +test('ResponseError', t => { + const meta = { + body: 1, + statusCode: 1, + headers: 1 + } + const err = new errors.ResponseError(meta) + t.true(err instanceof Error) + t.true(err instanceof errors.ElasticsearchClientError) + t.true(err.hasOwnProperty('meta')) + t.ok(err.body) + t.ok(err.statusCode) + t.ok(err.headers) + t.end() +}) diff --git a/test/unit/events.test.js b/test/unit/events.test.js index 0d314a6e6..432194a29 100644 --- a/test/unit/events.test.js +++ b/test/unit/events.test.js @@ -32,20 +32,41 @@ test('Should emit a request event when a request is performed', t => { Connection: MockConnection }) - client.on(events.REQUEST, (err, meta) => { + client.on(events.REQUEST, (err, request) => { t.error(err) - t.match(meta, { - connection: { - id: 'http://localhost:9200' - }, - request: { - method: 'GET', - path: '/test/doc/_search', - querystring: 'q=foo%3Abar' - }, - response: null, - attempts: 0, - aborted: false + t.match(request, { + body: null, + statusCode: null, + headers: null, + warnings: null, + meta: { + request: { + params: { + method: 'GET', + path: '/test/doc/_search', + body: '', + querystring: 'q=foo%3Abar', + headers: { + 'Content-Type': 'application/json', + 'Content-Length': '0' + } + }, + options: { + ignore: null, + requestTimeout: null, + maxRetries: null, + asStream: false, + headers: null, + compression: false, + warnings: null + } + }, + connection: { + id: 'http://localhost:9200' + }, + attempts: 0, + aborted: false + } }) }) @@ -66,28 +87,44 @@ test('Should emit a response event in case of a successful response', t => { Connection: MockConnection }) - client.on(events.RESPONSE, (err, meta) => { + client.on(events.RESPONSE, (err, request) => { t.error(err) - t.match(meta, { - connection: { - id: 'http://localhost:9200' + t.match(request, { + body: { hello: 'world' }, + statusCode: 200, + headers: { + 'content-type': 'application/json;utf=8', + 'connection': 'keep-alive' }, - request: { - method: 'GET', - path: '/test/doc/_search', - querystring: 'q=foo%3Abar' - }, - response: { - body: { hello: 'world' }, - statusCode: 200, - headers: { - 'content-type': 'application/json;utf=8', - 'connection': 'keep-alive' + warnings: null, + meta: { + request: { + params: { + method: 'GET', + path: '/test/doc/_search', + body: '', + querystring: 'q=foo%3Abar', + headers: { + 'Content-Type': 'application/json', + 'Content-Length': '0' + } + }, + options: { + ignore: null, + requestTimeout: null, + maxRetries: null, + asStream: false, + headers: null, + compression: false, + warnings: null + } }, - warnings: null - }, - attempts: 0, - aborted: false + connection: { + id: 'http://localhost:9200' + }, + attempts: 0, + aborted: false + } }) }) @@ -109,27 +146,49 @@ test('Should emit a response event with the error set', t => { maxRetries: 0 }) - client.on(events.RESPONSE, (err, meta) => { + client.on(events.RESPONSE, (err, request) => { t.ok(err instanceof TimeoutError) - t.match(meta, { - connection: { - id: 'http://localhost:9200' - }, - request: { - method: 'GET', - path: '/test/doc/_search', - querystring: 'q=foo%3Abar' - }, - response: null, - attempts: 0, - aborted: false + t.match(request, { + body: null, + statusCode: null, + headers: null, + warnings: null, + meta: { + request: { + params: { + method: 'GET', + path: '/test/doc/_search', + body: '', + querystring: 'q=foo%3Abar', + headers: { + 'Content-Type': 'application/json', + 'Content-Length': '0' + } + }, + options: { + ignore: null, + requestTimeout: 500, + maxRetries: null, + asStream: false, + headers: null, + compression: false, + warnings: null + } + }, + connection: { + id: 'http://localhost:9200' + }, + attempts: 0, + aborted: false + } }) }) client.search({ index: 'test', type: 'doc', - q: 'foo:bar', + q: 'foo:bar' + }, { requestTimeout: 500 }, (err, result) => { t.ok(err instanceof TimeoutError) From ae028b2ae20f3ad82aba4c79c515d5cd6fbbd5bc Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 11 Mar 2019 17:13:02 +0100 Subject: [PATCH 163/172] Consistency for the win - The result object contains also the metadata about the request - The events emits the same object of the API response - The errors, where possible, exposes the APi response object under the meta key --- lib/Transport.js | 49 ++++++++++++++++++++++++++++-------------------- lib/errors.js | 36 +++++++++++++++++++++++------------ 2 files changed, 53 insertions(+), 32 deletions(-) diff --git a/lib/Transport.js b/lib/Transport.js index 0e45581c0..61ee70c44 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -88,20 +88,24 @@ class Transport { } callback = once(callback) - // TODO: return in the result the metadata const meta = { + request: { + params: null, + options: null + }, connection: null, - request: null, - response: null, attempts: 0, aborted: false } + const result = { body: null, statusCode: null, headers: null, - warnings: options.warnings || null + warnings: options.warnings || null, + meta } + const maxRetries = options.maxRetries || this.maxRetries const compression = options.compression || this.compression var request = { abort: noop } @@ -163,12 +167,13 @@ class Transport { params.headers = headers // serializes the querystring params.querystring = this.serializer.qserialize(params.querystring) + + meta.request.params = params + meta.request.options = options + this.emit('request', null, result) + // handles request timeout params.timeout = toMs(options.requestTimeout || this.requestTimeout) - - meta.request = params - this.emit('request', null, meta) - if (options.asStream === true) params.asStream = true // perform the actual http request return meta.connection.request(params, onResponse) @@ -194,9 +199,13 @@ class Transport { const error = err instanceof TimeoutError ? err - : new ConnectionError(err.message, params) + : new ConnectionError(err.message, result) - this.emit('response', error, meta) + if (err.name === 'TimeoutError') { + err.meta = result + } + + this.emit('response', error, result) return callback(error, result) } @@ -211,8 +220,7 @@ class Transport { if (options.asStream === true) { result.body = response - meta.response = result - this.emit('response', null, meta) + this.emit('response', null, result) callback(null, result) return } @@ -223,8 +231,8 @@ class Transport { response.on('data', chunk => { payload += chunk }) /* istanbul ignore next */ response.on('error', err => { - const error = new ConnectionError(err.message, params) - this.emit('response', error, meta) + const error = new ConnectionError(err.message, result) + this.emit('response', error, result) callback(error, result) }) response.on('end', () => { @@ -241,7 +249,7 @@ class Transport { try { result.body = this.serializer.deserialize(payload) } catch (err) { - this.emit('response', err, meta) + this.emit('response', err, result) return callback(err, result) } } else { @@ -272,17 +280,16 @@ class Transport { this.connectionPool.markAlive(meta.connection) } - meta.response = result if (ignoreStatusCode === false && statusCode >= 400) { const error = new ResponseError(result) - this.emit('response', error, meta) + this.emit('response', error, result) callback(error, result) } else { // cast to boolean if the request method was HEAD if (isHead === true && statusCode === 404) { result.body = false } - this.emit('response', null, meta) + this.emit('response', null, result) callback(null, result) } }) @@ -334,7 +341,8 @@ class Transport { if (err != null) { debug('Sniffing errored', err) - this.emit('sniff', err, { hosts: [], reason }) + result.meta.sniff = { hosts: [], reason } + this.emit('sniff', err, result) return callback(err) } @@ -342,7 +350,8 @@ class Transport { const hosts = this.connectionPool.nodesToHost(result.body.nodes) this.connectionPool.update(hosts) - this.emit('sniff', null, { hosts, reason }) + result.meta.sniff = { hosts, reason } + this.emit('sniff', null, result) callback(null, hosts) }) } diff --git a/lib/errors.js b/lib/errors.js index b611c47a5..3f4fddb39 100644 --- a/lib/errors.js +++ b/lib/errors.js @@ -27,31 +27,32 @@ class ElasticsearchClientError extends Error { } class TimeoutError extends ElasticsearchClientError { - constructor (message, request) { + constructor (message, meta) { super(message) Error.captureStackTrace(this, TimeoutError) this.name = 'TimeoutError' this.message = message || 'Timeout Error' - this.request = request + this.meta = meta } } class ConnectionError extends ElasticsearchClientError { - constructor (message, request) { + constructor (message, meta) { super(message) Error.captureStackTrace(this, ConnectionError) this.name = 'ConnectionError' this.message = message || 'Connection Error' - this.request = request + this.meta = meta } } class NoLivingConnectionsError extends ElasticsearchClientError { - constructor (message) { + constructor (message, meta) { super(message) Error.captureStackTrace(this, NoLivingConnectionsError) this.name = 'NoLivingConnectionsError' this.message = message || 'No Living Connections Error' + this.meta = meta } } @@ -83,16 +84,27 @@ class ConfigurationError extends ElasticsearchClientError { } class ResponseError extends ElasticsearchClientError { - constructor ({ body, statusCode, headers }) { + constructor (meta) { super('Response Error') Error.captureStackTrace(this, ResponseError) this.name = 'ResponseError' - this.message = (body && body.error && body.error.type) || 'Response Error' - this.body = body - this.statusCode = body && typeof body.status === 'number' - ? body.status - : statusCode - this.headers = headers + this.message = (meta.body && meta.body.error && meta.body.error.type) || 'Response Error' + this.meta = meta + } + + get body () { + return this.meta.body + } + + get statusCode () { + if (this.meta.body && typeof this.meta.body.status === 'number') { + return this.meta.body.status + } + return this.meta.statusCode + } + + get headers () { + return this.meta.headers } } From 45c31df5c1a12a1e0e8f6a513b45e4881bab0300 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 11 Mar 2019 17:15:39 +0100 Subject: [PATCH 164/172] Updated docs --- docs/usage.asciidoc | 141 +++++++++++++++++++++++--------------------- 1 file changed, 75 insertions(+), 66 deletions(-) diff --git a/docs/usage.asciidoc b/docs/usage.asciidoc index fd7de728f..1abf7d217 100644 --- a/docs/usage.asciidoc +++ b/docs/usage.asciidoc @@ -156,70 +156,6 @@ const { events } = require('@elastic/elasticsearch') console.log(events) ---- -The client emits the following events: -[cols=2*] -|=== -|`request` -a|Emitted before to send the actual request to Elasticsearch. -[source,js] ----- -client.on('request', (err, meta) => { - console.log(err, meta) -}) ----- -`meta` is an object that contains the following informations: - -* `connection`: the connection instance -* `request`: every parameter that will be sent to Elasticsearch -* `response`: inside this event it will be always `null`. -* `attempts`: how many times the clients has tried to execute this request -* `aborted`: boolean check that is true if the request has been aborted. - -|`response` -a|Emitted before to send the actual request to Elasticsearch. -[source,js] ----- -client.on('response', (err, meta) => { - console.log(err, meta) -}) ----- -`meta` is an object that contains the following informations: - -* `connection`: the connection instance -* `request`: every parameter that will be sent to Elasticsearch -* `response`: the Elasticsearch response. -* `attempts`: how many times the clients has tried to execute this request -* `aborted`: boolean check that is true if the request has been aborted. - -|`sniff` -a|Emitted before to send the actual request to Elasticsearch. -[source,js] ----- -client.on('sniff', (err, meta) => { - console.log(err, meta) -}) ----- -`meta` is an object that contains the following informations: - -* `hosts`: the list of nodes obtained from Elasticsearch -* `reason`: the reason why the sniff was triggered. - -|`resurrect` -a|Emitted before to send the actual request to Elasticsearch. -[source,js] ----- -client.on('resurrect', (err, meta) => { - console.log(err, meta) -}) ----- -`meta` is an object that contains the following informations: - -* `connection`: the connection the client is trying to revive -* `strategy`: the strategy the client is using for reviving the connection -* `isAlive`: boolean value - -|=== - The event emitter functionality can be useful if you want to log every request, response and error that is happening during the use of the client. [source,js] @@ -228,11 +164,84 @@ const logger = require('my-logger')() const { Client } = require('@elastic/elasticsearch') const client = new Client({ node: 'http://localhost:9200' }) -client.on('response', (err, meta) => { +client.on('response', (err, req) => { if (err) { logger.error(err) } else { - logger.info(meta) + logger.info(req) } }) +---- + +The client emits the following events: +[cols=2*] +|=== +|`request` +a|Emitted before to send the actual request to Elasticsearch. +[source,js] +---- +client.on('request', (err, req) => { + console.log(err, req) +}) +---- + +|`response` +a|Emitted before to send the actual request to Elasticsearch. +[source,js] +---- +client.on('response', (err, req) => { + console.log(err, req) +}) +---- + +|`sniff` +a|Emitted before to send the actual request to Elasticsearch. +[source,js] +---- +client.on('sniff', (err, req) => { + console.log(err, req) +}) +---- + +|`resurrect` +a|Emitted before to send the actual request to Elasticsearch. +[source,js] +---- +client.on('resurrect', (err, req) => { + console.log(err, req) +}) +---- + +|=== + +The values of `req` in `request`, `response` and `sniff` will be: +[source,ts] +---- + body: any; + statusCode: number | null; + headers: anyObject | null; + warnings: string[] | null; + meta: { + request: { + params: TransportRequestParams; + options: TransportRequestOptions; + }; + connection: Connection; + attempts: number; + aborted: boolean; + sniff?: { + hosts: any[]; + reason: string; + }; + }; +---- + +While the `req` value in `resurrect` will be: +[source,ts] +---- +export interface ResurrectEvent { + strategy: string; + isAlive: boolean; + connection: Connection; +} ---- \ No newline at end of file From 5c6c5dea78048895db4c839cbd658409b407f417 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 11 Mar 2019 18:34:39 +0100 Subject: [PATCH 165/172] API generation --- api/api/bulk.js | 8 -------- api/api/cat.aliases.js | 8 -------- api/api/cat.allocation.js | 8 -------- api/api/cat.count.js | 8 -------- api/api/cat.fielddata.js | 8 -------- api/api/cat.health.js | 8 -------- api/api/cat.help.js | 8 -------- api/api/cat.indices.js | 8 -------- api/api/cat.master.js | 8 -------- api/api/cat.nodeattrs.js | 8 -------- api/api/cat.nodes.js | 8 -------- api/api/cat.pending_tasks.js | 8 -------- api/api/cat.plugins.js | 8 -------- api/api/cat.recovery.js | 8 -------- api/api/cat.repositories.js | 8 -------- api/api/cat.segments.js | 8 -------- api/api/cat.shards.js | 8 -------- api/api/cat.snapshots.js | 8 -------- api/api/cat.tasks.js | 8 -------- api/api/cat.templates.js | 8 -------- api/api/cat.thread_pool.js | 8 -------- api/api/ccr.delete_auto_follow_pattern.js | 8 -------- api/api/ccr.follow.js | 8 -------- api/api/ccr.follow_info.js | 8 -------- api/api/ccr.follow_stats.js | 8 -------- api/api/ccr.get_auto_follow_pattern.js | 8 -------- api/api/ccr.pause_follow.js | 8 -------- api/api/ccr.put_auto_follow_pattern.js | 8 -------- api/api/ccr.resume_follow.js | 8 -------- api/api/ccr.stats.js | 8 -------- api/api/ccr.unfollow.js | 8 -------- api/api/clear_scroll.js | 8 -------- api/api/cluster.allocation_explain.js | 8 -------- api/api/cluster.get_settings.js | 8 -------- api/api/cluster.health.js | 8 -------- api/api/cluster.pending_tasks.js | 8 -------- api/api/cluster.put_settings.js | 8 -------- api/api/cluster.remote_info.js | 8 -------- api/api/cluster.reroute.js | 8 -------- api/api/cluster.state.js | 8 -------- api/api/cluster.stats.js | 8 -------- api/api/count.js | 8 -------- api/api/create.js | 8 -------- api/api/delete.js | 8 -------- api/api/delete_by_query.js | 8 -------- api/api/delete_by_query_rethrottle.js | 8 -------- api/api/delete_script.js | 8 -------- api/api/exists.js | 8 -------- api/api/exists_source.js | 8 -------- api/api/explain.js | 8 -------- api/api/field_caps.js | 8 -------- api/api/get.js | 8 -------- api/api/get_script.js | 8 -------- api/api/get_source.js | 8 -------- api/api/ilm.delete_lifecycle.js | 8 -------- api/api/ilm.explain_lifecycle.js | 8 -------- api/api/ilm.get_lifecycle.js | 8 -------- api/api/ilm.get_status.js | 8 -------- api/api/ilm.move_to_step.js | 8 -------- api/api/ilm.put_lifecycle.js | 8 -------- api/api/ilm.remove_policy.js | 8 -------- api/api/ilm.retry.js | 8 -------- api/api/ilm.start.js | 8 -------- api/api/ilm.stop.js | 8 -------- api/api/index.js | 8 -------- api/api/indices.analyze.js | 8 -------- api/api/indices.clear_cache.js | 8 -------- api/api/indices.close.js | 8 -------- api/api/indices.create.js | 8 -------- api/api/indices.delete.js | 8 -------- api/api/indices.delete_alias.js | 8 -------- api/api/indices.delete_template.js | 8 -------- api/api/indices.exists.js | 8 -------- api/api/indices.exists_alias.js | 8 -------- api/api/indices.exists_template.js | 8 -------- api/api/indices.exists_type.js | 8 -------- api/api/indices.flush.js | 8 -------- api/api/indices.flush_synced.js | 8 -------- api/api/indices.forcemerge.js | 8 -------- api/api/indices.freeze.js | 8 -------- api/api/indices.get.js | 8 -------- api/api/indices.get_alias.js | 8 -------- api/api/indices.get_field_mapping.js | 8 -------- api/api/indices.get_mapping.js | 8 -------- api/api/indices.get_settings.js | 8 -------- api/api/indices.get_template.js | 8 -------- api/api/indices.get_upgrade.js | 8 -------- api/api/indices.open.js | 8 -------- api/api/indices.put_alias.js | 8 -------- api/api/indices.put_mapping.js | 8 -------- api/api/indices.put_settings.js | 8 -------- api/api/indices.put_template.js | 8 -------- api/api/indices.recovery.js | 8 -------- api/api/indices.refresh.js | 8 -------- api/api/indices.rollover.js | 8 -------- api/api/indices.segments.js | 8 -------- api/api/indices.shard_stores.js | 8 -------- api/api/indices.shrink.js | 8 -------- api/api/indices.split.js | 8 -------- api/api/indices.stats.js | 8 -------- api/api/indices.unfreeze.js | 8 -------- api/api/indices.update_aliases.js | 8 -------- api/api/indices.upgrade.js | 8 -------- api/api/indices.validate_query.js | 8 -------- api/api/info.js | 8 -------- api/api/ingest.delete_pipeline.js | 8 -------- api/api/ingest.get_pipeline.js | 8 -------- api/api/ingest.processor_grok.js | 8 -------- api/api/ingest.put_pipeline.js | 8 -------- api/api/ingest.simulate.js | 8 -------- api/api/mget.js | 8 -------- api/api/ml.close_job.js | 8 -------- api/api/ml.delete_calendar.js | 8 -------- api/api/ml.delete_calendar_event.js | 8 -------- api/api/ml.delete_calendar_job.js | 8 -------- api/api/ml.delete_datafeed.js | 8 -------- api/api/ml.delete_expired_data.js | 8 -------- api/api/ml.delete_filter.js | 8 -------- api/api/ml.delete_forecast.js | 8 -------- api/api/ml.delete_job.js | 8 -------- api/api/ml.delete_model_snapshot.js | 8 -------- api/api/ml.find_file_structure.js | 8 -------- api/api/ml.flush_job.js | 8 -------- api/api/ml.forecast.js | 8 -------- api/api/ml.get_buckets.js | 8 -------- api/api/ml.get_calendar_events.js | 8 -------- api/api/ml.get_calendars.js | 8 -------- api/api/ml.get_categories.js | 8 -------- api/api/ml.get_datafeed_stats.js | 8 -------- api/api/ml.get_datafeeds.js | 8 -------- api/api/ml.get_filters.js | 8 -------- api/api/ml.get_influencers.js | 8 -------- api/api/ml.get_job_stats.js | 8 -------- api/api/ml.get_jobs.js | 8 -------- api/api/ml.get_model_snapshots.js | 8 -------- api/api/ml.get_overall_buckets.js | 8 -------- api/api/ml.get_records.js | 8 -------- api/api/ml.info.js | 8 -------- api/api/ml.open_job.js | 8 -------- api/api/ml.post_calendar_events.js | 8 -------- api/api/ml.post_data.js | 8 -------- api/api/ml.preview_datafeed.js | 8 -------- api/api/ml.put_calendar.js | 8 -------- api/api/ml.put_calendar_job.js | 8 -------- api/api/ml.put_datafeed.js | 8 -------- api/api/ml.put_filter.js | 8 -------- api/api/ml.put_job.js | 8 -------- api/api/ml.revert_model_snapshot.js | 8 -------- api/api/ml.set_upgrade_mode.js | 8 -------- api/api/ml.start_datafeed.js | 8 -------- api/api/ml.stop_datafeed.js | 8 -------- api/api/ml.update_datafeed.js | 8 -------- api/api/ml.update_filter.js | 8 -------- api/api/ml.update_job.js | 8 -------- api/api/ml.update_model_snapshot.js | 8 -------- api/api/ml.validate.js | 8 -------- api/api/ml.validate_detector.js | 8 -------- api/api/monitoring.bulk.js | 8 -------- api/api/msearch.js | 8 -------- api/api/msearch_template.js | 8 -------- api/api/mtermvectors.js | 8 -------- api/api/nodes.hot_threads.js | 8 -------- api/api/nodes.info.js | 8 -------- api/api/nodes.reload_secure_settings.js | 8 -------- api/api/nodes.stats.js | 8 -------- api/api/nodes.usage.js | 8 -------- api/api/ping.js | 8 -------- api/api/put_script.js | 8 -------- api/api/rank_eval.js | 8 -------- api/api/reindex.js | 8 -------- api/api/reindex_rethrottle.js | 8 -------- api/api/render_search_template.js | 8 -------- api/api/scripts_painless_execute.js | 8 -------- api/api/scroll.js | 8 -------- api/api/search.js | 8 -------- api/api/search_shards.js | 8 -------- api/api/search_template.js | 8 -------- api/api/security.authenticate.js | 8 -------- api/api/security.change_password.js | 8 -------- api/api/security.clear_cached_realms.js | 8 -------- api/api/security.clear_cached_roles.js | 8 -------- api/api/security.create_api_key.js | 8 -------- api/api/security.delete_privileges.js | 8 -------- api/api/security.delete_role.js | 8 -------- api/api/security.delete_role_mapping.js | 8 -------- api/api/security.delete_user.js | 8 -------- api/api/security.disable_user.js | 8 -------- api/api/security.enable_user.js | 8 -------- api/api/security.get_api_key.js | 8 -------- api/api/security.get_privileges.js | 8 -------- api/api/security.get_role.js | 8 -------- api/api/security.get_role_mapping.js | 8 -------- api/api/security.get_token.js | 8 -------- api/api/security.get_user.js | 8 -------- api/api/security.get_user_privileges.js | 8 -------- api/api/security.has_privileges.js | 8 -------- api/api/security.invalidate_api_key.js | 8 -------- api/api/security.invalidate_token.js | 8 -------- api/api/security.put_privileges.js | 8 -------- api/api/security.put_role.js | 8 -------- api/api/security.put_role_mapping.js | 8 -------- api/api/security.put_user.js | 8 -------- api/api/snapshot.create.js | 8 -------- api/api/snapshot.create_repository.js | 8 -------- api/api/snapshot.delete.js | 8 -------- api/api/snapshot.delete_repository.js | 8 -------- api/api/snapshot.get.js | 8 -------- api/api/snapshot.get_repository.js | 8 -------- api/api/snapshot.restore.js | 8 -------- api/api/snapshot.status.js | 8 -------- api/api/snapshot.verify_repository.js | 8 -------- api/api/ssl.certificates.js | 8 -------- api/api/tasks.cancel.js | 8 -------- api/api/tasks.get.js | 8 -------- api/api/tasks.list.js | 8 -------- api/api/termvectors.js | 8 -------- api/api/update.js | 8 -------- api/api/update_by_query.js | 8 -------- api/api/update_by_query_rethrottle.js | 8 -------- api/api/xpack.graph.explore.js | 8 -------- api/api/xpack.info.js | 8 -------- api/api/xpack.license.delete.js | 8 -------- api/api/xpack.license.get.js | 8 -------- api/api/xpack.license.get_basic_status.js | 8 -------- api/api/xpack.license.get_trial_status.js | 8 -------- api/api/xpack.license.post.js | 8 -------- api/api/xpack.license.post_start_basic.js | 8 -------- api/api/xpack.license.post_start_trial.js | 8 -------- api/api/xpack.migration.deprecations.js | 8 -------- api/api/xpack.migration.get_assistance.js | 8 -------- api/api/xpack.migration.upgrade.js | 8 -------- api/api/xpack.rollup.delete_job.js | 8 -------- api/api/xpack.rollup.get_jobs.js | 8 -------- api/api/xpack.rollup.get_rollup_caps.js | 8 -------- api/api/xpack.rollup.get_rollup_index_caps.js | 8 -------- api/api/xpack.rollup.put_job.js | 8 -------- api/api/xpack.rollup.rollup_search.js | 8 -------- api/api/xpack.rollup.start_job.js | 8 -------- api/api/xpack.rollup.stop_job.js | 8 -------- api/api/xpack.sql.clear_cursor.js | 8 -------- api/api/xpack.sql.query.js | 8 -------- api/api/xpack.sql.translate.js | 8 -------- api/api/xpack.usage.js | 8 -------- api/api/xpack.watcher.ack_watch.js | 8 -------- api/api/xpack.watcher.activate_watch.js | 8 -------- api/api/xpack.watcher.deactivate_watch.js | 8 -------- api/api/xpack.watcher.delete_watch.js | 8 -------- api/api/xpack.watcher.execute_watch.js | 8 -------- api/api/xpack.watcher.get_watch.js | 8 -------- api/api/xpack.watcher.put_watch.js | 8 -------- api/api/xpack.watcher.start.js | 8 -------- api/api/xpack.watcher.stats.js | 8 -------- api/api/xpack.watcher.stop.js | 8 -------- 253 files changed, 2024 deletions(-) diff --git a/api/api/bulk.js b/api/api/bulk.js index 99eac7efc..957f215e0 100644 --- a/api/api/bulk.js +++ b/api/api/bulk.js @@ -78,14 +78,6 @@ function buildBulk (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - bulk(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/cat.aliases.js b/api/api/cat.aliases.js index 90a8b9b6c..8627157db 100644 --- a/api/api/cat.aliases.js +++ b/api/api/cat.aliases.js @@ -70,14 +70,6 @@ function buildCatAliases (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catAliases(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cat.allocation.js b/api/api/cat.allocation.js index d7011ee9a..767854188 100644 --- a/api/api/cat.allocation.js +++ b/api/api/cat.allocation.js @@ -72,14 +72,6 @@ function buildCatAllocation (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catAllocation(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cat.count.js b/api/api/cat.count.js index 847b8952f..6fa162c4a 100644 --- a/api/api/cat.count.js +++ b/api/api/cat.count.js @@ -70,14 +70,6 @@ function buildCatCount (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catCount(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cat.fielddata.js b/api/api/cat.fielddata.js index 39237bb99..22c9377a5 100644 --- a/api/api/cat.fielddata.js +++ b/api/api/cat.fielddata.js @@ -74,14 +74,6 @@ function buildCatFielddata (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catFielddata(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cat.health.js b/api/api/cat.health.js index a1fd09f95..eb255cc9a 100644 --- a/api/api/cat.health.js +++ b/api/api/cat.health.js @@ -71,14 +71,6 @@ function buildCatHealth (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catHealth(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cat.help.js b/api/api/cat.help.js index 86303fccf..ebea416e1 100644 --- a/api/api/cat.help.js +++ b/api/api/cat.help.js @@ -58,14 +58,6 @@ function buildCatHelp (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catHelp(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cat.indices.js b/api/api/cat.indices.js index fe29696f7..2ff28920d 100644 --- a/api/api/cat.indices.js +++ b/api/api/cat.indices.js @@ -76,14 +76,6 @@ function buildCatIndices (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catIndices(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cat.master.js b/api/api/cat.master.js index e675085ca..432dbd775 100644 --- a/api/api/cat.master.js +++ b/api/api/cat.master.js @@ -69,14 +69,6 @@ function buildCatMaster (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catMaster(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cat.nodeattrs.js b/api/api/cat.nodeattrs.js index 066ee65fa..2cebea1d7 100644 --- a/api/api/cat.nodeattrs.js +++ b/api/api/cat.nodeattrs.js @@ -69,14 +69,6 @@ function buildCatNodeattrs (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catNodeattrs(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cat.nodes.js b/api/api/cat.nodes.js index da0b693e1..dfa320a08 100644 --- a/api/api/cat.nodes.js +++ b/api/api/cat.nodes.js @@ -72,14 +72,6 @@ function buildCatNodes (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catNodes(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cat.pending_tasks.js b/api/api/cat.pending_tasks.js index 44793c3e0..4205042ae 100644 --- a/api/api/cat.pending_tasks.js +++ b/api/api/cat.pending_tasks.js @@ -69,14 +69,6 @@ function buildCatPendingTasks (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catPendingTasks(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cat.plugins.js b/api/api/cat.plugins.js index ed91b68ce..6fa73552c 100644 --- a/api/api/cat.plugins.js +++ b/api/api/cat.plugins.js @@ -69,14 +69,6 @@ function buildCatPlugins (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catPlugins(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cat.recovery.js b/api/api/cat.recovery.js index d002b1784..985ed4902 100644 --- a/api/api/cat.recovery.js +++ b/api/api/cat.recovery.js @@ -70,14 +70,6 @@ function buildCatRecovery (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catRecovery(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cat.repositories.js b/api/api/cat.repositories.js index c0d8cdd5e..742a2ce56 100644 --- a/api/api/cat.repositories.js +++ b/api/api/cat.repositories.js @@ -69,14 +69,6 @@ function buildCatRepositories (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catRepositories(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cat.segments.js b/api/api/cat.segments.js index c3166bd7c..2e4e5f184 100644 --- a/api/api/cat.segments.js +++ b/api/api/cat.segments.js @@ -67,14 +67,6 @@ function buildCatSegments (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catSegments(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cat.shards.js b/api/api/cat.shards.js index 649b07600..482dd015f 100644 --- a/api/api/cat.shards.js +++ b/api/api/cat.shards.js @@ -72,14 +72,6 @@ function buildCatShards (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catShards(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cat.snapshots.js b/api/api/cat.snapshots.js index bb966bf42..eaded0a18 100644 --- a/api/api/cat.snapshots.js +++ b/api/api/cat.snapshots.js @@ -71,14 +71,6 @@ function buildCatSnapshots (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catSnapshots(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cat.tasks.js b/api/api/cat.tasks.js index a01bbf89a..720459a6f 100644 --- a/api/api/cat.tasks.js +++ b/api/api/cat.tasks.js @@ -74,14 +74,6 @@ function buildCatTasks (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catTasks(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cat.templates.js b/api/api/cat.templates.js index e78d0aa2f..f3a4f11f7 100644 --- a/api/api/cat.templates.js +++ b/api/api/cat.templates.js @@ -70,14 +70,6 @@ function buildCatTemplates (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catTemplates(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cat.thread_pool.js b/api/api/cat.thread_pool.js index 1781e66da..44756ab39 100644 --- a/api/api/cat.thread_pool.js +++ b/api/api/cat.thread_pool.js @@ -72,14 +72,6 @@ function buildCatThreadPool (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catThreadPool(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/ccr.delete_auto_follow_pattern.js b/api/api/ccr.delete_auto_follow_pattern.js index bbb484897..04cfe48b5 100644 --- a/api/api/ccr.delete_auto_follow_pattern.js +++ b/api/api/ccr.delete_auto_follow_pattern.js @@ -50,14 +50,6 @@ function buildCcrDeleteAutoFollowPattern (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ccrDeleteAutoFollowPattern(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['name'] == null) { diff --git a/api/api/ccr.follow.js b/api/api/ccr.follow.js index 6a7194f88..6983bfea0 100644 --- a/api/api/ccr.follow.js +++ b/api/api/ccr.follow.js @@ -52,14 +52,6 @@ function buildCcrFollow (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ccrFollow(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/ccr.follow_info.js b/api/api/ccr.follow_info.js index 405600f7e..0a27de878 100644 --- a/api/api/ccr.follow_info.js +++ b/api/api/ccr.follow_info.js @@ -50,14 +50,6 @@ function buildCcrFollowInfo (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ccrFollowInfo(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { diff --git a/api/api/ccr.follow_stats.js b/api/api/ccr.follow_stats.js index 9da5104e4..c4f53e66c 100644 --- a/api/api/ccr.follow_stats.js +++ b/api/api/ccr.follow_stats.js @@ -50,14 +50,6 @@ function buildCcrFollowStats (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ccrFollowStats(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { diff --git a/api/api/ccr.get_auto_follow_pattern.js b/api/api/ccr.get_auto_follow_pattern.js index 2ff0087ad..6e59191e1 100644 --- a/api/api/ccr.get_auto_follow_pattern.js +++ b/api/api/ccr.get_auto_follow_pattern.js @@ -50,14 +50,6 @@ function buildCcrGetAutoFollowPattern (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ccrGetAutoFollowPattern(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { diff --git a/api/api/ccr.pause_follow.js b/api/api/ccr.pause_follow.js index 4b411bb07..2e15a0430 100644 --- a/api/api/ccr.pause_follow.js +++ b/api/api/ccr.pause_follow.js @@ -50,14 +50,6 @@ function buildCcrPauseFollow (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ccrPauseFollow(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/ccr.put_auto_follow_pattern.js b/api/api/ccr.put_auto_follow_pattern.js index aabd05699..d660fafc1 100644 --- a/api/api/ccr.put_auto_follow_pattern.js +++ b/api/api/ccr.put_auto_follow_pattern.js @@ -51,14 +51,6 @@ function buildCcrPutAutoFollowPattern (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ccrPutAutoFollowPattern(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['name'] == null) { diff --git a/api/api/ccr.resume_follow.js b/api/api/ccr.resume_follow.js index 5c77febe9..e4fec5dc5 100644 --- a/api/api/ccr.resume_follow.js +++ b/api/api/ccr.resume_follow.js @@ -51,14 +51,6 @@ function buildCcrResumeFollow (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ccrResumeFollow(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/ccr.stats.js b/api/api/ccr.stats.js index c8564820a..e127ae0ca 100644 --- a/api/api/ccr.stats.js +++ b/api/api/ccr.stats.js @@ -49,14 +49,6 @@ function buildCcrStats (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ccrStats(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { diff --git a/api/api/ccr.unfollow.js b/api/api/ccr.unfollow.js index 340dbd97c..44af6a3a8 100644 --- a/api/api/ccr.unfollow.js +++ b/api/api/ccr.unfollow.js @@ -50,14 +50,6 @@ function buildCcrUnfollow (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ccrUnfollow(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/clear_scroll.js b/api/api/clear_scroll.js index da2f9f712..bcf7a5afc 100644 --- a/api/api/clear_scroll.js +++ b/api/api/clear_scroll.js @@ -56,14 +56,6 @@ function buildClearScroll (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - clearScroll(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { diff --git a/api/api/cluster.allocation_explain.js b/api/api/cluster.allocation_explain.js index 527c10806..9463e1e90 100644 --- a/api/api/cluster.allocation_explain.js +++ b/api/api/cluster.allocation_explain.js @@ -61,14 +61,6 @@ function buildClusterAllocationExplain (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - clusterAllocationExplain(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { diff --git a/api/api/cluster.get_settings.js b/api/api/cluster.get_settings.js index 9c8bef4e6..8f7f13c41 100644 --- a/api/api/cluster.get_settings.js +++ b/api/api/cluster.get_settings.js @@ -65,14 +65,6 @@ function buildClusterGetSettings (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - clusterGetSettings(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cluster.health.js b/api/api/cluster.health.js index 687b0ac7c..6ff729d8a 100644 --- a/api/api/cluster.health.js +++ b/api/api/cluster.health.js @@ -82,14 +82,6 @@ function buildClusterHealth (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - clusterHealth(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cluster.pending_tasks.js b/api/api/cluster.pending_tasks.js index b9ef45a6e..86023cb45 100644 --- a/api/api/cluster.pending_tasks.js +++ b/api/api/cluster.pending_tasks.js @@ -59,14 +59,6 @@ function buildClusterPendingTasks (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - clusterPendingTasks(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cluster.put_settings.js b/api/api/cluster.put_settings.js index 256c4e291..110a5bf21 100644 --- a/api/api/cluster.put_settings.js +++ b/api/api/cluster.put_settings.js @@ -63,14 +63,6 @@ function buildClusterPutSettings (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - clusterPutSettings(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/cluster.remote_info.js b/api/api/cluster.remote_info.js index c30698370..93ba95308 100644 --- a/api/api/cluster.remote_info.js +++ b/api/api/cluster.remote_info.js @@ -54,14 +54,6 @@ function buildClusterRemoteInfo (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - clusterRemoteInfo(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cluster.reroute.js b/api/api/cluster.reroute.js index 7ee098d41..160b6b5b4 100644 --- a/api/api/cluster.reroute.js +++ b/api/api/cluster.reroute.js @@ -70,14 +70,6 @@ function buildClusterReroute (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - clusterReroute(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { diff --git a/api/api/cluster.state.js b/api/api/cluster.state.js index 3e63f2b57..91f68781c 100644 --- a/api/api/cluster.state.js +++ b/api/api/cluster.state.js @@ -79,14 +79,6 @@ function buildClusterState (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - clusterState(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/cluster.stats.js b/api/api/cluster.stats.js index 2c35519a9..a07b2a324 100644 --- a/api/api/cluster.stats.js +++ b/api/api/cluster.stats.js @@ -60,14 +60,6 @@ function buildClusterStats (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - clusterStats(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/count.js b/api/api/count.js index 5cba924c2..9dd09c294 100644 --- a/api/api/count.js +++ b/api/api/count.js @@ -93,14 +93,6 @@ function buildCount (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - count(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required url components if (params['type'] != null && (params['index'] == null)) { diff --git a/api/api/create.js b/api/api/create.js index 15047c9bc..eb18d517b 100644 --- a/api/api/create.js +++ b/api/api/create.js @@ -76,14 +76,6 @@ function buildCreate (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - create(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['id'] == null) { diff --git a/api/api/delete.js b/api/api/delete.js index f19ea699c..db3e90b35 100644 --- a/api/api/delete.js +++ b/api/api/delete.js @@ -79,14 +79,6 @@ function buildDelete (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - _delete(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['id'] == null) { diff --git a/api/api/delete_by_query.js b/api/api/delete_by_query.js index 8ee94a0ea..559bcd201 100644 --- a/api/api/delete_by_query.js +++ b/api/api/delete_by_query.js @@ -136,14 +136,6 @@ function buildDeleteByQuery (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - deleteByQuery(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/delete_by_query_rethrottle.js b/api/api/delete_by_query_rethrottle.js index b85f8ce49..3d9cb752f 100644 --- a/api/api/delete_by_query_rethrottle.js +++ b/api/api/delete_by_query_rethrottle.js @@ -58,14 +58,6 @@ function buildDeleteByQueryRethrottle (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - deleteByQueryRethrottle(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['task_id'] == null && params['taskId'] == null) { diff --git a/api/api/delete_script.js b/api/api/delete_script.js index 53e126116..fed63e09d 100644 --- a/api/api/delete_script.js +++ b/api/api/delete_script.js @@ -60,14 +60,6 @@ function buildDeleteScript (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - deleteScript(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['id'] == null) { diff --git a/api/api/exists.js b/api/api/exists.js index 42a614052..58dba35b1 100644 --- a/api/api/exists.js +++ b/api/api/exists.js @@ -83,14 +83,6 @@ function buildExists (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - exists(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['id'] == null) { diff --git a/api/api/exists_source.js b/api/api/exists_source.js index e41c6bd03..a4280b7eb 100644 --- a/api/api/exists_source.js +++ b/api/api/exists_source.js @@ -80,14 +80,6 @@ function buildExistsSource (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - existsSource(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['id'] == null) { diff --git a/api/api/explain.js b/api/api/explain.js index a99f97bdb..cdba2dc5c 100644 --- a/api/api/explain.js +++ b/api/api/explain.js @@ -89,14 +89,6 @@ function buildExplain (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - explain(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['id'] == null) { diff --git a/api/api/field_caps.js b/api/api/field_caps.js index 29e4d12f5..79f2ad7be 100644 --- a/api/api/field_caps.js +++ b/api/api/field_caps.js @@ -66,14 +66,6 @@ function buildFieldCaps (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - fieldCaps(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/get.js b/api/api/get.js index 632db9a58..af04e37c5 100644 --- a/api/api/get.js +++ b/api/api/get.js @@ -89,14 +89,6 @@ function buildGet (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - get(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['id'] == null) { diff --git a/api/api/get_script.js b/api/api/get_script.js index d128ca89e..ef873a5ee 100644 --- a/api/api/get_script.js +++ b/api/api/get_script.js @@ -58,14 +58,6 @@ function buildGetScript (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - getScript(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['id'] == null) { diff --git a/api/api/get_source.js b/api/api/get_source.js index 376441dd6..18ad2e4e6 100644 --- a/api/api/get_source.js +++ b/api/api/get_source.js @@ -80,14 +80,6 @@ function buildGetSource (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - getSource(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['id'] == null) { diff --git a/api/api/ilm.delete_lifecycle.js b/api/api/ilm.delete_lifecycle.js index 181d51ee5..8d2c2b6b5 100644 --- a/api/api/ilm.delete_lifecycle.js +++ b/api/api/ilm.delete_lifecycle.js @@ -50,14 +50,6 @@ function buildIlmDeleteLifecycle (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ilmDeleteLifecycle(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/ilm.explain_lifecycle.js b/api/api/ilm.explain_lifecycle.js index 34c645f8d..377959873 100644 --- a/api/api/ilm.explain_lifecycle.js +++ b/api/api/ilm.explain_lifecycle.js @@ -51,14 +51,6 @@ function buildIlmExplainLifecycle (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ilmExplainLifecycle(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/ilm.get_lifecycle.js b/api/api/ilm.get_lifecycle.js index 8d95641e0..d4aea2190 100644 --- a/api/api/ilm.get_lifecycle.js +++ b/api/api/ilm.get_lifecycle.js @@ -50,14 +50,6 @@ function buildIlmGetLifecycle (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ilmGetLifecycle(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/ilm.get_status.js b/api/api/ilm.get_status.js index 1e413b795..38df25c38 100644 --- a/api/api/ilm.get_status.js +++ b/api/api/ilm.get_status.js @@ -49,14 +49,6 @@ function buildIlmGetStatus (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ilmGetStatus(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/ilm.move_to_step.js b/api/api/ilm.move_to_step.js index 1e8ce0fd2..0f6b9274f 100644 --- a/api/api/ilm.move_to_step.js +++ b/api/api/ilm.move_to_step.js @@ -51,14 +51,6 @@ function buildIlmMoveToStep (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ilmMoveToStep(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { diff --git a/api/api/ilm.put_lifecycle.js b/api/api/ilm.put_lifecycle.js index eaa4090fd..de148ad62 100644 --- a/api/api/ilm.put_lifecycle.js +++ b/api/api/ilm.put_lifecycle.js @@ -51,14 +51,6 @@ function buildIlmPutLifecycle (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ilmPutLifecycle(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { diff --git a/api/api/ilm.remove_policy.js b/api/api/ilm.remove_policy.js index 243ed1b9c..f0258c29c 100644 --- a/api/api/ilm.remove_policy.js +++ b/api/api/ilm.remove_policy.js @@ -50,14 +50,6 @@ function buildIlmRemovePolicy (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ilmRemovePolicy(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/ilm.retry.js b/api/api/ilm.retry.js index 14eaea055..6568a0a40 100644 --- a/api/api/ilm.retry.js +++ b/api/api/ilm.retry.js @@ -50,14 +50,6 @@ function buildIlmRetry (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ilmRetry(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/ilm.start.js b/api/api/ilm.start.js index 50eeecfc6..840700141 100644 --- a/api/api/ilm.start.js +++ b/api/api/ilm.start.js @@ -49,14 +49,6 @@ function buildIlmStart (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ilmStart(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/ilm.stop.js b/api/api/ilm.stop.js index 946ef8a13..166ed28b1 100644 --- a/api/api/ilm.stop.js +++ b/api/api/ilm.stop.js @@ -49,14 +49,6 @@ function buildIlmStop (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ilmStop(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/index.js b/api/api/index.js index 99d742324..213b41ac5 100644 --- a/api/api/index.js +++ b/api/api/index.js @@ -85,14 +85,6 @@ function buildIndex (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - _index(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/indices.analyze.js b/api/api/indices.analyze.js index b922171ee..b4d697bc8 100644 --- a/api/api/indices.analyze.js +++ b/api/api/indices.analyze.js @@ -58,14 +58,6 @@ function buildIndicesAnalyze (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesAnalyze(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { diff --git a/api/api/indices.clear_cache.js b/api/api/indices.clear_cache.js index f3d17a8c0..2d6b3be6b 100644 --- a/api/api/indices.clear_cache.js +++ b/api/api/indices.clear_cache.js @@ -74,14 +74,6 @@ function buildIndicesClearCache (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesClearCache(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/indices.close.js b/api/api/indices.close.js index 855814b75..46a92f3a9 100644 --- a/api/api/indices.close.js +++ b/api/api/indices.close.js @@ -69,14 +69,6 @@ function buildIndicesClose (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesClose(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/indices.create.js b/api/api/indices.create.js index e22a3ff3f..fadcb4981 100644 --- a/api/api/indices.create.js +++ b/api/api/indices.create.js @@ -67,14 +67,6 @@ function buildIndicesCreate (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesCreate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/indices.delete.js b/api/api/indices.delete.js index f9da306fb..5a48c7794 100644 --- a/api/api/indices.delete.js +++ b/api/api/indices.delete.js @@ -69,14 +69,6 @@ function buildIndicesDelete (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesDelete(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/indices.delete_alias.js b/api/api/indices.delete_alias.js index c4f043368..5b57fbb63 100644 --- a/api/api/indices.delete_alias.js +++ b/api/api/indices.delete_alias.js @@ -61,14 +61,6 @@ function buildIndicesDeleteAlias (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesDeleteAlias(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/indices.delete_template.js b/api/api/indices.delete_template.js index 0c4d351dc..a7fb0aca5 100644 --- a/api/api/indices.delete_template.js +++ b/api/api/indices.delete_template.js @@ -60,14 +60,6 @@ function buildIndicesDeleteTemplate (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesDeleteTemplate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['name'] == null) { diff --git a/api/api/indices.exists.js b/api/api/indices.exists.js index e92b1eb63..a25cea993 100644 --- a/api/api/indices.exists.js +++ b/api/api/indices.exists.js @@ -72,14 +72,6 @@ function buildIndicesExists (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesExists(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/indices.exists_alias.js b/api/api/indices.exists_alias.js index cb76b7dd6..9a5de4520 100644 --- a/api/api/indices.exists_alias.js +++ b/api/api/indices.exists_alias.js @@ -67,14 +67,6 @@ function buildIndicesExistsAlias (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesExistsAlias(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['name'] == null) { diff --git a/api/api/indices.exists_template.js b/api/api/indices.exists_template.js index 6de62dc57..52f0ab596 100644 --- a/api/api/indices.exists_template.js +++ b/api/api/indices.exists_template.js @@ -63,14 +63,6 @@ function buildIndicesExistsTemplate (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesExistsTemplate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['name'] == null) { diff --git a/api/api/indices.exists_type.js b/api/api/indices.exists_type.js index c36e59af2..120f27f14 100644 --- a/api/api/indices.exists_type.js +++ b/api/api/indices.exists_type.js @@ -67,14 +67,6 @@ function buildIndicesExistsType (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesExistsType(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/indices.flush.js b/api/api/indices.flush.js index a50c12ec0..854665f33 100644 --- a/api/api/indices.flush.js +++ b/api/api/indices.flush.js @@ -69,14 +69,6 @@ function buildIndicesFlush (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesFlush(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/indices.flush_synced.js b/api/api/indices.flush_synced.js index 838f7d6ad..ca4fa36f6 100644 --- a/api/api/indices.flush_synced.js +++ b/api/api/indices.flush_synced.js @@ -64,14 +64,6 @@ function buildIndicesFlushSynced (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesFlushSynced(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/indices.forcemerge.js b/api/api/indices.forcemerge.js index ec60e5376..e4616ab7e 100644 --- a/api/api/indices.forcemerge.js +++ b/api/api/indices.forcemerge.js @@ -72,14 +72,6 @@ function buildIndicesForcemerge (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesForcemerge(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/indices.freeze.js b/api/api/indices.freeze.js index 2017ff35d..bc2745c56 100644 --- a/api/api/indices.freeze.js +++ b/api/api/indices.freeze.js @@ -65,14 +65,6 @@ function buildIndicesFreeze (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesFreeze(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/indices.get.js b/api/api/indices.get.js index 01ffba1b9..bfcefdf9b 100644 --- a/api/api/indices.get.js +++ b/api/api/indices.get.js @@ -78,14 +78,6 @@ function buildIndicesGet (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesGet(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/indices.get_alias.js b/api/api/indices.get_alias.js index a19719224..e0e06505d 100644 --- a/api/api/indices.get_alias.js +++ b/api/api/indices.get_alias.js @@ -67,14 +67,6 @@ function buildIndicesGetAlias (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesGetAlias(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/indices.get_field_mapping.js b/api/api/indices.get_field_mapping.js index ef9ada9a2..f4b3e968c 100644 --- a/api/api/indices.get_field_mapping.js +++ b/api/api/indices.get_field_mapping.js @@ -74,14 +74,6 @@ function buildIndicesGetFieldMapping (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesGetFieldMapping(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['fields'] == null) { diff --git a/api/api/indices.get_mapping.js b/api/api/indices.get_mapping.js index dbee4ed06..1f2f2b5d9 100644 --- a/api/api/indices.get_mapping.js +++ b/api/api/indices.get_mapping.js @@ -73,14 +73,6 @@ function buildIndicesGetMapping (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesGetMapping(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/indices.get_settings.js b/api/api/indices.get_settings.js index b52171127..6e444f08e 100644 --- a/api/api/indices.get_settings.js +++ b/api/api/indices.get_settings.js @@ -76,14 +76,6 @@ function buildIndicesGetSettings (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesGetSettings(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/indices.get_template.js b/api/api/indices.get_template.js index 144e913e6..58fb3d83a 100644 --- a/api/api/indices.get_template.js +++ b/api/api/indices.get_template.js @@ -66,14 +66,6 @@ function buildIndicesGetTemplate (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesGetTemplate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/indices.get_upgrade.js b/api/api/indices.get_upgrade.js index a452ad1bb..a2b34458b 100644 --- a/api/api/indices.get_upgrade.js +++ b/api/api/indices.get_upgrade.js @@ -64,14 +64,6 @@ function buildIndicesGetUpgrade (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesGetUpgrade(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/indices.open.js b/api/api/indices.open.js index e57a4bbca..b71427566 100644 --- a/api/api/indices.open.js +++ b/api/api/indices.open.js @@ -72,14 +72,6 @@ function buildIndicesOpen (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesOpen(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/indices.put_alias.js b/api/api/indices.put_alias.js index 8a5b4f9da..7e5566d44 100644 --- a/api/api/indices.put_alias.js +++ b/api/api/indices.put_alias.js @@ -62,14 +62,6 @@ function buildIndicesPutAlias (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesPutAlias(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/indices.put_mapping.js b/api/api/indices.put_mapping.js index 1c6e59893..da3c84df6 100644 --- a/api/api/indices.put_mapping.js +++ b/api/api/indices.put_mapping.js @@ -74,14 +74,6 @@ function buildIndicesPutMapping (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesPutMapping(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/indices.put_settings.js b/api/api/indices.put_settings.js index a98dea7f4..6fa62c36e 100644 --- a/api/api/indices.put_settings.js +++ b/api/api/indices.put_settings.js @@ -76,14 +76,6 @@ function buildIndicesPutSettings (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesPutSettings(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/indices.put_template.js b/api/api/indices.put_template.js index 0c82f6ef8..55157756a 100644 --- a/api/api/indices.put_template.js +++ b/api/api/indices.put_template.js @@ -71,14 +71,6 @@ function buildIndicesPutTemplate (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesPutTemplate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['name'] == null) { diff --git a/api/api/indices.recovery.js b/api/api/indices.recovery.js index 2cae29bbf..9fbb6c4ed 100644 --- a/api/api/indices.recovery.js +++ b/api/api/indices.recovery.js @@ -60,14 +60,6 @@ function buildIndicesRecovery (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesRecovery(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/indices.refresh.js b/api/api/indices.refresh.js index 5f136a12d..87cbb843d 100644 --- a/api/api/indices.refresh.js +++ b/api/api/indices.refresh.js @@ -64,14 +64,6 @@ function buildIndicesRefresh (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesRefresh(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/indices.rollover.js b/api/api/indices.rollover.js index 4e8dbd7ea..a2ad11201 100644 --- a/api/api/indices.rollover.js +++ b/api/api/indices.rollover.js @@ -71,14 +71,6 @@ function buildIndicesRollover (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesRollover(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['alias'] == null) { diff --git a/api/api/indices.segments.js b/api/api/indices.segments.js index 706df722c..cc1be5728 100644 --- a/api/api/indices.segments.js +++ b/api/api/indices.segments.js @@ -66,14 +66,6 @@ function buildIndicesSegments (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesSegments(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/indices.shard_stores.js b/api/api/indices.shard_stores.js index 12a04e792..8add1c770 100644 --- a/api/api/indices.shard_stores.js +++ b/api/api/indices.shard_stores.js @@ -66,14 +66,6 @@ function buildIndicesShardStores (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesShardStores(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/indices.shrink.js b/api/api/indices.shrink.js index ff001b6c5..3693be4d1 100644 --- a/api/api/indices.shrink.js +++ b/api/api/indices.shrink.js @@ -68,14 +68,6 @@ function buildIndicesShrink (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesShrink(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/indices.split.js b/api/api/indices.split.js index fc023cdd2..26b6cefd6 100644 --- a/api/api/indices.split.js +++ b/api/api/indices.split.js @@ -68,14 +68,6 @@ function buildIndicesSplit (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesSplit(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/indices.stats.js b/api/api/indices.stats.js index a199b3cdf..3c0b0906f 100644 --- a/api/api/indices.stats.js +++ b/api/api/indices.stats.js @@ -73,14 +73,6 @@ function buildIndicesStats (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesStats(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/indices.unfreeze.js b/api/api/indices.unfreeze.js index cb2caca29..7c40fb726 100644 --- a/api/api/indices.unfreeze.js +++ b/api/api/indices.unfreeze.js @@ -65,14 +65,6 @@ function buildIndicesUnfreeze (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesUnfreeze(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/indices.update_aliases.js b/api/api/indices.update_aliases.js index f5fb51d99..2d9dd6f15 100644 --- a/api/api/indices.update_aliases.js +++ b/api/api/indices.update_aliases.js @@ -60,14 +60,6 @@ function buildIndicesUpdateAliases (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesUpdateAliases(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/indices.upgrade.js b/api/api/indices.upgrade.js index f2c1b3bcb..6a16b1691 100644 --- a/api/api/indices.upgrade.js +++ b/api/api/indices.upgrade.js @@ -70,14 +70,6 @@ function buildIndicesUpgrade (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesUpgrade(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/indices.validate_query.js b/api/api/indices.validate_query.js index 16197340b..813358340 100644 --- a/api/api/indices.validate_query.js +++ b/api/api/indices.validate_query.js @@ -87,14 +87,6 @@ function buildIndicesValidateQuery (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesValidateQuery(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required url components if (params['type'] != null && (params['index'] == null)) { diff --git a/api/api/info.js b/api/api/info.js index 6a9eea357..95e6c55f7 100644 --- a/api/api/info.js +++ b/api/api/info.js @@ -54,14 +54,6 @@ function buildInfo (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - info(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/ingest.delete_pipeline.js b/api/api/ingest.delete_pipeline.js index 8bda91d4b..303c02ae1 100644 --- a/api/api/ingest.delete_pipeline.js +++ b/api/api/ingest.delete_pipeline.js @@ -60,14 +60,6 @@ function buildIngestDeletePipeline (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ingestDeletePipeline(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['id'] == null) { diff --git a/api/api/ingest.get_pipeline.js b/api/api/ingest.get_pipeline.js index 3a087b52e..2a6aa3938 100644 --- a/api/api/ingest.get_pipeline.js +++ b/api/api/ingest.get_pipeline.js @@ -58,14 +58,6 @@ function buildIngestGetPipeline (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ingestGetPipeline(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/ingest.processor_grok.js b/api/api/ingest.processor_grok.js index ac3e50156..d5b47b3d6 100644 --- a/api/api/ingest.processor_grok.js +++ b/api/api/ingest.processor_grok.js @@ -54,14 +54,6 @@ function buildIngestProcessorGrok (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ingestProcessorGrok(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/ingest.put_pipeline.js b/api/api/ingest.put_pipeline.js index 124995cea..13dc50ff3 100644 --- a/api/api/ingest.put_pipeline.js +++ b/api/api/ingest.put_pipeline.js @@ -61,14 +61,6 @@ function buildIngestPutPipeline (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ingestPutPipeline(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['id'] == null) { diff --git a/api/api/ingest.simulate.js b/api/api/ingest.simulate.js index 3f84a53c3..4d8c299f3 100644 --- a/api/api/ingest.simulate.js +++ b/api/api/ingest.simulate.js @@ -58,14 +58,6 @@ function buildIngestSimulate (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ingestSimulate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/mget.js b/api/api/mget.js index 7f723bf27..5857ca38c 100644 --- a/api/api/mget.js +++ b/api/api/mget.js @@ -76,14 +76,6 @@ function buildMget (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mget(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/ml.close_job.js b/api/api/ml.close_job.js index 9074eba30..1b923f530 100644 --- a/api/api/ml.close_job.js +++ b/api/api/ml.close_job.js @@ -57,14 +57,6 @@ function buildMlCloseJob (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlCloseJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['job_id'] == null && params['jobId'] == null) { diff --git a/api/api/ml.delete_calendar.js b/api/api/ml.delete_calendar.js index 4a8a37d8b..2e270a081 100644 --- a/api/api/ml.delete_calendar.js +++ b/api/api/ml.delete_calendar.js @@ -50,14 +50,6 @@ function buildMlDeleteCalendar (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlDeleteCalendar(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['calendar_id'] == null && params['calendarId'] == null) { diff --git a/api/api/ml.delete_calendar_event.js b/api/api/ml.delete_calendar_event.js index b7df3155f..b08e2b8ff 100644 --- a/api/api/ml.delete_calendar_event.js +++ b/api/api/ml.delete_calendar_event.js @@ -51,14 +51,6 @@ function buildMlDeleteCalendarEvent (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlDeleteCalendarEvent(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['calendar_id'] == null && params['calendarId'] == null) { diff --git a/api/api/ml.delete_calendar_job.js b/api/api/ml.delete_calendar_job.js index f21d9ac6a..4db8a932a 100644 --- a/api/api/ml.delete_calendar_job.js +++ b/api/api/ml.delete_calendar_job.js @@ -51,14 +51,6 @@ function buildMlDeleteCalendarJob (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlDeleteCalendarJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['calendar_id'] == null && params['calendarId'] == null) { diff --git a/api/api/ml.delete_datafeed.js b/api/api/ml.delete_datafeed.js index 54a45a41a..4e51efca3 100644 --- a/api/api/ml.delete_datafeed.js +++ b/api/api/ml.delete_datafeed.js @@ -51,14 +51,6 @@ function buildMlDeleteDatafeed (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlDeleteDatafeed(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['datafeed_id'] == null && params['datafeedId'] == null) { diff --git a/api/api/ml.delete_expired_data.js b/api/api/ml.delete_expired_data.js index 0542e14c8..30ca5cadd 100644 --- a/api/api/ml.delete_expired_data.js +++ b/api/api/ml.delete_expired_data.js @@ -49,14 +49,6 @@ function buildMlDeleteExpiredData (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlDeleteExpiredData(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/ml.delete_filter.js b/api/api/ml.delete_filter.js index 6a5de9739..8a3218408 100644 --- a/api/api/ml.delete_filter.js +++ b/api/api/ml.delete_filter.js @@ -50,14 +50,6 @@ function buildMlDeleteFilter (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlDeleteFilter(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['filter_id'] == null && params['filterId'] == null) { diff --git a/api/api/ml.delete_forecast.js b/api/api/ml.delete_forecast.js index 9f198e4b5..85c5d9d80 100644 --- a/api/api/ml.delete_forecast.js +++ b/api/api/ml.delete_forecast.js @@ -55,14 +55,6 @@ function buildMlDeleteForecast (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlDeleteForecast(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['job_id'] == null && params['jobId'] == null) { diff --git a/api/api/ml.delete_job.js b/api/api/ml.delete_job.js index eaadee6a9..5b692d36b 100644 --- a/api/api/ml.delete_job.js +++ b/api/api/ml.delete_job.js @@ -53,14 +53,6 @@ function buildMlDeleteJob (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlDeleteJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['job_id'] == null && params['jobId'] == null) { diff --git a/api/api/ml.delete_model_snapshot.js b/api/api/ml.delete_model_snapshot.js index 4cf55a783..3a13c967c 100644 --- a/api/api/ml.delete_model_snapshot.js +++ b/api/api/ml.delete_model_snapshot.js @@ -51,14 +51,6 @@ function buildMlDeleteModelSnapshot (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlDeleteModelSnapshot(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['job_id'] == null && params['jobId'] == null) { diff --git a/api/api/ml.find_file_structure.js b/api/api/ml.find_file_structure.js index 7ffdeea43..c3cb5179f 100644 --- a/api/api/ml.find_file_structure.js +++ b/api/api/ml.find_file_structure.js @@ -82,14 +82,6 @@ function buildMlFindFileStructure (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlFindFileStructure(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/ml.flush_job.js b/api/api/ml.flush_job.js index 82a25e63f..b72f9395c 100644 --- a/api/api/ml.flush_job.js +++ b/api/api/ml.flush_job.js @@ -62,14 +62,6 @@ function buildMlFlushJob (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlFlushJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['job_id'] == null && params['jobId'] == null) { diff --git a/api/api/ml.forecast.js b/api/api/ml.forecast.js index 2a85d6098..65d03b5f8 100644 --- a/api/api/ml.forecast.js +++ b/api/api/ml.forecast.js @@ -53,14 +53,6 @@ function buildMlForecast (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlForecast(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['job_id'] == null && params['jobId'] == null) { diff --git a/api/api/ml.get_buckets.js b/api/api/ml.get_buckets.js index c366ce6ba..4d70ccb5f 100644 --- a/api/api/ml.get_buckets.js +++ b/api/api/ml.get_buckets.js @@ -71,14 +71,6 @@ function buildMlGetBuckets (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetBuckets(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['job_id'] == null && params['jobId'] == null) { diff --git a/api/api/ml.get_calendar_events.js b/api/api/ml.get_calendar_events.js index 5fd1ce5e8..bdc373d30 100644 --- a/api/api/ml.get_calendar_events.js +++ b/api/api/ml.get_calendar_events.js @@ -60,14 +60,6 @@ function buildMlGetCalendarEvents (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetCalendarEvents(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['calendar_id'] == null && params['calendarId'] == null) { diff --git a/api/api/ml.get_calendars.js b/api/api/ml.get_calendars.js index f1495d808..810145c7f 100644 --- a/api/api/ml.get_calendars.js +++ b/api/api/ml.get_calendars.js @@ -53,14 +53,6 @@ function buildMlGetCalendars (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetCalendars(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/ml.get_categories.js b/api/api/ml.get_categories.js index 7a4962025..47c203b3e 100644 --- a/api/api/ml.get_categories.js +++ b/api/api/ml.get_categories.js @@ -55,14 +55,6 @@ function buildMlGetCategories (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetCategories(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['job_id'] == null && params['jobId'] == null) { diff --git a/api/api/ml.get_datafeed_stats.js b/api/api/ml.get_datafeed_stats.js index ed8f750e2..97c8ea3c0 100644 --- a/api/api/ml.get_datafeed_stats.js +++ b/api/api/ml.get_datafeed_stats.js @@ -51,14 +51,6 @@ function buildMlGetDatafeedStats (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetDatafeedStats(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/ml.get_datafeeds.js b/api/api/ml.get_datafeeds.js index 222ebec71..ae88fb528 100644 --- a/api/api/ml.get_datafeeds.js +++ b/api/api/ml.get_datafeeds.js @@ -51,14 +51,6 @@ function buildMlGetDatafeeds (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetDatafeeds(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/ml.get_filters.js b/api/api/ml.get_filters.js index cc312e6dc..5666cf902 100644 --- a/api/api/ml.get_filters.js +++ b/api/api/ml.get_filters.js @@ -53,14 +53,6 @@ function buildMlGetFilters (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetFilters(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/ml.get_influencers.js b/api/api/ml.get_influencers.js index 9dcf9b4db..498f13d20 100644 --- a/api/api/ml.get_influencers.js +++ b/api/api/ml.get_influencers.js @@ -68,14 +68,6 @@ function buildMlGetInfluencers (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetInfluencers(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['job_id'] == null && params['jobId'] == null) { diff --git a/api/api/ml.get_job_stats.js b/api/api/ml.get_job_stats.js index 7f7d269ce..7c8e8b653 100644 --- a/api/api/ml.get_job_stats.js +++ b/api/api/ml.get_job_stats.js @@ -51,14 +51,6 @@ function buildMlGetJobStats (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetJobStats(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/ml.get_jobs.js b/api/api/ml.get_jobs.js index 045fb72a6..fcb8734c7 100644 --- a/api/api/ml.get_jobs.js +++ b/api/api/ml.get_jobs.js @@ -51,14 +51,6 @@ function buildMlGetJobs (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetJobs(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/ml.get_model_snapshots.js b/api/api/ml.get_model_snapshots.js index 0c47346c9..f9b2aae7d 100644 --- a/api/api/ml.get_model_snapshots.js +++ b/api/api/ml.get_model_snapshots.js @@ -63,14 +63,6 @@ function buildMlGetModelSnapshots (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetModelSnapshots(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['job_id'] == null && params['jobId'] == null) { diff --git a/api/api/ml.get_overall_buckets.js b/api/api/ml.get_overall_buckets.js index c6a2ec4b5..d5e647590 100644 --- a/api/api/ml.get_overall_buckets.js +++ b/api/api/ml.get_overall_buckets.js @@ -68,14 +68,6 @@ function buildMlGetOverallBuckets (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetOverallBuckets(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['job_id'] == null && params['jobId'] == null) { diff --git a/api/api/ml.get_records.js b/api/api/ml.get_records.js index fd1608283..e38213f0f 100644 --- a/api/api/ml.get_records.js +++ b/api/api/ml.get_records.js @@ -68,14 +68,6 @@ function buildMlGetRecords (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetRecords(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['job_id'] == null && params['jobId'] == null) { diff --git a/api/api/ml.info.js b/api/api/ml.info.js index db91bad09..55c7c9e0e 100644 --- a/api/api/ml.info.js +++ b/api/api/ml.info.js @@ -49,14 +49,6 @@ function buildMlInfo (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlInfo(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { diff --git a/api/api/ml.open_job.js b/api/api/ml.open_job.js index b3ea5cf40..81f92ae12 100644 --- a/api/api/ml.open_job.js +++ b/api/api/ml.open_job.js @@ -52,14 +52,6 @@ function buildMlOpenJob (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlOpenJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['job_id'] == null && params['jobId'] == null) { diff --git a/api/api/ml.post_calendar_events.js b/api/api/ml.post_calendar_events.js index 58fea906c..a99b009da 100644 --- a/api/api/ml.post_calendar_events.js +++ b/api/api/ml.post_calendar_events.js @@ -51,14 +51,6 @@ function buildMlPostCalendarEvents (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlPostCalendarEvents(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['calendar_id'] == null && params['calendarId'] == null) { diff --git a/api/api/ml.post_data.js b/api/api/ml.post_data.js index bde273e14..702ad50a2 100644 --- a/api/api/ml.post_data.js +++ b/api/api/ml.post_data.js @@ -55,14 +55,6 @@ function buildMlPostData (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlPostData(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['job_id'] == null && params['jobId'] == null) { diff --git a/api/api/ml.preview_datafeed.js b/api/api/ml.preview_datafeed.js index 90fb528e3..c7b68045c 100644 --- a/api/api/ml.preview_datafeed.js +++ b/api/api/ml.preview_datafeed.js @@ -50,14 +50,6 @@ function buildMlPreviewDatafeed (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlPreviewDatafeed(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['datafeed_id'] == null && params['datafeedId'] == null) { diff --git a/api/api/ml.put_calendar.js b/api/api/ml.put_calendar.js index c3a7a716b..a47f770ce 100644 --- a/api/api/ml.put_calendar.js +++ b/api/api/ml.put_calendar.js @@ -51,14 +51,6 @@ function buildMlPutCalendar (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlPutCalendar(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['calendar_id'] == null && params['calendarId'] == null) { diff --git a/api/api/ml.put_calendar_job.js b/api/api/ml.put_calendar_job.js index 41000c788..7c23f126f 100644 --- a/api/api/ml.put_calendar_job.js +++ b/api/api/ml.put_calendar_job.js @@ -51,14 +51,6 @@ function buildMlPutCalendarJob (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlPutCalendarJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['calendar_id'] == null && params['calendarId'] == null) { diff --git a/api/api/ml.put_datafeed.js b/api/api/ml.put_datafeed.js index cb61c97bd..4a6856c83 100644 --- a/api/api/ml.put_datafeed.js +++ b/api/api/ml.put_datafeed.js @@ -51,14 +51,6 @@ function buildMlPutDatafeed (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlPutDatafeed(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['datafeed_id'] == null && params['datafeedId'] == null) { diff --git a/api/api/ml.put_filter.js b/api/api/ml.put_filter.js index e2b4a71f5..63d2b3ec9 100644 --- a/api/api/ml.put_filter.js +++ b/api/api/ml.put_filter.js @@ -51,14 +51,6 @@ function buildMlPutFilter (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlPutFilter(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['filter_id'] == null && params['filterId'] == null) { diff --git a/api/api/ml.put_job.js b/api/api/ml.put_job.js index 8d1a546f1..f5f363974 100644 --- a/api/api/ml.put_job.js +++ b/api/api/ml.put_job.js @@ -51,14 +51,6 @@ function buildMlPutJob (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlPutJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['job_id'] == null && params['jobId'] == null) { diff --git a/api/api/ml.revert_model_snapshot.js b/api/api/ml.revert_model_snapshot.js index 4a0266db9..81a70e0db 100644 --- a/api/api/ml.revert_model_snapshot.js +++ b/api/api/ml.revert_model_snapshot.js @@ -53,14 +53,6 @@ function buildMlRevertModelSnapshot (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlRevertModelSnapshot(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['job_id'] == null && params['jobId'] == null) { diff --git a/api/api/ml.set_upgrade_mode.js b/api/api/ml.set_upgrade_mode.js index 52895ccf5..cd95163a2 100644 --- a/api/api/ml.set_upgrade_mode.js +++ b/api/api/ml.set_upgrade_mode.js @@ -52,14 +52,6 @@ function buildMlSetUpgradeMode (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlSetUpgradeMode(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/ml.start_datafeed.js b/api/api/ml.start_datafeed.js index 2bd084273..1ca6a7362 100644 --- a/api/api/ml.start_datafeed.js +++ b/api/api/ml.start_datafeed.js @@ -56,14 +56,6 @@ function buildMlStartDatafeed (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlStartDatafeed(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['datafeed_id'] == null && params['datafeedId'] == null) { diff --git a/api/api/ml.stop_datafeed.js b/api/api/ml.stop_datafeed.js index 981a41836..13515e966 100644 --- a/api/api/ml.stop_datafeed.js +++ b/api/api/ml.stop_datafeed.js @@ -56,14 +56,6 @@ function buildMlStopDatafeed (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlStopDatafeed(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['datafeed_id'] == null && params['datafeedId'] == null) { diff --git a/api/api/ml.update_datafeed.js b/api/api/ml.update_datafeed.js index 9fb428ef5..e2e800fa2 100644 --- a/api/api/ml.update_datafeed.js +++ b/api/api/ml.update_datafeed.js @@ -51,14 +51,6 @@ function buildMlUpdateDatafeed (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlUpdateDatafeed(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['datafeed_id'] == null && params['datafeedId'] == null) { diff --git a/api/api/ml.update_filter.js b/api/api/ml.update_filter.js index c6c894cc5..b50f1cc3a 100644 --- a/api/api/ml.update_filter.js +++ b/api/api/ml.update_filter.js @@ -51,14 +51,6 @@ function buildMlUpdateFilter (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlUpdateFilter(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['filter_id'] == null && params['filterId'] == null) { diff --git a/api/api/ml.update_job.js b/api/api/ml.update_job.js index 34567cf42..f315e41af 100644 --- a/api/api/ml.update_job.js +++ b/api/api/ml.update_job.js @@ -51,14 +51,6 @@ function buildMlUpdateJob (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlUpdateJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['job_id'] == null && params['jobId'] == null) { diff --git a/api/api/ml.update_model_snapshot.js b/api/api/ml.update_model_snapshot.js index 938efb3d8..7d44400e5 100644 --- a/api/api/ml.update_model_snapshot.js +++ b/api/api/ml.update_model_snapshot.js @@ -52,14 +52,6 @@ function buildMlUpdateModelSnapshot (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlUpdateModelSnapshot(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['job_id'] == null && params['jobId'] == null) { diff --git a/api/api/ml.validate.js b/api/api/ml.validate.js index ab3767300..2f1401f3e 100644 --- a/api/api/ml.validate.js +++ b/api/api/ml.validate.js @@ -50,14 +50,6 @@ function buildMlValidate (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlValidate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/ml.validate_detector.js b/api/api/ml.validate_detector.js index 9041daa51..07570ddc6 100644 --- a/api/api/ml.validate_detector.js +++ b/api/api/ml.validate_detector.js @@ -50,14 +50,6 @@ function buildMlValidateDetector (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlValidateDetector(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/monitoring.bulk.js b/api/api/monitoring.bulk.js index 12b969770..082c26acb 100644 --- a/api/api/monitoring.bulk.js +++ b/api/api/monitoring.bulk.js @@ -58,14 +58,6 @@ function buildMonitoringBulk (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - monitoringBulk(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/msearch.js b/api/api/msearch.js index 7c9e7572b..a10558174 100644 --- a/api/api/msearch.js +++ b/api/api/msearch.js @@ -78,14 +78,6 @@ function buildMsearch (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - msearch(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/msearch_template.js b/api/api/msearch_template.js index d5cf00668..5fd848d92 100644 --- a/api/api/msearch_template.js +++ b/api/api/msearch_template.js @@ -72,14 +72,6 @@ function buildMsearchTemplate (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - msearchTemplate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/mtermvectors.js b/api/api/mtermvectors.js index fe88cb988..ceb3a089c 100644 --- a/api/api/mtermvectors.js +++ b/api/api/mtermvectors.js @@ -86,14 +86,6 @@ function buildMtermvectors (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mtermvectors(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required url components if (params['type'] != null && (params['index'] == null)) { diff --git a/api/api/nodes.hot_threads.js b/api/api/nodes.hot_threads.js index 44bd8dc3a..e78ea5213 100644 --- a/api/api/nodes.hot_threads.js +++ b/api/api/nodes.hot_threads.js @@ -68,14 +68,6 @@ function buildNodesHotThreads (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - nodesHotThreads(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/nodes.info.js b/api/api/nodes.info.js index b4ef6b8e1..41cbd98ce 100644 --- a/api/api/nodes.info.js +++ b/api/api/nodes.info.js @@ -61,14 +61,6 @@ function buildNodesInfo (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - nodesInfo(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/nodes.reload_secure_settings.js b/api/api/nodes.reload_secure_settings.js index dc185a7c9..a9fee39e7 100644 --- a/api/api/nodes.reload_secure_settings.js +++ b/api/api/nodes.reload_secure_settings.js @@ -57,14 +57,6 @@ function buildNodesReloadSecureSettings (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - nodesReloadSecureSettings(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/nodes.stats.js b/api/api/nodes.stats.js index 0ca0ac3af..f84e583de 100644 --- a/api/api/nodes.stats.js +++ b/api/api/nodes.stats.js @@ -76,14 +76,6 @@ function buildNodesStats (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - nodesStats(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/nodes.usage.js b/api/api/nodes.usage.js index a7edd6912..783066665 100644 --- a/api/api/nodes.usage.js +++ b/api/api/nodes.usage.js @@ -58,14 +58,6 @@ function buildNodesUsage (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - nodesUsage(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/ping.js b/api/api/ping.js index 92e3f970b..e696c1568 100644 --- a/api/api/ping.js +++ b/api/api/ping.js @@ -54,14 +54,6 @@ function buildPing (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ping(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/put_script.js b/api/api/put_script.js index db75d91cf..993e2130e 100644 --- a/api/api/put_script.js +++ b/api/api/put_script.js @@ -64,14 +64,6 @@ function buildPutScript (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - putScript(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['id'] == null) { diff --git a/api/api/rank_eval.js b/api/api/rank_eval.js index e92f7e316..e3c3f39dc 100644 --- a/api/api/rank_eval.js +++ b/api/api/rank_eval.js @@ -65,14 +65,6 @@ function buildRankEval (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - rankEval(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/reindex.js b/api/api/reindex.js index 357f98875..535fc265e 100644 --- a/api/api/reindex.js +++ b/api/api/reindex.js @@ -70,14 +70,6 @@ function buildReindex (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - reindex(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/reindex_rethrottle.js b/api/api/reindex_rethrottle.js index 44e14ffcf..4bdf99863 100644 --- a/api/api/reindex_rethrottle.js +++ b/api/api/reindex_rethrottle.js @@ -58,14 +58,6 @@ function buildReindexRethrottle (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - reindexRethrottle(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['task_id'] == null && params['taskId'] == null) { diff --git a/api/api/render_search_template.js b/api/api/render_search_template.js index f3404c6b4..8936dc4f9 100644 --- a/api/api/render_search_template.js +++ b/api/api/render_search_template.js @@ -56,14 +56,6 @@ function buildRenderSearchTemplate (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - renderSearchTemplate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { diff --git a/api/api/scripts_painless_execute.js b/api/api/scripts_painless_execute.js index bed28d199..0a0a8ae25 100644 --- a/api/api/scripts_painless_execute.js +++ b/api/api/scripts_painless_execute.js @@ -55,14 +55,6 @@ function buildScriptsPainlessExecute (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - scriptsPainlessExecute(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { diff --git a/api/api/scroll.js b/api/api/scroll.js index a0df2513c..beff548d2 100644 --- a/api/api/scroll.js +++ b/api/api/scroll.js @@ -64,14 +64,6 @@ function buildScroll (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - scroll(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { diff --git a/api/api/search.js b/api/api/search.js index fc74cb5e9..e5b3cdfa9 100644 --- a/api/api/search.js +++ b/api/api/search.js @@ -168,14 +168,6 @@ function buildSearch (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - search(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required url components if (params['type'] != null && (params['index'] == null)) { diff --git a/api/api/search_shards.js b/api/api/search_shards.js index dd0b89496..4ae9034ad 100644 --- a/api/api/search_shards.js +++ b/api/api/search_shards.js @@ -70,14 +70,6 @@ function buildSearchShards (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - searchShards(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/search_template.js b/api/api/search_template.js index f1b90ac28..466d669c1 100644 --- a/api/api/search_template.js +++ b/api/api/search_template.js @@ -91,14 +91,6 @@ function buildSearchTemplate (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - searchTemplate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/security.authenticate.js b/api/api/security.authenticate.js index d83a8967e..da504bdc4 100644 --- a/api/api/security.authenticate.js +++ b/api/api/security.authenticate.js @@ -49,14 +49,6 @@ function buildSecurityAuthenticate (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityAuthenticate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/security.change_password.js b/api/api/security.change_password.js index 053b3ddaa..569dbf449 100644 --- a/api/api/security.change_password.js +++ b/api/api/security.change_password.js @@ -52,14 +52,6 @@ function buildSecurityChangePassword (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityChangePassword(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/security.clear_cached_realms.js b/api/api/security.clear_cached_realms.js index 97e40cea6..97af5dcaf 100644 --- a/api/api/security.clear_cached_realms.js +++ b/api/api/security.clear_cached_realms.js @@ -51,14 +51,6 @@ function buildSecurityClearCachedRealms (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityClearCachedRealms(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['realms'] == null) { diff --git a/api/api/security.clear_cached_roles.js b/api/api/security.clear_cached_roles.js index efa455423..1741e5e1f 100644 --- a/api/api/security.clear_cached_roles.js +++ b/api/api/security.clear_cached_roles.js @@ -50,14 +50,6 @@ function buildSecurityClearCachedRoles (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityClearCachedRoles(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['name'] == null) { diff --git a/api/api/security.create_api_key.js b/api/api/security.create_api_key.js index d6d928716..b5dd7e597 100644 --- a/api/api/security.create_api_key.js +++ b/api/api/security.create_api_key.js @@ -51,14 +51,6 @@ function buildSecurityCreateApiKey (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityCreateApiKey(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/security.delete_privileges.js b/api/api/security.delete_privileges.js index 53dd69bb1..fa54275d3 100644 --- a/api/api/security.delete_privileges.js +++ b/api/api/security.delete_privileges.js @@ -52,14 +52,6 @@ function buildSecurityDeletePrivileges (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityDeletePrivileges(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['application'] == null) { diff --git a/api/api/security.delete_role.js b/api/api/security.delete_role.js index 5cb9a7856..f8046d046 100644 --- a/api/api/security.delete_role.js +++ b/api/api/security.delete_role.js @@ -51,14 +51,6 @@ function buildSecurityDeleteRole (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityDeleteRole(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['name'] == null) { diff --git a/api/api/security.delete_role_mapping.js b/api/api/security.delete_role_mapping.js index 4139ef209..269c7a87d 100644 --- a/api/api/security.delete_role_mapping.js +++ b/api/api/security.delete_role_mapping.js @@ -51,14 +51,6 @@ function buildSecurityDeleteRoleMapping (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityDeleteRoleMapping(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['name'] == null) { diff --git a/api/api/security.delete_user.js b/api/api/security.delete_user.js index 521c45e02..f89bb0fb9 100644 --- a/api/api/security.delete_user.js +++ b/api/api/security.delete_user.js @@ -51,14 +51,6 @@ function buildSecurityDeleteUser (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityDeleteUser(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['username'] == null) { diff --git a/api/api/security.disable_user.js b/api/api/security.disable_user.js index b1099099c..e7f1bccde 100644 --- a/api/api/security.disable_user.js +++ b/api/api/security.disable_user.js @@ -51,14 +51,6 @@ function buildSecurityDisableUser (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityDisableUser(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/security.enable_user.js b/api/api/security.enable_user.js index ff070099d..58a49c9d6 100644 --- a/api/api/security.enable_user.js +++ b/api/api/security.enable_user.js @@ -51,14 +51,6 @@ function buildSecurityEnableUser (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityEnableUser(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/security.get_api_key.js b/api/api/security.get_api_key.js index 0bfc2d550..4d3d97769 100644 --- a/api/api/security.get_api_key.js +++ b/api/api/security.get_api_key.js @@ -56,14 +56,6 @@ function buildSecurityGetApiKey (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityGetApiKey(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/security.get_privileges.js b/api/api/security.get_privileges.js index 78e2be06a..d285b6822 100644 --- a/api/api/security.get_privileges.js +++ b/api/api/security.get_privileges.js @@ -51,14 +51,6 @@ function buildSecurityGetPrivileges (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityGetPrivileges(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/security.get_role.js b/api/api/security.get_role.js index c652efd1f..24e2f384d 100644 --- a/api/api/security.get_role.js +++ b/api/api/security.get_role.js @@ -50,14 +50,6 @@ function buildSecurityGetRole (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityGetRole(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/security.get_role_mapping.js b/api/api/security.get_role_mapping.js index 93652ab6a..c56e81f8b 100644 --- a/api/api/security.get_role_mapping.js +++ b/api/api/security.get_role_mapping.js @@ -50,14 +50,6 @@ function buildSecurityGetRoleMapping (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityGetRoleMapping(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/security.get_token.js b/api/api/security.get_token.js index 41620b779..32ea01902 100644 --- a/api/api/security.get_token.js +++ b/api/api/security.get_token.js @@ -50,14 +50,6 @@ function buildSecurityGetToken (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityGetToken(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/security.get_user.js b/api/api/security.get_user.js index 23bfca1f2..6f29262a2 100644 --- a/api/api/security.get_user.js +++ b/api/api/security.get_user.js @@ -50,14 +50,6 @@ function buildSecurityGetUser (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityGetUser(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/security.get_user_privileges.js b/api/api/security.get_user_privileges.js index 560e07538..7a79ef740 100644 --- a/api/api/security.get_user_privileges.js +++ b/api/api/security.get_user_privileges.js @@ -49,14 +49,6 @@ function buildSecurityGetUserPrivileges (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityGetUserPrivileges(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/security.has_privileges.js b/api/api/security.has_privileges.js index 893604cc8..78987c6b8 100644 --- a/api/api/security.has_privileges.js +++ b/api/api/security.has_privileges.js @@ -51,14 +51,6 @@ function buildSecurityHasPrivileges (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityHasPrivileges(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/security.invalidate_api_key.js b/api/api/security.invalidate_api_key.js index 75428192b..1d4a7f877 100644 --- a/api/api/security.invalidate_api_key.js +++ b/api/api/security.invalidate_api_key.js @@ -50,14 +50,6 @@ function buildSecurityInvalidateApiKey (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityInvalidateApiKey(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/security.invalidate_token.js b/api/api/security.invalidate_token.js index 31e29f31a..fa2043b2c 100644 --- a/api/api/security.invalidate_token.js +++ b/api/api/security.invalidate_token.js @@ -50,14 +50,6 @@ function buildSecurityInvalidateToken (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityInvalidateToken(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/security.put_privileges.js b/api/api/security.put_privileges.js index 52d46d3c7..c08e9aa01 100644 --- a/api/api/security.put_privileges.js +++ b/api/api/security.put_privileges.js @@ -51,14 +51,6 @@ function buildSecurityPutPrivileges (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityPutPrivileges(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/security.put_role.js b/api/api/security.put_role.js index c4f284eb2..6bd851141 100644 --- a/api/api/security.put_role.js +++ b/api/api/security.put_role.js @@ -52,14 +52,6 @@ function buildSecurityPutRole (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityPutRole(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['name'] == null) { diff --git a/api/api/security.put_role_mapping.js b/api/api/security.put_role_mapping.js index 452bbe29a..c6450d155 100644 --- a/api/api/security.put_role_mapping.js +++ b/api/api/security.put_role_mapping.js @@ -52,14 +52,6 @@ function buildSecurityPutRoleMapping (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityPutRoleMapping(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['name'] == null) { diff --git a/api/api/security.put_user.js b/api/api/security.put_user.js index f47652fc4..16fb9182d 100644 --- a/api/api/security.put_user.js +++ b/api/api/security.put_user.js @@ -52,14 +52,6 @@ function buildSecurityPutUser (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityPutUser(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['username'] == null) { diff --git a/api/api/snapshot.create.js b/api/api/snapshot.create.js index e76b8414a..016a9fee6 100644 --- a/api/api/snapshot.create.js +++ b/api/api/snapshot.create.js @@ -63,14 +63,6 @@ function buildSnapshotCreate (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - snapshotCreate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['repository'] == null) { diff --git a/api/api/snapshot.create_repository.js b/api/api/snapshot.create_repository.js index 8cca44291..284f1e821 100644 --- a/api/api/snapshot.create_repository.js +++ b/api/api/snapshot.create_repository.js @@ -63,14 +63,6 @@ function buildSnapshotCreateRepository (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - snapshotCreateRepository(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['repository'] == null) { diff --git a/api/api/snapshot.delete.js b/api/api/snapshot.delete.js index 751501653..036535eb7 100644 --- a/api/api/snapshot.delete.js +++ b/api/api/snapshot.delete.js @@ -59,14 +59,6 @@ function buildSnapshotDelete (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - snapshotDelete(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['repository'] == null) { diff --git a/api/api/snapshot.delete_repository.js b/api/api/snapshot.delete_repository.js index 09edaa681..b552268c8 100644 --- a/api/api/snapshot.delete_repository.js +++ b/api/api/snapshot.delete_repository.js @@ -60,14 +60,6 @@ function buildSnapshotDeleteRepository (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - snapshotDeleteRepository(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['repository'] == null) { diff --git a/api/api/snapshot.get.js b/api/api/snapshot.get.js index e30b56ba5..f05948fea 100644 --- a/api/api/snapshot.get.js +++ b/api/api/snapshot.get.js @@ -64,14 +64,6 @@ function buildSnapshotGet (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - snapshotGet(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['repository'] == null) { diff --git a/api/api/snapshot.get_repository.js b/api/api/snapshot.get_repository.js index 473f293ed..1b0b32129 100644 --- a/api/api/snapshot.get_repository.js +++ b/api/api/snapshot.get_repository.js @@ -60,14 +60,6 @@ function buildSnapshotGetRepository (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - snapshotGetRepository(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/snapshot.restore.js b/api/api/snapshot.restore.js index fb2e74995..13865283f 100644 --- a/api/api/snapshot.restore.js +++ b/api/api/snapshot.restore.js @@ -63,14 +63,6 @@ function buildSnapshotRestore (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - snapshotRestore(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['repository'] == null) { diff --git a/api/api/snapshot.status.js b/api/api/snapshot.status.js index 6480c6760..cb3536c40 100644 --- a/api/api/snapshot.status.js +++ b/api/api/snapshot.status.js @@ -62,14 +62,6 @@ function buildSnapshotStatus (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - snapshotStatus(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/snapshot.verify_repository.js b/api/api/snapshot.verify_repository.js index 08bc473c9..12db7c034 100644 --- a/api/api/snapshot.verify_repository.js +++ b/api/api/snapshot.verify_repository.js @@ -60,14 +60,6 @@ function buildSnapshotVerifyRepository (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - snapshotVerifyRepository(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['repository'] == null) { diff --git a/api/api/ssl.certificates.js b/api/api/ssl.certificates.js index 75b371557..7e876c609 100644 --- a/api/api/ssl.certificates.js +++ b/api/api/ssl.certificates.js @@ -49,14 +49,6 @@ function buildSslCertificates (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - sslCertificates(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/tasks.cancel.js b/api/api/tasks.cancel.js index c333e0d36..2d226efd9 100644 --- a/api/api/tasks.cancel.js +++ b/api/api/tasks.cancel.js @@ -62,14 +62,6 @@ function buildTasksCancel (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - tasksCancel(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/tasks.get.js b/api/api/tasks.get.js index 416a64cf6..032ca29a8 100644 --- a/api/api/tasks.get.js +++ b/api/api/tasks.get.js @@ -60,14 +60,6 @@ function buildTasksGet (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - tasksGet(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['task_id'] == null && params['taskId'] == null) { diff --git a/api/api/tasks.list.js b/api/api/tasks.list.js index 1683df6f0..2d9362434 100644 --- a/api/api/tasks.list.js +++ b/api/api/tasks.list.js @@ -71,14 +71,6 @@ function buildTasksList (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - tasksList(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/termvectors.js b/api/api/termvectors.js index d4c822286..cb8a10d3e 100644 --- a/api/api/termvectors.js +++ b/api/api/termvectors.js @@ -85,14 +85,6 @@ function buildTermvectors (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - termvectors(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/update.js b/api/api/update.js index 997fb167f..a1bbe0b54 100644 --- a/api/api/update.js +++ b/api/api/update.js @@ -88,14 +88,6 @@ function buildUpdate (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - update(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['id'] == null) { diff --git a/api/api/update_by_query.js b/api/api/update_by_query.js index 6c31f79c6..a6455a813 100644 --- a/api/api/update_by_query.js +++ b/api/api/update_by_query.js @@ -141,14 +141,6 @@ function buildUpdateByQuery (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - updateByQuery(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/update_by_query_rethrottle.js b/api/api/update_by_query_rethrottle.js index 48bdffa57..b57d94b40 100644 --- a/api/api/update_by_query_rethrottle.js +++ b/api/api/update_by_query_rethrottle.js @@ -58,14 +58,6 @@ function buildUpdateByQueryRethrottle (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - updateByQueryRethrottle(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['task_id'] == null && params['taskId'] == null) { diff --git a/api/api/xpack.graph.explore.js b/api/api/xpack.graph.explore.js index 823e7f232..c991bc53e 100644 --- a/api/api/xpack.graph.explore.js +++ b/api/api/xpack.graph.explore.js @@ -55,14 +55,6 @@ function buildXpackGraphExplore (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackGraphExplore(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required url components if (params['type'] != null && (params['index'] == null)) { diff --git a/api/api/xpack.info.js b/api/api/xpack.info.js index c4db3ea38..6881278e2 100644 --- a/api/api/xpack.info.js +++ b/api/api/xpack.info.js @@ -50,14 +50,6 @@ function buildXpackInfo (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackInfo(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/xpack.license.delete.js b/api/api/xpack.license.delete.js index f60e1546e..0ba866644 100644 --- a/api/api/xpack.license.delete.js +++ b/api/api/xpack.license.delete.js @@ -49,14 +49,6 @@ function buildXpackLicenseDelete (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackLicenseDelete(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/xpack.license.get.js b/api/api/xpack.license.get.js index c2f887c29..fe2c0a32c 100644 --- a/api/api/xpack.license.get.js +++ b/api/api/xpack.license.get.js @@ -50,14 +50,6 @@ function buildXpackLicenseGet (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackLicenseGet(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/xpack.license.get_basic_status.js b/api/api/xpack.license.get_basic_status.js index 9dc5ee6ec..0ec25ff6d 100644 --- a/api/api/xpack.license.get_basic_status.js +++ b/api/api/xpack.license.get_basic_status.js @@ -49,14 +49,6 @@ function buildXpackLicenseGetBasicStatus (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackLicenseGetBasicStatus(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/xpack.license.get_trial_status.js b/api/api/xpack.license.get_trial_status.js index 3b5d68145..09660966b 100644 --- a/api/api/xpack.license.get_trial_status.js +++ b/api/api/xpack.license.get_trial_status.js @@ -49,14 +49,6 @@ function buildXpackLicenseGetTrialStatus (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackLicenseGetTrialStatus(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/xpack.license.post.js b/api/api/xpack.license.post.js index 5539a9131..ebbd77e2d 100644 --- a/api/api/xpack.license.post.js +++ b/api/api/xpack.license.post.js @@ -51,14 +51,6 @@ function buildXpackLicensePost (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackLicensePost(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { diff --git a/api/api/xpack.license.post_start_basic.js b/api/api/xpack.license.post_start_basic.js index 10af70ddd..9e9a6faae 100644 --- a/api/api/xpack.license.post_start_basic.js +++ b/api/api/xpack.license.post_start_basic.js @@ -50,14 +50,6 @@ function buildXpackLicensePostStartBasic (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackLicensePostStartBasic(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/xpack.license.post_start_trial.js b/api/api/xpack.license.post_start_trial.js index 7d7d6eb96..ac2c11f3a 100644 --- a/api/api/xpack.license.post_start_trial.js +++ b/api/api/xpack.license.post_start_trial.js @@ -52,14 +52,6 @@ function buildXpackLicensePostStartTrial (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackLicensePostStartTrial(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/xpack.migration.deprecations.js b/api/api/xpack.migration.deprecations.js index 0eaab511e..e5fbad087 100644 --- a/api/api/xpack.migration.deprecations.js +++ b/api/api/xpack.migration.deprecations.js @@ -50,14 +50,6 @@ function buildXpackMigrationDeprecations (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackMigrationDeprecations(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/xpack.migration.get_assistance.js b/api/api/xpack.migration.get_assistance.js index cfd98bdae..1840cdd9b 100644 --- a/api/api/xpack.migration.get_assistance.js +++ b/api/api/xpack.migration.get_assistance.js @@ -57,14 +57,6 @@ function buildXpackMigrationGetAssistance (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackMigrationGetAssistance(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { diff --git a/api/api/xpack.migration.upgrade.js b/api/api/xpack.migration.upgrade.js index e86a8fc50..305428a6c 100644 --- a/api/api/xpack.migration.upgrade.js +++ b/api/api/xpack.migration.upgrade.js @@ -51,14 +51,6 @@ function buildXpackMigrationUpgrade (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackMigrationUpgrade(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/xpack.rollup.delete_job.js b/api/api/xpack.rollup.delete_job.js index e80e0f24a..7dc7a4903 100644 --- a/api/api/xpack.rollup.delete_job.js +++ b/api/api/xpack.rollup.delete_job.js @@ -50,14 +50,6 @@ function buildXpackRollupDeleteJob (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackRollupDeleteJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['id'] == null) { diff --git a/api/api/xpack.rollup.get_jobs.js b/api/api/xpack.rollup.get_jobs.js index 6162d7dbd..cdb7b666a 100644 --- a/api/api/xpack.rollup.get_jobs.js +++ b/api/api/xpack.rollup.get_jobs.js @@ -50,14 +50,6 @@ function buildXpackRollupGetJobs (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackRollupGetJobs(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { diff --git a/api/api/xpack.rollup.get_rollup_caps.js b/api/api/xpack.rollup.get_rollup_caps.js index ce8fd7b8d..cb18eee62 100644 --- a/api/api/xpack.rollup.get_rollup_caps.js +++ b/api/api/xpack.rollup.get_rollup_caps.js @@ -50,14 +50,6 @@ function buildXpackRollupGetRollupCaps (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackRollupGetRollupCaps(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { diff --git a/api/api/xpack.rollup.get_rollup_index_caps.js b/api/api/xpack.rollup.get_rollup_index_caps.js index 75c68f601..de4191264 100644 --- a/api/api/xpack.rollup.get_rollup_index_caps.js +++ b/api/api/xpack.rollup.get_rollup_index_caps.js @@ -50,14 +50,6 @@ function buildXpackRollupGetRollupIndexCaps (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackRollupGetRollupIndexCaps(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/xpack.rollup.put_job.js b/api/api/xpack.rollup.put_job.js index b4b36b414..37de0684b 100644 --- a/api/api/xpack.rollup.put_job.js +++ b/api/api/xpack.rollup.put_job.js @@ -51,14 +51,6 @@ function buildXpackRollupPutJob (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackRollupPutJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['id'] == null) { diff --git a/api/api/xpack.rollup.rollup_search.js b/api/api/xpack.rollup.rollup_search.js index 0b8ef2969..e8bc75395 100644 --- a/api/api/xpack.rollup.rollup_search.js +++ b/api/api/xpack.rollup.rollup_search.js @@ -56,14 +56,6 @@ function buildXpackRollupRollupSearch (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackRollupRollupSearch(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['index'] == null) { diff --git a/api/api/xpack.rollup.start_job.js b/api/api/xpack.rollup.start_job.js index 763acadf4..33c3ac5fd 100644 --- a/api/api/xpack.rollup.start_job.js +++ b/api/api/xpack.rollup.start_job.js @@ -50,14 +50,6 @@ function buildXpackRollupStartJob (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackRollupStartJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['id'] == null) { diff --git a/api/api/xpack.rollup.stop_job.js b/api/api/xpack.rollup.stop_job.js index ac1f503b3..5bcf1373e 100644 --- a/api/api/xpack.rollup.stop_job.js +++ b/api/api/xpack.rollup.stop_job.js @@ -54,14 +54,6 @@ function buildXpackRollupStopJob (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackRollupStopJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['id'] == null) { diff --git a/api/api/xpack.sql.clear_cursor.js b/api/api/xpack.sql.clear_cursor.js index 26d64e8a1..f35f3e363 100644 --- a/api/api/xpack.sql.clear_cursor.js +++ b/api/api/xpack.sql.clear_cursor.js @@ -50,14 +50,6 @@ function buildXpackSqlClearCursor (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackSqlClearCursor(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/xpack.sql.query.js b/api/api/xpack.sql.query.js index bb5d2e381..125c577f6 100644 --- a/api/api/xpack.sql.query.js +++ b/api/api/xpack.sql.query.js @@ -51,14 +51,6 @@ function buildXpackSqlQuery (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackSqlQuery(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/xpack.sql.translate.js b/api/api/xpack.sql.translate.js index aadec40f7..c8df293e7 100644 --- a/api/api/xpack.sql.translate.js +++ b/api/api/xpack.sql.translate.js @@ -50,14 +50,6 @@ function buildXpackSqlTranslate (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackSqlTranslate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['body'] == null) { diff --git a/api/api/xpack.usage.js b/api/api/xpack.usage.js index fd612f4f2..dd85627f1 100644 --- a/api/api/xpack.usage.js +++ b/api/api/xpack.usage.js @@ -50,14 +50,6 @@ function buildXpackUsage (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackUsage(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/xpack.watcher.ack_watch.js b/api/api/xpack.watcher.ack_watch.js index 367fc0fa9..9a8a450c4 100644 --- a/api/api/xpack.watcher.ack_watch.js +++ b/api/api/xpack.watcher.ack_watch.js @@ -51,14 +51,6 @@ function buildXpackWatcherAckWatch (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackWatcherAckWatch(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['watch_id'] == null && params['watchId'] == null) { diff --git a/api/api/xpack.watcher.activate_watch.js b/api/api/xpack.watcher.activate_watch.js index 16b7547ad..1d114b189 100644 --- a/api/api/xpack.watcher.activate_watch.js +++ b/api/api/xpack.watcher.activate_watch.js @@ -50,14 +50,6 @@ function buildXpackWatcherActivateWatch (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackWatcherActivateWatch(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['watch_id'] == null && params['watchId'] == null) { diff --git a/api/api/xpack.watcher.deactivate_watch.js b/api/api/xpack.watcher.deactivate_watch.js index 6881f2017..1e7fe35ac 100644 --- a/api/api/xpack.watcher.deactivate_watch.js +++ b/api/api/xpack.watcher.deactivate_watch.js @@ -50,14 +50,6 @@ function buildXpackWatcherDeactivateWatch (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackWatcherDeactivateWatch(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['watch_id'] == null && params['watchId'] == null) { diff --git a/api/api/xpack.watcher.delete_watch.js b/api/api/xpack.watcher.delete_watch.js index aa7b84653..063788115 100644 --- a/api/api/xpack.watcher.delete_watch.js +++ b/api/api/xpack.watcher.delete_watch.js @@ -50,14 +50,6 @@ function buildXpackWatcherDeleteWatch (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackWatcherDeleteWatch(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['id'] == null) { diff --git a/api/api/xpack.watcher.execute_watch.js b/api/api/xpack.watcher.execute_watch.js index 25469dc54..8e14f3475 100644 --- a/api/api/xpack.watcher.execute_watch.js +++ b/api/api/xpack.watcher.execute_watch.js @@ -52,14 +52,6 @@ function buildXpackWatcherExecuteWatch (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackWatcherExecuteWatch(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { diff --git a/api/api/xpack.watcher.get_watch.js b/api/api/xpack.watcher.get_watch.js index d2a90ba0c..f18fcb992 100644 --- a/api/api/xpack.watcher.get_watch.js +++ b/api/api/xpack.watcher.get_watch.js @@ -50,14 +50,6 @@ function buildXpackWatcherGetWatch (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackWatcherGetWatch(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['id'] == null) { diff --git a/api/api/xpack.watcher.put_watch.js b/api/api/xpack.watcher.put_watch.js index 0b8ec0e0f..269e58d5a 100644 --- a/api/api/xpack.watcher.put_watch.js +++ b/api/api/xpack.watcher.put_watch.js @@ -59,14 +59,6 @@ function buildXpackWatcherPutWatch (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackWatcherPutWatch(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params['id'] == null) { diff --git a/api/api/xpack.watcher.start.js b/api/api/xpack.watcher.start.js index 0891bcfcd..e16a81eda 100644 --- a/api/api/xpack.watcher.start.js +++ b/api/api/xpack.watcher.start.js @@ -49,14 +49,6 @@ function buildXpackWatcherStart (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackWatcherStart(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/xpack.watcher.stats.js b/api/api/xpack.watcher.stats.js index 847e10ef6..6991ec20a 100644 --- a/api/api/xpack.watcher.stats.js +++ b/api/api/xpack.watcher.stats.js @@ -53,14 +53,6 @@ function buildXpackWatcherStats (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackWatcherStats(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { diff --git a/api/api/xpack.watcher.stop.js b/api/api/xpack.watcher.stop.js index 77c5d11d2..17f5c33a3 100644 --- a/api/api/xpack.watcher.stop.js +++ b/api/api/xpack.watcher.stop.js @@ -49,14 +49,6 @@ function buildXpackWatcherStop (opts) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackWatcherStop(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } // check required parameters if (params.body != null) { From 6eb4f874ccf12312dcd101c44025b7f1142eb0a8 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 11 Mar 2019 18:34:53 +0100 Subject: [PATCH 166/172] Updated docs --- docs/usage.asciidoc | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/docs/usage.asciidoc b/docs/usage.asciidoc index 1abf7d217..769087152 100644 --- a/docs/usage.asciidoc +++ b/docs/usage.asciidoc @@ -55,6 +55,55 @@ client.search({ }) ---- +=== Aborting a request + +When using the callback style API, the function will also return an object that allows you to abort the API request. + +[source,js] +---- +// calback API +const requesty = client.search({ + index: 'my-index', + body: { foo: 'bar' } +}, { + ignore: [404], + maxRetries: 3 +}, (err, { body }) => { + if (err) console.log(err) +}) + +request.abort() +---- + +Aborting a request with the promise style API is not supported, but you can easily achieve that with convenience wrapper. + +[source,js] +---- +function abortableRequest (params, options) { + var request = null + const promise = new Promise((resolve, reject) => { + request = client.search(params, options, (err, result) => { + err ? reject(err) : resolve(res) + }) + }) + return { + promise, + abort: () => request.abort() + } +} + +const request = abortableRequest({ + index: 'my-index', + body: { foo: 'bar' } +}, { + ignore: [404], + maxRetries: 3 +}) + +request.abort() +// access the promise with `request.promise.[method]` +---- + === Request specific options If needed you can pass request specific options in a second object: [source,js] @@ -79,6 +128,7 @@ client.search({ if (err) console.log(err) }) ---- + The supported request specific options are: [cols=2*] |=== From d4d7d0bef5bcefccb41768d5e00e2283c0d6ef10 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 11 Mar 2019 18:35:25 +0100 Subject: [PATCH 167/172] Updated code generation --- scripts/utils/generate.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/scripts/utils/generate.js b/scripts/utils/generate.js index 29cb4ec31..f7c7efede 100644 --- a/scripts/utils/generate.js +++ b/scripts/utils/generate.js @@ -105,14 +105,6 @@ function generate (spec, common) { params = {} options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ${safeWords(name)}(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } ${genRequiredChecks()} From 69fd7768f283144a48888f9c92245a318898ca91 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 12 Mar 2019 10:13:39 +0100 Subject: [PATCH 168/172] Updated dependencies --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ecce252e7..c752fbd74 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ }, "devDependencies": { "@types/node": "^10.12.24", + "dedent": "^0.7.0", "deepmerge": "^3.1.0", "js-yaml": "^3.12.1", "license-checker": "^25.0.1", @@ -58,7 +59,6 @@ "dependencies": { "debug": "^4.1.1", "decompress-response": "^4.0.0", - "dedent": "^0.7.0", "into-stream": "^4.0.0", "ms": "^2.1.1", "once": "^1.4.0", From 40023c53a7d7a8f4be54fb92c559cbcb78f02970 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 12 Mar 2019 10:14:00 +0100 Subject: [PATCH 169/172] Bumped v0.1.0-beta.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c752fbd74..a6628be34 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "main": "index.js", "types": "index.d.ts", "homepage": "http://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html", - "version": "0.1.0-beta.1", + "version": "0.1.0-beta.2", "keywords": [ "elasticsearch", "elastic", From dc27cb11ed2e31fbfd4d5d86949e8e323505014c Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 12 Mar 2019 10:50:58 +0100 Subject: [PATCH 170/172] Updated docs --- README.md | 1 + docs/index.asciidoc | 3 +++ docs/usage.asciidoc | 7 +++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index deac7f71b..bea340fb2 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ The official Node.js client for Elasticsearch. - Configurable, automatic discovery of cluster nodes. - Persistent, Keep-Alive connections. - Load balancing (with pluggable selection strategy) across all available nodes. +- TypeScript support out of the box. ## Install ``` diff --git a/docs/index.asciidoc b/docs/index.asciidoc index 352b06806..2c4d7fb87 100644 --- a/docs/index.asciidoc +++ b/docs/index.asciidoc @@ -8,6 +8,7 @@ The official Node.js client for Elasticsearch. * Configurable, automatic discovery of cluster nodes. * Persistent, Keep-Alive connections. * Load balancing (with pluggable selection strategy) across all available nodes. +* TypeScript support out of the box. == Install [source,sh] @@ -46,3 +47,5 @@ client.search({ * TypeScript support * Extend the client * Breaking changes from old client +* Authentication +* Child client diff --git a/docs/usage.asciidoc b/docs/usage.asciidoc index 769087152..5ef2f63df 100644 --- a/docs/usage.asciidoc +++ b/docs/usage.asciidoc @@ -30,13 +30,16 @@ The returned value of every API call is formed as follows: body: object | boolean statusCode: number headers: object - warnings: [string] + warnings: [string], + meta: object } ---- NOTE: The body will be a boolean value when using `HEAD` APIs. -The above valiue will be returned even if there is an error during the execution of the request, this means that you can safely use the https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment[destructuring assignment]. +The above value will be returned even if there is an error during the execution of the request, this means that you can safely use the https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment[destructuring assignment]. + +The `meta` key contains all the information regarding the request, such as attempt, options, and the connection that has been used. [source,js] ---- From 3396b5d818d50ba75ca6e9b697af6a672caf04e9 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 12 Mar 2019 12:04:13 +0100 Subject: [PATCH 171/172] Updated docs --- docs/breaking-changes.asciidoc | 39 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/docs/breaking-changes.asciidoc b/docs/breaking-changes.asciidoc index 1663eedbf..3170fd922 100644 --- a/docs/breaking-changes.asciidoc +++ b/docs/breaking-changes.asciidoc @@ -1,27 +1,26 @@ = Breaking changes coming from the old client -If you were already using the previous version of this client, the one you used to install with `npm install elasticsearch`, you will encounter some breaking changes. +If you were already using the previous version of this client --i.e. the one you used to install with `npm install elasticsearch`-- you will encounter some breaking changes. -=== Don't panic! +=== Don’t panic! -Every breaking change was carefully weighted, and every breaking change has solid reasons to introduce it, furthermore the new codebase has been rewritten with modern JavaScript, and has been carefully designed to be easy to maintain. +Every breaking change was carefully weighed, and each is justified. Furthermore, the new codebase has been rewritten with modern JavaScript and has been carefully designed to be easy to maintain. === Breaking changes * Minimum supported version of Node.js is `v6`. -* Everything has been rewritten using ES6 classes to help users extend more easily the defaults. +* Everything has been rewritten using ES6 classes to help users extend the defaults more easily. -* There is no more an integrated logger. The client now is an event emitter that emits the following events: `request`, `response`, and `error`. +* There is no longer an integrated logger. The client now is an event emitter that emits the following events: `request`, `response`, and `error`. -* The code is no longer shipped with all the versions of the API, but only the same major version of the package, this means that if you are using Elasticsearch `v6`, you will be required to install `@elasticelasticsearc@6`, and so on. +* The code is no longer shipped with all the versions of the API, but only that of the package’s major version, This means that if you are using Elasticsearch `v6`, you will be required to install `@elastic/elasticsearch@6`, and so on. -* The internals are completely different, so if you used to tweak a lot with them, you will need to refactor your code, while the surface API should be almost the same. +* The internals are completely different, so if you used to tweak them a lot, you will need to refactor your code. The public API should be almost the same. -* No more browser support, for that will be built another module, `@elastic/elasticsearch-browser`. This module is intended for Node.js only. +* No more browser support, for that will be distributed via another module, `@elastic/elasticsearch-browser`. This module is intended for Node.js only. -* The returned value of an API call will no longer be the `body`, `statusCode`, and `headers` for callbacks and just the `body` for promises. The new returned value will be a unique object containing the `body`, `statusCode`, `headers`, and `warnings`, for both callback and promises. + -With the `asStream` parameter you can get the original HTTP response stream if the case you need to pipe it to another response for a forwarding use case. +* The returned value of an API call will no longer be the `body`, `statusCode`, and `headers` for callbacks and just the `body` for promises. The new returned value will be a unique object containing the `body`, `statusCode`, `headers`, `warnings`, and `meta`, for both callback and promises. [source,js] ---- @@ -53,14 +52,14 @@ client.search({ ---- -* Errors: there is no longer a custom error class for every HTTP status code (such as `BadRequest` or `NotFound`), but there is a single `ResponseError` instead. -All the error classes have been renamed, and now all are suffixed with `Error` at the end. + -Errors that have been removed: -`RequestTypeError`, `Generic`, and all the status code specific errors. + -Errors that have been added: -`ConfigurationError` (in case of bad configurations) and `ResponseError`, which contains all the data you may need to handle the specific error, such as `statusCode`, `headers`, `body`, and `message`. + -All the new error classes also have well-defined types. + -Errors that has been renamed: +* Errors: there is no longer a custom error class for every HTTP status code (such as `BadRequest` or `NotFound`). There is instead a single `ResponseError`. Each error class has been renamed, and now each is suffixed with `Error` at the end. + +* Errors that have been removed: `RequestTypeError`, `Generic`, and all the status code specific errors (such as `BadRequest` or `NotFound`). + +* Errors that have been added: `ConfigurationError` (in case of bad configurations) and `ResponseError`, which contains all the data you may need to handle the specific error, such as `statusCode`, `headers`, `body`, and `message`. + + +* Errors that has been renamed: ** `RequestTimeout` (408 statusCode) => `TimeoutError` ** `ConnectionFault` => `ConnectionError` @@ -68,9 +67,9 @@ Errors that has been renamed: ** `Serialization` => `SerializationError` ** `Serialization` => `DeserializationError` -* You must specify the port number in the configuration. In the previous version you can specifiy the host and port in a variety of ways, with the new client there is only one via the `node` parameter. +* You must specify the port number in the configuration. In the previous version you can specify the host and port in a variety of ways, with the new client there is only one via the `node` parameter. -* The plugins option has been removed, if you want to extend the client now you should use the client.extend API. +* The `plugins` option has been removed, if you want to extend the client now you should use the `client.extend` API. [source,js] ---- From a713e2885376c3cd9108725eac5a20ceb47798d4 Mon Sep 17 00:00:00 2001 From: Tomas Della Vedova Date: Tue, 12 Mar 2019 16:45:49 +0100 Subject: [PATCH 172/172] WIP: benchmarks (#745) * Updated dependencies * Updated .gitignore * WIP: macro and micro benchmarks * Updated benchmark suite * Use the same suite for both macro and micro benchmarks * WIP: benchmark report * Updated benchmark suite * Updated docker scripts * Updated benchmark suite * Updated scripts * Updated benchmark suite * Added split2 --- .gitignore | 2 + package.json | 8 +- scripts/es-docker.sh | 2 + scripts/kibana-docker.sh | 8 + test/benchmarks/basic.bench.js | 125 ------------ test/benchmarks/macro/complex.bench.js | 101 +++++++++ test/benchmarks/macro/simple.bench.js | 269 ++++++++++++++++++++++++ test/benchmarks/micro/basic.bench.js | 98 +++++++++ test/benchmarks/suite.js | 272 +++++++++++++++++++++++++ 9 files changed, 758 insertions(+), 127 deletions(-) create mode 100755 scripts/kibana-docker.sh delete mode 100644 test/benchmarks/basic.bench.js create mode 100644 test/benchmarks/macro/complex.bench.js create mode 100644 test/benchmarks/macro/simple.bench.js create mode 100644 test/benchmarks/micro/basic.bench.js create mode 100644 test/benchmarks/suite.js diff --git a/.gitignore b/.gitignore index 6ecf99af0..37e981426 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,5 @@ elasticsearch* # Generated typings, we don't commit them # because we should copy them in the main .d.ts file api/generated.d.ts + +test/benchmarks/macro/fixtures/* diff --git a/package.json b/package.json index a6628be34..8dd66ec47 100644 --- a/package.json +++ b/package.json @@ -39,17 +39,21 @@ }, "devDependencies": { "@types/node": "^10.12.24", + "convert-hrtime": "^2.0.0", "dedent": "^0.7.0", "deepmerge": "^3.1.0", + "dezalgo": "^1.0.3", "js-yaml": "^3.12.1", "license-checker": "^25.0.1", "lolex": "^3.1.0", "minimist": "^1.2.0", - "nanobench": "github:delvedor/nanobench#repetitions", - "ora": "^3.1.0", + "ora": "^3.2.0", + "pretty-hrtime": "^1.0.3", "rimraf": "^2.6.3", "semver": "^5.6.0", "simple-git": "^1.107.0", + "simple-statistics": "^7.0.2", + "split2": "^3.1.0", "standard": "^12.0.1", "stoppable": "^1.1.0", "tap": "^12.6.0", diff --git a/scripts/es-docker.sh b/scripts/es-docker.sh index d09be3e26..d0e4f5adb 100755 --- a/scripts/es-docker.sh +++ b/scripts/es-docker.sh @@ -7,5 +7,7 @@ exec docker run \ -e "repositories.url.allowed_urls=http://snapshot.*" \ -e "discovery.type=single-node" \ -p 9200:9200 \ + --network=elastic \ + --name=elasticsearch \ docker.elastic.co/elasticsearch/elasticsearch:7.0.0-beta1 # docker.elastic.co/elasticsearch/elasticsearch:6.6.0 diff --git a/scripts/kibana-docker.sh b/scripts/kibana-docker.sh new file mode 100755 index 000000000..8c39f9647 --- /dev/null +++ b/scripts/kibana-docker.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +exec docker run \ + --rm \ + -e ELASTICSEARCH_URL="http://elasticsearch:9200" \ + -p 5601:5601 \ + --network=elastic \ + docker.elastic.co/kibana/kibana:7.0.0-beta1 diff --git a/test/benchmarks/basic.bench.js b/test/benchmarks/basic.bench.js deleted file mode 100644 index 6a070ed8d..000000000 --- a/test/benchmarks/basic.bench.js +++ /dev/null @@ -1,125 +0,0 @@ -'use strict' - -const bench = require('nanobench') -const { Client } = require('../../index') -const { connection } = require('../utils') - -bench('Initialization', { repetitions: 5 }, b => { - const client = new Client({ // eslint-disable-line - node: 'http://localhost:9200' - }) - b.end() -}) - -bench('Call api with lazy loading', { repetitions: 5 }, b => { - const client = new Client({ - node: 'http://localhost:9200', - Connection: connection.MockConnection - }) - - b.start() - client.info((err, result) => { - if (err) { - b.error(err) - return - } - - b.end() - }) -}) - -bench('Call api without lazy loading', { repetitions: 5 }, b => { - const client = new Client({ - node: 'http://localhost:9200', - Connection: connection.MockConnection - }) - - client.info((err, result) => { - if (err) { - b.error(err) - return - } - - b.start() - client.info((err, result) => { - if (err) { - b.error(err) - return - } - - b.end() - }) - }) -}) - -bench('Basic get', { repetitions: 5 }, b => { - const client = new Client({ - node: 'http://localhost:9200', - Connection: connection.MockConnection - }) - - // we run the method twice to skip the lazy loading overhead - client.search({ - index: 'test', - type: 'doc', - q: 'foo:bar' - }, (err, result) => { - if (err) { - b.error(err) - return - } - - b.start() - client.search({ - index: 'test', - type: 'doc', - q: 'foo:bar' - }, (err, result) => { - if (err) { - b.error(err) - return - } - b.end() - }) - }) -}) - -bench('Basic post', { repetitions: 5 }, b => { - const client = new Client({ - node: 'http://localhost:9200', - Connection: connection.MockConnection - }) - - // we run the method twice to skip the lazy loading overhead - client.search({ - index: 'test', - type: 'doc', - body: { - query: { - match: { foo: 'bar' } - } - } - }, (err, result) => { - if (err) { - b.error(err) - return - } - - b.start() - client.search({ - index: 'test', - type: 'doc', - body: { - query: { - match: { foo: 'bar' } - } - } - }, (err, result) => { - if (err) { - b.error(err) - return - } - b.end() - }) - }) -}) diff --git a/test/benchmarks/macro/complex.bench.js b/test/benchmarks/macro/complex.bench.js new file mode 100644 index 000000000..00cb6c47f --- /dev/null +++ b/test/benchmarks/macro/complex.bench.js @@ -0,0 +1,101 @@ +'use strict' + +// This file must be run with --max-old-space-size=8192 +// because we need more than 1Gb of memory +// eg: node --max-old-space-size=8192 complex.bench.js + +const { Client } = require('../../../index') +const { statSync, createReadStream } = require('fs') +const { join } = require('path') +const split = require('split2') +const { bench, beforeEach, afterEach } = require('../suite')({ + report: { + url: process.env.ES_RESULT_CLUSTER_URL, + username: process.env.ES_RESULT_CLUSTER_USERNAME, + password: process.env.ES_RESULT_CLUSTER_PASSWORD + } +}) + +var stackoverflow = [] +const stackoverflowPath = join( + __dirname, + 'fixtures', + 'stackoverflow.json' +) +const stackoverflowInfo = { + name: 'stackoverflow.json', + size: statSync(join(stackoverflowPath)).size, + num_documents: 2000000 +} + +const INDEX = 'stackoverflow' +const node = process.env.ELASTICSEARCH_URL || 'http://localhost:9200' + +const client = new Client({ node }) + +beforeEach(async b => { + if (stackoverflow.length === 0) { + stackoverflow = await readSOfile() + } + b.client = client + await b.client.indices.delete({ index: 'test-*' }) +}) + +afterEach(async b => { + await b.client.indices.delete({ index: 'test-*' }) +}) + +bench('Bulk index documents', { + warmup: 1, + measure: 1, + iterations: 1, + dataset: stackoverflowInfo, + action: 'bulk' +}, async b => { + b.start() + for (var i = 0; i < stackoverflow.length; i++) { + await b.client.bulk({ body: stackoverflow[i] }) + } + b.end() +}) + +bench('Complex search request', { + warmup: 3, + measure: 5, + iterations: 100, + dataset: stackoverflowInfo, + action: 'search' +}, async b => { + b.start() + for (var i = 0; i < b.iterations; i++) { + await b.client.search({ + index: INDEX, + body: { + query: { + match: { title: 'safe' } + } + } + }) + } + b.end() +}) + +function readSOfile () { + var i = 0 + var stackoverflow = [] + return new Promise((resolve, reject) => { + createReadStream(stackoverflowPath) + .pipe(split(JSON.parse)) + .on('data', chunk => { + stackoverflow[i] = stackoverflow[i] || [] + stackoverflow[i].push({ index: { _index: INDEX } }) + stackoverflow[i].push(chunk) + // 10k documents + if (stackoverflow[i].length >= 10000 * 2) { + i++ + } + }) + .on('error', reject) + .on('end', () => resolve(stackoverflow)) + }) +} diff --git a/test/benchmarks/macro/simple.bench.js b/test/benchmarks/macro/simple.bench.js new file mode 100644 index 000000000..f734d1ff2 --- /dev/null +++ b/test/benchmarks/macro/simple.bench.js @@ -0,0 +1,269 @@ +'use strict' + +const { Client } = require('../../../index') +const { statSync } = require('fs') +const { join } = require('path') +const { bench, beforeEach, afterEach } = require('../suite')({ + report: { + url: process.env.ES_RESULT_CLUSTER_URL, + username: process.env.ES_RESULT_CLUSTER_USERNAME, + password: process.env.ES_RESULT_CLUSTER_PASSWORD + } +}) + +const node = process.env.ELASTICSEARCH_URL || 'http://localhost:9200' + +const smallDocument = require('./fixtures/small_document.json') +const smallDocumentInfo = { + name: 'small_document.json', + size: statSync(join(__dirname, 'fixtures', 'small_document.json')).size, + num_documents: 1 +} +const largeDocument = require('./fixtures/large_document.json') +const largeDocumentInfo = { + name: 'large_document.json', + size: statSync(join(__dirname, 'fixtures', 'large_document.json')).size, + num_documents: 1 +} + +const client = new Client({ node }) + +beforeEach(async b => { + b.client = client + await b.client.indices.delete({ index: 'test-*' }) +}) + +afterEach(async b => { + await b.client.indices.delete({ index: 'test-*' }) +}) + +bench('Ping', { + warmup: 3, + measure: 5, + iterations: 100, + action: 'ping' +}, async b => { + b.start() + for (var i = 0; i < b.iterations; i++) { + await b.client.ping() + } + b.end() +}) + +bench('Create index', { + warmup: 3, + measure: 5, + iterations: 10, + action: 'indices.create' +}, async b => { + b.start() + for (var i = 0; i < b.iterations; i++) { + await b.client.indices.create({ index: `test-create-${i}` }) + } + b.end() +}) + +bench('Index small document', { + warmup: 3, + measure: 5, + iterations: 100, + dataset: smallDocumentInfo, + action: 'create' +}, async b => { + const now = Date.now() + '' + const index = `test-${now}` + await b.client.indices.create({ index }) + + b.start() + for (var i = 0; i < b.iterations; i++) { + await b.client.create({ + index, + type: '_doc', + id: i + now, + body: smallDocument + }) + } + b.end() +}) + +bench('Index large document', { + warmup: 3, + measure: 5, + iterations: 100, + dataset: largeDocumentInfo, + action: 'create' +}, async b => { + const now = Date.now() + '' + const index = `test-${now}` + await b.client.indices.create({ index }) + + b.start() + for (var i = 0; i < b.iterations; i++) { + await b.client.create({ + index, + type: '_doc', + id: i + now, + body: largeDocument + }) + } + b.end() +}) + +bench('Get small document', { + warmup: 3, + measure: 5, + iterations: 1000, + dataset: smallDocumentInfo, + action: 'get' +}, async b => { + const now = Date.now() + '' + const index = `test-${now}` + await b.client.indices.create({ index }) + + await b.client.create({ + index, + type: '_doc', + id: now, + body: smallDocument + }) + + b.start() + for (var i = 0; i < b.iterations; i++) { + await b.client.get({ + index, + type: '_doc', + id: now + }) + } + b.end() +}) + +bench('Get large document', { + warmup: 3, + measure: 5, + iterations: 1000, + dataset: largeDocumentInfo, + action: 'get' +}, async b => { + const now = Date.now() + '' + const index = `test-${now}` + await b.client.indices.create({ index }) + + await b.client.create({ + index, + type: '_doc', + id: now, + body: largeDocument + }) + + b.start() + for (var i = 0; i < b.iterations; i++) { + await b.client.get({ + index, + type: '_doc', + id: now + }) + } + b.end() +}) + +bench('Search small document', { + warmup: 3, + measure: 5, + iterations: 1000, + dataset: smallDocumentInfo, + action: 'search' +}, async b => { + const now = Date.now() + '' + const index = `test-${now}` + await b.client.indices.create({ index }) + + await b.client.create({ + index, + type: '_doc', + id: now, + refresh: true, + body: smallDocument + }) + + b.start() + for (var i = 0; i < b.iterations; i++) { + await b.client.search({ + index, + type: '_doc', + body: { + query: { + match: { cuisine: 'mexican' } + } + } + }) + } + b.end() +}) + +bench('Search large document', { + warmup: 3, + measure: 5, + iterations: 1000, + dataset: largeDocumentInfo, + action: 'search' +}, async b => { + const now = Date.now() + '' + const index = `test-${now}` + await b.client.indices.create({ index }) + + await b.client.create({ + index, + type: '_doc', + id: now, + refresh: true, + body: largeDocument + }) + + b.start() + for (var i = 0; i < b.iterations; i++) { + await b.client.search({ + index, + type: '_doc', + body: { + query: { + match: { 'user.lang': 'en' } + } + } + }) + } + b.end() +}) + +bench('Update small document', { + warmup: 3, + measure: 5, + iterations: 100, + dataset: smallDocumentInfo, + action: 'update' +}, async b => { + const now = Date.now() + '' + const index = `test-${now}` + await b.client.indices.create({ index }) + + await b.client.create({ + index, + type: '_doc', + id: now, + refresh: true, + body: smallDocument + }) + + b.start() + for (var i = 0; i < b.iterations; i++) { + await b.client.update({ + index, + type: '_doc', + id: now, + body: { + doc: { cuisine: 'italian' + i } + } + }) + } + b.end() +}) diff --git a/test/benchmarks/micro/basic.bench.js b/test/benchmarks/micro/basic.bench.js new file mode 100644 index 000000000..d829945ca --- /dev/null +++ b/test/benchmarks/micro/basic.bench.js @@ -0,0 +1,98 @@ +'use strict' + +const { bench } = require('../suite')({ + report: { + url: process.env.ES_RESULT_CLUSTER_URL, + username: process.env.ES_RESULT_CLUSTER_USERNAME, + password: process.env.ES_RESULT_CLUSTER_PASSWORD + } +}) +const { Client } = require('../../../index') +const { connection } = require('../../utils') + +bench('Initialization', { warmup: 5, measure: 10, iterations: 1000 }, async b => { + b.start() + for (var i = 0; i < b.iterations; i++) { + const client = new Client({ // eslint-disable-line + node: 'http://localhost:9200' + }) + } + b.end() +}) + +bench('Call api with lazy loading', { warmup: 5, measure: 10 }, async b => { + const client = new Client({ + node: 'http://localhost:9200', + Connection: connection.MockConnection + }) + + b.start() + await client.info() + b.end() +}) + +bench('Call api without lazy loading', { warmup: 5, measure: 10 }, async b => { + const client = new Client({ + node: 'http://localhost:9200', + Connection: connection.MockConnection + }) + + await client.info() + b.start() + await client.info() + b.end() +}) + +bench('Basic get', { warmup: 5, measure: 10, iterations: 1000 }, async b => { + const client = new Client({ + node: 'http://localhost:9200', + Connection: connection.MockConnection + }) + + // we run the method twice to skip the lazy loading overhead + await client.search({ + index: 'test', + type: 'doc', + q: 'foo:bar' + }) + b.start() + for (var i = 0; i < b.iterations; i++) { + await client.search({ + index: 'test', + type: 'doc', + q: 'foo:bar' + }) + } + b.end() +}) + +bench('Basic post', { warmup: 5, measure: 10, iterations: 1000 }, async b => { + const client = new Client({ + node: 'http://localhost:9200', + Connection: connection.MockConnection + }) + + // we run the method twice to skip the lazy loading overhead + await client.search({ + index: 'test', + type: 'doc', + body: { + query: { + match: { foo: 'bar' } + } + } + }) + b.start() + for (var i = 0; i < b.iterations; i++) { + await client.search({ + index: 'test', + type: 'doc', + body: { + query: { + match: { foo: 'bar' } + } + } + }) + } + b.end() +}) diff --git a/test/benchmarks/suite.js b/test/benchmarks/suite.js new file mode 100644 index 000000000..251e58749 --- /dev/null +++ b/test/benchmarks/suite.js @@ -0,0 +1,272 @@ +'use strict' + +const { Client } = require('../../index') +const clientVersion = require('../../package.json').version +const { EventEmitter } = require('events') +const os = require('os') +const dezalgo = require('dezalgo') +const convertHrtime = require('convert-hrtime') +const Git = require('simple-git/promise') +const workq = require('workq') +const dedent = require('dedent') +const ss = require('simple-statistics') + +function buildBenchmark (options = {}) { + const q = workq() + const stats = {} + const reports = [] + var beforeEach = null + var afterEach = null + var setup = null + var teardown = null + + function setBeforeEach (fn) { + beforeEach = fn + } + + function setAfterEach (fn) { + afterEach = fn + } + + function setSetup (fn) { + setup = fn + } + + function setTeardown (fn) { + teardown = fn + } + + function runSetup (q, done) { + if (setup !== null) { + setup(() => { + setup = null + done() + }) + } else { + done() + } + } + + function benchmark (title, opts, fn) { + if (fn == null) { + fn = opts + opts = {} + } + + stats[title] = [] + var { measure, warmup } = opts + const b = new B({ iterations: opts.iterations }) + + q.add(runSetup) + q.add(runBenchmark) + q.add(elaborateStats) + + // Task that runs the benchmark and collects the stats + function runBenchmark (q, done) { + b.comment(`\n# ${title}`) + b.once('fail', err => { + b.comment(err) + if (b.client) { + b.client.close(done) + } else { + done() + } + }) + + process.nextTick(run) + async function run () { + if (beforeEach) { + try { + await beforeEach(b) + } catch (err) { + b.comment('Error: beforeEach hook has failed') + return b.fail(err) + } + } + + try { + await fn(b) + } catch (err) { + return b.fail(err) + } + + if (afterEach) { + try { + await afterEach(b) + } catch (err) { + b.comment('Error: afterEach hook has failed') + return b.fail(err) + } + } + + // still need to warmup + if (warmup-- > 0) { + process.nextTick(run) + // save the actual measure + } else if (measure-- > 0) { + stats[title].push(convertHrtime(b.time)) + process.nextTick(run) + // calculate the statistics + } else { + done() + } + } + } + + // task that elaborate the collected stats + async function elaborateStats (q) { + const times = stats[title].map(s => s.milliseconds / b.iterations) + reports.push({ + description: title, + action: opts.action, + category: opts.category || 'simple', + dataset: opts.dataset || null, + stats: { + mean: ss.mean(times), + median: ss.median(times), + min: ss.min(times), + max: ss.max(times), + standard_deviation: ss.standardDeviation(times) + }, + repetitions: { + measured: opts.measure, + warmup: opts.warmup, + iterations: opts.iterations + } + }) + + if (b.client) { + const { body } = await b.client.nodes.stats({ metric: 'http,jvm,os' }) + const esStats = body.nodes[Object.keys(body.nodes)[0]] + b.comment(dedent` + mean: ${ss.mean(times)} ms + median: ${ss.median(times)} ms + min: ${ss.min(times)} ms + max: ${ss.max(times)} ms + standard deviation: ${ss.standardDeviation(times)} + http total connections: ${esStats.http.total_opened} + jvm heap used: ${esStats.jvm.mem.heap_used_percent}% + `) + } else { + b.comment(dedent` + mean: ${ss.mean(times)} ms + median: ${ss.median(times)} ms + min: ${ss.min(times)} ms + max: ${ss.max(times)} ms + standard deviation: ${ss.standardDeviation(times)} + `) + } + } + } + + q.drain(done => { + if (teardown) { + teardown(done) + } else { + done() + } + if (options.report && options.report.url) { + sendReport() + } + }) + + async function sendReport () { + const client = new Client({ + node: { + url: new URL(options.report.url), + username: options.report.username, + password: options.report.password + } + }) + const git = Git(__dirname) + const commit = await git.log(['-1']) + const branch = await git.revparse(['--abbrev-ref', 'HEAD']) + const { body: esInfo } = await client.info() + const { body: esNodes } = await client.nodes.stats({ metric: 'os' }) + + const results = reports.map(report => { + return { + '@timestamp': new Date(), + event: { + description: report.description, + category: report.category, + action: report.action, + duration: 0, + statistics: report.stats, + repetitions: report.repetitions, + dataset: (report.dataset && report.dataset.name) || null, + dataset_details: { + size: (report.dataset && report.dataset.size) || 0, + num_documents: (report.dataset && report.dataset.num_documents) || 0 + } + }, + agent: { + version: clientVersion, + name: '@elastic/elasticsearch-js', + git: { + branch: branch.slice(0, -1), + sha: commit.latest.hash, + commit_message: commit.latest.message, + repository: 'elasticsearch-js' + }, + language: { + version: process.version + }, + os: { + platform: `${os.platform()} ${os.release()}`, + type: os.type(), + architecture: os.arch() + } + }, + server: { + version: esInfo.version.number, + nodes_info: esNodes + } + } + }) + + for (var i = 0; i < results.length; i++) { + await client.index({ + index: 'benchmarking_results', + type: '_doc', + body: results[i] + }) + } + } + + return { + bench: dezalgo(benchmark), + beforeEach: setBeforeEach, + afterEach: setAfterEach, + setup: setSetup, + teardown: setTeardown + } +} + +class B extends EventEmitter { + constructor (opts) { + super() + this.begin = 0 + this.time = 0 + this.iterations = opts.iterations || 1 + this.client = null + } + + start () { + this.begin = process.hrtime() + } + + end () { + this.time = process.hrtime(this.begin) + } + + fail (err) { + this.emit('fail', err) + } + + comment (...args) { + console.log(...args) + } +} + +module.exports = buildBenchmark