diff --git a/README.md b/README.md index 78b153f96..5d707fb60 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,10 @@ The client is designed to be easily configured as you see fit for your needs, fo nodeFilter: nodeFilterFn; // custom selection strategy, defaults `round-robin` nodeSelector: nodeSelectorFn | string; + // function to generate the request id for every request + generateRequestId: generateRequestIdFn; + // name to identify the client instance in the events + name: string; } ``` @@ -143,7 +147,9 @@ The supported *request specific options* are: asStream: boolean, // default `false` compression: string, // default `false` headers: object, // default `null` - querystring: object // default `null` + querystring: object // default `null`, + context: object // default `null`, + id: any // default incr. integer } ``` diff --git a/api/api/bulk.js b/api/api/bulk.js index 23f31feac..fda39fb40 100644 --- a/api/api/bulk.js +++ b/api/api/bulk.js @@ -138,6 +138,8 @@ function buildBulk (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cat.aliases.js b/api/api/cat.aliases.js index 1e37847a5..dda2b5e37 100644 --- a/api/api/cat.aliases.js +++ b/api/api/cat.aliases.js @@ -120,6 +120,8 @@ function buildCatAliases (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cat.allocation.js b/api/api/cat.allocation.js index 30e8290ce..daa974d9e 100644 --- a/api/api/cat.allocation.js +++ b/api/api/cat.allocation.js @@ -122,6 +122,8 @@ function buildCatAllocation (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cat.count.js b/api/api/cat.count.js index ee8c60347..dba60e054 100644 --- a/api/api/cat.count.js +++ b/api/api/cat.count.js @@ -120,6 +120,8 @@ function buildCatCount (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cat.fielddata.js b/api/api/cat.fielddata.js index c0220e7f4..ad03e8510 100644 --- a/api/api/cat.fielddata.js +++ b/api/api/cat.fielddata.js @@ -124,6 +124,8 @@ function buildCatFielddata (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cat.health.js b/api/api/cat.health.js index 81f20bc69..959ebc58b 100644 --- a/api/api/cat.health.js +++ b/api/api/cat.health.js @@ -117,6 +117,8 @@ function buildCatHealth (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cat.help.js b/api/api/cat.help.js index f580ccaf6..5cd06ef63 100644 --- a/api/api/cat.help.js +++ b/api/api/cat.help.js @@ -104,6 +104,8 @@ function buildCatHelp (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cat.indices.js b/api/api/cat.indices.js index 9376f118e..a949f7d16 100644 --- a/api/api/cat.indices.js +++ b/api/api/cat.indices.js @@ -126,6 +126,8 @@ function buildCatIndices (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cat.master.js b/api/api/cat.master.js index 037770881..d17566356 100644 --- a/api/api/cat.master.js +++ b/api/api/cat.master.js @@ -115,6 +115,8 @@ function buildCatMaster (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cat.nodeattrs.js b/api/api/cat.nodeattrs.js index 854484990..cadad2dfc 100644 --- a/api/api/cat.nodeattrs.js +++ b/api/api/cat.nodeattrs.js @@ -115,6 +115,8 @@ function buildCatNodeattrs (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cat.nodes.js b/api/api/cat.nodes.js index 480f9e3f2..b387abda8 100644 --- a/api/api/cat.nodes.js +++ b/api/api/cat.nodes.js @@ -118,6 +118,8 @@ function buildCatNodes (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cat.pending_tasks.js b/api/api/cat.pending_tasks.js index 5f4a0faf8..e9a1e2870 100644 --- a/api/api/cat.pending_tasks.js +++ b/api/api/cat.pending_tasks.js @@ -115,6 +115,8 @@ function buildCatPendingTasks (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cat.plugins.js b/api/api/cat.plugins.js index 261e3cf4d..7d2c60f3a 100644 --- a/api/api/cat.plugins.js +++ b/api/api/cat.plugins.js @@ -115,6 +115,8 @@ function buildCatPlugins (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cat.recovery.js b/api/api/cat.recovery.js index 8133bb812..022695436 100644 --- a/api/api/cat.recovery.js +++ b/api/api/cat.recovery.js @@ -120,6 +120,8 @@ function buildCatRecovery (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cat.repositories.js b/api/api/cat.repositories.js index 0404e9b79..79fe7ad6c 100644 --- a/api/api/cat.repositories.js +++ b/api/api/cat.repositories.js @@ -115,6 +115,8 @@ function buildCatRepositories (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cat.segments.js b/api/api/cat.segments.js index 64003c8a5..357ba372d 100644 --- a/api/api/cat.segments.js +++ b/api/api/cat.segments.js @@ -117,6 +117,8 @@ function buildCatSegments (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cat.shards.js b/api/api/cat.shards.js index d5c6229c3..505787744 100644 --- a/api/api/cat.shards.js +++ b/api/api/cat.shards.js @@ -122,6 +122,8 @@ function buildCatShards (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cat.snapshots.js b/api/api/cat.snapshots.js index 05c8313c0..943f27233 100644 --- a/api/api/cat.snapshots.js +++ b/api/api/cat.snapshots.js @@ -125,6 +125,8 @@ function buildCatSnapshots (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cat.tasks.js b/api/api/cat.tasks.js index d4c69f616..73cd320ab 100644 --- a/api/api/cat.tasks.js +++ b/api/api/cat.tasks.js @@ -123,6 +123,8 @@ function buildCatTasks (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cat.templates.js b/api/api/cat.templates.js index 2a8cc435a..61f5c7b8c 100644 --- a/api/api/cat.templates.js +++ b/api/api/cat.templates.js @@ -120,6 +120,8 @@ function buildCatTemplates (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cat.thread_pool.js b/api/api/cat.thread_pool.js index 37615cb37..1cd7c2a2e 100644 --- a/api/api/cat.thread_pool.js +++ b/api/api/cat.thread_pool.js @@ -122,6 +122,8 @@ function buildCatThreadPool (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/ccr.delete_auto_follow_pattern.js b/api/api/ccr.delete_auto_follow_pattern.js new file mode 100644 index 000000000..f5241c473 --- /dev/null +++ b/api/api/ccr.delete_auto_follow_pattern.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildCcrDeleteAutoFollowPattern (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ccr.delete_auto_follow_pattern](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html) request + * + * @param {string} name - The name of the auto follow pattern. + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + 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 = {} + } + + // check required parameters + if (params['name'] == null) { + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'DELETE' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildCcrDeleteAutoFollowPattern diff --git a/api/api/ccr.follow.js b/api/api/ccr.follow.js new file mode 100644 index 000000000..9ee3158c6 --- /dev/null +++ b/api/api/ccr.follow.js @@ -0,0 +1,130 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildCcrFollow (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ccr.follow](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html) request + * + * @param {string} index - The name of the follower index + * @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before returning. Defaults to 0. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + * @param {object} body - The name of the leader index and other optional ccr related parameters + */ + + const acceptedQuerystring = [ + 'wait_for_active_shards' + ] + + const snakeCase = { + waitForActiveShards: 'wait_for_active_shards' + } + + return function ccrFollow (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['index'] == null) { + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'follow' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildCcrFollow diff --git a/api/api/ccr.follow_info.js b/api/api/ccr.follow_info.js new file mode 100644 index 000000000..1e8040461 --- /dev/null +++ b/api/api/ccr.follow_info.js @@ -0,0 +1,118 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildCcrFollowInfo (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ccr.follow_info](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-info.html) request + * + * @param {list} index - A comma-separated list of index patterns; use `_all` to perform the operation on all indices + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function ccrFollowInfo (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'info' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildCcrFollowInfo diff --git a/api/api/ccr.follow_stats.js b/api/api/ccr.follow_stats.js new file mode 100644 index 000000000..52373f123 --- /dev/null +++ b/api/api/ccr.follow_stats.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildCcrFollowStats (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ccr.follow_stats](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html) request + * + * @param {list} index - A comma-separated list of index patterns; use `_all` to perform the operation on all indices + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + 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 = {} + } + + // check required parameters + if (params['index'] == null) { + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'stats' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildCcrFollowStats diff --git a/api/api/ccr.forget_follower.js b/api/api/ccr.forget_follower.js new file mode 100644 index 000000000..db17668a5 --- /dev/null +++ b/api/api/ccr.forget_follower.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildCcrForgetFollower (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ccr.forget_follower](http://www.elastic.co/guide/en/elasticsearch/reference/current) request + * + * @param {string} index - the name of the leader index for which specified follower retention leases should be removed + * @param {object} body - the name and UUID of the follower index, the name of the cluster containing the follower index, and the alias from the perspective of that cluster for the remote cluster containing the leader index + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function ccrForgetFollower (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['index'] == null) { + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'forget_follower' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildCcrForgetFollower diff --git a/api/api/ccr.get_auto_follow_pattern.js b/api/api/ccr.get_auto_follow_pattern.js new file mode 100644 index 000000000..577e229ac --- /dev/null +++ b/api/api/ccr.get_auto_follow_pattern.js @@ -0,0 +1,122 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildCcrGetAutoFollowPattern (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ccr.get_auto_follow_pattern](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html) request + * + * @param {string} name - The name of the auto follow pattern. + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + 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 = {} + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((name) != null) { + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) + } else { + path = '/' + '_ccr' + '/' + 'auto_follow' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildCcrGetAutoFollowPattern diff --git a/api/api/ccr.pause_follow.js b/api/api/ccr.pause_follow.js new file mode 100644 index 000000000..462e30be4 --- /dev/null +++ b/api/api/ccr.pause_follow.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildCcrPauseFollow (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ccr.pause_follow](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html) request + * + * @param {string} index - The name of the follower index that should pause following its leader index. + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + 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 = {} + } + + // check required parameters + if (params['index'] == null) { + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'pause_follow' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildCcrPauseFollow diff --git a/api/api/ccr.put_auto_follow_pattern.js b/api/api/ccr.put_auto_follow_pattern.js new file mode 100644 index 000000000..0f2691714 --- /dev/null +++ b/api/api/ccr.put_auto_follow_pattern.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildCcrPutAutoFollowPattern (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ccr.put_auto_follow_pattern](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html) request + * + * @param {string} name - The name of the auto follow pattern. + * @param {object} body - The specification of the auto follow pattern + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + 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 = {} + } + + // check required parameters + if (params['name'] == null) { + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildCcrPutAutoFollowPattern diff --git a/api/api/ccr.resume_follow.js b/api/api/ccr.resume_follow.js new file mode 100644 index 000000000..36c666531 --- /dev/null +++ b/api/api/ccr.resume_follow.js @@ -0,0 +1,125 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildCcrResumeFollow (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ccr.resume_follow](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-resume-follow.html) request + * + * @param {string} index - The name of the follow index to resume following. + * @param {object} body - The name of the leader index and other optional ccr related parameters + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + 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 = {} + } + + // check required parameters + if (params['index'] == null) { + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'resume_follow' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildCcrResumeFollow diff --git a/api/api/ccr.stats.js b/api/api/ccr.stats.js new file mode 100644 index 000000000..3f1d9bc39 --- /dev/null +++ b/api/api/ccr.stats.js @@ -0,0 +1,117 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildCcrStats (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ccr.stats](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html) request + * + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function ccrStats (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ccr' + '/' + 'stats' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildCcrStats diff --git a/api/api/ccr.unfollow.js b/api/api/ccr.unfollow.js new file mode 100644 index 000000000..43c1ba4b1 --- /dev/null +++ b/api/api/ccr.unfollow.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildCcrUnfollow (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ccr.unfollow](http://www.elastic.co/guide/en/elasticsearch/reference/current) request + * + * @param {string} index - The name of the follower index that should be turned into a regular index. + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + 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 = {} + } + + // check required parameters + if (params['index'] == null) { + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'unfollow' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildCcrUnfollow diff --git a/api/api/clear_scroll.js b/api/api/clear_scroll.js index a05a916ca..01c4c6f52 100644 --- a/api/api/clear_scroll.js +++ b/api/api/clear_scroll.js @@ -100,6 +100,8 @@ function buildClearScroll (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cluster.allocation_explain.js b/api/api/cluster.allocation_explain.js index 7ab6e3dd6..6e21d9e7b 100644 --- a/api/api/cluster.allocation_explain.js +++ b/api/api/cluster.allocation_explain.js @@ -101,6 +101,8 @@ function buildClusterAllocationExplain (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cluster.get_settings.js b/api/api/cluster.get_settings.js index 1b7a95d08..44b8d6b2a 100644 --- a/api/api/cluster.get_settings.js +++ b/api/api/cluster.get_settings.js @@ -111,6 +111,8 @@ function buildClusterGetSettings (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cluster.health.js b/api/api/cluster.health.js index f717a519b..51154f37f 100644 --- a/api/api/cluster.health.js +++ b/api/api/cluster.health.js @@ -129,6 +129,8 @@ function buildClusterHealth (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cluster.pending_tasks.js b/api/api/cluster.pending_tasks.js index c1c3457a2..6657254d9 100644 --- a/api/api/cluster.pending_tasks.js +++ b/api/api/cluster.pending_tasks.js @@ -105,6 +105,8 @@ function buildClusterPendingTasks (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cluster.put_settings.js b/api/api/cluster.put_settings.js index 0410399fa..c88a26c2d 100644 --- a/api/api/cluster.put_settings.js +++ b/api/api/cluster.put_settings.js @@ -103,6 +103,8 @@ function buildClusterPutSettings (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cluster.remote_info.js b/api/api/cluster.remote_info.js index 913100d86..5dbf7e36c 100644 --- a/api/api/cluster.remote_info.js +++ b/api/api/cluster.remote_info.js @@ -100,6 +100,8 @@ function buildClusterRemoteInfo (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cluster.reroute.js b/api/api/cluster.reroute.js index 394f5bfd5..bf5f88232 100644 --- a/api/api/cluster.reroute.js +++ b/api/api/cluster.reroute.js @@ -110,6 +110,8 @@ function buildClusterReroute (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cluster.state.js b/api/api/cluster.state.js index 30f9a90eb..87df58fe2 100644 --- a/api/api/cluster.state.js +++ b/api/api/cluster.state.js @@ -131,6 +131,8 @@ function buildClusterState (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/cluster.stats.js b/api/api/cluster.stats.js index 17095f42e..feb83ca69 100644 --- a/api/api/cluster.stats.js +++ b/api/api/cluster.stats.js @@ -110,6 +110,8 @@ function buildClusterStats (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/count.js b/api/api/count.js index 60b4c5f83..93569520f 100644 --- a/api/api/count.js +++ b/api/api/count.js @@ -142,6 +142,8 @@ function buildCount (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/count_percolate.js b/api/api/count_percolate.js index 75b3f7948..8bae716b2 100644 --- a/api/api/count_percolate.js +++ b/api/api/count_percolate.js @@ -145,6 +145,8 @@ function buildCountPercolate (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/create.js b/api/api/create.js index ee10fb263..cecaa4312 100644 --- a/api/api/create.js +++ b/api/api/create.js @@ -138,6 +138,8 @@ function buildCreate (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/data_frame.delete_data_frame_transform.js b/api/api/data_frame.delete_data_frame_transform.js new file mode 100644 index 000000000..469f2c6d9 --- /dev/null +++ b/api/api/data_frame.delete_data_frame_transform.js @@ -0,0 +1,128 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildDataFrameDeleteDataFrameTransform (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [data_frame.delete_data_frame_transform](https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-data-frame-transform.html) request + * + * @param {string} transform_id - The id of the transform to delete + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function dataFrameDeleteDataFrameTransform (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['transform_id'] == null && params['transformId'] == null) { + const err = new ConfigurationError('Missing required parameter: transform_id or transformId') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, transformId, transform_id } = params + var querystring = semicopy(params, ['method', 'body', 'transformId', 'transform_id']) + + if (method == null) { + method = 'DELETE' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_data_frame' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId) + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildDataFrameDeleteDataFrameTransform diff --git a/api/api/data_frame.get_data_frame_transform.js b/api/api/data_frame.get_data_frame_transform.js new file mode 100644 index 000000000..7c58b2a92 --- /dev/null +++ b/api/api/data_frame.get_data_frame_transform.js @@ -0,0 +1,131 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildDataFrameGetDataFrameTransform (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [data_frame.get_data_frame_transform](https://www.elastic.co/guide/en/elasticsearch/reference/current/get-data-frame-transform.html) request + * + * @param {string} transform_id - The id or comma delimited list of id expressions of the transforms to get, '_all' or '*' implies get all transforms + * @param {int} from - skips a number of transform configs, defaults to 0 + * @param {int} size - specifies a max number of transforms to get, defaults to 100 + */ + + const acceptedQuerystring = [ + 'from', + 'size' + ] + + const snakeCase = { + + } + + return function dataFrameGetDataFrameTransform (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, transformId, transform_id } = params + var querystring = semicopy(params, ['method', 'body', 'transformId', 'transform_id']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((transform_id || transformId) != null) { + path = '/' + '_data_frame' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId) + } else { + path = '/' + '_data_frame' + '/' + 'transforms' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildDataFrameGetDataFrameTransform diff --git a/api/api/data_frame.get_data_frame_transform_stats.js b/api/api/data_frame.get_data_frame_transform_stats.js new file mode 100644 index 000000000..40264ccd5 --- /dev/null +++ b/api/api/data_frame.get_data_frame_transform_stats.js @@ -0,0 +1,127 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildDataFrameGetDataFrameTransformStats (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [data_frame.get_data_frame_transform_stats](https://www.elastic.co/guide/en/elasticsearch/reference/current/get-data-frame-transform-stats.html) request + * + * @param {string} transform_id - The id of the transform for which to get stats. '_all' or '*' implies all transforms + * @param {number} from - skips a number of transform stats, defaults to 0 + * @param {number} size - specifies a max number of transform stats to get, defaults to 100 + */ + + const acceptedQuerystring = [ + 'from', + 'size' + ] + + const snakeCase = { + + } + + return function dataFrameGetDataFrameTransformStats (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, transformId, transform_id } = params + var querystring = semicopy(params, ['method', 'body', 'transformId', 'transform_id']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_data_frame' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_stats' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildDataFrameGetDataFrameTransformStats diff --git a/api/api/data_frame.preview_data_frame_transform.js b/api/api/data_frame.preview_data_frame_transform.js new file mode 100644 index 000000000..85bd668a0 --- /dev/null +++ b/api/api/data_frame.preview_data_frame_transform.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildDataFramePreviewDataFrameTransform (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [data_frame.preview_data_frame_transform](https://www.elastic.co/guide/en/elasticsearch/reference/current/preview-data-frame-transform.html) request + * + * @param {object} body - The definition for the data_frame transform to preview + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function dataFramePreviewDataFrameTransform (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_data_frame' + '/' + 'transforms' + '/' + '_preview' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildDataFramePreviewDataFrameTransform diff --git a/api/api/data_frame.put_data_frame_transform.js b/api/api/data_frame.put_data_frame_transform.js new file mode 100644 index 000000000..9514f7895 --- /dev/null +++ b/api/api/data_frame.put_data_frame_transform.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildDataFramePutDataFrameTransform (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [data_frame.put_data_frame_transform](https://www.elastic.co/guide/en/elasticsearch/reference/current/put-data-frame-transform.html) request + * + * @param {string} transform_id - The id of the new transform. + * @param {object} body - The data frame transform definition + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function dataFramePutDataFrameTransform (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['transform_id'] == null && params['transformId'] == null) { + const err = new ConfigurationError('Missing required parameter: transform_id or transformId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, transformId, transform_id } = params + var querystring = semicopy(params, ['method', 'body', 'transformId', 'transform_id']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_data_frame' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildDataFramePutDataFrameTransform diff --git a/api/api/data_frame.start_data_frame_transform.js b/api/api/data_frame.start_data_frame_transform.js new file mode 100644 index 000000000..6f2218cca --- /dev/null +++ b/api/api/data_frame.start_data_frame_transform.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildDataFrameStartDataFrameTransform (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [data_frame.start_data_frame_transform](https://www.elastic.co/guide/en/elasticsearch/reference/current/start-data-frame-transform.html) request + * + * @param {string} transform_id - The id of the transform to start + * @param {time} timeout - Controls the time to wait for the transform to start + */ + + const acceptedQuerystring = [ + 'timeout' + ] + + const snakeCase = { + + } + + return function dataFrameStartDataFrameTransform (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['transform_id'] == null && params['transformId'] == null) { + const err = new ConfigurationError('Missing required parameter: transform_id or transformId') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, transformId, transform_id } = params + var querystring = semicopy(params, ['method', 'body', 'transformId', 'transform_id']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_data_frame' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_start' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildDataFrameStartDataFrameTransform diff --git a/api/api/data_frame.stop_data_frame_transform.js b/api/api/data_frame.stop_data_frame_transform.js new file mode 100644 index 000000000..be3919984 --- /dev/null +++ b/api/api/data_frame.stop_data_frame_transform.js @@ -0,0 +1,132 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildDataFrameStopDataFrameTransform (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [data_frame.stop_data_frame_transform](https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-data-frame-transform.html) request + * + * @param {string} transform_id - The id of the transform to stop + * @param {boolean} wait_for_completion - Whether to wait for the transform to fully stop before returning or not. Default to false + * @param {time} timeout - Controls the time to wait until the transform has stopped. Default to 30 seconds + */ + + const acceptedQuerystring = [ + 'wait_for_completion', + 'timeout' + ] + + const snakeCase = { + waitForCompletion: 'wait_for_completion' + + } + + return function dataFrameStopDataFrameTransform (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['transform_id'] == null && params['transformId'] == null) { + const err = new ConfigurationError('Missing required parameter: transform_id or transformId') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, transformId, transform_id } = params + var querystring = semicopy(params, ['method', 'body', 'transformId', 'transform_id']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_data_frame' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_stop' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildDataFrameStopDataFrameTransform diff --git a/api/api/delete.js b/api/api/delete.js index d8a107649..357e4411a 100644 --- a/api/api/delete.js +++ b/api/api/delete.js @@ -140,6 +140,8 @@ function buildDelete (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/delete_by_query.js b/api/api/delete_by_query.js index 069b14098..363dc902a 100644 --- a/api/api/delete_by_query.js +++ b/api/api/delete_by_query.js @@ -196,6 +196,8 @@ function buildDeleteByQuery (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/delete_by_query_rethrottle.js b/api/api/delete_by_query_rethrottle.js new file mode 100644 index 000000000..8cc90e6ab --- /dev/null +++ b/api/api/delete_by_query_rethrottle.js @@ -0,0 +1,140 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildDeleteByQueryRethrottle (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [delete_by_query_rethrottle](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html) request + * + * @param {string} task_id - The task id to rethrottle + * @param {number} requests_per_second - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. + */ + + const acceptedQuerystring = [ + 'requests_per_second', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + requestsPerSecond: 'requests_per_second', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + + return function deleteByQueryRethrottle (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['task_id'] == null && params['taskId'] == null) { + const err = new ConfigurationError('Missing required parameter: task_id or taskId') + return handleError(err, callback) + } + if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) { + const err = new ConfigurationError('Missing required parameter: requests_per_second or requestsPerSecond') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, taskId, task_id } = params + var querystring = semicopy(params, ['method', 'body', 'taskId', 'task_id']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_delete_by_query' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_rethrottle' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildDeleteByQueryRethrottle diff --git a/api/api/delete_script.js b/api/api/delete_script.js index 468967516..90c329149 100644 --- a/api/api/delete_script.js +++ b/api/api/delete_script.js @@ -125,6 +125,8 @@ function buildDeleteScript (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/delete_template.js b/api/api/delete_template.js index 97cf90404..2a9a733f7 100644 --- a/api/api/delete_template.js +++ b/api/api/delete_template.js @@ -105,6 +105,8 @@ function buildDeleteTemplate (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/exists.js b/api/api/exists.js index 7b74e78cd..147f6a543 100644 --- a/api/api/exists.js +++ b/api/api/exists.js @@ -141,6 +141,8 @@ function buildExists (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/exists_source.js b/api/api/exists_source.js index 944f478b7..443d8f15a 100644 --- a/api/api/exists_source.js +++ b/api/api/exists_source.js @@ -147,6 +147,8 @@ function buildExistsSource (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/explain.js b/api/api/explain.js index b53a48326..104873fcc 100644 --- a/api/api/explain.js +++ b/api/api/explain.js @@ -143,6 +143,8 @@ function buildExplain (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/field_caps.js b/api/api/field_caps.js index 5d792bfc9..e15254570 100644 --- a/api/api/field_caps.js +++ b/api/api/field_caps.js @@ -111,6 +111,8 @@ function buildFieldCaps (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/field_stats.js b/api/api/field_stats.js index b44e7ab49..2a1bafe27 100644 --- a/api/api/field_stats.js +++ b/api/api/field_stats.js @@ -113,6 +113,8 @@ function buildFieldStats (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/get.js b/api/api/get.js index b78399d13..5eb22f1f9 100644 --- a/api/api/get.js +++ b/api/api/get.js @@ -141,6 +141,8 @@ function buildGet (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/get_script.js b/api/api/get_script.js index 9011627d4..da9ae5546 100644 --- a/api/api/get_script.js +++ b/api/api/get_script.js @@ -120,6 +120,8 @@ function buildGetScript (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/get_source.js b/api/api/get_source.js index 77da2b54a..1bfba7def 100644 --- a/api/api/get_source.js +++ b/api/api/get_source.js @@ -138,6 +138,8 @@ function buildGetSource (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/get_template.js b/api/api/get_template.js index 1b1207c59..9579e7c61 100644 --- a/api/api/get_template.js +++ b/api/api/get_template.js @@ -105,6 +105,8 @@ function buildGetTemplate (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/graph.explore.js b/api/api/graph.explore.js new file mode 100644 index 000000000..44da987fb --- /dev/null +++ b/api/api/graph.explore.js @@ -0,0 +1,133 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildGraphExplore (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [graph.explore](https://www.elastic.co/guide/en/elasticsearch/reference/current/graph-explore-api.html) request + * + * @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + * @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types + * @param {string} routing - Specific routing value + * @param {time} timeout - Explicit operation timeout + * @param {object} body - Graph Query DSL + */ + + const acceptedQuerystring = [ + 'routing', + 'timeout' + ] + + const snakeCase = { + + } + + return function graphExplore (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + const err = new ConfigurationError('Missing required parameter of the url: index') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'type']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_graph' + '/' + 'explore' + } else { + path = '/' + encodeURIComponent(index) + '/' + '_graph' + '/' + 'explore' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildGraphExplore diff --git a/api/api/ilm.delete_lifecycle.js b/api/api/ilm.delete_lifecycle.js new file mode 100644 index 000000000..57ced77cc --- /dev/null +++ b/api/api/ilm.delete_lifecycle.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildIlmDeleteLifecycle (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ilm.delete_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-delete-lifecycle.html) request + * + * @param {string} policy - The name of the index lifecycle policy + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function ilmDeleteLifecycle (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, policy } = params + var querystring = semicopy(params, ['method', 'body', 'policy']) + + if (method == null) { + method = 'DELETE' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(policy) + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildIlmDeleteLifecycle diff --git a/api/api/ilm.explain_lifecycle.js b/api/api/ilm.explain_lifecycle.js new file mode 100644 index 000000000..62362c7ec --- /dev/null +++ b/api/api/ilm.explain_lifecycle.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildIlmExplainLifecycle (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ilm.explain_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-explain-lifecycle.html) request + * + * @param {string} index - The name of the index to explain + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function ilmExplainLifecycle (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(index) + '/' + '_ilm' + '/' + 'explain' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildIlmExplainLifecycle diff --git a/api/api/ilm.get_lifecycle.js b/api/api/ilm.get_lifecycle.js new file mode 100644 index 000000000..1145c399a --- /dev/null +++ b/api/api/ilm.get_lifecycle.js @@ -0,0 +1,128 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildIlmGetLifecycle (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ilm.get_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-lifecycle.html) request + * + * @param {string} policy - The name of the index lifecycle policy + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function ilmGetLifecycle (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, policy } = params + var querystring = semicopy(params, ['method', 'body', 'policy']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((policy) != null) { + path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(policy) + } else { + path = '/' + '_ilm' + '/' + 'policy' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildIlmGetLifecycle diff --git a/api/api/ilm.get_status.js b/api/api/ilm.get_status.js new file mode 100644 index 000000000..f27b964e3 --- /dev/null +++ b/api/api/ilm.get_status.js @@ -0,0 +1,123 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildIlmGetStatus (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ilm.get_status](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-status.html) request + * + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function ilmGetStatus (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ilm' + '/' + 'status' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildIlmGetStatus diff --git a/api/api/ilm.move_to_step.js b/api/api/ilm.move_to_step.js new file mode 100644 index 000000000..c450a083a --- /dev/null +++ b/api/api/ilm.move_to_step.js @@ -0,0 +1,119 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildIlmMoveToStep (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ilm.move_to_step](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-move-to-step.html) request + * + * @param {string} index - The name of the index whose lifecycle step is to change + * @param {object} body - The new lifecycle step to move to + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function ilmMoveToStep (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ilm' + '/' + 'move' + '/' + encodeURIComponent(index) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildIlmMoveToStep diff --git a/api/api/ilm.put_lifecycle.js b/api/api/ilm.put_lifecycle.js new file mode 100644 index 000000000..b8d58d5f3 --- /dev/null +++ b/api/api/ilm.put_lifecycle.js @@ -0,0 +1,119 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildIlmPutLifecycle (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ilm.put_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-put-lifecycle.html) request + * + * @param {string} policy - The name of the index lifecycle policy + * @param {object} body - The lifecycle policy definition to register + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function ilmPutLifecycle (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, policy } = params + var querystring = semicopy(params, ['method', 'body', 'policy']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(policy) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildIlmPutLifecycle diff --git a/api/api/ilm.remove_policy.js b/api/api/ilm.remove_policy.js new file mode 100644 index 000000000..ca37399d2 --- /dev/null +++ b/api/api/ilm.remove_policy.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildIlmRemovePolicy (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ilm.remove_policy](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-remove-policy.html) request + * + * @param {string} index - The name of the index to remove policy on + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function ilmRemovePolicy (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(index) + '/' + '_ilm' + '/' + 'remove' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildIlmRemovePolicy diff --git a/api/api/ilm.retry.js b/api/api/ilm.retry.js new file mode 100644 index 000000000..1fbcdd1da --- /dev/null +++ b/api/api/ilm.retry.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildIlmRetry (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ilm.retry](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-retry-policy.html) request + * + * @param {string} index - The name of the indices (comma-separated) whose failed lifecycle step is to be retry + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function ilmRetry (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(index) + '/' + '_ilm' + '/' + 'retry' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildIlmRetry diff --git a/api/api/ilm.start.js b/api/api/ilm.start.js new file mode 100644 index 000000000..8c907d91d --- /dev/null +++ b/api/api/ilm.start.js @@ -0,0 +1,123 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildIlmStart (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ilm.start](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-start.html) request + * + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function ilmStart (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ilm' + '/' + 'start' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildIlmStart diff --git a/api/api/ilm.stop.js b/api/api/ilm.stop.js new file mode 100644 index 000000000..b056fa599 --- /dev/null +++ b/api/api/ilm.stop.js @@ -0,0 +1,123 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildIlmStop (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ilm.stop](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-stop.html) request + * + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function ilmStop (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ilm' + '/' + 'stop' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildIlmStop diff --git a/api/api/index.js b/api/api/index.js index 81ae22b9a..663144e16 100644 --- a/api/api/index.js +++ b/api/api/index.js @@ -150,6 +150,8 @@ function buildIndex (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.analyze.js b/api/api/indices.analyze.js index 1d34d1dab..4a20415bc 100644 --- a/api/api/indices.analyze.js +++ b/api/api/indices.analyze.js @@ -124,6 +124,8 @@ function buildIndicesAnalyze (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.clear_cache.js b/api/api/indices.clear_cache.js index 102f85d38..f825fa774 100644 --- a/api/api/indices.clear_cache.js +++ b/api/api/indices.clear_cache.js @@ -132,6 +132,8 @@ function buildIndicesClearCache (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.close.js b/api/api/indices.close.js index 0d8bd81ca..3e58357fe 100644 --- a/api/api/indices.close.js +++ b/api/api/indices.close.js @@ -119,6 +119,8 @@ function buildIndicesClose (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.create.js b/api/api/indices.create.js index 674b4994d..1170ea979 100644 --- a/api/api/indices.create.js +++ b/api/api/indices.create.js @@ -113,6 +113,8 @@ function buildIndicesCreate (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.delete.js b/api/api/indices.delete.js index 5d89bff97..be49c746e 100644 --- a/api/api/indices.delete.js +++ b/api/api/indices.delete.js @@ -110,6 +110,8 @@ function buildIndicesDelete (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.delete_alias.js b/api/api/indices.delete_alias.js index ede909dac..49bd23d3d 100644 --- a/api/api/indices.delete_alias.js +++ b/api/api/indices.delete_alias.js @@ -125,6 +125,8 @@ function buildIndicesDeleteAlias (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.delete_template.js b/api/api/indices.delete_template.js index ee490456a..051d6062b 100644 --- a/api/api/indices.delete_template.js +++ b/api/api/indices.delete_template.js @@ -110,6 +110,8 @@ function buildIndicesDeleteTemplate (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.exists.js b/api/api/indices.exists.js index 711916d43..3baf2fa13 100644 --- a/api/api/indices.exists.js +++ b/api/api/indices.exists.js @@ -122,6 +122,8 @@ function buildIndicesExists (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.exists_alias.js b/api/api/indices.exists_alias.js index 36a09aa3b..14f811ed7 100644 --- a/api/api/indices.exists_alias.js +++ b/api/api/indices.exists_alias.js @@ -117,6 +117,8 @@ function buildIndicesExistsAlias (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.exists_template.js b/api/api/indices.exists_template.js index 1584e52bf..cadc5924e 100644 --- a/api/api/indices.exists_template.js +++ b/api/api/indices.exists_template.js @@ -113,6 +113,8 @@ function buildIndicesExistsTemplate (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.exists_type.js b/api/api/indices.exists_type.js index 55e54e9b8..e460e7ae0 100644 --- a/api/api/indices.exists_type.js +++ b/api/api/indices.exists_type.js @@ -127,6 +127,8 @@ function buildIndicesExistsType (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.flush.js b/api/api/indices.flush.js index cbfb11bae..d75aeb94c 100644 --- a/api/api/indices.flush.js +++ b/api/api/indices.flush.js @@ -119,6 +119,8 @@ function buildIndicesFlush (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.flush_synced.js b/api/api/indices.flush_synced.js index a3c39f6cb..d58b9ebaa 100644 --- a/api/api/indices.flush_synced.js +++ b/api/api/indices.flush_synced.js @@ -114,6 +114,8 @@ function buildIndicesFlushSynced (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.forcemerge.js b/api/api/indices.forcemerge.js index 085df4aee..b11fee565 100644 --- a/api/api/indices.forcemerge.js +++ b/api/api/indices.forcemerge.js @@ -128,6 +128,8 @@ function buildIndicesForcemerge (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.get.js b/api/api/indices.get.js index 9b760b78a..76b8733a2 100644 --- a/api/api/indices.get.js +++ b/api/api/indices.get.js @@ -133,6 +133,8 @@ function buildIndicesGet (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.get_alias.js b/api/api/indices.get_alias.js index 8f2614910..b66004bb9 100644 --- a/api/api/indices.get_alias.js +++ b/api/api/indices.get_alias.js @@ -121,6 +121,8 @@ function buildIndicesGetAlias (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.get_field_mapping.js b/api/api/indices.get_field_mapping.js index 6d4871de3..5f758a158 100644 --- a/api/api/indices.get_field_mapping.js +++ b/api/api/indices.get_field_mapping.js @@ -129,6 +129,8 @@ function buildIndicesGetFieldMapping (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.get_mapping.js b/api/api/indices.get_mapping.js index ac90ebd75..1d2fc10d6 100644 --- a/api/api/indices.get_mapping.js +++ b/api/api/indices.get_mapping.js @@ -121,6 +121,8 @@ function buildIndicesGetMapping (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.get_settings.js b/api/api/indices.get_settings.js index d0be4b987..0b813572c 100644 --- a/api/api/indices.get_settings.js +++ b/api/api/indices.get_settings.js @@ -127,6 +127,8 @@ function buildIndicesGetSettings (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.get_template.js b/api/api/indices.get_template.js index 79245e4cb..12b78be18 100644 --- a/api/api/indices.get_template.js +++ b/api/api/indices.get_template.js @@ -113,6 +113,8 @@ function buildIndicesGetTemplate (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.get_upgrade.js b/api/api/indices.get_upgrade.js index 467722d43..bfe74bd37 100644 --- a/api/api/indices.get_upgrade.js +++ b/api/api/indices.get_upgrade.js @@ -114,6 +114,8 @@ function buildIndicesGetUpgrade (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.open.js b/api/api/indices.open.js index ef2953ffd..1435cbe45 100644 --- a/api/api/indices.open.js +++ b/api/api/indices.open.js @@ -119,6 +119,8 @@ function buildIndicesOpen (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.put_alias.js b/api/api/indices.put_alias.js index 60dbf626a..b80bda3ee 100644 --- a/api/api/indices.put_alias.js +++ b/api/api/indices.put_alias.js @@ -122,6 +122,8 @@ function buildIndicesPutAlias (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.put_mapping.js b/api/api/indices.put_mapping.js index e4f93362b..50b7ed297 100644 --- a/api/api/indices.put_mapping.js +++ b/api/api/indices.put_mapping.js @@ -136,6 +136,8 @@ function buildIndicesPutMapping (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.put_settings.js b/api/api/indices.put_settings.js index 8a2630ecb..1fd1cc1a2 100644 --- a/api/api/indices.put_settings.js +++ b/api/api/indices.put_settings.js @@ -124,6 +124,8 @@ function buildIndicesPutSettings (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.put_template.js b/api/api/indices.put_template.js index 6f8b8d217..03bac22c6 100644 --- a/api/api/indices.put_template.js +++ b/api/api/indices.put_template.js @@ -118,6 +118,8 @@ function buildIndicesPutTemplate (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.recovery.js b/api/api/indices.recovery.js index 2af8951d5..4cc7fe21c 100644 --- a/api/api/indices.recovery.js +++ b/api/api/indices.recovery.js @@ -110,6 +110,8 @@ function buildIndicesRecovery (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.refresh.js b/api/api/indices.refresh.js index dd052431f..c34808a10 100644 --- a/api/api/indices.refresh.js +++ b/api/api/indices.refresh.js @@ -114,6 +114,8 @@ function buildIndicesRefresh (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.rollover.js b/api/api/indices.rollover.js index 5d51b8ef2..27b81828b 100644 --- a/api/api/indices.rollover.js +++ b/api/api/indices.rollover.js @@ -124,6 +124,8 @@ function buildIndicesRollover (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.segments.js b/api/api/indices.segments.js index eed68385d..7552e0c55 100644 --- a/api/api/indices.segments.js +++ b/api/api/indices.segments.js @@ -119,6 +119,8 @@ function buildIndicesSegments (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.shard_stores.js b/api/api/indices.shard_stores.js index 42e061d6f..0ce6d2a64 100644 --- a/api/api/indices.shard_stores.js +++ b/api/api/indices.shard_stores.js @@ -119,6 +119,8 @@ function buildIndicesShardStores (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.shrink.js b/api/api/indices.shrink.js index d268e2229..98d6ebcd1 100644 --- a/api/api/indices.shrink.js +++ b/api/api/indices.shrink.js @@ -121,6 +121,8 @@ function buildIndicesShrink (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.stats.js b/api/api/indices.stats.js index 40544f6e5..a801d7f2d 100644 --- a/api/api/indices.stats.js +++ b/api/api/indices.stats.js @@ -127,6 +127,8 @@ function buildIndicesStats (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.update_aliases.js b/api/api/indices.update_aliases.js index 317ccf519..dd7bbb659 100644 --- a/api/api/indices.update_aliases.js +++ b/api/api/indices.update_aliases.js @@ -106,6 +106,8 @@ function buildIndicesUpdateAliases (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.upgrade.js b/api/api/indices.upgrade.js index bf9fcd72c..97910c123 100644 --- a/api/api/indices.upgrade.js +++ b/api/api/indices.upgrade.js @@ -120,6 +120,8 @@ function buildIndicesUpgrade (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/indices.validate_query.js b/api/api/indices.validate_query.js index 37ecefd08..45ee95382 100644 --- a/api/api/indices.validate_query.js +++ b/api/api/indices.validate_query.js @@ -142,6 +142,8 @@ function buildIndicesValidateQuery (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/info.js b/api/api/info.js index 2bedeb333..534d473b1 100644 --- a/api/api/info.js +++ b/api/api/info.js @@ -100,6 +100,8 @@ function buildInfo (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/ingest.delete_pipeline.js b/api/api/ingest.delete_pipeline.js index 6a2077cb9..f44e632b7 100644 --- a/api/api/ingest.delete_pipeline.js +++ b/api/api/ingest.delete_pipeline.js @@ -110,6 +110,8 @@ function buildIngestDeletePipeline (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/ingest.get_pipeline.js b/api/api/ingest.get_pipeline.js index 992cc60f3..186bdc947 100644 --- a/api/api/ingest.get_pipeline.js +++ b/api/api/ingest.get_pipeline.js @@ -108,6 +108,8 @@ function buildIngestGetPipeline (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/ingest.processor_grok.js b/api/api/ingest.processor_grok.js index f3c88aa8f..056843cb2 100644 --- a/api/api/ingest.processor_grok.js +++ b/api/api/ingest.processor_grok.js @@ -100,6 +100,8 @@ function buildIngestProcessorGrok (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/ingest.put_pipeline.js b/api/api/ingest.put_pipeline.js index 2bb48563d..2329542f5 100644 --- a/api/api/ingest.put_pipeline.js +++ b/api/api/ingest.put_pipeline.js @@ -111,6 +111,8 @@ function buildIngestPutPipeline (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/ingest.simulate.js b/api/api/ingest.simulate.js index 130d5f63f..603eaf9e5 100644 --- a/api/api/ingest.simulate.js +++ b/api/api/ingest.simulate.js @@ -108,6 +108,8 @@ function buildIngestSimulate (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/license.delete.js b/api/api/license.delete.js new file mode 100644 index 000000000..fdf2efbc6 --- /dev/null +++ b/api/api/license.delete.js @@ -0,0 +1,123 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildLicenseDelete (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [license.delete](https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-license.html) request + * + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function licenseDelete (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'DELETE' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_license' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildLicenseDelete diff --git a/api/api/license.get.js b/api/api/license.get.js new file mode 100644 index 000000000..57266aa82 --- /dev/null +++ b/api/api/license.get.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildLicenseGet (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [license.get](https://www.elastic.co/guide/en/elasticsearch/reference/master/get-license.html) request + * + * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) + */ + + const acceptedQuerystring = [ + 'local' + ] + + const snakeCase = { + + } + + return function licenseGet (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_license' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildLicenseGet diff --git a/api/api/license.get_basic_status.js b/api/api/license.get_basic_status.js new file mode 100644 index 000000000..cccf3ffef --- /dev/null +++ b/api/api/license.get_basic_status.js @@ -0,0 +1,123 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildLicenseGetBasicStatus (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [license.get_basic_status](https://www.elastic.co/guide/en/elasticsearch/reference/master/get-basic-status.html) request + * + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function licenseGetBasicStatus (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_license' + '/' + 'basic_status' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildLicenseGetBasicStatus diff --git a/api/api/license.get_trial_status.js b/api/api/license.get_trial_status.js new file mode 100644 index 000000000..dcc9091cc --- /dev/null +++ b/api/api/license.get_trial_status.js @@ -0,0 +1,123 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildLicenseGetTrialStatus (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [license.get_trial_status](https://www.elastic.co/guide/en/elasticsearch/reference/master/get-trial-status.html) request + * + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function licenseGetTrialStatus (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_license' + '/' + 'trial_status' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildLicenseGetTrialStatus diff --git a/api/api/license.post.js b/api/api/license.post.js new file mode 100644 index 000000000..b29cb4d32 --- /dev/null +++ b/api/api/license.post.js @@ -0,0 +1,119 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildLicensePost (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [license.post](https://www.elastic.co/guide/en/elasticsearch/reference/master/update-license.html) request + * + * @param {boolean} acknowledge - whether the user has acknowledged acknowledge messages (default: false) + * @param {object} body - licenses to be installed + */ + + const acceptedQuerystring = [ + 'acknowledge' + ] + + const snakeCase = { + + } + + return function licensePost (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_license' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildLicensePost diff --git a/api/api/license.post_start_basic.js b/api/api/license.post_start_basic.js new file mode 100644 index 000000000..272e61fc4 --- /dev/null +++ b/api/api/license.post_start_basic.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildLicensePostStartBasic (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [license.post_start_basic](https://www.elastic.co/guide/en/elasticsearch/reference/master/start-basic.html) request + * + * @param {boolean} acknowledge - whether the user has acknowledged acknowledge messages (default: false) + */ + + const acceptedQuerystring = [ + 'acknowledge' + ] + + const snakeCase = { + + } + + return function licensePostStartBasic (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_license' + '/' + 'start_basic' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildLicensePostStartBasic diff --git a/api/api/license.post_start_trial.js b/api/api/license.post_start_trial.js new file mode 100644 index 000000000..79207341f --- /dev/null +++ b/api/api/license.post_start_trial.js @@ -0,0 +1,126 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildLicensePostStartTrial (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [license.post_start_trial](https://www.elastic.co/guide/en/elasticsearch/reference/master/start-trial.html) request + * + * @param {string} type - The type of trial license to generate (default: "trial") + * @param {boolean} acknowledge - whether the user has acknowledged acknowledge messages (default: false) + */ + + const acceptedQuerystring = [ + 'type', + 'acknowledge' + ] + + const snakeCase = { + + } + + return function licensePostStartTrial (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_license' + '/' + 'start_trial' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildLicensePostStartTrial diff --git a/api/api/mget.js b/api/api/mget.js index d9093a53e..baef820ff 100644 --- a/api/api/mget.js +++ b/api/api/mget.js @@ -134,6 +134,8 @@ function buildMget (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/migration.deprecations.js b/api/api/migration.deprecations.js new file mode 100644 index 000000000..727d3a5ba --- /dev/null +++ b/api/api/migration.deprecations.js @@ -0,0 +1,128 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMigrationDeprecations (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [migration.deprecations](http://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-deprecation.html) request + * + * @param {string} index - Index pattern + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function migrationDeprecations (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((index) != null) { + path = '/' + encodeURIComponent(index) + '/' + '_migration' + '/' + 'deprecations' + } else { + path = '/' + '_migration' + '/' + 'deprecations' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMigrationDeprecations diff --git a/api/api/ml.close_job.js b/api/api/ml.close_job.js new file mode 100644 index 000000000..ec61d7008 --- /dev/null +++ b/api/api/ml.close_job.js @@ -0,0 +1,131 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlCloseJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.close_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-close-job.html) request + * + * @param {string} job_id - The name of the job to close + * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + * @param {boolean} force - True if the job should be forcefully closed + * @param {time} timeout - Controls the time to wait until a job has closed. Default to 30 minutes + * @param {object} body - The URL params optionally sent in the body + */ + + const acceptedQuerystring = [ + 'allow_no_jobs', + 'force', + 'timeout' + ] + + const snakeCase = { + allowNoJobs: 'allow_no_jobs' + + } + + return function mlCloseJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_close' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlCloseJob diff --git a/api/api/ml.delete_calendar.js b/api/api/ml.delete_calendar.js new file mode 100644 index 000000000..dc94d6b92 --- /dev/null +++ b/api/api/ml.delete_calendar.js @@ -0,0 +1,128 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlDeleteCalendar (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.delete_calendar](undefined) request + * + * @param {string} calendar_id - The ID of the calendar to delete + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function mlDeleteCalendar (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + const err = new ConfigurationError('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, calendarId, calendar_id } = params + var querystring = semicopy(params, ['method', 'body', 'calendarId', 'calendar_id']) + + if (method == null) { + method = 'DELETE' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlDeleteCalendar diff --git a/api/api/ml.delete_calendar_event.js b/api/api/ml.delete_calendar_event.js new file mode 100644 index 000000000..4846c13fe --- /dev/null +++ b/api/api/ml.delete_calendar_event.js @@ -0,0 +1,139 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlDeleteCalendarEvent (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.delete_calendar_event](undefined) request + * + * @param {string} calendar_id - The ID of the calendar to modify + * @param {string} event_id - The ID of the event to remove from the calendar + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function mlDeleteCalendarEvent (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + const err = new ConfigurationError('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) + } + if (params['event_id'] == null && params['eventId'] == null) { + const err = new ConfigurationError('Missing required parameter: event_id or eventId') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // check required url components + if ((params['event_id'] != null || params['eventId'] != null) && ((params['calendar_id'] == null && params['calendarId'] == null))) { + const err = new ConfigurationError('Missing required parameter of the url: calendar_id') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, calendarId, calendar_id, eventId, event_id } = params + var querystring = semicopy(params, ['method', 'body', 'calendarId', 'calendar_id', 'eventId', 'event_id']) + + if (method == null) { + method = 'DELETE' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'events' + '/' + encodeURIComponent(event_id || eventId) + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlDeleteCalendarEvent diff --git a/api/api/ml.delete_calendar_job.js b/api/api/ml.delete_calendar_job.js new file mode 100644 index 000000000..27ebb4341 --- /dev/null +++ b/api/api/ml.delete_calendar_job.js @@ -0,0 +1,139 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlDeleteCalendarJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.delete_calendar_job](undefined) request + * + * @param {string} calendar_id - The ID of the calendar to modify + * @param {string} job_id - The ID of the job to remove from the calendar + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function mlDeleteCalendarJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + const err = new ConfigurationError('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) + } + if (params['job_id'] == null && params['jobId'] == null) { + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // check required url components + if ((params['job_id'] != null || params['jobId'] != null) && ((params['calendar_id'] == null && params['calendarId'] == null))) { + const err = new ConfigurationError('Missing required parameter of the url: calendar_id') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, calendarId, calendar_id, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'calendarId', 'calendar_id', 'jobId', 'job_id']) + + if (method == null) { + method = 'DELETE' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'jobs' + '/' + encodeURIComponent(job_id || jobId) + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlDeleteCalendarJob diff --git a/api/api/ml.delete_datafeed.js b/api/api/ml.delete_datafeed.js new file mode 100644 index 000000000..5350874cb --- /dev/null +++ b/api/api/ml.delete_datafeed.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlDeleteDatafeed (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.delete_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html) request + * + * @param {string} datafeed_id - The ID of the datafeed to delete + * @param {boolean} force - True if the datafeed should be forcefully deleted + */ + + const acceptedQuerystring = [ + 'force' + ] + + const snakeCase = { + + } + + return function mlDeleteDatafeed (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + const err = new ConfigurationError('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, datafeedId, datafeed_id } = params + var querystring = semicopy(params, ['method', 'body', 'datafeedId', 'datafeed_id']) + + if (method == null) { + method = 'DELETE' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlDeleteDatafeed diff --git a/api/api/ml.delete_expired_data.js b/api/api/ml.delete_expired_data.js new file mode 100644 index 000000000..d28a54756 --- /dev/null +++ b/api/api/ml.delete_expired_data.js @@ -0,0 +1,123 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlDeleteExpiredData (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.delete_expired_data](undefined) request + * + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function mlDeleteExpiredData (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'DELETE' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + '_delete_expired_data' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlDeleteExpiredData diff --git a/api/api/ml.delete_filter.js b/api/api/ml.delete_filter.js new file mode 100644 index 000000000..e14c6004a --- /dev/null +++ b/api/api/ml.delete_filter.js @@ -0,0 +1,128 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlDeleteFilter (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.delete_filter](undefined) request + * + * @param {string} filter_id - The ID of the filter to delete + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function mlDeleteFilter (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['filter_id'] == null && params['filterId'] == null) { + const err = new ConfigurationError('Missing required parameter: filter_id or filterId') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, filterId, filter_id } = params + var querystring = semicopy(params, ['method', 'body', 'filterId', 'filter_id']) + + if (method == null) { + method = 'DELETE' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(filter_id || filterId) + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlDeleteFilter diff --git a/api/api/ml.delete_forecast.js b/api/api/ml.delete_forecast.js new file mode 100644 index 000000000..61578af3c --- /dev/null +++ b/api/api/ml.delete_forecast.js @@ -0,0 +1,143 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlDeleteForecast (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.delete_forecast](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html) request + * + * @param {string} job_id - The ID of the job from which to delete forecasts + * @param {string} forecast_id - The ID of the forecast to delete, can be comma delimited list. Leaving blank implies `_all` + * @param {boolean} allow_no_forecasts - Whether to ignore if `_all` matches no forecasts + * @param {time} timeout - Controls the time to wait until the forecast(s) are deleted. Default to 30 seconds + */ + + const acceptedQuerystring = [ + 'allow_no_forecasts', + 'timeout' + ] + + const snakeCase = { + allowNoForecasts: 'allow_no_forecasts' + + } + + return function mlDeleteForecast (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // check required url components + if ((params['forecast_id'] != null || params['forecastId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { + const err = new ConfigurationError('Missing required parameter of the url: job_id') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, jobId, job_id, forecastId, forecast_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id', 'forecastId', 'forecast_id']) + + if (method == null) { + method = 'DELETE' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((job_id || jobId) != null && (forecast_id || forecastId) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_forecast' + '/' + encodeURIComponent(forecast_id || forecastId) + } else { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_forecast' + } + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlDeleteForecast diff --git a/api/api/ml.delete_job.js b/api/api/ml.delete_job.js new file mode 100644 index 000000000..2dab49868 --- /dev/null +++ b/api/api/ml.delete_job.js @@ -0,0 +1,131 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlDeleteJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.delete_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html) request + * + * @param {string} job_id - The ID of the job to delete + * @param {boolean} force - True if the job should be forcefully deleted + * @param {boolean} wait_for_completion - Should this request wait until the operation has completed before returning + */ + + const acceptedQuerystring = [ + 'force', + 'wait_for_completion' + ] + + const snakeCase = { + waitForCompletion: 'wait_for_completion' + } + + return function mlDeleteJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = 'DELETE' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlDeleteJob diff --git a/api/api/ml.delete_model_snapshot.js b/api/api/ml.delete_model_snapshot.js new file mode 100644 index 000000000..ee7e86377 --- /dev/null +++ b/api/api/ml.delete_model_snapshot.js @@ -0,0 +1,139 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlDeleteModelSnapshot (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.delete_model_snapshot](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-snapshot.html) request + * + * @param {string} job_id - The ID of the job to fetch + * @param {string} snapshot_id - The ID of the snapshot to delete + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function mlDeleteModelSnapshot (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params['snapshot_id'] == null && params['snapshotId'] == null) { + const err = new ConfigurationError('Missing required parameter: snapshot_id or snapshotId') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // check required url components + if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { + const err = new ConfigurationError('Missing required parameter of the url: job_id') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, jobId, job_id, snapshotId, snapshot_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id', 'snapshotId', 'snapshot_id']) + + if (method == null) { + method = 'DELETE' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + '/' + encodeURIComponent(snapshot_id || snapshotId) + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlDeleteModelSnapshot diff --git a/api/api/ml.find_file_structure.js b/api/api/ml.find_file_structure.js new file mode 100644 index 000000000..1e6de545e --- /dev/null +++ b/api/api/ml.find_file_structure.js @@ -0,0 +1,156 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlFindFileStructure (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.find_file_structure](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-find-file-structure.html) request + * + * @param {int} lines_to_sample - How many lines of the file should be included in the analysis + * @param {time} timeout - Timeout after which the analysis will be aborted + * @param {string} charset - Optional parameter to specify the character set of the file + * @param {enum} format - Optional parameter to specify the high level file format + * @param {boolean} has_header_row - Optional parameter to specify whether a delimited file includes the column names in its first row + * @param {list} column_names - Optional parameter containing a comma separated list of the column names for a delimited file + * @param {string} delimiter - Optional parameter to specify the delimiter character for a delimited file - must be a single character + * @param {string} quote - Optional parameter to specify the quote character for a delimited file - must be a single character + * @param {boolean} should_trim_fields - Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them + * @param {string} grok_pattern - Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file + * @param {string} timestamp_field - Optional parameter to specify the timestamp field in the file + * @param {string} timestamp_format - Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format + * @param {boolean} explain - Whether to include a commentary on how the structure was derived + * @param {object} body - The contents of the file to be analyzed + */ + + const acceptedQuerystring = [ + 'lines_to_sample', + 'timeout', + 'charset', + 'format', + 'has_header_row', + 'column_names', + 'delimiter', + 'quote', + 'should_trim_fields', + 'grok_pattern', + 'timestamp_field', + 'timestamp_format', + 'explain' + ] + + const snakeCase = { + linesToSample: 'lines_to_sample', + hasHeaderRow: 'has_header_row', + columnNames: 'column_names', + shouldTrimFields: 'should_trim_fields', + grokPattern: 'grok_pattern', + timestampField: 'timestamp_field', + timestampFormat: 'timestamp_format' + + } + + return function mlFindFileStructure (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'find_file_structure' + + // build request object + const request = { + method, + path, + bulkBody: body, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlFindFileStructure diff --git a/api/api/ml.flush_job.js b/api/api/ml.flush_job.js new file mode 100644 index 000000000..f2b062ee2 --- /dev/null +++ b/api/api/ml.flush_job.js @@ -0,0 +1,136 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlFlushJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.flush_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-flush-job.html) request + * + * @param {string} job_id - The name of the job to flush + * @param {boolean} calc_interim - Calculates interim results for the most recent bucket or all buckets within the latency period + * @param {string} start - When used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results + * @param {string} end - When used in conjunction with calc_interim, specifies the range of buckets on which to calculate interim results + * @param {string} advance_time - Advances time to the given value generating results and updating the model for the advanced interval + * @param {string} skip_time - Skips time to the given value without generating results or updating the model for the skipped interval + * @param {object} body - Flush parameters + */ + + const acceptedQuerystring = [ + 'calc_interim', + 'start', + 'end', + 'advance_time', + 'skip_time' + ] + + const snakeCase = { + calcInterim: 'calc_interim', + advanceTime: 'advance_time', + skipTime: 'skip_time' + } + + return function mlFlushJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_flush' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlFlushJob diff --git a/api/api/ml.forecast.js b/api/api/ml.forecast.js new file mode 100644 index 000000000..065d17c6c --- /dev/null +++ b/api/api/ml.forecast.js @@ -0,0 +1,131 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlForecast (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.forecast](undefined) request + * + * @param {string} job_id - The ID of the job to forecast for + * @param {time} duration - The duration of the forecast + * @param {time} expires_in - The time interval after which the forecast expires. Expired forecasts will be deleted at the first opportunity. + */ + + const acceptedQuerystring = [ + 'duration', + 'expires_in' + ] + + const snakeCase = { + expiresIn: 'expires_in' + } + + return function mlForecast (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_forecast' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlForecast diff --git a/api/api/ml.get_buckets.js b/api/api/ml.get_buckets.js new file mode 100644 index 000000000..f00ae7a47 --- /dev/null +++ b/api/api/ml.get_buckets.js @@ -0,0 +1,155 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlGetBuckets (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.get_buckets](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-bucket.html) request + * + * @param {string} job_id - ID of the job to get bucket results from + * @param {string} timestamp - The timestamp of the desired single bucket result + * @param {boolean} expand - Include anomaly records + * @param {boolean} exclude_interim - Exclude interim results + * @param {int} from - skips a number of buckets + * @param {int} size - specifies a max number of buckets to get + * @param {string} start - Start time filter for buckets + * @param {string} end - End time filter for buckets + * @param {double} anomaly_score - Filter for the most anomalous buckets + * @param {string} sort - Sort buckets by a particular field + * @param {boolean} desc - Set the sort direction + * @param {object} body - Bucket selection details if not provided in URI + */ + + const acceptedQuerystring = [ + 'expand', + 'exclude_interim', + 'from', + 'size', + 'start', + 'end', + 'anomaly_score', + 'sort', + 'desc' + ] + + const snakeCase = { + excludeInterim: 'exclude_interim', + anomalyScore: 'anomaly_score' + + } + + return function mlGetBuckets (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + // check required url components + if (params['timestamp'] != null && ((params['job_id'] == null && params['jobId'] == null))) { + const err = new ConfigurationError('Missing required parameter of the url: job_id') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, jobId, job_id, timestamp } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id', 'timestamp']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((job_id || jobId) != null && (timestamp) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'buckets' + '/' + encodeURIComponent(timestamp) + } else { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'buckets' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlGetBuckets diff --git a/api/api/ml.get_calendar_events.js b/api/api/ml.get_calendar_events.js new file mode 100644 index 000000000..85540eb2a --- /dev/null +++ b/api/api/ml.get_calendar_events.js @@ -0,0 +1,138 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlGetCalendarEvents (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.get_calendar_events](undefined) request + * + * @param {string} calendar_id - The ID of the calendar containing the events + * @param {string} job_id - Get events for the job. When this option is used calendar_id must be '_all' + * @param {string} start - Get events after this time + * @param {date} end - Get events before this time + * @param {int} from - Skips a number of events + * @param {int} size - Specifies a max number of events to get + */ + + const acceptedQuerystring = [ + 'job_id', + 'start', + 'end', + 'from', + 'size' + ] + + const snakeCase = { + jobId: 'job_id' + + } + + return function mlGetCalendarEvents (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + const err = new ConfigurationError('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, calendarId, calendar_id } = params + var querystring = semicopy(params, ['method', 'body', 'calendarId', 'calendar_id']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'events' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlGetCalendarEvents diff --git a/api/api/ml.get_calendars.js b/api/api/ml.get_calendars.js new file mode 100644 index 000000000..71d9b2771 --- /dev/null +++ b/api/api/ml.get_calendars.js @@ -0,0 +1,126 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlGetCalendars (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.get_calendars](undefined) request + * + * @param {string} calendar_id - The ID of the calendar to fetch + * @param {int} from - skips a number of calendars + * @param {int} size - specifies a max number of calendars to get + * @param {object} body - The from and size parameters optionally sent in the body + */ + + const acceptedQuerystring = [ + 'from', + 'size' + ] + + const snakeCase = { + + } + + return function mlGetCalendars (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, calendarId, calendar_id } = params + var querystring = semicopy(params, ['method', 'body', 'calendarId', 'calendar_id']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((calendar_id || calendarId) != null) { + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + } else { + path = '/' + '_ml' + '/' + 'calendars' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlGetCalendars diff --git a/api/api/ml.get_categories.js b/api/api/ml.get_categories.js new file mode 100644 index 000000000..8ee43bac5 --- /dev/null +++ b/api/api/ml.get_categories.js @@ -0,0 +1,133 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlGetCategories (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.get_categories](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-category.html) request + * + * @param {string} job_id - The name of the job + * @param {long} category_id - The identifier of the category definition of interest + * @param {int} from - skips a number of categories + * @param {int} size - specifies a max number of categories to get + * @param {object} body - Category selection details if not provided in URI + */ + + const acceptedQuerystring = [ + 'from', + 'size' + ] + + const snakeCase = { + + } + + return function mlGetCategories (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, jobId, job_id, categoryId, category_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id', 'categoryId', 'category_id']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((job_id || jobId) != null && (category_id || categoryId) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'categories' + '/' + encodeURIComponent(category_id || categoryId) + } else { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'categories' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlGetCategories diff --git a/api/api/ml.get_datafeed_stats.js b/api/api/ml.get_datafeed_stats.js new file mode 100644 index 000000000..d7dd811aa --- /dev/null +++ b/api/api/ml.get_datafeed_stats.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlGetDatafeedStats (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.get_datafeed_stats](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed-stats.html) request + * + * @param {string} datafeed_id - The ID of the datafeeds stats to fetch + * @param {boolean} allow_no_datafeeds - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + */ + + const acceptedQuerystring = [ + 'allow_no_datafeeds' + ] + + const snakeCase = { + allowNoDatafeeds: 'allow_no_datafeeds' + } + + return function mlGetDatafeedStats (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, datafeedId, datafeed_id } = params + var querystring = semicopy(params, ['method', 'body', 'datafeedId', 'datafeed_id']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((datafeed_id || datafeedId) != null) { + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_stats' + } else { + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + '_stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlGetDatafeedStats diff --git a/api/api/ml.get_datafeeds.js b/api/api/ml.get_datafeeds.js new file mode 100644 index 000000000..6135237cb --- /dev/null +++ b/api/api/ml.get_datafeeds.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlGetDatafeeds (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.get_datafeeds](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed.html) request + * + * @param {string} datafeed_id - The ID of the datafeeds to fetch + * @param {boolean} allow_no_datafeeds - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + */ + + const acceptedQuerystring = [ + 'allow_no_datafeeds' + ] + + const snakeCase = { + allowNoDatafeeds: 'allow_no_datafeeds' + } + + return function mlGetDatafeeds (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, datafeedId, datafeed_id } = params + var querystring = semicopy(params, ['method', 'body', 'datafeedId', 'datafeed_id']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((datafeed_id || datafeedId) != null) { + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + } else { + path = '/' + '_ml' + '/' + 'datafeeds' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlGetDatafeeds diff --git a/api/api/ml.get_filters.js b/api/api/ml.get_filters.js new file mode 100644 index 000000000..3c83a37f8 --- /dev/null +++ b/api/api/ml.get_filters.js @@ -0,0 +1,131 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlGetFilters (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.get_filters](undefined) request + * + * @param {string} filter_id - The ID of the filter to fetch + * @param {int} from - skips a number of filters + * @param {int} size - specifies a max number of filters to get + */ + + const acceptedQuerystring = [ + 'from', + 'size' + ] + + const snakeCase = { + + } + + return function mlGetFilters (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, filterId, filter_id } = params + var querystring = semicopy(params, ['method', 'body', 'filterId', 'filter_id']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((filter_id || filterId) != null) { + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(filter_id || filterId) + } else { + path = '/' + '_ml' + '/' + 'filters' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlGetFilters diff --git a/api/api/ml.get_influencers.js b/api/api/ml.get_influencers.js new file mode 100644 index 000000000..6ce303a12 --- /dev/null +++ b/api/api/ml.get_influencers.js @@ -0,0 +1,142 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlGetInfluencers (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.get_influencers](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-influencer.html) request + * + * @param {string} job_id - + * @param {boolean} exclude_interim - Exclude interim results + * @param {int} from - skips a number of influencers + * @param {int} size - specifies a max number of influencers to get + * @param {string} start - start timestamp for the requested influencers + * @param {string} end - end timestamp for the requested influencers + * @param {double} influencer_score - influencer score threshold for the requested influencers + * @param {string} sort - sort field for the requested influencers + * @param {boolean} desc - whether the results should be sorted in decending order + * @param {object} body - Influencer selection criteria + */ + + const acceptedQuerystring = [ + 'exclude_interim', + 'from', + 'size', + 'start', + 'end', + 'influencer_score', + 'sort', + 'desc' + ] + + const snakeCase = { + excludeInterim: 'exclude_interim', + influencerScore: 'influencer_score' + + } + + return function mlGetInfluencers (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'influencers' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlGetInfluencers diff --git a/api/api/ml.get_job_stats.js b/api/api/ml.get_job_stats.js new file mode 100644 index 000000000..8b5a68e27 --- /dev/null +++ b/api/api/ml.get_job_stats.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlGetJobStats (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.get_job_stats](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-stats.html) request + * + * @param {string} job_id - The ID of the jobs stats to fetch + * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + */ + + const acceptedQuerystring = [ + 'allow_no_jobs' + ] + + const snakeCase = { + allowNoJobs: 'allow_no_jobs' + } + + return function mlGetJobStats (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((job_id || jobId) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_stats' + } else { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlGetJobStats diff --git a/api/api/ml.get_jobs.js b/api/api/ml.get_jobs.js new file mode 100644 index 000000000..688334416 --- /dev/null +++ b/api/api/ml.get_jobs.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlGetJobs (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.get_jobs](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job.html) request + * + * @param {string} job_id - The ID of the jobs to fetch + * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + */ + + const acceptedQuerystring = [ + 'allow_no_jobs' + ] + + const snakeCase = { + allowNoJobs: 'allow_no_jobs' + } + + return function mlGetJobs (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((job_id || jobId) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + } else { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlGetJobs diff --git a/api/api/ml.get_model_snapshots.js b/api/api/ml.get_model_snapshots.js new file mode 100644 index 000000000..7bfa74eb3 --- /dev/null +++ b/api/api/ml.get_model_snapshots.js @@ -0,0 +1,147 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlGetModelSnapshots (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.get_model_snapshots](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-snapshot.html) request + * + * @param {string} job_id - The ID of the job to fetch + * @param {string} snapshot_id - The ID of the snapshot to fetch + * @param {int} from - Skips a number of documents + * @param {int} size - The default number of documents returned in queries as a string. + * @param {date} start - The filter 'start' query parameter + * @param {date} end - The filter 'end' query parameter + * @param {string} sort - Name of the field to sort on + * @param {boolean} desc - True if the results should be sorted in descending order + * @param {object} body - Model snapshot selection criteria + */ + + const acceptedQuerystring = [ + 'from', + 'size', + 'start', + 'end', + 'sort', + 'desc' + ] + + const snakeCase = { + + } + + return function mlGetModelSnapshots (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + // check required url components + if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { + const err = new ConfigurationError('Missing required parameter of the url: job_id') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, jobId, job_id, snapshotId, snapshot_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id', 'snapshotId', 'snapshot_id']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((job_id || jobId) != null && (snapshot_id || snapshotId) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + '/' + encodeURIComponent(snapshot_id || snapshotId) + } else { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlGetModelSnapshots diff --git a/api/api/ml.get_overall_buckets.js b/api/api/ml.get_overall_buckets.js new file mode 100644 index 000000000..e6ee6338c --- /dev/null +++ b/api/api/ml.get_overall_buckets.js @@ -0,0 +1,142 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlGetOverallBuckets (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.get_overall_buckets](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-overall-buckets.html) request + * + * @param {string} job_id - The job IDs for which to calculate overall bucket results + * @param {int} top_n - The number of top job bucket scores to be used in the overall_score calculation + * @param {string} bucket_span - The span of the overall buckets. Defaults to the longest job bucket_span + * @param {double} overall_score - Returns overall buckets with overall scores higher than this value + * @param {boolean} exclude_interim - If true overall buckets that include interim buckets will be excluded + * @param {string} start - Returns overall buckets with timestamps after this time + * @param {string} end - Returns overall buckets with timestamps earlier than this time + * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + * @param {object} body - Overall bucket selection details if not provided in URI + */ + + const acceptedQuerystring = [ + 'top_n', + 'bucket_span', + 'overall_score', + 'exclude_interim', + 'start', + 'end', + 'allow_no_jobs' + ] + + const snakeCase = { + topN: 'top_n', + bucketSpan: 'bucket_span', + overallScore: 'overall_score', + excludeInterim: 'exclude_interim', + allowNoJobs: 'allow_no_jobs' + } + + return function mlGetOverallBuckets (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'overall_buckets' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlGetOverallBuckets diff --git a/api/api/ml.get_records.js b/api/api/ml.get_records.js new file mode 100644 index 000000000..5bcfbe7b0 --- /dev/null +++ b/api/api/ml.get_records.js @@ -0,0 +1,142 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlGetRecords (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.get_records](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-record.html) request + * + * @param {string} job_id - + * @param {boolean} exclude_interim - Exclude interim results + * @param {int} from - skips a number of records + * @param {int} size - specifies a max number of records to get + * @param {string} start - Start time filter for records + * @param {string} end - End time filter for records + * @param {double} record_score - + * @param {string} sort - Sort records by a particular field + * @param {boolean} desc - Set the sort direction + * @param {object} body - Record selection criteria + */ + + const acceptedQuerystring = [ + 'exclude_interim', + 'from', + 'size', + 'start', + 'end', + 'record_score', + 'sort', + 'desc' + ] + + const snakeCase = { + excludeInterim: 'exclude_interim', + recordScore: 'record_score' + + } + + return function mlGetRecords (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'records' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlGetRecords diff --git a/api/api/ml.info.js b/api/api/ml.info.js new file mode 100644 index 000000000..b53019e0e --- /dev/null +++ b/api/api/ml.info.js @@ -0,0 +1,117 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlInfo (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.info](undefined) request + * + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function mlInfo (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'info' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlInfo diff --git a/api/api/ml.open_job.js b/api/api/ml.open_job.js new file mode 100644 index 000000000..ec9a3268f --- /dev/null +++ b/api/api/ml.open_job.js @@ -0,0 +1,130 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlOpenJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.open_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html) request + * + * @param {string} job_id - The ID of the job to open + * @param {boolean} ignore_downtime - Controls if gaps in data are treated as anomalous or as a maintenance window after a job re-start + * @param {time} timeout - Controls the time to wait until a job has opened. Default to 30 minutes + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function mlOpenJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, jobId, job_id, ignoreDowntime, ignore_downtime, timeout } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id', 'ignoreDowntime', 'ignore_downtime', 'timeout']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_open' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlOpenJob diff --git a/api/api/ml.post_calendar_events.js b/api/api/ml.post_calendar_events.js new file mode 100644 index 000000000..e671d27f9 --- /dev/null +++ b/api/api/ml.post_calendar_events.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlPostCalendarEvents (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.post_calendar_events](undefined) request + * + * @param {string} calendar_id - The ID of the calendar to modify + * @param {object} body - A list of events + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function mlPostCalendarEvents (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + const err = new ConfigurationError('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, calendarId, calendar_id } = params + var querystring = semicopy(params, ['method', 'body', 'calendarId', 'calendar_id']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'events' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlPostCalendarEvents diff --git a/api/api/ml.post_data.js b/api/api/ml.post_data.js new file mode 100644 index 000000000..5f500c989 --- /dev/null +++ b/api/api/ml.post_data.js @@ -0,0 +1,133 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlPostData (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.post_data](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-data.html) request + * + * @param {string} job_id - The name of the job receiving the data + * @param {string} reset_start - Optional parameter to specify the start of the bucket resetting range + * @param {string} reset_end - Optional parameter to specify the end of the bucket resetting range + * @param {object} body - The data to process + */ + + const acceptedQuerystring = [ + 'reset_start', + 'reset_end' + ] + + const snakeCase = { + resetStart: 'reset_start', + resetEnd: 'reset_end' + } + + return function mlPostData (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_data' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlPostData diff --git a/api/api/ml.preview_datafeed.js b/api/api/ml.preview_datafeed.js new file mode 100644 index 000000000..4a09368a1 --- /dev/null +++ b/api/api/ml.preview_datafeed.js @@ -0,0 +1,128 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlPreviewDatafeed (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.preview_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html) request + * + * @param {string} datafeed_id - The ID of the datafeed to preview + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function mlPreviewDatafeed (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + const err = new ConfigurationError('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, datafeedId, datafeed_id } = params + var querystring = semicopy(params, ['method', 'body', 'datafeedId', 'datafeed_id']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_preview' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlPreviewDatafeed diff --git a/api/api/ml.put_calendar.js b/api/api/ml.put_calendar.js new file mode 100644 index 000000000..5f469ac85 --- /dev/null +++ b/api/api/ml.put_calendar.js @@ -0,0 +1,125 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlPutCalendar (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.put_calendar](undefined) request + * + * @param {string} calendar_id - The ID of the calendar to create + * @param {object} body - The calendar details + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function mlPutCalendar (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + const err = new ConfigurationError('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, calendarId, calendar_id } = params + var querystring = semicopy(params, ['method', 'body', 'calendarId', 'calendar_id']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlPutCalendar diff --git a/api/api/ml.put_calendar_job.js b/api/api/ml.put_calendar_job.js new file mode 100644 index 000000000..4af04e926 --- /dev/null +++ b/api/api/ml.put_calendar_job.js @@ -0,0 +1,139 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlPutCalendarJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.put_calendar_job](undefined) request + * + * @param {string} calendar_id - The ID of the calendar to modify + * @param {string} job_id - The ID of the job to add to the calendar + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function mlPutCalendarJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + const err = new ConfigurationError('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) + } + if (params['job_id'] == null && params['jobId'] == null) { + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // check required url components + if ((params['job_id'] != null || params['jobId'] != null) && ((params['calendar_id'] == null && params['calendarId'] == null))) { + const err = new ConfigurationError('Missing required parameter of the url: calendar_id') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, calendarId, calendar_id, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'calendarId', 'calendar_id', 'jobId', 'job_id']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'jobs' + '/' + encodeURIComponent(job_id || jobId) + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlPutCalendarJob diff --git a/api/api/ml.put_datafeed.js b/api/api/ml.put_datafeed.js new file mode 100644 index 000000000..d7da534fe --- /dev/null +++ b/api/api/ml.put_datafeed.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlPutDatafeed (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.put_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-datafeed.html) request + * + * @param {string} datafeed_id - The ID of the datafeed to create + * @param {object} body - The datafeed config + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function mlPutDatafeed (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + const err = new ConfigurationError('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, datafeedId, datafeed_id } = params + var querystring = semicopy(params, ['method', 'body', 'datafeedId', 'datafeed_id']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlPutDatafeed diff --git a/api/api/ml.put_filter.js b/api/api/ml.put_filter.js new file mode 100644 index 000000000..6f423c071 --- /dev/null +++ b/api/api/ml.put_filter.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlPutFilter (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.put_filter](undefined) request + * + * @param {string} filter_id - The ID of the filter to create + * @param {object} body - The filter details + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function mlPutFilter (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['filter_id'] == null && params['filterId'] == null) { + const err = new ConfigurationError('Missing required parameter: filter_id or filterId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, filterId, filter_id } = params + var querystring = semicopy(params, ['method', 'body', 'filterId', 'filter_id']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(filter_id || filterId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlPutFilter diff --git a/api/api/ml.put_job.js b/api/api/ml.put_job.js new file mode 100644 index 000000000..fa78d3239 --- /dev/null +++ b/api/api/ml.put_job.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlPutJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.put_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html) request + * + * @param {string} job_id - The ID of the job to create + * @param {object} body - The job + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function mlPutJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlPutJob diff --git a/api/api/ml.revert_model_snapshot.js b/api/api/ml.revert_model_snapshot.js new file mode 100644 index 000000000..162a2682c --- /dev/null +++ b/api/api/ml.revert_model_snapshot.js @@ -0,0 +1,137 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlRevertModelSnapshot (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.revert_model_snapshot](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-revert-snapshot.html) request + * + * @param {string} job_id - The ID of the job to fetch + * @param {string} snapshot_id - The ID of the snapshot to revert to + * @param {boolean} delete_intervening_results - Should we reset the results back to the time of the snapshot? + * @param {object} body - Reversion options + */ + + const acceptedQuerystring = [ + 'delete_intervening_results' + ] + + const snakeCase = { + deleteInterveningResults: 'delete_intervening_results' + } + + return function mlRevertModelSnapshot (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params['snapshot_id'] == null && params['snapshotId'] == null) { + const err = new ConfigurationError('Missing required parameter: snapshot_id or snapshotId') + return handleError(err, callback) + } + + // check required url components + if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { + const err = new ConfigurationError('Missing required parameter of the url: job_id') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, jobId, job_id, snapshotId, snapshot_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id', 'snapshotId', 'snapshot_id']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + '/' + encodeURIComponent(snapshot_id || snapshotId) + '/' + '_revert' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlRevertModelSnapshot diff --git a/api/api/ml.set_upgrade_mode.js b/api/api/ml.set_upgrade_mode.js new file mode 100644 index 000000000..d095c71f0 --- /dev/null +++ b/api/api/ml.set_upgrade_mode.js @@ -0,0 +1,126 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlSetUpgradeMode (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.set_upgrade_mode](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-set-upgrade-mode.html) request + * + * @param {boolean} enabled - Whether to enable upgrade_mode ML setting or not. Defaults to false. + * @param {time} timeout - Controls the time to wait before action times out. Defaults to 30 seconds + */ + + const acceptedQuerystring = [ + 'enabled', + 'timeout' + ] + + const snakeCase = { + + } + + return function mlSetUpgradeMode (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'set_upgrade_mode' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlSetUpgradeMode diff --git a/api/api/ml.start_datafeed.js b/api/api/ml.start_datafeed.js new file mode 100644 index 000000000..9ae986cf7 --- /dev/null +++ b/api/api/ml.start_datafeed.js @@ -0,0 +1,130 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlStartDatafeed (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.start_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-start-datafeed.html) request + * + * @param {string} datafeed_id - The ID of the datafeed to start + * @param {string} start - The start time from where the datafeed should begin + * @param {string} end - The end time when the datafeed should stop. When not set, the datafeed continues in real time + * @param {time} timeout - Controls the time to wait until a datafeed has started. Default to 20 seconds + * @param {object} body - The start datafeed parameters + */ + + const acceptedQuerystring = [ + 'start', + 'end', + 'timeout' + ] + + const snakeCase = { + + } + + return function mlStartDatafeed (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + const err = new ConfigurationError('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, datafeedId, datafeed_id } = params + var querystring = semicopy(params, ['method', 'body', 'datafeedId', 'datafeed_id']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_start' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlStartDatafeed diff --git a/api/api/ml.stop_datafeed.js b/api/api/ml.stop_datafeed.js new file mode 100644 index 000000000..8e684ae2c --- /dev/null +++ b/api/api/ml.stop_datafeed.js @@ -0,0 +1,130 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlStopDatafeed (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.stop_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-stop-datafeed.html) request + * + * @param {string} datafeed_id - The ID of the datafeed to stop + * @param {boolean} allow_no_datafeeds - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + * @param {boolean} force - True if the datafeed should be forcefully stopped. + * @param {time} timeout - Controls the time to wait until a datafeed has stopped. Default to 20 seconds + */ + + const acceptedQuerystring = [ + 'allow_no_datafeeds', + 'force', + 'timeout' + ] + + const snakeCase = { + allowNoDatafeeds: 'allow_no_datafeeds' + + } + + return function mlStopDatafeed (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + const err = new ConfigurationError('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, datafeedId, datafeed_id } = params + var querystring = semicopy(params, ['method', 'body', 'datafeedId', 'datafeed_id']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_stop' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlStopDatafeed diff --git a/api/api/ml.update_datafeed.js b/api/api/ml.update_datafeed.js new file mode 100644 index 000000000..7e5447521 --- /dev/null +++ b/api/api/ml.update_datafeed.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlUpdateDatafeed (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.update_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-datafeed.html) request + * + * @param {string} datafeed_id - The ID of the datafeed to update + * @param {object} body - The datafeed update settings + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function mlUpdateDatafeed (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + const err = new ConfigurationError('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, datafeedId, datafeed_id } = params + var querystring = semicopy(params, ['method', 'body', 'datafeedId', 'datafeed_id']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_update' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlUpdateDatafeed diff --git a/api/api/ml.update_filter.js b/api/api/ml.update_filter.js new file mode 100644 index 000000000..f8de4abc7 --- /dev/null +++ b/api/api/ml.update_filter.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlUpdateFilter (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.update_filter](undefined) request + * + * @param {string} filter_id - The ID of the filter to update + * @param {object} body - The filter update + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function mlUpdateFilter (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['filter_id'] == null && params['filterId'] == null) { + const err = new ConfigurationError('Missing required parameter: filter_id or filterId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, filterId, filter_id } = params + var querystring = semicopy(params, ['method', 'body', 'filterId', 'filter_id']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(filter_id || filterId) + '/' + '_update' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlUpdateFilter diff --git a/api/api/ml.update_job.js b/api/api/ml.update_job.js new file mode 100644 index 000000000..c34144cd3 --- /dev/null +++ b/api/api/ml.update_job.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlUpdateJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.update_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-job.html) request + * + * @param {string} job_id - The ID of the job to create + * @param {object} body - The job update settings + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function mlUpdateJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, jobId, job_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_update' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlUpdateJob diff --git a/api/api/ml.update_model_snapshot.js b/api/api/ml.update_model_snapshot.js new file mode 100644 index 000000000..e0dc3043f --- /dev/null +++ b/api/api/ml.update_model_snapshot.js @@ -0,0 +1,140 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlUpdateModelSnapshot (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.update_model_snapshot](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-snapshot.html) request + * + * @param {string} job_id - The ID of the job to fetch + * @param {string} snapshot_id - The ID of the snapshot to update + * @param {object} body - The model snapshot properties to update + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function mlUpdateModelSnapshot (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params['snapshot_id'] == null && params['snapshotId'] == null) { + const err = new ConfigurationError('Missing required parameter: snapshot_id or snapshotId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // check required url components + if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { + const err = new ConfigurationError('Missing required parameter of the url: job_id') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, jobId, job_id, snapshotId, snapshot_id } = params + var querystring = semicopy(params, ['method', 'body', 'jobId', 'job_id', 'snapshotId', 'snapshot_id']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + '/' + encodeURIComponent(snapshot_id || snapshotId) + '/' + '_update' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlUpdateModelSnapshot diff --git a/api/api/ml.validate.js b/api/api/ml.validate.js new file mode 100644 index 000000000..256da469a --- /dev/null +++ b/api/api/ml.validate.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlValidate (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.validate](undefined) request + * + * @param {object} body - The job config + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function mlValidate (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_validate' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlValidate diff --git a/api/api/ml.validate_detector.js b/api/api/ml.validate_detector.js new file mode 100644 index 000000000..4540ff1d5 --- /dev/null +++ b/api/api/ml.validate_detector.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMlValidateDetector (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ml.validate_detector](undefined) request + * + * @param {object} body - The detector + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function mlValidateDetector (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_validate' + '/' + 'detector' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMlValidateDetector diff --git a/api/api/monitoring.bulk.js b/api/api/monitoring.bulk.js new file mode 100644 index 000000000..96a7caba3 --- /dev/null +++ b/api/api/monitoring.bulk.js @@ -0,0 +1,136 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildMonitoringBulk (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [monitoring.bulk](https://www.elastic.co/guide/en/elasticsearch/reference/master/es-monitoring.html) request + * + * @param {string} type - Default document type for items which don't provide one + * @param {string} system_id - Identifier of the monitored system + * @param {string} system_api_version - API Version of the monitored system + * @param {string} interval - Collection interval (e.g., '10s' or '10000ms') of the payload + * @param {object} body - The operation definition and data (action-data pairs), separated by newlines + */ + + const acceptedQuerystring = [ + 'system_id', + 'system_api_version', + 'interval' + ] + + const snakeCase = { + systemId: 'system_id', + systemApiVersion: 'system_api_version' + + } + + return function monitoringBulk (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, type } = params + var querystring = semicopy(params, ['method', 'body', 'type']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((type) != null) { + path = '/' + '_monitoring' + '/' + encodeURIComponent(type) + '/' + 'bulk' + } else { + path = '/' + '_monitoring' + '/' + 'bulk' + } + + // build request object + const request = { + method, + path, + bulkBody: body, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildMonitoringBulk diff --git a/api/api/mpercolate.js b/api/api/mpercolate.js index 50817ac53..191de1c96 100644 --- a/api/api/mpercolate.js +++ b/api/api/mpercolate.js @@ -124,6 +124,8 @@ function buildMpercolate (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/msearch.js b/api/api/msearch.js index 1003a3880..46aa3fafb 100644 --- a/api/api/msearch.js +++ b/api/api/msearch.js @@ -127,6 +127,8 @@ function buildMsearch (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/msearch_template.js b/api/api/msearch_template.js index 87581321e..6ff1a174c 100644 --- a/api/api/msearch_template.js +++ b/api/api/msearch_template.js @@ -124,6 +124,8 @@ function buildMsearchTemplate (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/mtermvectors.js b/api/api/mtermvectors.js index e68b195d0..3095d391c 100644 --- a/api/api/mtermvectors.js +++ b/api/api/mtermvectors.js @@ -138,6 +138,8 @@ function buildMtermvectors (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/nodes.hot_threads.js b/api/api/nodes.hot_threads.js index 79d27914d..ea9a349df 100644 --- a/api/api/nodes.hot_threads.js +++ b/api/api/nodes.hot_threads.js @@ -124,6 +124,8 @@ function buildNodesHotThreads (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/nodes.info.js b/api/api/nodes.info.js index 8f546bafb..848bec235 100644 --- a/api/api/nodes.info.js +++ b/api/api/nodes.info.js @@ -115,6 +115,8 @@ function buildNodesInfo (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/nodes.reload_secure_settings.js b/api/api/nodes.reload_secure_settings.js new file mode 100644 index 000000000..7753eb77e --- /dev/null +++ b/api/api/nodes.reload_secure_settings.js @@ -0,0 +1,135 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildNodesReloadSecureSettings (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [nodes.reload_secure_settings](https://www.elastic.co/guide/en/elasticsearch/reference/master/secure-settings.html#reloadable-secure-settings) request + * + * @param {list} node_id - A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes. + * @param {time} timeout - Explicit operation timeout + */ + + const acceptedQuerystring = [ + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + + return function nodesReloadSecureSettings (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, nodeId, node_id } = params + var querystring = semicopy(params, ['method', 'body', 'nodeId', 'node_id']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((node_id || nodeId) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'reload_secure_settings' + } else { + path = '/' + '_nodes' + '/' + 'reload_secure_settings' + } + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildNodesReloadSecureSettings diff --git a/api/api/nodes.stats.js b/api/api/nodes.stats.js index 9d0d3db6b..c0bc77f79 100644 --- a/api/api/nodes.stats.js +++ b/api/api/nodes.stats.js @@ -134,6 +134,8 @@ function buildNodesStats (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/nodes.usage.js b/api/api/nodes.usage.js new file mode 100644 index 000000000..1d62545be --- /dev/null +++ b/api/api/nodes.usage.js @@ -0,0 +1,140 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildNodesUsage (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [nodes.usage](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html) request + * + * @param {list} metric - Limit the information returned to the specified metrics + * @param {list} node_id - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + * @param {time} timeout - Explicit operation timeout + */ + + const acceptedQuerystring = [ + 'timeout', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + + return function nodesUsage (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, metric, nodeId, node_id } = params + var querystring = semicopy(params, ['method', 'body', 'metric', 'nodeId', 'node_id']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((node_id || nodeId) != null && (metric) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'usage' + '/' + encodeURIComponent(metric) + } else if ((node_id || nodeId) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'usage' + } else if ((metric) != null) { + path = '/' + '_nodes' + '/' + 'usage' + '/' + encodeURIComponent(metric) + } else { + path = '/' + '_nodes' + '/' + 'usage' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildNodesUsage diff --git a/api/api/ping.js b/api/api/ping.js index 9d6fe51b7..a3afdfe7b 100644 --- a/api/api/ping.js +++ b/api/api/ping.js @@ -100,6 +100,8 @@ function buildPing (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/put_script.js b/api/api/put_script.js index 2da0cade5..c59742229 100644 --- a/api/api/put_script.js +++ b/api/api/put_script.js @@ -126,6 +126,8 @@ function buildPutScript (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/put_template.js b/api/api/put_template.js index 18fc273f8..ed3596def 100644 --- a/api/api/put_template.js +++ b/api/api/put_template.js @@ -106,6 +106,8 @@ function buildPutTemplate (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/reindex.js b/api/api/reindex.js index d3aad88ae..f7818984e 100644 --- a/api/api/reindex.js +++ b/api/api/reindex.js @@ -116,6 +116,8 @@ function buildReindex (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/reindex_rethrottle.js b/api/api/reindex_rethrottle.js index 90a3a89c5..a3a2878bc 100644 --- a/api/api/reindex_rethrottle.js +++ b/api/api/reindex_rethrottle.js @@ -114,6 +114,8 @@ function buildReindexRethrottle (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/render_search_template.js b/api/api/render_search_template.js index 751468bc5..8f494e653 100644 --- a/api/api/render_search_template.js +++ b/api/api/render_search_template.js @@ -100,6 +100,8 @@ function buildRenderSearchTemplate (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/rollup.delete_job.js b/api/api/rollup.delete_job.js new file mode 100644 index 000000000..b0a06fdb5 --- /dev/null +++ b/api/api/rollup.delete_job.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildRollupDeleteJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [rollup.delete_job]() request + * + * @param {string} id - The ID of the job to delete + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function rollupDeleteJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['id'] == null) { + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'DELETE' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildRollupDeleteJob diff --git a/api/api/rollup.get_jobs.js b/api/api/rollup.get_jobs.js new file mode 100644 index 000000000..cb1da9051 --- /dev/null +++ b/api/api/rollup.get_jobs.js @@ -0,0 +1,122 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildRollupGetJobs (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [rollup.get_jobs]() request + * + * @param {string} id - The ID of the job(s) to fetch. Accepts glob patterns, or left blank for all jobs + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function rollupGetJobs (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((id) != null) { + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) + } else { + path = '/' + '_rollup' + '/' + 'job' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildRollupGetJobs diff --git a/api/api/rollup.get_rollup_caps.js b/api/api/rollup.get_rollup_caps.js new file mode 100644 index 000000000..3d24fbbaf --- /dev/null +++ b/api/api/rollup.get_rollup_caps.js @@ -0,0 +1,122 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildRollupGetRollupCaps (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [rollup.get_rollup_caps]() request + * + * @param {string} id - The ID of the index to check rollup capabilities on, or left blank for all jobs + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function rollupGetRollupCaps (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((id) != null) { + path = '/' + '_rollup' + '/' + 'data' + '/' + encodeURIComponent(id) + } else { + path = '/' + '_rollup' + '/' + 'data' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildRollupGetRollupCaps diff --git a/api/api/rollup.get_rollup_index_caps.js b/api/api/rollup.get_rollup_index_caps.js new file mode 100644 index 000000000..54f161dc9 --- /dev/null +++ b/api/api/rollup.get_rollup_index_caps.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildRollupGetRollupIndexCaps (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [rollup.get_rollup_index_caps]() request + * + * @param {string} index - The rollup index or index pattern to obtain rollup capabilities from. + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function rollupGetRollupIndexCaps (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['index'] == null) { + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, index } = params + var querystring = semicopy(params, ['method', 'body', 'index']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(index) + '/' + '_rollup' + '/' + 'data' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildRollupGetRollupIndexCaps diff --git a/api/api/rollup.rollup_search.js b/api/api/rollup.rollup_search.js new file mode 100644 index 000000000..4329cd2d9 --- /dev/null +++ b/api/api/rollup.rollup_search.js @@ -0,0 +1,144 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildRollupRollupSearch (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [rollup.rollup_search]() request + * + * @param {list} index - The indices or index-pattern(s) (containing rollup or regular data) that should be searched + * @param {string} type - The doc type inside the index + * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response + * @param {object} body - The search request body + */ + + const acceptedQuerystring = [ + 'typed_keys', + 'rest_total_hits_as_int' + ] + + const snakeCase = { + typedKeys: 'typed_keys', + restTotalHitsAsInt: 'rest_total_hits_as_int' + } + + return function rollupRollupSearch (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['index'] == null) { + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + const err = new ConfigurationError('Missing required parameter of the url: index') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, index, type } = params + var querystring = semicopy(params, ['method', 'body', 'index', 'type']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((index) != null && (type) != null) { + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_rollup_search' + } else { + path = '/' + encodeURIComponent(index) + '/' + '_rollup_search' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildRollupRollupSearch diff --git a/api/api/rollup.start_job.js b/api/api/rollup.start_job.js new file mode 100644 index 000000000..ced1af7fa --- /dev/null +++ b/api/api/rollup.start_job.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildRollupStartJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [rollup.start_job]() request + * + * @param {string} id - The ID of the job to start + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function rollupStartJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['id'] == null) { + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) + '/' + '_start' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildRollupStartJob diff --git a/api/api/rollup.stop_job.js b/api/api/rollup.stop_job.js new file mode 100644 index 000000000..856bdfe09 --- /dev/null +++ b/api/api/rollup.stop_job.js @@ -0,0 +1,128 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildRollupStopJob (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [rollup.stop_job]() request + * + * @param {string} id - The ID of the job to stop + * @param {boolean} wait_for_completion - True if the API should block until the job has fully stopped, false if should be executed async. Defaults to false. + * @param {time} timeout - Block for (at maximum) the specified duration while waiting for the job to stop. Defaults to 30s. + */ + + const acceptedQuerystring = [ + 'wait_for_completion', + 'timeout' + ] + + const snakeCase = { + waitForCompletion: 'wait_for_completion' + + } + + return function rollupStopJob (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['id'] == null) { + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) + '/' + '_stop' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildRollupStopJob diff --git a/api/api/scripts_painless_context.js b/api/api/scripts_painless_context.js new file mode 100644 index 000000000..0ef7d852a --- /dev/null +++ b/api/api/scripts_painless_context.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildScriptsPainlessContext (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [scripts_painless_context](undefined) request + * + * @param {string} context - Select a specific context to retrieve API information about + */ + + const acceptedQuerystring = [ + 'context', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + + return function scriptsPainlessContext (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_scripts' + '/' + 'painless' + '/' + '_context' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildScriptsPainlessContext diff --git a/api/api/scripts_painless_execute.js b/api/api/scripts_painless_execute.js new file mode 100644 index 000000000..231a3e461 --- /dev/null +++ b/api/api/scripts_painless_execute.js @@ -0,0 +1,123 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildScriptsPainlessExecute (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [scripts_painless_execute](https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html) request + * + * @param {object} body - The script to execute + */ + + const acceptedQuerystring = [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + + return function scriptsPainlessExecute (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_scripts' + '/' + 'painless' + '/' + '_execute' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildScriptsPainlessExecute diff --git a/api/api/scroll.js b/api/api/scroll.js index 5675b9f16..c9b075cfb 100644 --- a/api/api/scroll.js +++ b/api/api/scroll.js @@ -105,6 +105,8 @@ function buildScroll (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/search.js b/api/api/search.js index d1b8dd8b8..7f632d487 100644 --- a/api/api/search.js +++ b/api/api/search.js @@ -205,6 +205,8 @@ function buildSearch (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/search_shards.js b/api/api/search_shards.js index 7ef1fad25..3da0d0b9f 100644 --- a/api/api/search_shards.js +++ b/api/api/search_shards.js @@ -129,6 +129,8 @@ function buildSearchShards (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/search_template.js b/api/api/search_template.js index 02a34c0c7..641c00564 100644 --- a/api/api/search_template.js +++ b/api/api/search_template.js @@ -134,6 +134,8 @@ function buildSearchTemplate (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/security.authenticate.js b/api/api/security.authenticate.js new file mode 100644 index 000000000..0a144693a --- /dev/null +++ b/api/api/security.authenticate.js @@ -0,0 +1,123 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityAuthenticate (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.authenticate](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-authenticate.html) request + * + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function securityAuthenticate (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + '_authenticate' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityAuthenticate diff --git a/api/api/security.change_password.js b/api/api/security.change_password.js new file mode 100644 index 000000000..3a78e5825 --- /dev/null +++ b/api/api/security.change_password.js @@ -0,0 +1,130 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityChangePassword (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.change_password](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-change-password.html) request + * + * @param {string} username - The username of the user to change the password for + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * @param {object} body - the new password for the user + */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + + return function securityChangePassword (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, username } = params + var querystring = semicopy(params, ['method', 'body', 'username']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((username) != null) { + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + '/' + '_password' + } else { + path = '/' + '_security' + '/' + 'user' + '/' + '_password' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityChangePassword diff --git a/api/api/security.clear_cached_realms.js b/api/api/security.clear_cached_realms.js new file mode 100644 index 000000000..aab70cec5 --- /dev/null +++ b/api/api/security.clear_cached_realms.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityClearCachedRealms (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.clear_cached_realms](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-cache.html) request + * + * @param {list} realms - Comma-separated list of realms to clear + * @param {list} usernames - Comma-separated list of usernames to clear from the cache + */ + + const acceptedQuerystring = [ + 'usernames' + ] + + const snakeCase = { + + } + + return function securityClearCachedRealms (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['realms'] == null) { + const err = new ConfigurationError('Missing required parameter: realms') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, realms } = params + var querystring = semicopy(params, ['method', 'body', 'realms']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + 'realm' + '/' + encodeURIComponent(realms) + '/' + '_clear_cache' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityClearCachedRealms diff --git a/api/api/security.clear_cached_roles.js b/api/api/security.clear_cached_roles.js new file mode 100644 index 000000000..c23b1c66e --- /dev/null +++ b/api/api/security.clear_cached_roles.js @@ -0,0 +1,128 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityClearCachedRoles (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.clear_cached_roles](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-role-cache.html) request + * + * @param {list} name - Role name + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function securityClearCachedRoles (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['name'] == null) { + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(name) + '/' + '_clear_cache' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityClearCachedRoles diff --git a/api/api/security.create_api_key.js b/api/api/security.create_api_key.js new file mode 100644 index 000000000..a2e0cd315 --- /dev/null +++ b/api/api/security.create_api_key.js @@ -0,0 +1,125 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityCreateApiKey (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.create_api_key](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html) request + * + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * @param {object} body - The api key request to create an API key + */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + + return function securityCreateApiKey (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + 'api_key' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityCreateApiKey diff --git a/api/api/security.delete_privileges.js b/api/api/security.delete_privileges.js new file mode 100644 index 000000000..e64714740 --- /dev/null +++ b/api/api/security.delete_privileges.js @@ -0,0 +1,140 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityDeletePrivileges (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.delete_privileges](TODO) request + * + * @param {string} application - Application name + * @param {string} name - Privilege name + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + + return function securityDeletePrivileges (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['application'] == null) { + const err = new ConfigurationError('Missing required parameter: application') + return handleError(err, callback) + } + if (params['name'] == null) { + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // check required url components + if (params['name'] != null && (params['application'] == null)) { + const err = new ConfigurationError('Missing required parameter of the url: application') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, application, name } = params + var querystring = semicopy(params, ['method', 'body', 'application', 'name']) + + if (method == null) { + method = 'DELETE' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(application) + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityDeletePrivileges diff --git a/api/api/security.delete_role.js b/api/api/security.delete_role.js new file mode 100644 index 000000000..96ea78039 --- /dev/null +++ b/api/api/security.delete_role.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityDeleteRole (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.delete_role](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role.html) request + * + * @param {string} name - Role name + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + + return function securityDeleteRole (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['name'] == null) { + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'DELETE' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityDeleteRole diff --git a/api/api/security.delete_role_mapping.js b/api/api/security.delete_role_mapping.js new file mode 100644 index 000000000..208c950fa --- /dev/null +++ b/api/api/security.delete_role_mapping.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityDeleteRoleMapping (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.delete_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role-mapping.html) request + * + * @param {string} name - Role-mapping name + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + + return function securityDeleteRoleMapping (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['name'] == null) { + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'DELETE' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityDeleteRoleMapping diff --git a/api/api/security.delete_user.js b/api/api/security.delete_user.js new file mode 100644 index 000000000..3e176ea8d --- /dev/null +++ b/api/api/security.delete_user.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityDeleteUser (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.delete_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-user.html) request + * + * @param {string} username - username + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + + return function securityDeleteUser (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['username'] == null) { + const err = new ConfigurationError('Missing required parameter: username') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, username } = params + var querystring = semicopy(params, ['method', 'body', 'username']) + + if (method == null) { + method = 'DELETE' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityDeleteUser diff --git a/api/api/security.disable_user.js b/api/api/security.disable_user.js new file mode 100644 index 000000000..3c7d3c000 --- /dev/null +++ b/api/api/security.disable_user.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityDisableUser (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.disable_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-disable-user.html) request + * + * @param {string} username - The username of the user to disable + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + + return function securityDisableUser (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['username'] == null) { + const err = new ConfigurationError('Missing required parameter: username') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, username } = params + var querystring = semicopy(params, ['method', 'body', 'username']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + '/' + '_disable' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityDisableUser diff --git a/api/api/security.enable_user.js b/api/api/security.enable_user.js new file mode 100644 index 000000000..2b044b3a5 --- /dev/null +++ b/api/api/security.enable_user.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityEnableUser (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.enable_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-enable-user.html) request + * + * @param {string} username - The username of the user to enable + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + + return function securityEnableUser (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['username'] == null) { + const err = new ConfigurationError('Missing required parameter: username') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, username } = params + var querystring = semicopy(params, ['method', 'body', 'username']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + '/' + '_enable' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityEnableUser diff --git a/api/api/security.get_api_key.js b/api/api/security.get_api_key.js new file mode 100644 index 000000000..eb8af6ea9 --- /dev/null +++ b/api/api/security.get_api_key.js @@ -0,0 +1,130 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityGetApiKey (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.get_api_key](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-api-key.html) request + * + * @param {string} id - API key id of the API key to be retrieved + * @param {string} name - API key name of the API key to be retrieved + * @param {string} username - user name of the user who created this API key to be retrieved + * @param {string} realm_name - realm name of the user who created this API key to be retrieved + */ + + const acceptedQuerystring = [ + 'id', + 'name', + 'username', + 'realm_name' + ] + + const snakeCase = { + realmName: 'realm_name' + } + + return function securityGetApiKey (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + 'api_key' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityGetApiKey diff --git a/api/api/security.get_privileges.js b/api/api/security.get_privileges.js new file mode 100644 index 000000000..f7e697124 --- /dev/null +++ b/api/api/security.get_privileges.js @@ -0,0 +1,137 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityGetPrivileges (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.get_privileges](TODO) request + * + * @param {string} application - Application name + * @param {string} name - Privilege name + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function securityGetPrivileges (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // check required url components + if (params['name'] != null && (params['application'] == null)) { + const err = new ConfigurationError('Missing required parameter of the url: application') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, application, name } = params + var querystring = semicopy(params, ['method', 'body', 'application', 'name']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((application) != null && (name) != null) { + path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(application) + '/' + encodeURIComponent(name) + } else if ((application) != null) { + path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(application) + } else { + path = '/' + '_security' + '/' + 'privilege' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityGetPrivileges diff --git a/api/api/security.get_role.js b/api/api/security.get_role.js new file mode 100644 index 000000000..ca9e9a542 --- /dev/null +++ b/api/api/security.get_role.js @@ -0,0 +1,128 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityGetRole (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.get_role](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html) request + * + * @param {string} name - Role name + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function securityGetRole (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((name) != null) { + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(name) + } else { + path = '/' + '_security' + '/' + 'role' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityGetRole diff --git a/api/api/security.get_role_mapping.js b/api/api/security.get_role_mapping.js new file mode 100644 index 000000000..77c43e053 --- /dev/null +++ b/api/api/security.get_role_mapping.js @@ -0,0 +1,128 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityGetRoleMapping (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.get_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role-mapping.html) request + * + * @param {string} name - Role-Mapping name + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function securityGetRoleMapping (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((name) != null) { + path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(name) + } else { + path = '/' + '_security' + '/' + 'role_mapping' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityGetRoleMapping diff --git a/api/api/security.get_token.js b/api/api/security.get_token.js new file mode 100644 index 000000000..b397e77cd --- /dev/null +++ b/api/api/security.get_token.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityGetToken (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.get_token](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html) request + * + * @param {object} body - The token request to get + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function securityGetToken (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + 'oauth2' + '/' + 'token' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityGetToken diff --git a/api/api/security.get_user.js b/api/api/security.get_user.js new file mode 100644 index 000000000..d8bb47568 --- /dev/null +++ b/api/api/security.get_user.js @@ -0,0 +1,128 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityGetUser (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.get_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user.html) request + * + * @param {list} username - A comma-separated list of usernames + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function securityGetUser (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, username } = params + var querystring = semicopy(params, ['method', 'body', 'username']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((username) != null) { + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + } else { + path = '/' + '_security' + '/' + 'user' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityGetUser diff --git a/api/api/security.get_user_privileges.js b/api/api/security.get_user_privileges.js new file mode 100644 index 000000000..fdf7e5168 --- /dev/null +++ b/api/api/security.get_user_privileges.js @@ -0,0 +1,123 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityGetUserPrivileges (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.get_user_privileges](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-privileges.html) request + * + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function securityGetUserPrivileges (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + 'user' + '/' + '_privileges' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityGetUserPrivileges diff --git a/api/api/security.has_privileges.js b/api/api/security.has_privileges.js new file mode 100644 index 000000000..22c4c6cf1 --- /dev/null +++ b/api/api/security.has_privileges.js @@ -0,0 +1,129 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityHasPrivileges (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.has_privileges](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html) request + * + * @param {string} user - Username + * @param {object} body - The privileges to test + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function securityHasPrivileges (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, user } = params + var querystring = semicopy(params, ['method', 'body', 'user']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((user) != null) { + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(user) + '/' + '_has_privileges' + } else { + path = '/' + '_security' + '/' + 'user' + '/' + '_has_privileges' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityHasPrivileges diff --git a/api/api/security.invalidate_api_key.js b/api/api/security.invalidate_api_key.js new file mode 100644 index 000000000..983ef2ac8 --- /dev/null +++ b/api/api/security.invalidate_api_key.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityInvalidateApiKey (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.invalidate_api_key](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-api-key.html) request + * + * @param {object} body - The api key request to invalidate API key(s) + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function securityInvalidateApiKey (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'DELETE' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + 'api_key' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityInvalidateApiKey diff --git a/api/api/security.invalidate_token.js b/api/api/security.invalidate_token.js new file mode 100644 index 000000000..98e6eb702 --- /dev/null +++ b/api/api/security.invalidate_token.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityInvalidateToken (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.invalidate_token](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html) request + * + * @param {object} body - The token to invalidate + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function securityInvalidateToken (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'DELETE' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + 'oauth2' + '/' + 'token' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityInvalidateToken diff --git a/api/api/security.put_privileges.js b/api/api/security.put_privileges.js new file mode 100644 index 000000000..4de0d967f --- /dev/null +++ b/api/api/security.put_privileges.js @@ -0,0 +1,125 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityPutPrivileges (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.put_privileges](TODO) request + * + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * @param {object} body - The privilege(s) to add + */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + + return function securityPutPrivileges (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + 'privilege' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityPutPrivileges diff --git a/api/api/security.put_role.js b/api/api/security.put_role.js new file mode 100644 index 000000000..388ff9709 --- /dev/null +++ b/api/api/security.put_role.js @@ -0,0 +1,130 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityPutRole (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.put_role](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html) request + * + * @param {string} name - Role name + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * @param {object} body - The role to add + */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + + return function securityPutRole (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['name'] == null) { + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityPutRole diff --git a/api/api/security.put_role_mapping.js b/api/api/security.put_role_mapping.js new file mode 100644 index 000000000..8b3847096 --- /dev/null +++ b/api/api/security.put_role_mapping.js @@ -0,0 +1,130 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityPutRoleMapping (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.put_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role-mapping.html) request + * + * @param {string} name - Role-mapping name + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * @param {object} body - The role mapping to add + */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + + return function securityPutRoleMapping (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['name'] == null) { + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, name } = params + var querystring = semicopy(params, ['method', 'body', 'name']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityPutRoleMapping diff --git a/api/api/security.put_user.js b/api/api/security.put_user.js new file mode 100644 index 000000000..9703b86fd --- /dev/null +++ b/api/api/security.put_user.js @@ -0,0 +1,130 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSecurityPutUser (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [security.put_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html) request + * + * @param {string} username - The username of the User + * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + * @param {object} body - The user to add + */ + + const acceptedQuerystring = [ + 'refresh' + ] + + const snakeCase = { + + } + + return function securityPutUser (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['username'] == null) { + const err = new ConfigurationError('Missing required parameter: username') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, username } = params + var querystring = semicopy(params, ['method', 'body', 'username']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSecurityPutUser diff --git a/api/api/snapshot.create.js b/api/api/snapshot.create.js index 5ace8a4d9..271534554 100644 --- a/api/api/snapshot.create.js +++ b/api/api/snapshot.create.js @@ -119,6 +119,8 @@ function buildSnapshotCreate (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/snapshot.create_repository.js b/api/api/snapshot.create_repository.js index 0da59fecc..db438b595 100644 --- a/api/api/snapshot.create_repository.js +++ b/api/api/snapshot.create_repository.js @@ -113,6 +113,8 @@ function buildSnapshotCreateRepository (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/snapshot.delete.js b/api/api/snapshot.delete.js index be932ddff..86c5c51b5 100644 --- a/api/api/snapshot.delete.js +++ b/api/api/snapshot.delete.js @@ -119,6 +119,8 @@ function buildSnapshotDelete (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/snapshot.delete_repository.js b/api/api/snapshot.delete_repository.js index a5c0843b8..5800155f1 100644 --- a/api/api/snapshot.delete_repository.js +++ b/api/api/snapshot.delete_repository.js @@ -110,6 +110,8 @@ function buildSnapshotDeleteRepository (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/snapshot.get.js b/api/api/snapshot.get.js index 40ac33586..cd4f447ef 100644 --- a/api/api/snapshot.get.js +++ b/api/api/snapshot.get.js @@ -124,6 +124,8 @@ function buildSnapshotGet (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/snapshot.get_repository.js b/api/api/snapshot.get_repository.js index 8df2a00db..96916887c 100644 --- a/api/api/snapshot.get_repository.js +++ b/api/api/snapshot.get_repository.js @@ -110,6 +110,8 @@ function buildSnapshotGetRepository (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/snapshot.restore.js b/api/api/snapshot.restore.js index 2c517171d..33647efeb 100644 --- a/api/api/snapshot.restore.js +++ b/api/api/snapshot.restore.js @@ -119,6 +119,8 @@ function buildSnapshotRestore (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/snapshot.status.js b/api/api/snapshot.status.js index 05fc1069c..4363c30f4 100644 --- a/api/api/snapshot.status.js +++ b/api/api/snapshot.status.js @@ -120,6 +120,8 @@ function buildSnapshotStatus (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/snapshot.verify_repository.js b/api/api/snapshot.verify_repository.js index bc818de5b..de4111896 100644 --- a/api/api/snapshot.verify_repository.js +++ b/api/api/snapshot.verify_repository.js @@ -110,6 +110,8 @@ function buildSnapshotVerifyRepository (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/sql.clear_cursor.js b/api/api/sql.clear_cursor.js new file mode 100644 index 000000000..fccf6ba8d --- /dev/null +++ b/api/api/sql.clear_cursor.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSqlClearCursor (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [sql.clear_cursor](Clear SQL cursor) request + * + * @param {object} body - Specify the cursor value in the `cursor` element to clean the cursor. + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function sqlClearCursor (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_sql' + '/' + 'close' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSqlClearCursor diff --git a/api/api/sql.query.js b/api/api/sql.query.js new file mode 100644 index 000000000..2bcd7f6e7 --- /dev/null +++ b/api/api/sql.query.js @@ -0,0 +1,125 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSqlQuery (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [sql.query](Execute SQL) request + * + * @param {string} format - a short version of the Accept header, e.g. json, yaml + * @param {object} body - Use the `query` element to start a query. Use the `cursor` element to continue a query. + */ + + const acceptedQuerystring = [ + 'format' + ] + + const snakeCase = { + + } + + return function sqlQuery (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_sql' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSqlQuery diff --git a/api/api/sql.translate.js b/api/api/sql.translate.js new file mode 100644 index 000000000..6b5147bb4 --- /dev/null +++ b/api/api/sql.translate.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSqlTranslate (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [sql.translate](Translate SQL into Elasticsearch queries) request + * + * @param {object} body - Specify the query in the `query` element. + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function sqlTranslate (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = body == null ? 'GET' : 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_sql' + '/' + 'translate' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSqlTranslate diff --git a/api/api/ssl.certificates.js b/api/api/ssl.certificates.js new file mode 100644 index 000000000..8bf875df8 --- /dev/null +++ b/api/api/ssl.certificates.js @@ -0,0 +1,123 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildSslCertificates (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [ssl.certificates](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-ssl.html) request + * + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function sslCertificates (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ssl' + '/' + 'certificates' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildSslCertificates diff --git a/api/api/suggest.js b/api/api/suggest.js index 40e4bbb20..8261e9b46 100644 --- a/api/api/suggest.js +++ b/api/api/suggest.js @@ -119,6 +119,8 @@ function buildSuggest (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/tasks.cancel.js b/api/api/tasks.cancel.js index c0de4ddc2..78535ec27 100644 --- a/api/api/tasks.cancel.js +++ b/api/api/tasks.cancel.js @@ -115,6 +115,8 @@ function buildTasksCancel (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/tasks.get.js b/api/api/tasks.get.js index 9db2373c4..cb670d622 100644 --- a/api/api/tasks.get.js +++ b/api/api/tasks.get.js @@ -104,6 +104,8 @@ function buildTasksGet (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/tasks.list.js b/api/api/tasks.list.js index 0dc323be5..c0157e0d5 100644 --- a/api/api/tasks.list.js +++ b/api/api/tasks.list.js @@ -118,6 +118,8 @@ function buildTasksList (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/termvectors.js b/api/api/termvectors.js index 56bcf1b93..180826603 100644 --- a/api/api/termvectors.js +++ b/api/api/termvectors.js @@ -139,6 +139,8 @@ function buildTermvectors (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/update.js b/api/api/update.js index 0f3abc719..b4abc7e40 100644 --- a/api/api/update.js +++ b/api/api/update.js @@ -147,6 +147,8 @@ function buildUpdate (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/update_by_query.js b/api/api/update_by_query.js index aae664ccb..72ae55897 100644 --- a/api/api/update_by_query.js +++ b/api/api/update_by_query.js @@ -197,6 +197,8 @@ function buildUpdateByQuery (opts) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/api/api/update_by_query_rethrottle.js b/api/api/update_by_query_rethrottle.js new file mode 100644 index 000000000..050feed99 --- /dev/null +++ b/api/api/update_by_query_rethrottle.js @@ -0,0 +1,140 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildUpdateByQueryRethrottle (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [update_by_query_rethrottle](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html) request + * + * @param {string} task_id - The task id to rethrottle + * @param {number} requests_per_second - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. + */ + + const acceptedQuerystring = [ + 'requests_per_second', + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + requestsPerSecond: 'requests_per_second', + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + + return function updateByQueryRethrottle (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['task_id'] == null && params['taskId'] == null) { + const err = new ConfigurationError('Missing required parameter: task_id or taskId') + return handleError(err, callback) + } + if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) { + const err = new ConfigurationError('Missing required parameter: requests_per_second or requestsPerSecond') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, taskId, task_id } = params + var querystring = semicopy(params, ['method', 'body', 'taskId', 'task_id']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_update_by_query' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_rethrottle' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildUpdateByQueryRethrottle diff --git a/api/api/watcher.ack_watch.js b/api/api/watcher.ack_watch.js new file mode 100644 index 000000000..cc385c644 --- /dev/null +++ b/api/api/watcher.ack_watch.js @@ -0,0 +1,139 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildWatcherAckWatch (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [watcher.ack_watch](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-ack-watch.html) request + * + * @param {string} watch_id - Watch ID + * @param {list} action_id - A comma-separated list of the action ids to be acked + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function watcherAckWatch (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['watch_id'] == null && params['watchId'] == null) { + const err = new ConfigurationError('Missing required parameter: watch_id or watchId') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // check required url components + if ((params['action_id'] != null || params['actionId'] != null) && ((params['watch_id'] == null && params['watchId'] == null))) { + const err = new ConfigurationError('Missing required parameter of the url: watch_id') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, watchId, watch_id, actionId, action_id } = params + var querystring = semicopy(params, ['method', 'body', 'watchId', 'watch_id', 'actionId', 'action_id']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((watch_id || watchId) != null && (action_id || actionId) != null) { + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(watch_id || watchId) + '/' + '_ack' + '/' + encodeURIComponent(action_id || actionId) + } else { + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(watch_id || watchId) + '/' + '_ack' + } + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildWatcherAckWatch diff --git a/api/api/watcher.activate_watch.js b/api/api/watcher.activate_watch.js new file mode 100644 index 000000000..6823f734b --- /dev/null +++ b/api/api/watcher.activate_watch.js @@ -0,0 +1,128 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildWatcherActivateWatch (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [watcher.activate_watch](https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-activate-watch.html) request + * + * @param {string} watch_id - Watch ID + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function watcherActivateWatch (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['watch_id'] == null && params['watchId'] == null) { + const err = new ConfigurationError('Missing required parameter: watch_id or watchId') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, watchId, watch_id } = params + var querystring = semicopy(params, ['method', 'body', 'watchId', 'watch_id']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(watch_id || watchId) + '/' + '_activate' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildWatcherActivateWatch diff --git a/api/api/watcher.deactivate_watch.js b/api/api/watcher.deactivate_watch.js new file mode 100644 index 000000000..5d089ca4b --- /dev/null +++ b/api/api/watcher.deactivate_watch.js @@ -0,0 +1,128 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildWatcherDeactivateWatch (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [watcher.deactivate_watch](https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-deactivate-watch.html) request + * + * @param {string} watch_id - Watch ID + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function watcherDeactivateWatch (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['watch_id'] == null && params['watchId'] == null) { + const err = new ConfigurationError('Missing required parameter: watch_id or watchId') + return handleError(err, callback) + } + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, watchId, watch_id } = params + var querystring = semicopy(params, ['method', 'body', 'watchId', 'watch_id']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(watch_id || watchId) + '/' + '_deactivate' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildWatcherDeactivateWatch diff --git a/api/api/watcher.execute_watch.js b/api/api/watcher.execute_watch.js new file mode 100644 index 000000000..8b5cf89d2 --- /dev/null +++ b/api/api/watcher.execute_watch.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildWatcherExecuteWatch (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [watcher.execute_watch](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-execute-watch.html) request + * + * @param {string} id - Watch ID + * @param {boolean} debug - indicates whether the watch should execute in debug mode + * @param {object} body - Execution control + */ + + const acceptedQuerystring = [ + 'debug' + ] + + const snakeCase = { + + } + + return function watcherExecuteWatch (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((id) != null) { + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(id) + '/' + '_execute' + } else { + path = '/' + '_watcher' + '/' + 'watch' + '/' + '_execute' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildWatcherExecuteWatch diff --git a/api/api/watcher.put_watch.js b/api/api/watcher.put_watch.js new file mode 100644 index 000000000..695f6eb19 --- /dev/null +++ b/api/api/watcher.put_watch.js @@ -0,0 +1,133 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildWatcherPutWatch (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [watcher.put_watch](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html) request + * + * @param {string} id - Watch ID + * @param {boolean} active - Specify whether the watch is in/active by default + * @param {number} version - Explicit version number for concurrency control + * @param {number} if_seq_no - only update the watch if the last operation that has changed the watch has the specified sequence number + * @param {number} if_primary_term - only update the watch if the last operation that has changed the watch has the specified primary term + * @param {object} body - The watch + */ + + const acceptedQuerystring = [ + 'active', + 'version', + 'if_seq_no', + 'if_primary_term' + ] + + const snakeCase = { + ifSeqNo: 'if_seq_no', + ifPrimaryTerm: 'if_primary_term' + } + + return function watcherPutWatch (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['id'] == null) { + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, id } = params + var querystring = semicopy(params, ['method', 'body', 'id']) + + if (method == null) { + method = 'PUT' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildWatcherPutWatch diff --git a/api/api/watcher.start.js b/api/api/watcher.start.js new file mode 100644 index 000000000..1053693f5 --- /dev/null +++ b/api/api/watcher.start.js @@ -0,0 +1,123 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildWatcherStart (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [watcher.start](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-start.html) request + * + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function watcherStart (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_watcher' + '/' + '_start' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildWatcherStart diff --git a/api/api/watcher.stats.js b/api/api/watcher.stats.js new file mode 100644 index 000000000..ffa6b9bd9 --- /dev/null +++ b/api/api/watcher.stats.js @@ -0,0 +1,131 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildWatcherStats (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [watcher.stats](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stats.html) request + * + * @param {list} metric - Controls what additional stat metrics should be include in the response + * @param {list} metric - Controls what additional stat metrics should be include in the response + * @param {boolean} emit_stacktraces - Emits stack traces of currently running watches + */ + + const acceptedQuerystring = [ + 'metric', + 'emit_stacktraces' + ] + + const snakeCase = { + emitStacktraces: 'emit_stacktraces' + } + + return function watcherStats (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body, metric } = params + var querystring = semicopy(params, ['method', 'body', 'metric']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((metric) != null) { + path = '/' + '_watcher' + '/' + 'stats' + '/' + encodeURIComponent(metric) + } else { + path = '/' + '_watcher' + '/' + 'stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildWatcherStats diff --git a/api/api/watcher.stop.js b/api/api/watcher.stop.js new file mode 100644 index 000000000..d7873de19 --- /dev/null +++ b/api/api/watcher.stop.js @@ -0,0 +1,123 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildWatcherStop (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [watcher.stop](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stop.html) request + * + */ + + const acceptedQuerystring = [ + + ] + + const snakeCase = { + + } + + return function watcherStop (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'POST' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_watcher' + '/' + '_stop' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildWatcherStop diff --git a/api/api/xpack.info.js b/api/api/xpack.info.js new file mode 100644 index 000000000..22d1f9f18 --- /dev/null +++ b/api/api/xpack.info.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildXpackInfo (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [xpack.info](https://www.elastic.co/guide/en/elasticsearch/reference/current/info-api.html) request + * + * @param {list} categories - Comma-separated list of info categories. Can be any of: build, license, features + */ + + const acceptedQuerystring = [ + 'categories' + ] + + const snakeCase = { + + } + + 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 = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_xpack' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildXpackInfo diff --git a/api/api/xpack.usage.js b/api/api/xpack.usage.js new file mode 100644 index 000000000..1885f4d93 --- /dev/null +++ b/api/api/xpack.usage.js @@ -0,0 +1,124 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildXpackUsage (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError } = opts + /** + * Perform a [xpack.usage](Retrieve information about xpack features usage) request + * + * @param {time} master_timeout - Specify timeout for watch write operation + */ + + const acceptedQuerystring = [ + 'master_timeout' + ] + + const snakeCase = { + masterTimeout: 'master_timeout' + } + + return function xpackUsage (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params.body != null) { + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = null + var { method, body } = params + var querystring = semicopy(params, ['method', 'body']) + + if (method == null) { + method = 'GET' + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_xpack' + '/' + 'usage' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null, + querystring: options.querystring || null, + compression: options.compression || false, + id: options.id || null, + context: options.context || null, + warnings + } + + return makeRequest(request, requestOptions, callback) + + function semicopy (obj, exclude) { + var target = {} + var keys = Object.keys(obj) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (exclude.indexOf(key) === -1) { + target[snakeCase[key] || key] = obj[key] + if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { + warnings = warnings || [] + warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') + } + } + } + return target + } + } +} + +module.exports = buildXpackUsage diff --git a/docs/configuration.asciidoc b/docs/configuration.asciidoc index 45f186fd4..3d52ad5a5 100644 --- a/docs/configuration.asciidoc +++ b/docs/configuration.asciidoc @@ -133,6 +133,23 @@ function nodeSelector (connections) { return connections[index] } ---- + +|`generateRequestId` +a|`function` - function to generate the request id for every request, it takes two parameters, the request parameters and options. + +By default it generates an incremental integer for every request. + +_Custom function example:_ +[source,js] +---- +function generateRequestId (params, options) { + // your id generation logic + // must be syncronous + return 'id' +} +---- + +|`name` +|`string` - The name to identify the client instance in the events. + +_Default:_ `elasticsearch-js` |=== === Advanced configuration @@ -229,4 +246,4 @@ class MySerializer extends Serializer { const client = new Client({ Serializer: MySerializer }) ----- \ No newline at end of file +---- diff --git a/docs/index.asciidoc b/docs/index.asciidoc index a9d0d81f7..cff59ad46 100644 --- a/docs/index.asciidoc +++ b/docs/index.asciidoc @@ -9,6 +9,7 @@ include::configuration.asciidoc[] include::reference.asciidoc[] include::breaking-changes.asciidoc[] include::authentication.asciidoc[] +include::observability.asciidoc[] include::child.asciidoc[] include::extend.asciidoc[] include::typescript.asciidoc[] diff --git a/docs/observability.asciidoc b/docs/observability.asciidoc new file mode 100644 index 000000000..c72c340e1 --- /dev/null +++ b/docs/observability.asciidoc @@ -0,0 +1,250 @@ +[[observability]] +== Observability + +The client does not provide a default logger, but instead it offers an event emitter interfaces to hook into internal events, such as `request` and `response`. + +Correlating those events can be quite hard, especially if your applications have a large codebase with many events happening at the same time. + +To help you with this, the client offers you a correlation id system and other features, let's see them in action. + +=== Events +The client is an event emitter, this means that you can listen for its event and add additional logic to your code, without need to change the client internals or your normal usage. + +You can find the events names by access the `events` key of the client. + +[source,js] +---- +const { events } = require('@elastic/elasticsearch') +console.log(events) +---- + +The event emitter functionality can be useful if you want to log every request, response and error that is happening during the use of the client. + +[source,js] +---- +const logger = require('my-logger')() +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ node: 'http://localhost:9200' }) + +client.on('response', (err, result) => { + if (err) { + logger.error(err) + } else { + logger.info(result) + } +}) +---- + +The client emits the following events: +[cols=2*] +|=== +|`request` +a|Emitted before sending the actual request to Elasticsearch _(emitted multiple times in case of retries)_. +[source,js] +---- +client.on('request', (err, result) => { + console.log(err, result) +}) +---- + +|`response` +a|Emitted once Elasticsearch response has been received and parsed. +[source,js] +---- +client.on('response', (err, result) => { + console.log(err, result) +}) +---- + +|`sniff` +a|Emitted when the client ends a sniffing request. +[source,js] +---- +client.on('sniff', (err, result) => { + console.log(err, result) +}) +---- + +|`resurrect` +a|Emitted if the client is able to resurrect a dead node. +[source,js] +---- +client.on('resurrect', (err, result) => { + console.log(err, result) +}) +---- + +|=== + +The values of `result` in `request`, `response` and `sniff` will be: +[source,ts] +---- +body: any; +statusCode: number | null; +headers: anyObject | null; +warnings: string[] | null; +meta: { + context: any; + name: string; + request: { + params: TransportRequestParams; + options: TransportRequestOptions; + id: any; + }; + connection: Connection; + attempts: number; + aborted: boolean; + sniff?: { + hosts: any[]; + reason: string; + }; +}; +---- + +While the `result` value in `resurrect` will be: +[source,ts] +---- +strategy: string; +isAlive: boolean; +connection: Connection; +name: string; +request: { + id: any; +}; +---- + +=== Correlation id +Correlating events can be quite hard, especially if there are many events at the same time. The client offers you an automatic (and configurable) system to help you handle this problem. +[source,js] +---- +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ node: 'http://localhost:9200' }) + +client.on('request', (err, result) => { + const { id } = result.meta.request + if (err) { + console.log({ error: err, reqId: id }) + } +}) + +client.on('response', (err, result) => { + const { id } = result.meta.request + if (err) { + console.log({ error: err, reqId: id }) + } +}) + +client.search({ + index: 'my-index', + body: { foo: 'bar' } +}, (err, result) => { + if (err) console.log(err) +}) +---- + +By default the id is an incremental integer, but you can easily configure that with the `generateRequestId` option: +[source,js] +---- +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ + node: 'http://localhost:9200', + // it takes two parameters, the request parameters and options + generateRequestId: function (params, options) { + // your id generation logic + // must be syncronous + return 'id' + } +}) +---- + +You can also specify a custom id per request: +[source,js] +---- +client.search({ + index: 'my-index', + body: { foo: 'bar' } +}, { + id: 'custom-id' +}, (err, result) => { + if (err) console.log(err) +}) +---- + +=== Context object +Sometimes, you might need to make some custom data available in your events, you can do that via the `context` option of a request: +[source,js] +---- +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ node: 'http://localhost:9200' }) + +client.on('request', (err, result) => { + const { id } = result.meta.request + const { context } = result.meta + if (err) { + console.log({ error: err, reqId: id, context }) + } +}) + +client.on('response', (err, result) => { + const { id } = result.meta.request + const { winter } = result.meta.context + if (err) { + console.log({ error: err, reqId: id, winter }) + } +}) + +client.search({ + index: 'my-index', + body: { foo: 'bar' } +}, { + context: { winter: 'is coming' } +}, (err, result) => { + if (err) console.log(err) +}) +---- + +=== Client name +If you are using multiple instances of the client or if you are using multiple child clients _(which is the recommended way to have multiple instances of the client)_, you might need to recognize which client you are using, the `name` options will help you in this regard: +[source,js] +---- +const { Client } = require('@elastic/elasticsearch') +const client = new Client({ + node: 'http://localhost:9200', + name: 'parent-client' // default to 'elasticsearch-js' +}) + +const child = client.child({ + name: 'child-client' +}) + +console.log(client.name, child.name) + +client.on('request', (err, result) => { + const { id } = result.meta.request + const { name } = result.meta + if (err) { + console.log({ error: err, reqId: id, name }) + } +}) + +client.on('response', (err, result) => { + const { id } = result.meta.request + const { name } = result.meta + if (err) { + console.log({ error: err, reqId: id, name }) + } +}) + +client.search({ + index: 'my-index', + body: { foo: 'bar' } +}, (err, result) => { + if (err) console.log(err) +}) + +child.search({ + index: 'my-index', + body: { foo: 'bar' } +}, (err, result) => { + if (err) console.log(err) +}) +---- diff --git a/docs/usage.asciidoc b/docs/usage.asciidoc index ed81ef2fc..bc1eeb60f 100644 --- a/docs/usage.asciidoc +++ b/docs/usage.asciidoc @@ -164,6 +164,14 @@ _Default:_ `null` |`querystring` |`object` - Custom querystring for the request. + _Default:_ `null` + +|`id` +|`any` - Custom request id. _(overrides the top level request id generator)_ + +_Default:_ `null` + +|`context` +|`any` - Custom object per request. _(you can use it to pass some data to the clients events)_ + +_Default:_ `null` |=== === Error handling @@ -203,103 +211,3 @@ Following you can find the errors exported by the client. |`ResponseError` |Generated when in case of a `4xx` or `5xx` response. |=== - -=== Events -The client is an event emitter, this means that you can listen for its event and add additional logic to your code, without need to change the client internals or your normal usage. + -You can find the events names by access the `events` key of the client. - -[source,js] ----- -const { events } = require('@elastic/elasticsearch') -console.log(events) ----- - -The event emitter functionality can be useful if you want to log every request, response and error that is happening during the use of the client. - -[source,js] ----- -const logger = require('my-logger')() -const { Client } = require('@elastic/elasticsearch') -const client = new Client({ node: 'http://localhost:9200' }) - -client.on('response', (err, req) => { - if (err) { - logger.error(err) - } else { - logger.info(req) - } -}) ----- - -The client emits the following events: -[cols=2*] -|=== -|`request` -a|Emitted before to send the actual request to Elasticsearch. -[source,js] ----- -client.on('request', (err, req) => { - console.log(err, req) -}) ----- - -|`response` -a|Emitted before to send the actual request to Elasticsearch. -[source,js] ----- -client.on('response', (err, req) => { - console.log(err, req) -}) ----- - -|`sniff` -a|Emitted before to send the actual request to Elasticsearch. -[source,js] ----- -client.on('sniff', (err, req) => { - console.log(err, req) -}) ----- - -|`resurrect` -a|Emitted before to send the actual request to Elasticsearch. -[source,js] ----- -client.on('resurrect', (err, req) => { - console.log(err, req) -}) ----- - -|=== - -The values of `req` in `request`, `response` and `sniff` will be: -[source,ts] ----- - body: any; - statusCode: number | null; - headers: anyObject | null; - warnings: string[] | null; - meta: { - request: { - params: TransportRequestParams; - options: TransportRequestOptions; - }; - connection: Connection; - attempts: number; - aborted: boolean; - sniff?: { - hosts: any[]; - reason: string; - }; - }; ----- - -While the `req` value in `resurrect` will be: -[source,ts] ----- -export interface ResurrectEvent { - strategy: string; - isAlive: boolean; - connection: Connection; -} ----- diff --git a/index.d.ts b/index.d.ts index 71f7f8045..807300a55 100644 --- a/index.d.ts +++ b/index.d.ts @@ -28,6 +28,7 @@ import Transport, { TransportRequestOptions, nodeFilterFn, nodeSelectorFn, + generateRequestIdFn, TransportRequestCallback } from './lib/Transport'; import Connection, { AgentOptions, agentFn } from './lib/Connection'; @@ -93,6 +94,8 @@ interface ClientOptions { nodeFilter?: nodeFilterFn; nodeSelector?: nodeSelectorFn | string; headers?: anyObject; + generateRequestId?: generateRequestIdFn; + name?: string; cloud?: { id: string; username: string; diff --git a/index.js b/index.js index 27a77a9ac..7f5b3c1c3 100644 --- a/index.js +++ b/index.js @@ -80,12 +80,15 @@ class Client extends EventEmitter { agent: null, headers: {}, nodeFilter: null, - nodeSelector: 'round-robin' + nodeSelector: 'round-robin', + generateRequestId: null, + name: 'elasticsearch-js' }, opts) this[kInitialOptions] = options this[kExtensions] = [] + this.name = options.name this.serializer = new options.Serializer() this.connectionPool = new options.ConnectionPool({ pingTimeout: options.pingTimeout, @@ -118,7 +121,9 @@ class Client extends EventEmitter { compression: options.compression, headers: options.headers, nodeFilter: options.nodeFilter, - nodeSelector: options.nodeSelector + nodeSelector: options.nodeSelector, + generateRequestId: options.generateRequestId, + name: options.name }) const apis = buildApi({ diff --git a/lib/ConnectionPool.d.ts b/lib/ConnectionPool.d.ts index 9acbb7d01..5b68d7d36 100644 --- a/lib/ConnectionPool.d.ts +++ b/lib/ConnectionPool.d.ts @@ -36,10 +36,20 @@ export interface getConnectionOptions { selector?: nodeSelectorFn; } +export interface resurrectOptions { + now?: number; + requestId: string; + name: string; +} + export interface ResurrectEvent { strategy: string; isAlive: boolean; connection: Connection; + name: string; + request: { + id: any; + }; } export default class ConnectionPool { @@ -79,10 +89,10 @@ export default class ConnectionPool { * If enabled, tries to resurrect a connection with the given * resurrect strategy ('ping', 'optimistic', 'none'). * - * @param {number} epoch + * @param {object} { now, requestId, name } * @param {function} callback (isAlive, connection) */ - resurrect(now?: number, callback?: (isAlive: boolean | null, connection: Connection | null) => void): void; + resurrect(opts: resurrectOptions, callback?: (isAlive: boolean | null, connection: Connection | null) => void): void; /** * Returns an alive connection if present, * otherwise returns null. diff --git a/lib/ConnectionPool.js b/lib/ConnectionPool.js index 6a164d4ae..3f12a64a4 100644 --- a/lib/ConnectionPool.js +++ b/lib/ConnectionPool.js @@ -108,10 +108,10 @@ class ConnectionPool { * If enabled, tries to resurrect a connection with the given * resurrect strategy ('ping', 'optimistic', 'none'). * - * @param {number} epoch + * @param {object} { now, requestId } * @param {function} callback (isAlive, connection) */ - resurrect (now = Date.now(), callback = noop) { + resurrect (opts, callback = noop) { if (this.resurrectStrategy === 0 || this.dead.length === 0) { debug('Nothing to resurrect') callback(null, null) @@ -121,7 +121,7 @@ class ConnectionPool { // the dead list is sorted in ascending order based on the timeout // so the first element will always be the one with the smaller timeout const connection = this.connections.get(this.dead[0]) - if (now < connection.resurrectTimeout) { + if ((opts.now || Date.now()) < connection.resurrectTimeout) { debug('Nothing to resurrect') callback(null, null) return @@ -147,7 +147,13 @@ class ConnectionPool { debug(`Resurrect: connection '${id}' is now alive`) this.markAlive(connection) } - this.emit('resurrect', null, { strategy: 'ping', isAlive, connection }) + this.emit('resurrect', null, { + strategy: 'ping', + name: opts.name, + request: { id: opts.requestId }, + isAlive, + connection + }) callback(isAlive, connection) }) // optimistic strategy @@ -155,7 +161,13 @@ class ConnectionPool { debug(`Resurrect: optimistic resurrection for connection '${id}'`) this.dead.splice(this.dead.indexOf(id), 1) connection.status = Connection.statuses.ALIVE - this.emit('resurrect', null, { strategy: 'optimistic', isAlive: true, connection }) + this.emit('resurrect', null, { + strategy: 'optimistic', + name: opts.name, + request: { id: opts.requestId }, + isAlive: true, + connection + }) // eslint-disable-next-line standard/no-callback-literal callback(true, connection) } diff --git a/lib/Transport.d.ts b/lib/Transport.d.ts index 89ec11573..83981cf32 100644 --- a/lib/Transport.d.ts +++ b/lib/Transport.d.ts @@ -29,6 +29,10 @@ export interface nodeFilterFn { (connection: Connection): boolean; } +export interface generateRequestIdFn { + (params: TransportRequestParams, options: TransportRequestOptions): any; +} + declare type noopFn = (...args: any[]) => void; declare type emitFn = (event: string | symbol, ...args: any[]) => boolean; @@ -47,17 +51,22 @@ interface TransportOptions { nodeFilter?: nodeFilterFn; nodeSelector?: string | nodeSelectorFn; headers?: anyObject; + generateRequestId?: generateRequestIdFn; + name: string; } -export interface RequestEvent { +export interface RequestEvent { body: T; statusCode: number | null; headers: anyObject | null; warnings: string[] | null; meta: { + context: C; + name: string; request: { params: TransportRequestParams; options: TransportRequestOptions; + id: any; }; connection: Connection; attempts: number; @@ -71,7 +80,7 @@ export interface RequestEvent { // ApiResponse and RequestEvent are the same thing // we are doing this for have more clear names -export interface ApiResponse extends RequestEvent {} +export interface ApiResponse extends RequestEvent {} declare type anyObject = { [key: string]: any; @@ -93,6 +102,8 @@ export interface TransportRequestOptions { headers?: anyObject; querystring?: anyObject; compression?: string; + id?: any; + context?: any; warnings?: [string]; } @@ -100,6 +111,15 @@ export interface TransportRequestCallback { abort: () => void; } +export interface TransportGetConnectionOptions { + requestId: string; +} + +export interface TransportSniffOptions { + reason: string; + requestId?: string; +} + export default class Transport { static sniffReasons: { SNIFF_ON_START: string; @@ -123,8 +143,8 @@ export default class Transport { constructor(opts: TransportOptions); request(params: TransportRequestParams, options?: TransportRequestOptions): Promise; request(params: TransportRequestParams, options?: TransportRequestOptions, callback?: (err: Error | null, result: ApiResponse) => void): TransportRequestCallback; - getConnection(): Connection | null; - sniff(callback?: (...args: any[]) => void): void; + getConnection(opts: TransportGetConnectionOptions): Connection | null; + sniff(opts?: TransportSniffOptions, callback?: (...args: any[]) => void): void; } export {}; diff --git a/lib/Transport.js b/lib/Transport.js index f9ff4f092..3ea692b3a 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -50,6 +50,8 @@ class Transport { this.sniffInterval = opts.sniffInterval this.sniffOnConnectionFault = opts.sniffOnConnectionFault this.sniffEndpoint = opts.sniffEndpoint + this.generateRequestId = opts.generateRequestId || generateRequestId() + this.name = opts.name this.nodeFilter = opts.nodeFilter || defaultNodeFilter if (typeof opts.nodeSelector === 'function') { @@ -67,7 +69,7 @@ class Transport { this._isSniffing = false if (opts.sniffOnStart === true) { - this.sniff(Transport.sniffReasons.SNIFF_ON_START) + this.sniff({ reason: Transport.sniffReasons.SNIFF_ON_START }) } } @@ -89,10 +91,13 @@ class Transport { callback = once(callback) const meta = { + context: options.context || null, request: { params: null, - options: null + options: null, + id: options.id || this.generateRequestId(params, options) }, + name: this.name, connection: null, attempts: 0, aborted: false @@ -112,7 +117,7 @@ class Transport { const makeRequest = () => { if (meta.aborted === true) return - meta.connection = this.getConnection() + meta.connection = this.getConnection({ requestId: meta.request.id }) if (meta.connection === null) { return callback(new NoLivingConnectionsError('There are not living connections'), result) } @@ -192,7 +197,10 @@ class Transport { this.connectionPool.markDead(meta.connection) if (this.sniffOnConnectionFault === true) { - this.sniff(Transport.sniffReasons.SNIFF_ON_CONNECTION_FAULT) + this.sniff({ + reason: Transport.sniffReasons.SNIFF_ON_CONNECTION_FAULT, + requestId: meta.request.id + }) } // retry logic @@ -312,34 +320,36 @@ class Transport { } } - getConnection () { + getConnection (opts) { const now = Date.now() if (this._sniffEnabled === true && now > this._nextSniff) { - this.sniff(Transport.sniffReasons.SNIFF_INTERVAL) + this.sniff({ reason: Transport.sniffReasons.SNIFF_INTERVAL, requestId: opts.requestId }) } - this.connectionPool.resurrect(now) + this.connectionPool.resurrect({ now, requestId: opts.requestId, name: this.name }) return this.connectionPool.getConnection({ filter: this.nodeFilter, selector: this.nodeSelector }) } - sniff (reason = Transport.sniffReasons.DEFAULT, callback = noop) { + sniff (opts, callback = noop) { if (this._isSniffing === true) return this._isSniffing = true debug('Started sniffing request') - if (typeof reason === 'function') { - callback = reason - reason = Transport.sniffReasons.DEFAULT + if (typeof opts === 'function') { + callback = opts + opts = { reason: Transport.sniffReasons.DEFAULT } } + const { reason } = opts + const request = { method: 'GET', path: this.sniffEndpoint } - this.request(request, (err, result) => { + this.request(request, { id: opts.requestId }, (err, result) => { this._isSniffing = false if (this._sniffEnabled === true) { this._nextSniff = Date.now() + this.sniffInterval @@ -414,5 +424,12 @@ function randomSelector (connections) { return connections[index] } +function generateRequestId () { + var maxInt = 2147483647 + var nextReqId = 0 + return function genReqId (params, options) { + return (nextReqId = (nextReqId + 1) & maxInt) + } +} module.exports = Transport -module.exports.internals = { defaultNodeFilter, roundRobinSelector, randomSelector } +module.exports.internals = { defaultNodeFilter, roundRobinSelector, randomSelector, generateRequestId } diff --git a/scripts/utils/generateApis.js b/scripts/utils/generateApis.js index 33fd4eded..9e1bfc046 100644 --- a/scripts/utils/generateApis.js +++ b/scripts/utils/generateApis.js @@ -151,6 +151,8 @@ function generate (spec, common) { headers: options.headers || null, querystring: options.querystring || null, compression: options.compression || false, + id: options.id || null, + context: options.context || null, warnings } diff --git a/test/behavior/observability.test.js b/test/behavior/observability.test.js new file mode 100644 index 000000000..65c16ca6d --- /dev/null +++ b/test/behavior/observability.test.js @@ -0,0 +1,334 @@ +'use strict' + +const { test } = require('tap') +const lolex = require('lolex') +const { Client, Transport } = require('../../index') +const { + connection: { MockConnection, MockConnectionSniff } +} = require('../utils') +const noop = () => {} + +test('Request id', t => { + t.test('Default generateRequestId', t => { + const { generateRequestId } = Transport.internals + t.type(generateRequestId, 'function') + + const genReqId = generateRequestId() + t.type(genReqId, 'function') + + for (var i = 1; i <= 10; i++) { + t.strictEqual(genReqId(), i) + } + + t.end() + }) + + t.test('Custom generateRequestId', t => { + t.plan(7) + + const options = { context: { winter: 'is coming' } } + + const client = new Client({ + node: 'http://localhost:9200', + Connection: MockConnection, + generateRequestId: function (requestParams, requestOptions) { + t.match(requestParams, { method: 'GET', path: '/' }) + t.match(requestOptions, options) + return 'custom-id' + } + }) + + client.on('request', (err, { meta }) => { + t.error(err) + t.strictEqual(meta.request.id, 'custom-id') + }) + + client.on('response', (err, { meta }) => { + t.error(err) + t.strictEqual(meta.request.id, 'custom-id') + }) + + client.info({}, options, t.error) + }) + + t.test('Custom request id in method options', t => { + t.plan(5) + + const client = new Client({ + node: 'http://localhost:9200', + Connection: MockConnection + }) + + client.on('request', (err, { meta }) => { + t.error(err) + t.strictEqual(meta.request.id, 'custom-id') + }) + + client.on('response', (err, { meta }) => { + t.error(err) + t.strictEqual(meta.request.id, 'custom-id') + }) + + client.info({}, { id: 'custom-id' }, t.error) + }) + + t.test('Sniff and correlation id', t => { + t.test('sniffOnStart - should autogenerate the id', t => { + t.plan(2) + + const client = new Client({ + node: 'http://localhost:9200', + Connection: MockConnectionSniff, + sniffOnStart: true + }) + + client.on('sniff', (err, { meta }) => { + t.error(err) + t.strictEqual(meta.request.id, 1) + }) + }) + + t.test('sniffOnConnectionFault - should use the request id', t => { + t.plan(5) + + const client = new Client({ + nodes: ['http://localhost:9200', 'http://localhost:9201'], + Connection: MockConnectionSniff, + sniffOnConnectionFault: true, + maxRetries: 0 + }) + + client.on('request', (e, { meta }) => { + t.strictEqual(meta.request.id, 'custom') + }) + + client.on('response', (e, { meta }) => { + t.strictEqual(meta.request.id, 'custom') + }) + + client.on('sniff', (e, { meta }) => { + t.strictEqual(meta.request.id, 'custom') + }) + + client.transport.request({ + path: '/500', + method: 'GET' + }, { + id: 'custom', + headers: { timeout: 'true' } + }, noop) + }) + + t.end() + }) + + t.test('Resurrect should use the same request id of the request that starts it', t => { + t.plan(2) + + const clock = lolex.install({ toFake: ['Date'] }) + const client = new Client({ + node: 'http://localhost:9200', + Connection: MockConnection, + sniffOnConnectionFault: true, + maxRetries: 0 + }) + + const conn = client.connectionPool.getConnection() + client.connectionPool.markDead(conn) + clock.tick(1000 * 61) + + client.on('resurrect', (err, meta) => { + t.error(err) + t.strictEqual(meta.request.id, 'custom') + clock.uninstall() + }) + + client.info({}, { id: 'custom' }, noop) + }) + + t.end() +}) + +test('Request context', t => { + t.test('no value', t => { + t.plan(5) + + const client = new Client({ + node: 'http://localhost:9200', + Connection: MockConnection + }) + + client.on('request', (err, { meta }) => { + t.error(err) + t.strictEqual(meta.context, null) + }) + + client.on('response', (err, { meta }) => { + t.error(err) + t.strictEqual(meta.context, null) + }) + + client.info(t.error) + }) + + t.test('custom value', t => { + t.plan(5) + + const client = new Client({ + node: 'http://localhost:9200', + Connection: MockConnection + }) + + client.on('request', (err, { meta }) => { + t.error(err) + t.deepEqual(meta.context, { winter: 'is coming' }) + }) + + client.on('response', (err, { meta }) => { + t.error(err) + t.deepEqual(meta.context, { winter: 'is coming' }) + }) + + client.info({}, { context: { winter: 'is coming' } }, t.error) + }) + + t.end() +}) + +test('Client name', t => { + t.test('Property of the client instance', t => { + const client = new Client({ + node: 'http://localhost:9200', + name: 'cluster' + }) + t.strictEqual(client.name, 'cluster') + t.end() + }) + + t.test('Is present in the event metadata', t => { + t.plan(6) + const client = new Client({ + node: 'http://localhost:9200', + Connection: MockConnection, + name: 'cluster' + }) + + client.on('request', (err, { meta }) => { + t.error(err) + t.strictEqual(meta.name, 'cluster') + }) + + client.on('response', (err, { meta }) => { + t.error(err) + t.strictEqual(meta.name, 'cluster') + }) + + client.info((err, { meta }) => { + t.error(err) + t.strictEqual(meta.name, 'cluster') + }) + }) + + t.test('Sniff and client name', t => { + t.test('sniffOnStart', t => { + t.plan(2) + + const client = new Client({ + node: 'http://localhost:9200', + Connection: MockConnectionSniff, + sniffOnStart: true + }) + + client.on('sniff', (err, { meta }) => { + t.error(err) + t.strictEqual(meta.name, 'elasticsearch-js') + }) + }) + + t.test('sniffOnConnectionFault', t => { + t.plan(5) + + const client = new Client({ + nodes: ['http://localhost:9200', 'http://localhost:9201'], + Connection: MockConnectionSniff, + sniffOnConnectionFault: true, + maxRetries: 0 + }) + + client.on('request', (e, { meta }) => { + t.strictEqual(meta.name, 'elasticsearch-js') + }) + + client.on('response', (e, { meta }) => { + t.strictEqual(meta.name, 'elasticsearch-js') + }) + + client.on('sniff', (e, { meta }) => { + t.strictEqual(meta.name, 'elasticsearch-js') + }) + + client.transport.request({ + path: '/500', + method: 'GET' + }, { + headers: { timeout: 'true' } + }, noop) + }) + + t.end() + }) + + t.test('Resurrect should have the client name configured', t => { + t.plan(2) + + const clock = lolex.install({ toFake: ['Date'] }) + const client = new Client({ + node: 'http://localhost:9200', + Connection: MockConnection, + sniffOnConnectionFault: true, + maxRetries: 0 + }) + + const conn = client.connectionPool.getConnection() + client.connectionPool.markDead(conn) + clock.tick(1000 * 61) + + client.on('resurrect', (err, meta) => { + t.error(err) + t.strictEqual(meta.name, 'elasticsearch-js') + clock.uninstall() + }) + + client.info({}, { id: 'custom' }, noop) + }) + + t.test('Resurrect should have the client name configured (child client)', t => { + t.plan(2) + + const clock = lolex.install({ toFake: ['Date'] }) + const client = new Client({ + node: 'http://localhost:9200', + Connection: MockConnection, + sniffOnConnectionFault: true, + maxRetries: 0 + }) + + const child = client.child({ + name: 'child-client' + }) + + const conn = client.connectionPool.getConnection() + client.connectionPool.markDead(conn) + clock.tick(1000 * 61) + + client.on('resurrect', (err, meta) => { + t.error(err) + t.strictEqual(meta.name, 'child-client') + clock.uninstall() + }) + + child.info({}, { id: 'custom' }, noop) + }) + + t.end() +}) diff --git a/test/behavior/resurrect.test.js b/test/behavior/resurrect.test.js index 68aba8353..8c4d38ba2 100644 --- a/test/behavior/resurrect.test.js +++ b/test/behavior/resurrect.test.js @@ -37,7 +37,7 @@ const { Client, events } = require('../../index') */ test('Should execute the recurrect API with the ping strategy', t => { - t.plan(6) + t.plan(8) const clock = lolex.install({ toFake: ['Date'] }) const q = workq() @@ -59,6 +59,8 @@ test('Should execute the recurrect API with the ping strategy', t => { t.strictEqual(meta.strategy, 'ping') t.false(meta.isAlive) t.strictEqual(meta.connection.id, 'node0') + t.strictEqual(meta.name, 'elasticsearch-js') + t.deepEqual(meta.request, { id: 2 }) }) q.add((q, done) => { @@ -89,7 +91,7 @@ test('Should execute the recurrect API with the ping strategy', t => { }) test('Resurrect a node and handle 502/3/4 status code', t => { - t.plan(11) + t.plan(15) const clock = lolex.install({ toFake: ['Date'] }) const q = workq() @@ -114,10 +116,13 @@ test('Resurrect a node and handle 502/3/4 status code', t => { maxRetries: 0 }) + var idCount = 2 client.on(events.RESURRECT, (err, meta) => { t.error(err) t.strictEqual(meta.strategy, 'ping') t.strictEqual(meta.connection.id, 'node0') + t.strictEqual(meta.name, 'elasticsearch-js') + t.deepEqual(meta.request, { id: idCount++ }) if (count < 3) { t.false(meta.isAlive) } else { @@ -156,7 +161,7 @@ test('Resurrect a node and handle 502/3/4 status code', t => { }) test('Should execute the recurrect API with the optimistic strategy', t => { - t.plan(6) + t.plan(8) const clock = lolex.install({ toFake: ['Date'] }) const q = workq() @@ -179,6 +184,8 @@ test('Should execute the recurrect API with the optimistic strategy', t => { t.strictEqual(meta.strategy, 'optimistic') t.true(meta.isAlive) t.strictEqual(meta.connection.id, 'node0') + t.strictEqual(meta.name, 'elasticsearch-js') + t.deepEqual(meta.request, { id: 2 }) }) q.add((q, done) => { diff --git a/test/unit/child.test.js b/test/unit/child.test.js index 2e8ea1554..110a7e866 100644 --- a/test/unit/child.test.js +++ b/test/unit/child.test.js @@ -211,3 +211,72 @@ test('Should share the event emitter', t => { t.end() }) + +test('Should create a child client (generateRequestId check)', t => { + t.plan(6) + + function generateRequestId1 () { + var id = 0 + return () => `trace-1-${id++}` + } + + function generateRequestId2 () { + var id = 0 + return () => `trace-2-${id++}` + } + + const client = new Client({ + node: 'http://localhost:9200', + Connection: MockConnection, + generateRequestId: generateRequestId1() + }) + const child = client.child({ + Connection: MockConnection, + generateRequestId: generateRequestId2() + }) + + var count = 0 + client.on('request', (err, { meta }) => { + t.error(err) + t.strictEqual( + meta.request.id, + count++ === 0 ? 'trace-1-0' : 'trace-2-0' + ) + }) + + client.info(err => { + t.error(err) + child.info(t.error) + }) +}) + +test('Should create a child client (name check)', t => { + t.plan(8) + + const client = new Client({ + node: 'http://localhost:9200', + Connection: MockConnection, + name: 'parent' + }) + const child = client.child({ + Connection: MockConnection, + name: 'child' + }) + + t.strictEqual(client.name, 'parent') + t.strictEqual(child.name, 'child') + + var count = 0 + client.on('request', (err, { meta }) => { + t.error(err) + t.strictEqual( + meta.name, + count++ === 0 ? 'parent' : 'child' + ) + }) + + client.info(err => { + t.error(err) + child.info(t.error) + }) +}) diff --git a/test/unit/connection-pool.test.js b/test/unit/connection-pool.test.js index b288a6a43..fc9495766 100644 --- a/test/unit/connection-pool.test.js +++ b/test/unit/connection-pool.test.js @@ -118,7 +118,12 @@ test('API', t => { const href = 'http://localhost:9200/' var connection = pool.addConnection(href) pool.markDead(connection) - pool.resurrect(Date.now() + 1000 * 60 * 3, (isAlive, connection) => { + const opts = { + now: Date.now() + 1000 * 60 * 3, + requestId: 1, + name: 'elasticsearch-js' + } + pool.resurrect(opts, (isAlive, connection) => { t.true(isAlive) connection = pool.connections.get(connection.id) t.strictEqual(connection.deadCount, 0) @@ -139,7 +144,12 @@ test('API', t => { const href = 'http://localhost:9200/' var connection = pool.addConnection(href) pool.markDead(connection) - pool.resurrect(Date.now() + 1000 * 60 * 3, (isAlive, connection) => { + const opts = { + now: Date.now() + 1000 * 60 * 3, + requestId: 1, + name: 'elasticsearch-js' + } + pool.resurrect(opts, (isAlive, connection) => { t.false(isAlive) connection = pool.connections.get(connection.id) t.strictEqual(connection.deadCount, 2) @@ -162,7 +172,12 @@ test('API', t => { const href = 'http://localhost:9200/' var connection = pool.addConnection(href) pool.markDead(connection) - pool.resurrect(Date.now() + 1000 * 60 * 3, (isAlive, connection) => { + const opts = { + now: Date.now() + 1000 * 60 * 3, + requestId: 1, + name: 'elasticsearch-js' + } + pool.resurrect(opts, (isAlive, connection) => { t.true(isAlive) connection = pool.connections.get(connection.id) t.strictEqual(connection.deadCount, 1) @@ -182,7 +197,12 @@ test('API', t => { const href = 'http://localhost:9200/' var connection = pool.addConnection(href) pool.markDead(connection) - pool.resurrect(Date.now() + 1000 * 60 * 3, (isAlive, connection) => { + const opts = { + now: Date.now() + 1000 * 60 * 3, + requestId: 1, + name: 'elasticsearch-js' + } + pool.resurrect(opts, (isAlive, connection) => { t.ok(isAlive === null) t.ok(connection === null) connection = pool.connections.get(href) diff --git a/test/unit/events.test.js b/test/unit/events.test.js index 432194a29..1312de932 100644 --- a/test/unit/events.test.js +++ b/test/unit/events.test.js @@ -40,6 +40,8 @@ test('Should emit a request event when a request is performed', t => { headers: null, warnings: null, meta: { + context: null, + name: 'elasticsearch-js', request: { params: { method: 'GET', @@ -59,7 +61,8 @@ test('Should emit a request event when a request is performed', t => { headers: null, compression: false, warnings: null - } + }, + id: 1 }, connection: { id: 'http://localhost:9200' @@ -98,6 +101,8 @@ test('Should emit a response event in case of a successful response', t => { }, warnings: null, meta: { + context: null, + name: 'elasticsearch-js', request: { params: { method: 'GET', @@ -117,7 +122,8 @@ test('Should emit a response event in case of a successful response', t => { headers: null, compression: false, warnings: null - } + }, + id: 1 }, connection: { id: 'http://localhost:9200' @@ -154,6 +160,8 @@ test('Should emit a response event with the error set', t => { headers: null, warnings: null, meta: { + context: null, + name: 'elasticsearch-js', request: { params: { method: 'GET', @@ -173,7 +181,8 @@ test('Should emit a response event with the error set', t => { headers: null, compression: false, warnings: null - } + }, + id: 1 }, connection: { id: 'http://localhost:9200' diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index c7c789950..b9e079dc3 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -704,11 +704,13 @@ test('Should call markAlive with a successful response', t => { }) test('Should call resurrect on every request', t => { - t.plan(3) + t.plan(5) class CustomConnectionPool extends ConnectionPool { - resurrect (now) { + resurrect ({ now, requestId, name }) { t.type(now, 'number') + t.type(requestId, 'number') + t.type(name, 'string') } } @@ -725,7 +727,8 @@ test('Should call resurrect on every request', t => { maxRetries: 3, requestTimeout: 30000, sniffInterval: false, - sniffOnStart: false + sniffOnStart: false, + name: 'elasticsearch-js' }) transport.request({ @@ -2107,3 +2110,30 @@ test('Should accept custom querystring in the optons object', t => { t.end() }) + +test('Should pass request params and options to generateRequestId', t => { + t.plan(3) + + const pool = new ConnectionPool({ Connection: MockConnection }) + pool.addConnection('http://localhost:9200') + + const params = { method: 'GET', path: '/hello' } + const options = { context: { winter: 'is coming' } } + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false, + generateRequestId: function (requestParams, requestOptions) { + t.deepEqual(requestParams, params) + t.deepEqual(requestOptions, options) + return 'id' + } + }) + + transport.request(params, options, t.error) +}) diff --git a/test/utils/MockConnection.js b/test/utils/MockConnection.js index 938bfd47a..7f16e27d4 100644 --- a/test/utils/MockConnection.js +++ b/test/utils/MockConnection.js @@ -73,6 +73,47 @@ class MockConnectionError extends Connection { } } +class MockConnectionSniff extends Connection { + request (params, callback) { + var aborted = false + const sniffResult = { + nodes: { + 'node-1': { + http: { + publish_address: 'localhost:9200' + }, + roles: ['master', 'data', 'ingest'] + }, + 'node-2': { + http: { + publish_address: 'localhost:9201' + }, + roles: ['master', 'data', 'ingest'] + } + } + } + const stream = intoStream(JSON.stringify(sniffResult)) + stream.statusCode = setStatusCode(params.path) + stream.headers = { + 'content-type': 'application/json;utf=8', + 'date': new Date().toISOString(), + 'connection': 'keep-alive', + 'content-length': '205' + } + process.nextTick(() => { + if (!aborted) { + if (params.headers.timeout) { + callback(new TimeoutError('Request timed out', params), null) + } else { + callback(null, stream) + } + } + }) + return { + abort: () => { aborted = true } + } + } +} function setStatusCode (path) { const statusCode = Number(path.slice(1)) if (Number.isInteger(statusCode)) { @@ -81,4 +122,9 @@ function setStatusCode (path) { return 200 } -module.exports = { MockConnection, MockConnectionTimeout, MockConnectionError } +module.exports = { + MockConnection, + MockConnectionTimeout, + MockConnectionError, + MockConnectionSniff +}