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) } }