From 2ca3754d20bb9a18de6eb32b6f5d5ed33d100db8 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 13 Mar 2019 14:12:38 +0100 Subject: [PATCH 01/22] API generation --- api/api/bulk.js | 9 +++++++++ api/api/cat.aliases.js | 9 +++++++++ api/api/cat.allocation.js | 9 +++++++++ api/api/cat.count.js | 9 +++++++++ api/api/cat.fielddata.js | 9 +++++++++ api/api/cat.health.js | 9 +++++++++ api/api/cat.help.js | 9 +++++++++ api/api/cat.indices.js | 9 +++++++++ api/api/cat.master.js | 9 +++++++++ api/api/cat.nodeattrs.js | 9 +++++++++ api/api/cat.nodes.js | 9 +++++++++ api/api/cat.pending_tasks.js | 9 +++++++++ api/api/cat.plugins.js | 9 +++++++++ api/api/cat.recovery.js | 9 +++++++++ api/api/cat.repositories.js | 9 +++++++++ api/api/cat.segments.js | 9 +++++++++ api/api/cat.shards.js | 9 +++++++++ api/api/cat.snapshots.js | 9 +++++++++ api/api/cat.tasks.js | 9 +++++++++ api/api/cat.templates.js | 9 +++++++++ api/api/cat.thread_pool.js | 9 +++++++++ api/api/ccr.delete_auto_follow_pattern.js | 9 +++++++++ api/api/ccr.follow.js | 9 +++++++++ api/api/ccr.follow_info.js | 9 +++++++++ api/api/ccr.follow_stats.js | 9 +++++++++ api/api/ccr.get_auto_follow_pattern.js | 9 +++++++++ api/api/ccr.pause_follow.js | 9 +++++++++ api/api/ccr.put_auto_follow_pattern.js | 9 +++++++++ api/api/ccr.resume_follow.js | 9 +++++++++ api/api/ccr.stats.js | 9 +++++++++ api/api/ccr.unfollow.js | 9 +++++++++ api/api/clear_scroll.js | 9 +++++++++ api/api/cluster.allocation_explain.js | 9 +++++++++ api/api/cluster.get_settings.js | 9 +++++++++ api/api/cluster.health.js | 9 +++++++++ api/api/cluster.pending_tasks.js | 9 +++++++++ api/api/cluster.put_settings.js | 9 +++++++++ api/api/cluster.remote_info.js | 9 +++++++++ api/api/cluster.reroute.js | 9 +++++++++ api/api/cluster.state.js | 9 +++++++++ api/api/cluster.stats.js | 9 +++++++++ api/api/count.js | 9 +++++++++ api/api/create.js | 9 +++++++++ api/api/delete.js | 9 +++++++++ api/api/delete_by_query.js | 9 +++++++++ api/api/delete_by_query_rethrottle.js | 9 +++++++++ api/api/delete_script.js | 9 +++++++++ api/api/exists.js | 9 +++++++++ api/api/exists_source.js | 9 +++++++++ api/api/explain.js | 9 +++++++++ api/api/field_caps.js | 9 +++++++++ api/api/get.js | 9 +++++++++ api/api/get_script.js | 9 +++++++++ api/api/get_source.js | 9 +++++++++ api/api/ilm.delete_lifecycle.js | 9 +++++++++ api/api/ilm.explain_lifecycle.js | 9 +++++++++ api/api/ilm.get_lifecycle.js | 9 +++++++++ api/api/ilm.get_status.js | 9 +++++++++ api/api/ilm.move_to_step.js | 9 +++++++++ api/api/ilm.put_lifecycle.js | 9 +++++++++ api/api/ilm.remove_policy.js | 9 +++++++++ api/api/ilm.retry.js | 9 +++++++++ api/api/ilm.start.js | 9 +++++++++ api/api/ilm.stop.js | 9 +++++++++ api/api/index.js | 9 +++++++++ api/api/indices.analyze.js | 9 +++++++++ api/api/indices.clear_cache.js | 9 +++++++++ api/api/indices.close.js | 9 +++++++++ api/api/indices.create.js | 9 +++++++++ api/api/indices.delete.js | 9 +++++++++ api/api/indices.delete_alias.js | 9 +++++++++ api/api/indices.delete_template.js | 9 +++++++++ api/api/indices.exists.js | 9 +++++++++ api/api/indices.exists_alias.js | 9 +++++++++ api/api/indices.exists_template.js | 9 +++++++++ api/api/indices.exists_type.js | 9 +++++++++ api/api/indices.flush.js | 9 +++++++++ api/api/indices.flush_synced.js | 9 +++++++++ api/api/indices.forcemerge.js | 9 +++++++++ api/api/indices.freeze.js | 9 +++++++++ api/api/indices.get.js | 9 +++++++++ api/api/indices.get_alias.js | 9 +++++++++ api/api/indices.get_field_mapping.js | 9 +++++++++ api/api/indices.get_mapping.js | 9 +++++++++ api/api/indices.get_settings.js | 9 +++++++++ api/api/indices.get_template.js | 9 +++++++++ api/api/indices.get_upgrade.js | 9 +++++++++ api/api/indices.open.js | 9 +++++++++ api/api/indices.put_alias.js | 9 +++++++++ api/api/indices.put_mapping.js | 9 +++++++++ api/api/indices.put_settings.js | 9 +++++++++ api/api/indices.put_template.js | 9 +++++++++ api/api/indices.recovery.js | 9 +++++++++ api/api/indices.refresh.js | 9 +++++++++ api/api/indices.rollover.js | 9 +++++++++ api/api/indices.segments.js | 9 +++++++++ api/api/indices.shard_stores.js | 9 +++++++++ api/api/indices.shrink.js | 9 +++++++++ api/api/indices.split.js | 9 +++++++++ api/api/indices.stats.js | 9 +++++++++ api/api/indices.unfreeze.js | 9 +++++++++ api/api/indices.update_aliases.js | 9 +++++++++ api/api/indices.upgrade.js | 9 +++++++++ api/api/indices.validate_query.js | 9 +++++++++ api/api/info.js | 9 +++++++++ api/api/ingest.delete_pipeline.js | 9 +++++++++ api/api/ingest.get_pipeline.js | 9 +++++++++ api/api/ingest.processor_grok.js | 9 +++++++++ api/api/ingest.put_pipeline.js | 9 +++++++++ api/api/ingest.simulate.js | 9 +++++++++ api/api/mget.js | 9 +++++++++ api/api/ml.close_job.js | 9 +++++++++ api/api/ml.delete_calendar.js | 9 +++++++++ api/api/ml.delete_calendar_event.js | 9 +++++++++ api/api/ml.delete_calendar_job.js | 9 +++++++++ api/api/ml.delete_datafeed.js | 9 +++++++++ api/api/ml.delete_expired_data.js | 9 +++++++++ api/api/ml.delete_filter.js | 9 +++++++++ api/api/ml.delete_forecast.js | 9 +++++++++ api/api/ml.delete_job.js | 9 +++++++++ api/api/ml.delete_model_snapshot.js | 9 +++++++++ api/api/ml.find_file_structure.js | 9 +++++++++ api/api/ml.flush_job.js | 9 +++++++++ api/api/ml.forecast.js | 9 +++++++++ api/api/ml.get_buckets.js | 9 +++++++++ api/api/ml.get_calendar_events.js | 9 +++++++++ api/api/ml.get_calendars.js | 9 +++++++++ api/api/ml.get_categories.js | 9 +++++++++ api/api/ml.get_datafeed_stats.js | 9 +++++++++ api/api/ml.get_datafeeds.js | 9 +++++++++ api/api/ml.get_filters.js | 9 +++++++++ api/api/ml.get_influencers.js | 9 +++++++++ api/api/ml.get_job_stats.js | 9 +++++++++ api/api/ml.get_jobs.js | 9 +++++++++ api/api/ml.get_model_snapshots.js | 9 +++++++++ api/api/ml.get_overall_buckets.js | 9 +++++++++ api/api/ml.get_records.js | 9 +++++++++ api/api/ml.info.js | 9 +++++++++ api/api/ml.open_job.js | 9 +++++++++ api/api/ml.post_calendar_events.js | 9 +++++++++ api/api/ml.post_data.js | 9 +++++++++ api/api/ml.preview_datafeed.js | 9 +++++++++ api/api/ml.put_calendar.js | 9 +++++++++ api/api/ml.put_calendar_job.js | 9 +++++++++ api/api/ml.put_datafeed.js | 9 +++++++++ api/api/ml.put_filter.js | 9 +++++++++ api/api/ml.put_job.js | 9 +++++++++ api/api/ml.revert_model_snapshot.js | 9 +++++++++ api/api/ml.set_upgrade_mode.js | 9 +++++++++ api/api/ml.start_datafeed.js | 9 +++++++++ api/api/ml.stop_datafeed.js | 9 +++++++++ api/api/ml.update_datafeed.js | 9 +++++++++ api/api/ml.update_filter.js | 9 +++++++++ api/api/ml.update_job.js | 9 +++++++++ api/api/ml.update_model_snapshot.js | 9 +++++++++ api/api/ml.validate.js | 9 +++++++++ api/api/ml.validate_detector.js | 9 +++++++++ api/api/monitoring.bulk.js | 9 +++++++++ api/api/msearch.js | 9 +++++++++ api/api/msearch_template.js | 9 +++++++++ api/api/mtermvectors.js | 9 +++++++++ api/api/nodes.hot_threads.js | 9 +++++++++ api/api/nodes.info.js | 9 +++++++++ api/api/nodes.reload_secure_settings.js | 9 +++++++++ api/api/nodes.stats.js | 9 +++++++++ api/api/nodes.usage.js | 9 +++++++++ api/api/ping.js | 9 +++++++++ api/api/put_script.js | 9 +++++++++ api/api/rank_eval.js | 9 +++++++++ api/api/reindex.js | 9 +++++++++ api/api/reindex_rethrottle.js | 9 +++++++++ api/api/render_search_template.js | 9 +++++++++ api/api/scripts_painless_execute.js | 9 +++++++++ api/api/scroll.js | 9 +++++++++ api/api/search.js | 9 +++++++++ api/api/search_shards.js | 9 +++++++++ api/api/search_template.js | 9 +++++++++ api/api/security.authenticate.js | 9 +++++++++ api/api/security.change_password.js | 9 +++++++++ api/api/security.clear_cached_realms.js | 9 +++++++++ api/api/security.clear_cached_roles.js | 9 +++++++++ api/api/security.create_api_key.js | 9 +++++++++ api/api/security.delete_privileges.js | 9 +++++++++ api/api/security.delete_role.js | 9 +++++++++ api/api/security.delete_role_mapping.js | 9 +++++++++ api/api/security.delete_user.js | 9 +++++++++ api/api/security.disable_user.js | 9 +++++++++ api/api/security.enable_user.js | 9 +++++++++ api/api/security.get_api_key.js | 9 +++++++++ api/api/security.get_privileges.js | 9 +++++++++ api/api/security.get_role.js | 9 +++++++++ api/api/security.get_role_mapping.js | 9 +++++++++ api/api/security.get_token.js | 9 +++++++++ api/api/security.get_user.js | 9 +++++++++ api/api/security.get_user_privileges.js | 9 +++++++++ api/api/security.has_privileges.js | 9 +++++++++ api/api/security.invalidate_api_key.js | 9 +++++++++ api/api/security.invalidate_token.js | 9 +++++++++ api/api/security.put_privileges.js | 9 +++++++++ api/api/security.put_role.js | 9 +++++++++ api/api/security.put_role_mapping.js | 9 +++++++++ api/api/security.put_user.js | 9 +++++++++ api/api/snapshot.create.js | 9 +++++++++ api/api/snapshot.create_repository.js | 9 +++++++++ api/api/snapshot.delete.js | 9 +++++++++ api/api/snapshot.delete_repository.js | 9 +++++++++ api/api/snapshot.get.js | 9 +++++++++ api/api/snapshot.get_repository.js | 9 +++++++++ api/api/snapshot.restore.js | 9 +++++++++ api/api/snapshot.status.js | 9 +++++++++ api/api/snapshot.verify_repository.js | 9 +++++++++ api/api/ssl.certificates.js | 9 +++++++++ api/api/tasks.cancel.js | 9 +++++++++ api/api/tasks.get.js | 9 +++++++++ api/api/tasks.list.js | 9 +++++++++ api/api/termvectors.js | 9 +++++++++ api/api/update.js | 9 +++++++++ api/api/update_by_query.js | 9 +++++++++ api/api/update_by_query_rethrottle.js | 9 +++++++++ api/api/xpack.graph.explore.js | 9 +++++++++ api/api/xpack.info.js | 9 +++++++++ api/api/xpack.license.delete.js | 9 +++++++++ api/api/xpack.license.get.js | 9 +++++++++ api/api/xpack.license.get_basic_status.js | 9 +++++++++ api/api/xpack.license.get_trial_status.js | 9 +++++++++ api/api/xpack.license.post.js | 9 +++++++++ api/api/xpack.license.post_start_basic.js | 9 +++++++++ api/api/xpack.license.post_start_trial.js | 9 +++++++++ api/api/xpack.migration.deprecations.js | 9 +++++++++ api/api/xpack.migration.get_assistance.js | 9 +++++++++ api/api/xpack.migration.upgrade.js | 9 +++++++++ api/api/xpack.rollup.delete_job.js | 9 +++++++++ api/api/xpack.rollup.get_jobs.js | 9 +++++++++ api/api/xpack.rollup.get_rollup_caps.js | 9 +++++++++ api/api/xpack.rollup.get_rollup_index_caps.js | 9 +++++++++ api/api/xpack.rollup.put_job.js | 9 +++++++++ api/api/xpack.rollup.rollup_search.js | 9 +++++++++ api/api/xpack.rollup.start_job.js | 9 +++++++++ api/api/xpack.rollup.stop_job.js | 9 +++++++++ api/api/xpack.sql.clear_cursor.js | 9 +++++++++ api/api/xpack.sql.query.js | 9 +++++++++ api/api/xpack.sql.translate.js | 9 +++++++++ api/api/xpack.usage.js | 9 +++++++++ api/api/xpack.watcher.ack_watch.js | 9 +++++++++ api/api/xpack.watcher.activate_watch.js | 9 +++++++++ api/api/xpack.watcher.deactivate_watch.js | 9 +++++++++ api/api/xpack.watcher.delete_watch.js | 9 +++++++++ api/api/xpack.watcher.execute_watch.js | 9 +++++++++ api/api/xpack.watcher.get_watch.js | 9 +++++++++ api/api/xpack.watcher.put_watch.js | 9 +++++++++ api/api/xpack.watcher.start.js | 9 +++++++++ api/api/xpack.watcher.stats.js | 9 +++++++++ api/api/xpack.watcher.stop.js | 9 +++++++++ 253 files changed, 2277 insertions(+) diff --git a/api/api/bulk.js b/api/api/bulk.js index 957f215e0..419b56196 100644 --- a/api/api/bulk.js +++ b/api/api/bulk.js @@ -79,6 +79,15 @@ function buildBulk (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + bulk(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/cat.aliases.js b/api/api/cat.aliases.js index 8627157db..9b28f6edd 100644 --- a/api/api/cat.aliases.js +++ b/api/api/cat.aliases.js @@ -71,6 +71,15 @@ function buildCatAliases (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catAliases(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cat.allocation.js b/api/api/cat.allocation.js index 767854188..98f257d96 100644 --- a/api/api/cat.allocation.js +++ b/api/api/cat.allocation.js @@ -73,6 +73,15 @@ function buildCatAllocation (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catAllocation(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cat.count.js b/api/api/cat.count.js index 6fa162c4a..c57074c9f 100644 --- a/api/api/cat.count.js +++ b/api/api/cat.count.js @@ -71,6 +71,15 @@ function buildCatCount (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catCount(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cat.fielddata.js b/api/api/cat.fielddata.js index 22c9377a5..6fb432d58 100644 --- a/api/api/cat.fielddata.js +++ b/api/api/cat.fielddata.js @@ -75,6 +75,15 @@ function buildCatFielddata (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catFielddata(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cat.health.js b/api/api/cat.health.js index eb255cc9a..0db6c289b 100644 --- a/api/api/cat.health.js +++ b/api/api/cat.health.js @@ -72,6 +72,15 @@ function buildCatHealth (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catHealth(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cat.help.js b/api/api/cat.help.js index ebea416e1..f85171721 100644 --- a/api/api/cat.help.js +++ b/api/api/cat.help.js @@ -59,6 +59,15 @@ function buildCatHelp (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catHelp(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cat.indices.js b/api/api/cat.indices.js index 2ff28920d..62f365588 100644 --- a/api/api/cat.indices.js +++ b/api/api/cat.indices.js @@ -77,6 +77,15 @@ function buildCatIndices (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catIndices(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cat.master.js b/api/api/cat.master.js index 432dbd775..31adac93f 100644 --- a/api/api/cat.master.js +++ b/api/api/cat.master.js @@ -70,6 +70,15 @@ function buildCatMaster (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catMaster(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cat.nodeattrs.js b/api/api/cat.nodeattrs.js index 2cebea1d7..9e97e6a24 100644 --- a/api/api/cat.nodeattrs.js +++ b/api/api/cat.nodeattrs.js @@ -70,6 +70,15 @@ function buildCatNodeattrs (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catNodeattrs(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cat.nodes.js b/api/api/cat.nodes.js index dfa320a08..bcd3c0662 100644 --- a/api/api/cat.nodes.js +++ b/api/api/cat.nodes.js @@ -73,6 +73,15 @@ function buildCatNodes (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catNodes(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cat.pending_tasks.js b/api/api/cat.pending_tasks.js index 4205042ae..f24bff525 100644 --- a/api/api/cat.pending_tasks.js +++ b/api/api/cat.pending_tasks.js @@ -70,6 +70,15 @@ function buildCatPendingTasks (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catPendingTasks(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cat.plugins.js b/api/api/cat.plugins.js index 6fa73552c..c55fcdd29 100644 --- a/api/api/cat.plugins.js +++ b/api/api/cat.plugins.js @@ -70,6 +70,15 @@ function buildCatPlugins (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catPlugins(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cat.recovery.js b/api/api/cat.recovery.js index 985ed4902..42e0c1e0c 100644 --- a/api/api/cat.recovery.js +++ b/api/api/cat.recovery.js @@ -71,6 +71,15 @@ function buildCatRecovery (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catRecovery(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cat.repositories.js b/api/api/cat.repositories.js index 742a2ce56..8e8b6f6c9 100644 --- a/api/api/cat.repositories.js +++ b/api/api/cat.repositories.js @@ -70,6 +70,15 @@ function buildCatRepositories (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catRepositories(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cat.segments.js b/api/api/cat.segments.js index 2e4e5f184..c10af3b23 100644 --- a/api/api/cat.segments.js +++ b/api/api/cat.segments.js @@ -68,6 +68,15 @@ function buildCatSegments (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catSegments(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cat.shards.js b/api/api/cat.shards.js index 482dd015f..5ae0d1b18 100644 --- a/api/api/cat.shards.js +++ b/api/api/cat.shards.js @@ -73,6 +73,15 @@ function buildCatShards (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catShards(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cat.snapshots.js b/api/api/cat.snapshots.js index eaded0a18..af82bc574 100644 --- a/api/api/cat.snapshots.js +++ b/api/api/cat.snapshots.js @@ -72,6 +72,15 @@ function buildCatSnapshots (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catSnapshots(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cat.tasks.js b/api/api/cat.tasks.js index 720459a6f..c8005d5e7 100644 --- a/api/api/cat.tasks.js +++ b/api/api/cat.tasks.js @@ -75,6 +75,15 @@ function buildCatTasks (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catTasks(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cat.templates.js b/api/api/cat.templates.js index f3a4f11f7..ff89cb284 100644 --- a/api/api/cat.templates.js +++ b/api/api/cat.templates.js @@ -71,6 +71,15 @@ function buildCatTemplates (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catTemplates(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cat.thread_pool.js b/api/api/cat.thread_pool.js index 44756ab39..0b07b0e0a 100644 --- a/api/api/cat.thread_pool.js +++ b/api/api/cat.thread_pool.js @@ -73,6 +73,15 @@ function buildCatThreadPool (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + catThreadPool(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/ccr.delete_auto_follow_pattern.js b/api/api/ccr.delete_auto_follow_pattern.js index 04cfe48b5..d5ebd1cfd 100644 --- a/api/api/ccr.delete_auto_follow_pattern.js +++ b/api/api/ccr.delete_auto_follow_pattern.js @@ -51,6 +51,15 @@ function buildCcrDeleteAutoFollowPattern (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ccrDeleteAutoFollowPattern(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['name'] == null) { return callback( diff --git a/api/api/ccr.follow.js b/api/api/ccr.follow.js index 6983bfea0..7c86848bf 100644 --- a/api/api/ccr.follow.js +++ b/api/api/ccr.follow.js @@ -53,6 +53,15 @@ function buildCcrFollow (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ccrFollow(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/ccr.follow_info.js b/api/api/ccr.follow_info.js index 0a27de878..ec9923b1f 100644 --- a/api/api/ccr.follow_info.js +++ b/api/api/ccr.follow_info.js @@ -51,6 +51,15 @@ function buildCcrFollowInfo (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ccrFollowInfo(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { return callback( diff --git a/api/api/ccr.follow_stats.js b/api/api/ccr.follow_stats.js index c4f53e66c..62ee7f266 100644 --- a/api/api/ccr.follow_stats.js +++ b/api/api/ccr.follow_stats.js @@ -51,6 +51,15 @@ function buildCcrFollowStats (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ccrFollowStats(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { return callback( diff --git a/api/api/ccr.get_auto_follow_pattern.js b/api/api/ccr.get_auto_follow_pattern.js index 6e59191e1..261bce9ac 100644 --- a/api/api/ccr.get_auto_follow_pattern.js +++ b/api/api/ccr.get_auto_follow_pattern.js @@ -51,6 +51,15 @@ function buildCcrGetAutoFollowPattern (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ccrGetAutoFollowPattern(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { return callback( diff --git a/api/api/ccr.pause_follow.js b/api/api/ccr.pause_follow.js index 2e15a0430..81b0cde7b 100644 --- a/api/api/ccr.pause_follow.js +++ b/api/api/ccr.pause_follow.js @@ -51,6 +51,15 @@ function buildCcrPauseFollow (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ccrPauseFollow(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/ccr.put_auto_follow_pattern.js b/api/api/ccr.put_auto_follow_pattern.js index d660fafc1..846a29445 100644 --- a/api/api/ccr.put_auto_follow_pattern.js +++ b/api/api/ccr.put_auto_follow_pattern.js @@ -52,6 +52,15 @@ function buildCcrPutAutoFollowPattern (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ccrPutAutoFollowPattern(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['name'] == null) { return callback( diff --git a/api/api/ccr.resume_follow.js b/api/api/ccr.resume_follow.js index e4fec5dc5..ac47bfac5 100644 --- a/api/api/ccr.resume_follow.js +++ b/api/api/ccr.resume_follow.js @@ -52,6 +52,15 @@ function buildCcrResumeFollow (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ccrResumeFollow(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/ccr.stats.js b/api/api/ccr.stats.js index e127ae0ca..4de395d30 100644 --- a/api/api/ccr.stats.js +++ b/api/api/ccr.stats.js @@ -50,6 +50,15 @@ function buildCcrStats (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ccrStats(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { return callback( diff --git a/api/api/ccr.unfollow.js b/api/api/ccr.unfollow.js index 44af6a3a8..5886296b2 100644 --- a/api/api/ccr.unfollow.js +++ b/api/api/ccr.unfollow.js @@ -51,6 +51,15 @@ function buildCcrUnfollow (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ccrUnfollow(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/clear_scroll.js b/api/api/clear_scroll.js index bcf7a5afc..d3e0ec0ac 100644 --- a/api/api/clear_scroll.js +++ b/api/api/clear_scroll.js @@ -57,6 +57,15 @@ function buildClearScroll (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + clearScroll(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { return callback( diff --git a/api/api/cluster.allocation_explain.js b/api/api/cluster.allocation_explain.js index 9463e1e90..2392e61c7 100644 --- a/api/api/cluster.allocation_explain.js +++ b/api/api/cluster.allocation_explain.js @@ -62,6 +62,15 @@ function buildClusterAllocationExplain (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + clusterAllocationExplain(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { return callback( diff --git a/api/api/cluster.get_settings.js b/api/api/cluster.get_settings.js index 8f7f13c41..d024742cb 100644 --- a/api/api/cluster.get_settings.js +++ b/api/api/cluster.get_settings.js @@ -66,6 +66,15 @@ function buildClusterGetSettings (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + clusterGetSettings(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cluster.health.js b/api/api/cluster.health.js index 6ff729d8a..f8a75c1f4 100644 --- a/api/api/cluster.health.js +++ b/api/api/cluster.health.js @@ -83,6 +83,15 @@ function buildClusterHealth (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + clusterHealth(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cluster.pending_tasks.js b/api/api/cluster.pending_tasks.js index 86023cb45..43ddbf53c 100644 --- a/api/api/cluster.pending_tasks.js +++ b/api/api/cluster.pending_tasks.js @@ -60,6 +60,15 @@ function buildClusterPendingTasks (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + clusterPendingTasks(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cluster.put_settings.js b/api/api/cluster.put_settings.js index 110a5bf21..54ec859ed 100644 --- a/api/api/cluster.put_settings.js +++ b/api/api/cluster.put_settings.js @@ -64,6 +64,15 @@ function buildClusterPutSettings (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + clusterPutSettings(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/cluster.remote_info.js b/api/api/cluster.remote_info.js index 93ba95308..95f965c44 100644 --- a/api/api/cluster.remote_info.js +++ b/api/api/cluster.remote_info.js @@ -55,6 +55,15 @@ function buildClusterRemoteInfo (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + clusterRemoteInfo(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cluster.reroute.js b/api/api/cluster.reroute.js index 160b6b5b4..d106cd13c 100644 --- a/api/api/cluster.reroute.js +++ b/api/api/cluster.reroute.js @@ -71,6 +71,15 @@ function buildClusterReroute (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + clusterReroute(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { return callback( diff --git a/api/api/cluster.state.js b/api/api/cluster.state.js index 91f68781c..a8b350120 100644 --- a/api/api/cluster.state.js +++ b/api/api/cluster.state.js @@ -80,6 +80,15 @@ function buildClusterState (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + clusterState(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/cluster.stats.js b/api/api/cluster.stats.js index a07b2a324..b313c7827 100644 --- a/api/api/cluster.stats.js +++ b/api/api/cluster.stats.js @@ -61,6 +61,15 @@ function buildClusterStats (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + clusterStats(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/count.js b/api/api/count.js index 9dd09c294..536c07f62 100644 --- a/api/api/count.js +++ b/api/api/count.js @@ -94,6 +94,15 @@ function buildCount (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + count(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required url components if (params['type'] != null && (params['index'] == null)) { return callback( diff --git a/api/api/create.js b/api/api/create.js index eb18d517b..4b7a113da 100644 --- a/api/api/create.js +++ b/api/api/create.js @@ -77,6 +77,15 @@ function buildCreate (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + create(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['id'] == null) { return callback( diff --git a/api/api/delete.js b/api/api/delete.js index db3e90b35..dd78e7c19 100644 --- a/api/api/delete.js +++ b/api/api/delete.js @@ -80,6 +80,15 @@ function buildDelete (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + _delete(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['id'] == null) { return callback( diff --git a/api/api/delete_by_query.js b/api/api/delete_by_query.js index 559bcd201..cd0a34e9a 100644 --- a/api/api/delete_by_query.js +++ b/api/api/delete_by_query.js @@ -137,6 +137,15 @@ function buildDeleteByQuery (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + deleteByQuery(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/delete_by_query_rethrottle.js b/api/api/delete_by_query_rethrottle.js index 3d9cb752f..089ccf67c 100644 --- a/api/api/delete_by_query_rethrottle.js +++ b/api/api/delete_by_query_rethrottle.js @@ -59,6 +59,15 @@ function buildDeleteByQueryRethrottle (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + deleteByQueryRethrottle(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['task_id'] == null && params['taskId'] == null) { return callback( diff --git a/api/api/delete_script.js b/api/api/delete_script.js index fed63e09d..804c4bd3e 100644 --- a/api/api/delete_script.js +++ b/api/api/delete_script.js @@ -61,6 +61,15 @@ function buildDeleteScript (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + deleteScript(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['id'] == null) { return callback( diff --git a/api/api/exists.js b/api/api/exists.js index 58dba35b1..b9b28eec3 100644 --- a/api/api/exists.js +++ b/api/api/exists.js @@ -84,6 +84,15 @@ function buildExists (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + exists(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['id'] == null) { return callback( diff --git a/api/api/exists_source.js b/api/api/exists_source.js index a4280b7eb..bd5a93303 100644 --- a/api/api/exists_source.js +++ b/api/api/exists_source.js @@ -81,6 +81,15 @@ function buildExistsSource (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + existsSource(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['id'] == null) { return callback( diff --git a/api/api/explain.js b/api/api/explain.js index cdba2dc5c..d37b203ab 100644 --- a/api/api/explain.js +++ b/api/api/explain.js @@ -90,6 +90,15 @@ function buildExplain (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + explain(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['id'] == null) { return callback( diff --git a/api/api/field_caps.js b/api/api/field_caps.js index 79f2ad7be..b8a091fb2 100644 --- a/api/api/field_caps.js +++ b/api/api/field_caps.js @@ -67,6 +67,15 @@ function buildFieldCaps (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + fieldCaps(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/get.js b/api/api/get.js index af04e37c5..d59494cc8 100644 --- a/api/api/get.js +++ b/api/api/get.js @@ -90,6 +90,15 @@ function buildGet (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + get(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['id'] == null) { return callback( diff --git a/api/api/get_script.js b/api/api/get_script.js index ef873a5ee..e0c42cfab 100644 --- a/api/api/get_script.js +++ b/api/api/get_script.js @@ -59,6 +59,15 @@ function buildGetScript (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + getScript(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['id'] == null) { return callback( diff --git a/api/api/get_source.js b/api/api/get_source.js index 18ad2e4e6..1ea12b53d 100644 --- a/api/api/get_source.js +++ b/api/api/get_source.js @@ -81,6 +81,15 @@ function buildGetSource (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + getSource(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['id'] == null) { return callback( diff --git a/api/api/ilm.delete_lifecycle.js b/api/api/ilm.delete_lifecycle.js index 8d2c2b6b5..fcab49377 100644 --- a/api/api/ilm.delete_lifecycle.js +++ b/api/api/ilm.delete_lifecycle.js @@ -51,6 +51,15 @@ function buildIlmDeleteLifecycle (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmDeleteLifecycle(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/ilm.explain_lifecycle.js b/api/api/ilm.explain_lifecycle.js index 377959873..0e25f2fa0 100644 --- a/api/api/ilm.explain_lifecycle.js +++ b/api/api/ilm.explain_lifecycle.js @@ -52,6 +52,15 @@ function buildIlmExplainLifecycle (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmExplainLifecycle(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/ilm.get_lifecycle.js b/api/api/ilm.get_lifecycle.js index d4aea2190..5b3a25a17 100644 --- a/api/api/ilm.get_lifecycle.js +++ b/api/api/ilm.get_lifecycle.js @@ -51,6 +51,15 @@ function buildIlmGetLifecycle (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmGetLifecycle(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/ilm.get_status.js b/api/api/ilm.get_status.js index 38df25c38..801ff5275 100644 --- a/api/api/ilm.get_status.js +++ b/api/api/ilm.get_status.js @@ -50,6 +50,15 @@ function buildIlmGetStatus (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmGetStatus(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/ilm.move_to_step.js b/api/api/ilm.move_to_step.js index 0f6b9274f..392421dbb 100644 --- a/api/api/ilm.move_to_step.js +++ b/api/api/ilm.move_to_step.js @@ -52,6 +52,15 @@ function buildIlmMoveToStep (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmMoveToStep(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { return callback( diff --git a/api/api/ilm.put_lifecycle.js b/api/api/ilm.put_lifecycle.js index de148ad62..dfbc27f82 100644 --- a/api/api/ilm.put_lifecycle.js +++ b/api/api/ilm.put_lifecycle.js @@ -52,6 +52,15 @@ function buildIlmPutLifecycle (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmPutLifecycle(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { return callback( diff --git a/api/api/ilm.remove_policy.js b/api/api/ilm.remove_policy.js index f0258c29c..c0d45128b 100644 --- a/api/api/ilm.remove_policy.js +++ b/api/api/ilm.remove_policy.js @@ -51,6 +51,15 @@ function buildIlmRemovePolicy (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmRemovePolicy(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/ilm.retry.js b/api/api/ilm.retry.js index 6568a0a40..337f19ecf 100644 --- a/api/api/ilm.retry.js +++ b/api/api/ilm.retry.js @@ -51,6 +51,15 @@ function buildIlmRetry (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmRetry(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/ilm.start.js b/api/api/ilm.start.js index 840700141..1b692b3c0 100644 --- a/api/api/ilm.start.js +++ b/api/api/ilm.start.js @@ -50,6 +50,15 @@ function buildIlmStart (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmStart(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/ilm.stop.js b/api/api/ilm.stop.js index 166ed28b1..be9dfdaef 100644 --- a/api/api/ilm.stop.js +++ b/api/api/ilm.stop.js @@ -50,6 +50,15 @@ function buildIlmStop (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmStop(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/index.js b/api/api/index.js index 213b41ac5..bb15a2ab3 100644 --- a/api/api/index.js +++ b/api/api/index.js @@ -86,6 +86,15 @@ function buildIndex (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + _index(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/indices.analyze.js b/api/api/indices.analyze.js index b4d697bc8..c4ae2ea1f 100644 --- a/api/api/indices.analyze.js +++ b/api/api/indices.analyze.js @@ -59,6 +59,15 @@ function buildIndicesAnalyze (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesAnalyze(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { return callback( diff --git a/api/api/indices.clear_cache.js b/api/api/indices.clear_cache.js index 2d6b3be6b..55fcf8db1 100644 --- a/api/api/indices.clear_cache.js +++ b/api/api/indices.clear_cache.js @@ -75,6 +75,15 @@ function buildIndicesClearCache (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesClearCache(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/indices.close.js b/api/api/indices.close.js index 46a92f3a9..c021ed985 100644 --- a/api/api/indices.close.js +++ b/api/api/indices.close.js @@ -70,6 +70,15 @@ function buildIndicesClose (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesClose(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/indices.create.js b/api/api/indices.create.js index fadcb4981..669e763e0 100644 --- a/api/api/indices.create.js +++ b/api/api/indices.create.js @@ -68,6 +68,15 @@ function buildIndicesCreate (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesCreate(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/indices.delete.js b/api/api/indices.delete.js index 5a48c7794..8f7521a27 100644 --- a/api/api/indices.delete.js +++ b/api/api/indices.delete.js @@ -70,6 +70,15 @@ function buildIndicesDelete (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesDelete(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/indices.delete_alias.js b/api/api/indices.delete_alias.js index 5b57fbb63..73cdac0f8 100644 --- a/api/api/indices.delete_alias.js +++ b/api/api/indices.delete_alias.js @@ -62,6 +62,15 @@ function buildIndicesDeleteAlias (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesDeleteAlias(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/indices.delete_template.js b/api/api/indices.delete_template.js index a7fb0aca5..149b731bd 100644 --- a/api/api/indices.delete_template.js +++ b/api/api/indices.delete_template.js @@ -61,6 +61,15 @@ function buildIndicesDeleteTemplate (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesDeleteTemplate(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['name'] == null) { return callback( diff --git a/api/api/indices.exists.js b/api/api/indices.exists.js index a25cea993..106fe6ecd 100644 --- a/api/api/indices.exists.js +++ b/api/api/indices.exists.js @@ -73,6 +73,15 @@ function buildIndicesExists (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesExists(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/indices.exists_alias.js b/api/api/indices.exists_alias.js index 9a5de4520..9549b8d45 100644 --- a/api/api/indices.exists_alias.js +++ b/api/api/indices.exists_alias.js @@ -68,6 +68,15 @@ function buildIndicesExistsAlias (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesExistsAlias(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['name'] == null) { return callback( diff --git a/api/api/indices.exists_template.js b/api/api/indices.exists_template.js index 52f0ab596..a8c7b5818 100644 --- a/api/api/indices.exists_template.js +++ b/api/api/indices.exists_template.js @@ -64,6 +64,15 @@ function buildIndicesExistsTemplate (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesExistsTemplate(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['name'] == null) { return callback( diff --git a/api/api/indices.exists_type.js b/api/api/indices.exists_type.js index 120f27f14..7c405dd56 100644 --- a/api/api/indices.exists_type.js +++ b/api/api/indices.exists_type.js @@ -68,6 +68,15 @@ function buildIndicesExistsType (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesExistsType(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/indices.flush.js b/api/api/indices.flush.js index 854665f33..d949c3eb6 100644 --- a/api/api/indices.flush.js +++ b/api/api/indices.flush.js @@ -70,6 +70,15 @@ function buildIndicesFlush (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesFlush(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/indices.flush_synced.js b/api/api/indices.flush_synced.js index ca4fa36f6..a1dae252d 100644 --- a/api/api/indices.flush_synced.js +++ b/api/api/indices.flush_synced.js @@ -65,6 +65,15 @@ function buildIndicesFlushSynced (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesFlushSynced(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/indices.forcemerge.js b/api/api/indices.forcemerge.js index e4616ab7e..455718fcb 100644 --- a/api/api/indices.forcemerge.js +++ b/api/api/indices.forcemerge.js @@ -73,6 +73,15 @@ function buildIndicesForcemerge (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesForcemerge(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/indices.freeze.js b/api/api/indices.freeze.js index bc2745c56..4e2d6e6c2 100644 --- a/api/api/indices.freeze.js +++ b/api/api/indices.freeze.js @@ -66,6 +66,15 @@ function buildIndicesFreeze (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesFreeze(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/indices.get.js b/api/api/indices.get.js index bfcefdf9b..87597eed6 100644 --- a/api/api/indices.get.js +++ b/api/api/indices.get.js @@ -79,6 +79,15 @@ function buildIndicesGet (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesGet(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/indices.get_alias.js b/api/api/indices.get_alias.js index e0e06505d..454d60580 100644 --- a/api/api/indices.get_alias.js +++ b/api/api/indices.get_alias.js @@ -68,6 +68,15 @@ function buildIndicesGetAlias (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesGetAlias(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/indices.get_field_mapping.js b/api/api/indices.get_field_mapping.js index f4b3e968c..c3bf09e61 100644 --- a/api/api/indices.get_field_mapping.js +++ b/api/api/indices.get_field_mapping.js @@ -75,6 +75,15 @@ function buildIndicesGetFieldMapping (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesGetFieldMapping(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['fields'] == null) { return callback( diff --git a/api/api/indices.get_mapping.js b/api/api/indices.get_mapping.js index 1f2f2b5d9..173d1d7c6 100644 --- a/api/api/indices.get_mapping.js +++ b/api/api/indices.get_mapping.js @@ -74,6 +74,15 @@ function buildIndicesGetMapping (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesGetMapping(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/indices.get_settings.js b/api/api/indices.get_settings.js index 6e444f08e..08f5f7bc7 100644 --- a/api/api/indices.get_settings.js +++ b/api/api/indices.get_settings.js @@ -77,6 +77,15 @@ function buildIndicesGetSettings (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesGetSettings(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/indices.get_template.js b/api/api/indices.get_template.js index 58fb3d83a..2dfed0419 100644 --- a/api/api/indices.get_template.js +++ b/api/api/indices.get_template.js @@ -67,6 +67,15 @@ function buildIndicesGetTemplate (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesGetTemplate(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/indices.get_upgrade.js b/api/api/indices.get_upgrade.js index a2b34458b..6ddbc646d 100644 --- a/api/api/indices.get_upgrade.js +++ b/api/api/indices.get_upgrade.js @@ -65,6 +65,15 @@ function buildIndicesGetUpgrade (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesGetUpgrade(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/indices.open.js b/api/api/indices.open.js index b71427566..87e7b1417 100644 --- a/api/api/indices.open.js +++ b/api/api/indices.open.js @@ -73,6 +73,15 @@ function buildIndicesOpen (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesOpen(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/indices.put_alias.js b/api/api/indices.put_alias.js index 7e5566d44..c6c5a2ee5 100644 --- a/api/api/indices.put_alias.js +++ b/api/api/indices.put_alias.js @@ -63,6 +63,15 @@ function buildIndicesPutAlias (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesPutAlias(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/indices.put_mapping.js b/api/api/indices.put_mapping.js index da3c84df6..c62fd80a6 100644 --- a/api/api/indices.put_mapping.js +++ b/api/api/indices.put_mapping.js @@ -75,6 +75,15 @@ function buildIndicesPutMapping (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesPutMapping(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/indices.put_settings.js b/api/api/indices.put_settings.js index 6fa62c36e..8cf46293f 100644 --- a/api/api/indices.put_settings.js +++ b/api/api/indices.put_settings.js @@ -77,6 +77,15 @@ function buildIndicesPutSettings (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesPutSettings(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/indices.put_template.js b/api/api/indices.put_template.js index 55157756a..8f6f1c10e 100644 --- a/api/api/indices.put_template.js +++ b/api/api/indices.put_template.js @@ -72,6 +72,15 @@ function buildIndicesPutTemplate (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesPutTemplate(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['name'] == null) { return callback( diff --git a/api/api/indices.recovery.js b/api/api/indices.recovery.js index 9fbb6c4ed..9556b44ee 100644 --- a/api/api/indices.recovery.js +++ b/api/api/indices.recovery.js @@ -61,6 +61,15 @@ function buildIndicesRecovery (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesRecovery(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/indices.refresh.js b/api/api/indices.refresh.js index 87cbb843d..72298aca3 100644 --- a/api/api/indices.refresh.js +++ b/api/api/indices.refresh.js @@ -65,6 +65,15 @@ function buildIndicesRefresh (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesRefresh(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/indices.rollover.js b/api/api/indices.rollover.js index a2ad11201..c3bcd699a 100644 --- a/api/api/indices.rollover.js +++ b/api/api/indices.rollover.js @@ -72,6 +72,15 @@ function buildIndicesRollover (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesRollover(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['alias'] == null) { return callback( diff --git a/api/api/indices.segments.js b/api/api/indices.segments.js index cc1be5728..f0058cc6d 100644 --- a/api/api/indices.segments.js +++ b/api/api/indices.segments.js @@ -67,6 +67,15 @@ function buildIndicesSegments (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesSegments(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/indices.shard_stores.js b/api/api/indices.shard_stores.js index 8add1c770..ff22da906 100644 --- a/api/api/indices.shard_stores.js +++ b/api/api/indices.shard_stores.js @@ -67,6 +67,15 @@ function buildIndicesShardStores (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesShardStores(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/indices.shrink.js b/api/api/indices.shrink.js index 3693be4d1..8f3eb332a 100644 --- a/api/api/indices.shrink.js +++ b/api/api/indices.shrink.js @@ -69,6 +69,15 @@ function buildIndicesShrink (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesShrink(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/indices.split.js b/api/api/indices.split.js index 26b6cefd6..51e22c94f 100644 --- a/api/api/indices.split.js +++ b/api/api/indices.split.js @@ -69,6 +69,15 @@ function buildIndicesSplit (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesSplit(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/indices.stats.js b/api/api/indices.stats.js index 3c0b0906f..879ff40ad 100644 --- a/api/api/indices.stats.js +++ b/api/api/indices.stats.js @@ -74,6 +74,15 @@ function buildIndicesStats (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesStats(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/indices.unfreeze.js b/api/api/indices.unfreeze.js index 7c40fb726..58ac257ac 100644 --- a/api/api/indices.unfreeze.js +++ b/api/api/indices.unfreeze.js @@ -66,6 +66,15 @@ function buildIndicesUnfreeze (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesUnfreeze(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/indices.update_aliases.js b/api/api/indices.update_aliases.js index 2d9dd6f15..7188e5112 100644 --- a/api/api/indices.update_aliases.js +++ b/api/api/indices.update_aliases.js @@ -61,6 +61,15 @@ function buildIndicesUpdateAliases (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesUpdateAliases(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/indices.upgrade.js b/api/api/indices.upgrade.js index 6a16b1691..a1614f0ff 100644 --- a/api/api/indices.upgrade.js +++ b/api/api/indices.upgrade.js @@ -71,6 +71,15 @@ function buildIndicesUpgrade (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesUpgrade(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/indices.validate_query.js b/api/api/indices.validate_query.js index 813358340..6088e7d7e 100644 --- a/api/api/indices.validate_query.js +++ b/api/api/indices.validate_query.js @@ -88,6 +88,15 @@ function buildIndicesValidateQuery (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesValidateQuery(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required url components if (params['type'] != null && (params['index'] == null)) { return callback( diff --git a/api/api/info.js b/api/api/info.js index 95e6c55f7..611a7382c 100644 --- a/api/api/info.js +++ b/api/api/info.js @@ -55,6 +55,15 @@ function buildInfo (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + info(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/ingest.delete_pipeline.js b/api/api/ingest.delete_pipeline.js index 303c02ae1..8a567cde5 100644 --- a/api/api/ingest.delete_pipeline.js +++ b/api/api/ingest.delete_pipeline.js @@ -61,6 +61,15 @@ function buildIngestDeletePipeline (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ingestDeletePipeline(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['id'] == null) { return callback( diff --git a/api/api/ingest.get_pipeline.js b/api/api/ingest.get_pipeline.js index 2a6aa3938..9c6a1f39f 100644 --- a/api/api/ingest.get_pipeline.js +++ b/api/api/ingest.get_pipeline.js @@ -59,6 +59,15 @@ function buildIngestGetPipeline (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ingestGetPipeline(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/ingest.processor_grok.js b/api/api/ingest.processor_grok.js index d5b47b3d6..0d040e3e0 100644 --- a/api/api/ingest.processor_grok.js +++ b/api/api/ingest.processor_grok.js @@ -55,6 +55,15 @@ function buildIngestProcessorGrok (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ingestProcessorGrok(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/ingest.put_pipeline.js b/api/api/ingest.put_pipeline.js index 13dc50ff3..2030a6be0 100644 --- a/api/api/ingest.put_pipeline.js +++ b/api/api/ingest.put_pipeline.js @@ -62,6 +62,15 @@ function buildIngestPutPipeline (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ingestPutPipeline(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['id'] == null) { return callback( diff --git a/api/api/ingest.simulate.js b/api/api/ingest.simulate.js index 4d8c299f3..00caaa44b 100644 --- a/api/api/ingest.simulate.js +++ b/api/api/ingest.simulate.js @@ -59,6 +59,15 @@ function buildIngestSimulate (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ingestSimulate(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/mget.js b/api/api/mget.js index 5857ca38c..5844be7e5 100644 --- a/api/api/mget.js +++ b/api/api/mget.js @@ -77,6 +77,15 @@ function buildMget (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mget(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/ml.close_job.js b/api/api/ml.close_job.js index 1b923f530..729923e0d 100644 --- a/api/api/ml.close_job.js +++ b/api/api/ml.close_job.js @@ -58,6 +58,15 @@ function buildMlCloseJob (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlCloseJob(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['job_id'] == null && params['jobId'] == null) { return callback( diff --git a/api/api/ml.delete_calendar.js b/api/api/ml.delete_calendar.js index 2e270a081..dd57aed36 100644 --- a/api/api/ml.delete_calendar.js +++ b/api/api/ml.delete_calendar.js @@ -51,6 +51,15 @@ function buildMlDeleteCalendar (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlDeleteCalendar(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['calendar_id'] == null && params['calendarId'] == null) { return callback( diff --git a/api/api/ml.delete_calendar_event.js b/api/api/ml.delete_calendar_event.js index b08e2b8ff..fcda6a576 100644 --- a/api/api/ml.delete_calendar_event.js +++ b/api/api/ml.delete_calendar_event.js @@ -52,6 +52,15 @@ function buildMlDeleteCalendarEvent (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlDeleteCalendarEvent(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['calendar_id'] == null && params['calendarId'] == null) { return callback( diff --git a/api/api/ml.delete_calendar_job.js b/api/api/ml.delete_calendar_job.js index 4db8a932a..5a7b39f8f 100644 --- a/api/api/ml.delete_calendar_job.js +++ b/api/api/ml.delete_calendar_job.js @@ -52,6 +52,15 @@ function buildMlDeleteCalendarJob (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlDeleteCalendarJob(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['calendar_id'] == null && params['calendarId'] == null) { return callback( diff --git a/api/api/ml.delete_datafeed.js b/api/api/ml.delete_datafeed.js index 4e51efca3..057949b22 100644 --- a/api/api/ml.delete_datafeed.js +++ b/api/api/ml.delete_datafeed.js @@ -52,6 +52,15 @@ function buildMlDeleteDatafeed (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlDeleteDatafeed(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['datafeed_id'] == null && params['datafeedId'] == null) { return callback( diff --git a/api/api/ml.delete_expired_data.js b/api/api/ml.delete_expired_data.js index 30ca5cadd..62bafbc88 100644 --- a/api/api/ml.delete_expired_data.js +++ b/api/api/ml.delete_expired_data.js @@ -50,6 +50,15 @@ function buildMlDeleteExpiredData (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlDeleteExpiredData(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/ml.delete_filter.js b/api/api/ml.delete_filter.js index 8a3218408..33ceea713 100644 --- a/api/api/ml.delete_filter.js +++ b/api/api/ml.delete_filter.js @@ -51,6 +51,15 @@ function buildMlDeleteFilter (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlDeleteFilter(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['filter_id'] == null && params['filterId'] == null) { return callback( diff --git a/api/api/ml.delete_forecast.js b/api/api/ml.delete_forecast.js index 85c5d9d80..bfa10cf2e 100644 --- a/api/api/ml.delete_forecast.js +++ b/api/api/ml.delete_forecast.js @@ -56,6 +56,15 @@ function buildMlDeleteForecast (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlDeleteForecast(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['job_id'] == null && params['jobId'] == null) { return callback( diff --git a/api/api/ml.delete_job.js b/api/api/ml.delete_job.js index 5b692d36b..af969304e 100644 --- a/api/api/ml.delete_job.js +++ b/api/api/ml.delete_job.js @@ -54,6 +54,15 @@ function buildMlDeleteJob (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlDeleteJob(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['job_id'] == null && params['jobId'] == null) { return callback( diff --git a/api/api/ml.delete_model_snapshot.js b/api/api/ml.delete_model_snapshot.js index 3a13c967c..5108169e9 100644 --- a/api/api/ml.delete_model_snapshot.js +++ b/api/api/ml.delete_model_snapshot.js @@ -52,6 +52,15 @@ function buildMlDeleteModelSnapshot (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlDeleteModelSnapshot(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['job_id'] == null && params['jobId'] == null) { return callback( diff --git a/api/api/ml.find_file_structure.js b/api/api/ml.find_file_structure.js index c3cb5179f..9d9aabbaf 100644 --- a/api/api/ml.find_file_structure.js +++ b/api/api/ml.find_file_structure.js @@ -83,6 +83,15 @@ function buildMlFindFileStructure (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlFindFileStructure(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/ml.flush_job.js b/api/api/ml.flush_job.js index b72f9395c..0f8c275d9 100644 --- a/api/api/ml.flush_job.js +++ b/api/api/ml.flush_job.js @@ -63,6 +63,15 @@ function buildMlFlushJob (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlFlushJob(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['job_id'] == null && params['jobId'] == null) { return callback( diff --git a/api/api/ml.forecast.js b/api/api/ml.forecast.js index 65d03b5f8..45e94b8ac 100644 --- a/api/api/ml.forecast.js +++ b/api/api/ml.forecast.js @@ -54,6 +54,15 @@ function buildMlForecast (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlForecast(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['job_id'] == null && params['jobId'] == null) { return callback( diff --git a/api/api/ml.get_buckets.js b/api/api/ml.get_buckets.js index 4d70ccb5f..a4b9cab22 100644 --- a/api/api/ml.get_buckets.js +++ b/api/api/ml.get_buckets.js @@ -72,6 +72,15 @@ function buildMlGetBuckets (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlGetBuckets(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['job_id'] == null && params['jobId'] == null) { return callback( diff --git a/api/api/ml.get_calendar_events.js b/api/api/ml.get_calendar_events.js index bdc373d30..3c3a4924d 100644 --- a/api/api/ml.get_calendar_events.js +++ b/api/api/ml.get_calendar_events.js @@ -61,6 +61,15 @@ function buildMlGetCalendarEvents (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlGetCalendarEvents(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['calendar_id'] == null && params['calendarId'] == null) { return callback( diff --git a/api/api/ml.get_calendars.js b/api/api/ml.get_calendars.js index 810145c7f..e75331e41 100644 --- a/api/api/ml.get_calendars.js +++ b/api/api/ml.get_calendars.js @@ -54,6 +54,15 @@ function buildMlGetCalendars (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlGetCalendars(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/ml.get_categories.js b/api/api/ml.get_categories.js index 47c203b3e..82b1c3d2f 100644 --- a/api/api/ml.get_categories.js +++ b/api/api/ml.get_categories.js @@ -56,6 +56,15 @@ function buildMlGetCategories (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlGetCategories(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['job_id'] == null && params['jobId'] == null) { return callback( diff --git a/api/api/ml.get_datafeed_stats.js b/api/api/ml.get_datafeed_stats.js index 97c8ea3c0..0775f5b57 100644 --- a/api/api/ml.get_datafeed_stats.js +++ b/api/api/ml.get_datafeed_stats.js @@ -52,6 +52,15 @@ function buildMlGetDatafeedStats (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlGetDatafeedStats(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/ml.get_datafeeds.js b/api/api/ml.get_datafeeds.js index ae88fb528..a6840e049 100644 --- a/api/api/ml.get_datafeeds.js +++ b/api/api/ml.get_datafeeds.js @@ -52,6 +52,15 @@ function buildMlGetDatafeeds (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlGetDatafeeds(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/ml.get_filters.js b/api/api/ml.get_filters.js index 5666cf902..aa5db006a 100644 --- a/api/api/ml.get_filters.js +++ b/api/api/ml.get_filters.js @@ -54,6 +54,15 @@ function buildMlGetFilters (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlGetFilters(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/ml.get_influencers.js b/api/api/ml.get_influencers.js index 498f13d20..496a313f5 100644 --- a/api/api/ml.get_influencers.js +++ b/api/api/ml.get_influencers.js @@ -69,6 +69,15 @@ function buildMlGetInfluencers (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlGetInfluencers(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['job_id'] == null && params['jobId'] == null) { return callback( diff --git a/api/api/ml.get_job_stats.js b/api/api/ml.get_job_stats.js index 7c8e8b653..53ac81c06 100644 --- a/api/api/ml.get_job_stats.js +++ b/api/api/ml.get_job_stats.js @@ -52,6 +52,15 @@ function buildMlGetJobStats (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlGetJobStats(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/ml.get_jobs.js b/api/api/ml.get_jobs.js index fcb8734c7..dd8a91275 100644 --- a/api/api/ml.get_jobs.js +++ b/api/api/ml.get_jobs.js @@ -52,6 +52,15 @@ function buildMlGetJobs (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlGetJobs(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/ml.get_model_snapshots.js b/api/api/ml.get_model_snapshots.js index f9b2aae7d..6eeb06ab2 100644 --- a/api/api/ml.get_model_snapshots.js +++ b/api/api/ml.get_model_snapshots.js @@ -64,6 +64,15 @@ function buildMlGetModelSnapshots (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlGetModelSnapshots(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['job_id'] == null && params['jobId'] == null) { return callback( diff --git a/api/api/ml.get_overall_buckets.js b/api/api/ml.get_overall_buckets.js index d5e647590..5c34b0921 100644 --- a/api/api/ml.get_overall_buckets.js +++ b/api/api/ml.get_overall_buckets.js @@ -69,6 +69,15 @@ function buildMlGetOverallBuckets (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlGetOverallBuckets(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['job_id'] == null && params['jobId'] == null) { return callback( diff --git a/api/api/ml.get_records.js b/api/api/ml.get_records.js index e38213f0f..c8fecd3c7 100644 --- a/api/api/ml.get_records.js +++ b/api/api/ml.get_records.js @@ -69,6 +69,15 @@ function buildMlGetRecords (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlGetRecords(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['job_id'] == null && params['jobId'] == null) { return callback( diff --git a/api/api/ml.info.js b/api/api/ml.info.js index 55c7c9e0e..401611802 100644 --- a/api/api/ml.info.js +++ b/api/api/ml.info.js @@ -50,6 +50,15 @@ function buildMlInfo (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlInfo(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { return callback( diff --git a/api/api/ml.open_job.js b/api/api/ml.open_job.js index 81f92ae12..5f77f2dbe 100644 --- a/api/api/ml.open_job.js +++ b/api/api/ml.open_job.js @@ -53,6 +53,15 @@ function buildMlOpenJob (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlOpenJob(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['job_id'] == null && params['jobId'] == null) { return callback( diff --git a/api/api/ml.post_calendar_events.js b/api/api/ml.post_calendar_events.js index a99b009da..6d956007d 100644 --- a/api/api/ml.post_calendar_events.js +++ b/api/api/ml.post_calendar_events.js @@ -52,6 +52,15 @@ function buildMlPostCalendarEvents (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlPostCalendarEvents(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['calendar_id'] == null && params['calendarId'] == null) { return callback( diff --git a/api/api/ml.post_data.js b/api/api/ml.post_data.js index 702ad50a2..a6964a52d 100644 --- a/api/api/ml.post_data.js +++ b/api/api/ml.post_data.js @@ -56,6 +56,15 @@ function buildMlPostData (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlPostData(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['job_id'] == null && params['jobId'] == null) { return callback( diff --git a/api/api/ml.preview_datafeed.js b/api/api/ml.preview_datafeed.js index c7b68045c..562e09331 100644 --- a/api/api/ml.preview_datafeed.js +++ b/api/api/ml.preview_datafeed.js @@ -51,6 +51,15 @@ function buildMlPreviewDatafeed (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlPreviewDatafeed(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['datafeed_id'] == null && params['datafeedId'] == null) { return callback( diff --git a/api/api/ml.put_calendar.js b/api/api/ml.put_calendar.js index a47f770ce..82fd3db68 100644 --- a/api/api/ml.put_calendar.js +++ b/api/api/ml.put_calendar.js @@ -52,6 +52,15 @@ function buildMlPutCalendar (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlPutCalendar(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['calendar_id'] == null && params['calendarId'] == null) { return callback( diff --git a/api/api/ml.put_calendar_job.js b/api/api/ml.put_calendar_job.js index 7c23f126f..f4882f2ed 100644 --- a/api/api/ml.put_calendar_job.js +++ b/api/api/ml.put_calendar_job.js @@ -52,6 +52,15 @@ function buildMlPutCalendarJob (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlPutCalendarJob(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['calendar_id'] == null && params['calendarId'] == null) { return callback( diff --git a/api/api/ml.put_datafeed.js b/api/api/ml.put_datafeed.js index 4a6856c83..8b0626212 100644 --- a/api/api/ml.put_datafeed.js +++ b/api/api/ml.put_datafeed.js @@ -52,6 +52,15 @@ function buildMlPutDatafeed (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlPutDatafeed(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['datafeed_id'] == null && params['datafeedId'] == null) { return callback( diff --git a/api/api/ml.put_filter.js b/api/api/ml.put_filter.js index 63d2b3ec9..3d637bf22 100644 --- a/api/api/ml.put_filter.js +++ b/api/api/ml.put_filter.js @@ -52,6 +52,15 @@ function buildMlPutFilter (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlPutFilter(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['filter_id'] == null && params['filterId'] == null) { return callback( diff --git a/api/api/ml.put_job.js b/api/api/ml.put_job.js index f5f363974..08d444d1e 100644 --- a/api/api/ml.put_job.js +++ b/api/api/ml.put_job.js @@ -52,6 +52,15 @@ function buildMlPutJob (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlPutJob(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['job_id'] == null && params['jobId'] == null) { return callback( diff --git a/api/api/ml.revert_model_snapshot.js b/api/api/ml.revert_model_snapshot.js index 81a70e0db..e3daf24aa 100644 --- a/api/api/ml.revert_model_snapshot.js +++ b/api/api/ml.revert_model_snapshot.js @@ -54,6 +54,15 @@ function buildMlRevertModelSnapshot (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlRevertModelSnapshot(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['job_id'] == null && params['jobId'] == null) { return callback( diff --git a/api/api/ml.set_upgrade_mode.js b/api/api/ml.set_upgrade_mode.js index cd95163a2..eaf40d34f 100644 --- a/api/api/ml.set_upgrade_mode.js +++ b/api/api/ml.set_upgrade_mode.js @@ -53,6 +53,15 @@ function buildMlSetUpgradeMode (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlSetUpgradeMode(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/ml.start_datafeed.js b/api/api/ml.start_datafeed.js index 1ca6a7362..62c0e24c7 100644 --- a/api/api/ml.start_datafeed.js +++ b/api/api/ml.start_datafeed.js @@ -57,6 +57,15 @@ function buildMlStartDatafeed (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlStartDatafeed(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['datafeed_id'] == null && params['datafeedId'] == null) { return callback( diff --git a/api/api/ml.stop_datafeed.js b/api/api/ml.stop_datafeed.js index 13515e966..693a941b0 100644 --- a/api/api/ml.stop_datafeed.js +++ b/api/api/ml.stop_datafeed.js @@ -57,6 +57,15 @@ function buildMlStopDatafeed (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlStopDatafeed(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['datafeed_id'] == null && params['datafeedId'] == null) { return callback( diff --git a/api/api/ml.update_datafeed.js b/api/api/ml.update_datafeed.js index e2e800fa2..3ab93f76b 100644 --- a/api/api/ml.update_datafeed.js +++ b/api/api/ml.update_datafeed.js @@ -52,6 +52,15 @@ function buildMlUpdateDatafeed (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlUpdateDatafeed(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['datafeed_id'] == null && params['datafeedId'] == null) { return callback( diff --git a/api/api/ml.update_filter.js b/api/api/ml.update_filter.js index b50f1cc3a..470ab31b8 100644 --- a/api/api/ml.update_filter.js +++ b/api/api/ml.update_filter.js @@ -52,6 +52,15 @@ function buildMlUpdateFilter (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlUpdateFilter(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['filter_id'] == null && params['filterId'] == null) { return callback( diff --git a/api/api/ml.update_job.js b/api/api/ml.update_job.js index f315e41af..56c58a686 100644 --- a/api/api/ml.update_job.js +++ b/api/api/ml.update_job.js @@ -52,6 +52,15 @@ function buildMlUpdateJob (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlUpdateJob(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['job_id'] == null && params['jobId'] == null) { return callback( diff --git a/api/api/ml.update_model_snapshot.js b/api/api/ml.update_model_snapshot.js index 7d44400e5..fc83d0ecb 100644 --- a/api/api/ml.update_model_snapshot.js +++ b/api/api/ml.update_model_snapshot.js @@ -53,6 +53,15 @@ function buildMlUpdateModelSnapshot (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlUpdateModelSnapshot(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['job_id'] == null && params['jobId'] == null) { return callback( diff --git a/api/api/ml.validate.js b/api/api/ml.validate.js index 2f1401f3e..d7fb5728a 100644 --- a/api/api/ml.validate.js +++ b/api/api/ml.validate.js @@ -51,6 +51,15 @@ function buildMlValidate (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlValidate(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/ml.validate_detector.js b/api/api/ml.validate_detector.js index 07570ddc6..9c1afae6f 100644 --- a/api/api/ml.validate_detector.js +++ b/api/api/ml.validate_detector.js @@ -51,6 +51,15 @@ function buildMlValidateDetector (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mlValidateDetector(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/monitoring.bulk.js b/api/api/monitoring.bulk.js index 082c26acb..6b2c1e739 100644 --- a/api/api/monitoring.bulk.js +++ b/api/api/monitoring.bulk.js @@ -59,6 +59,15 @@ function buildMonitoringBulk (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + monitoringBulk(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/msearch.js b/api/api/msearch.js index a10558174..f411473f2 100644 --- a/api/api/msearch.js +++ b/api/api/msearch.js @@ -79,6 +79,15 @@ function buildMsearch (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + msearch(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/msearch_template.js b/api/api/msearch_template.js index 5fd848d92..13a23fa80 100644 --- a/api/api/msearch_template.js +++ b/api/api/msearch_template.js @@ -73,6 +73,15 @@ function buildMsearchTemplate (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + msearchTemplate(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/mtermvectors.js b/api/api/mtermvectors.js index ceb3a089c..c06dafd2c 100644 --- a/api/api/mtermvectors.js +++ b/api/api/mtermvectors.js @@ -87,6 +87,15 @@ function buildMtermvectors (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + mtermvectors(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required url components if (params['type'] != null && (params['index'] == null)) { return callback( diff --git a/api/api/nodes.hot_threads.js b/api/api/nodes.hot_threads.js index e78ea5213..a4f70ff12 100644 --- a/api/api/nodes.hot_threads.js +++ b/api/api/nodes.hot_threads.js @@ -69,6 +69,15 @@ function buildNodesHotThreads (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + nodesHotThreads(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/nodes.info.js b/api/api/nodes.info.js index 41cbd98ce..c5a8648aa 100644 --- a/api/api/nodes.info.js +++ b/api/api/nodes.info.js @@ -62,6 +62,15 @@ function buildNodesInfo (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + nodesInfo(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/nodes.reload_secure_settings.js b/api/api/nodes.reload_secure_settings.js index a9fee39e7..59fa010c3 100644 --- a/api/api/nodes.reload_secure_settings.js +++ b/api/api/nodes.reload_secure_settings.js @@ -58,6 +58,15 @@ function buildNodesReloadSecureSettings (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + nodesReloadSecureSettings(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/nodes.stats.js b/api/api/nodes.stats.js index f84e583de..25f02f5a4 100644 --- a/api/api/nodes.stats.js +++ b/api/api/nodes.stats.js @@ -77,6 +77,15 @@ function buildNodesStats (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + nodesStats(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/nodes.usage.js b/api/api/nodes.usage.js index 783066665..9400db998 100644 --- a/api/api/nodes.usage.js +++ b/api/api/nodes.usage.js @@ -59,6 +59,15 @@ function buildNodesUsage (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + nodesUsage(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/ping.js b/api/api/ping.js index e696c1568..fe6acf9af 100644 --- a/api/api/ping.js +++ b/api/api/ping.js @@ -55,6 +55,15 @@ function buildPing (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ping(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/put_script.js b/api/api/put_script.js index 993e2130e..ae5cdce30 100644 --- a/api/api/put_script.js +++ b/api/api/put_script.js @@ -65,6 +65,15 @@ function buildPutScript (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + putScript(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['id'] == null) { return callback( diff --git a/api/api/rank_eval.js b/api/api/rank_eval.js index e3c3f39dc..2d97a62d2 100644 --- a/api/api/rank_eval.js +++ b/api/api/rank_eval.js @@ -66,6 +66,15 @@ function buildRankEval (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + rankEval(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/reindex.js b/api/api/reindex.js index 535fc265e..ced743919 100644 --- a/api/api/reindex.js +++ b/api/api/reindex.js @@ -71,6 +71,15 @@ function buildReindex (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + reindex(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/reindex_rethrottle.js b/api/api/reindex_rethrottle.js index 4bdf99863..eebcc7f1e 100644 --- a/api/api/reindex_rethrottle.js +++ b/api/api/reindex_rethrottle.js @@ -59,6 +59,15 @@ function buildReindexRethrottle (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + reindexRethrottle(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['task_id'] == null && params['taskId'] == null) { return callback( diff --git a/api/api/render_search_template.js b/api/api/render_search_template.js index 8936dc4f9..f9b53e3ba 100644 --- a/api/api/render_search_template.js +++ b/api/api/render_search_template.js @@ -57,6 +57,15 @@ function buildRenderSearchTemplate (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + renderSearchTemplate(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { return callback( diff --git a/api/api/scripts_painless_execute.js b/api/api/scripts_painless_execute.js index 0a0a8ae25..0bf6379a6 100644 --- a/api/api/scripts_painless_execute.js +++ b/api/api/scripts_painless_execute.js @@ -56,6 +56,15 @@ function buildScriptsPainlessExecute (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + scriptsPainlessExecute(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { return callback( diff --git a/api/api/scroll.js b/api/api/scroll.js index beff548d2..91cfbb82d 100644 --- a/api/api/scroll.js +++ b/api/api/scroll.js @@ -65,6 +65,15 @@ function buildScroll (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + scroll(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { return callback( diff --git a/api/api/search.js b/api/api/search.js index e5b3cdfa9..6d43f26aa 100644 --- a/api/api/search.js +++ b/api/api/search.js @@ -169,6 +169,15 @@ function buildSearch (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + search(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required url components if (params['type'] != null && (params['index'] == null)) { return callback( diff --git a/api/api/search_shards.js b/api/api/search_shards.js index 4ae9034ad..a142145a9 100644 --- a/api/api/search_shards.js +++ b/api/api/search_shards.js @@ -71,6 +71,15 @@ function buildSearchShards (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + searchShards(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/search_template.js b/api/api/search_template.js index 466d669c1..36b832f47 100644 --- a/api/api/search_template.js +++ b/api/api/search_template.js @@ -92,6 +92,15 @@ function buildSearchTemplate (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + searchTemplate(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/security.authenticate.js b/api/api/security.authenticate.js index da504bdc4..3603102e0 100644 --- a/api/api/security.authenticate.js +++ b/api/api/security.authenticate.js @@ -50,6 +50,15 @@ function buildSecurityAuthenticate (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityAuthenticate(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/security.change_password.js b/api/api/security.change_password.js index 569dbf449..f289f027f 100644 --- a/api/api/security.change_password.js +++ b/api/api/security.change_password.js @@ -53,6 +53,15 @@ function buildSecurityChangePassword (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityChangePassword(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/security.clear_cached_realms.js b/api/api/security.clear_cached_realms.js index 97af5dcaf..736b06ea6 100644 --- a/api/api/security.clear_cached_realms.js +++ b/api/api/security.clear_cached_realms.js @@ -52,6 +52,15 @@ function buildSecurityClearCachedRealms (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityClearCachedRealms(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['realms'] == null) { return callback( diff --git a/api/api/security.clear_cached_roles.js b/api/api/security.clear_cached_roles.js index 1741e5e1f..4acd50cb0 100644 --- a/api/api/security.clear_cached_roles.js +++ b/api/api/security.clear_cached_roles.js @@ -51,6 +51,15 @@ function buildSecurityClearCachedRoles (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityClearCachedRoles(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['name'] == null) { return callback( diff --git a/api/api/security.create_api_key.js b/api/api/security.create_api_key.js index b5dd7e597..c1b19ef5b 100644 --- a/api/api/security.create_api_key.js +++ b/api/api/security.create_api_key.js @@ -52,6 +52,15 @@ function buildSecurityCreateApiKey (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityCreateApiKey(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/security.delete_privileges.js b/api/api/security.delete_privileges.js index fa54275d3..934365e50 100644 --- a/api/api/security.delete_privileges.js +++ b/api/api/security.delete_privileges.js @@ -53,6 +53,15 @@ function buildSecurityDeletePrivileges (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityDeletePrivileges(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['application'] == null) { return callback( diff --git a/api/api/security.delete_role.js b/api/api/security.delete_role.js index f8046d046..50fc608ac 100644 --- a/api/api/security.delete_role.js +++ b/api/api/security.delete_role.js @@ -52,6 +52,15 @@ function buildSecurityDeleteRole (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityDeleteRole(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['name'] == null) { return callback( diff --git a/api/api/security.delete_role_mapping.js b/api/api/security.delete_role_mapping.js index 269c7a87d..af0f32c32 100644 --- a/api/api/security.delete_role_mapping.js +++ b/api/api/security.delete_role_mapping.js @@ -52,6 +52,15 @@ function buildSecurityDeleteRoleMapping (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityDeleteRoleMapping(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['name'] == null) { return callback( diff --git a/api/api/security.delete_user.js b/api/api/security.delete_user.js index f89bb0fb9..5f6c778ff 100644 --- a/api/api/security.delete_user.js +++ b/api/api/security.delete_user.js @@ -52,6 +52,15 @@ function buildSecurityDeleteUser (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityDeleteUser(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['username'] == null) { return callback( diff --git a/api/api/security.disable_user.js b/api/api/security.disable_user.js index e7f1bccde..a07f6f433 100644 --- a/api/api/security.disable_user.js +++ b/api/api/security.disable_user.js @@ -52,6 +52,15 @@ function buildSecurityDisableUser (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityDisableUser(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/security.enable_user.js b/api/api/security.enable_user.js index 58a49c9d6..aefe27d78 100644 --- a/api/api/security.enable_user.js +++ b/api/api/security.enable_user.js @@ -52,6 +52,15 @@ function buildSecurityEnableUser (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityEnableUser(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/security.get_api_key.js b/api/api/security.get_api_key.js index 4d3d97769..231ccd8bc 100644 --- a/api/api/security.get_api_key.js +++ b/api/api/security.get_api_key.js @@ -57,6 +57,15 @@ function buildSecurityGetApiKey (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityGetApiKey(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/security.get_privileges.js b/api/api/security.get_privileges.js index d285b6822..3e5f5d5c3 100644 --- a/api/api/security.get_privileges.js +++ b/api/api/security.get_privileges.js @@ -52,6 +52,15 @@ function buildSecurityGetPrivileges (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityGetPrivileges(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/security.get_role.js b/api/api/security.get_role.js index 24e2f384d..b3d05555d 100644 --- a/api/api/security.get_role.js +++ b/api/api/security.get_role.js @@ -51,6 +51,15 @@ function buildSecurityGetRole (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityGetRole(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/security.get_role_mapping.js b/api/api/security.get_role_mapping.js index c56e81f8b..d760fb184 100644 --- a/api/api/security.get_role_mapping.js +++ b/api/api/security.get_role_mapping.js @@ -51,6 +51,15 @@ function buildSecurityGetRoleMapping (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityGetRoleMapping(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/security.get_token.js b/api/api/security.get_token.js index 32ea01902..407ff5b35 100644 --- a/api/api/security.get_token.js +++ b/api/api/security.get_token.js @@ -51,6 +51,15 @@ function buildSecurityGetToken (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityGetToken(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/security.get_user.js b/api/api/security.get_user.js index 6f29262a2..1de5e97bf 100644 --- a/api/api/security.get_user.js +++ b/api/api/security.get_user.js @@ -51,6 +51,15 @@ function buildSecurityGetUser (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityGetUser(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/security.get_user_privileges.js b/api/api/security.get_user_privileges.js index 7a79ef740..46f1706da 100644 --- a/api/api/security.get_user_privileges.js +++ b/api/api/security.get_user_privileges.js @@ -50,6 +50,15 @@ function buildSecurityGetUserPrivileges (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityGetUserPrivileges(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/security.has_privileges.js b/api/api/security.has_privileges.js index 78987c6b8..d0419c2c2 100644 --- a/api/api/security.has_privileges.js +++ b/api/api/security.has_privileges.js @@ -52,6 +52,15 @@ function buildSecurityHasPrivileges (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityHasPrivileges(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/security.invalidate_api_key.js b/api/api/security.invalidate_api_key.js index 1d4a7f877..d02d2148b 100644 --- a/api/api/security.invalidate_api_key.js +++ b/api/api/security.invalidate_api_key.js @@ -51,6 +51,15 @@ function buildSecurityInvalidateApiKey (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityInvalidateApiKey(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/security.invalidate_token.js b/api/api/security.invalidate_token.js index fa2043b2c..e58a221e4 100644 --- a/api/api/security.invalidate_token.js +++ b/api/api/security.invalidate_token.js @@ -51,6 +51,15 @@ function buildSecurityInvalidateToken (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityInvalidateToken(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/security.put_privileges.js b/api/api/security.put_privileges.js index c08e9aa01..d102615b1 100644 --- a/api/api/security.put_privileges.js +++ b/api/api/security.put_privileges.js @@ -52,6 +52,15 @@ function buildSecurityPutPrivileges (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityPutPrivileges(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/security.put_role.js b/api/api/security.put_role.js index 6bd851141..d4e2de603 100644 --- a/api/api/security.put_role.js +++ b/api/api/security.put_role.js @@ -53,6 +53,15 @@ function buildSecurityPutRole (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityPutRole(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['name'] == null) { return callback( diff --git a/api/api/security.put_role_mapping.js b/api/api/security.put_role_mapping.js index c6450d155..721d41ca6 100644 --- a/api/api/security.put_role_mapping.js +++ b/api/api/security.put_role_mapping.js @@ -53,6 +53,15 @@ function buildSecurityPutRoleMapping (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityPutRoleMapping(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['name'] == null) { return callback( diff --git a/api/api/security.put_user.js b/api/api/security.put_user.js index 16fb9182d..4a9dc7467 100644 --- a/api/api/security.put_user.js +++ b/api/api/security.put_user.js @@ -53,6 +53,15 @@ function buildSecurityPutUser (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + securityPutUser(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['username'] == null) { return callback( diff --git a/api/api/snapshot.create.js b/api/api/snapshot.create.js index 016a9fee6..fb74315c5 100644 --- a/api/api/snapshot.create.js +++ b/api/api/snapshot.create.js @@ -64,6 +64,15 @@ function buildSnapshotCreate (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + snapshotCreate(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['repository'] == null) { return callback( diff --git a/api/api/snapshot.create_repository.js b/api/api/snapshot.create_repository.js index 284f1e821..010a3b2b1 100644 --- a/api/api/snapshot.create_repository.js +++ b/api/api/snapshot.create_repository.js @@ -64,6 +64,15 @@ function buildSnapshotCreateRepository (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + snapshotCreateRepository(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['repository'] == null) { return callback( diff --git a/api/api/snapshot.delete.js b/api/api/snapshot.delete.js index 036535eb7..ab0e48383 100644 --- a/api/api/snapshot.delete.js +++ b/api/api/snapshot.delete.js @@ -60,6 +60,15 @@ function buildSnapshotDelete (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + snapshotDelete(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['repository'] == null) { return callback( diff --git a/api/api/snapshot.delete_repository.js b/api/api/snapshot.delete_repository.js index b552268c8..18c4ae4bb 100644 --- a/api/api/snapshot.delete_repository.js +++ b/api/api/snapshot.delete_repository.js @@ -61,6 +61,15 @@ function buildSnapshotDeleteRepository (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + snapshotDeleteRepository(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['repository'] == null) { return callback( diff --git a/api/api/snapshot.get.js b/api/api/snapshot.get.js index f05948fea..fd03f0260 100644 --- a/api/api/snapshot.get.js +++ b/api/api/snapshot.get.js @@ -65,6 +65,15 @@ function buildSnapshotGet (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + snapshotGet(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['repository'] == null) { return callback( diff --git a/api/api/snapshot.get_repository.js b/api/api/snapshot.get_repository.js index 1b0b32129..a71c5f723 100644 --- a/api/api/snapshot.get_repository.js +++ b/api/api/snapshot.get_repository.js @@ -61,6 +61,15 @@ function buildSnapshotGetRepository (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + snapshotGetRepository(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/snapshot.restore.js b/api/api/snapshot.restore.js index 13865283f..5feeaf569 100644 --- a/api/api/snapshot.restore.js +++ b/api/api/snapshot.restore.js @@ -64,6 +64,15 @@ function buildSnapshotRestore (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + snapshotRestore(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['repository'] == null) { return callback( diff --git a/api/api/snapshot.status.js b/api/api/snapshot.status.js index cb3536c40..6c376244f 100644 --- a/api/api/snapshot.status.js +++ b/api/api/snapshot.status.js @@ -63,6 +63,15 @@ function buildSnapshotStatus (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + snapshotStatus(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/snapshot.verify_repository.js b/api/api/snapshot.verify_repository.js index 12db7c034..27e1df088 100644 --- a/api/api/snapshot.verify_repository.js +++ b/api/api/snapshot.verify_repository.js @@ -61,6 +61,15 @@ function buildSnapshotVerifyRepository (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + snapshotVerifyRepository(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['repository'] == null) { return callback( diff --git a/api/api/ssl.certificates.js b/api/api/ssl.certificates.js index 7e876c609..287edc0df 100644 --- a/api/api/ssl.certificates.js +++ b/api/api/ssl.certificates.js @@ -50,6 +50,15 @@ function buildSslCertificates (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + sslCertificates(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/tasks.cancel.js b/api/api/tasks.cancel.js index 2d226efd9..98e123fcd 100644 --- a/api/api/tasks.cancel.js +++ b/api/api/tasks.cancel.js @@ -63,6 +63,15 @@ function buildTasksCancel (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + tasksCancel(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/tasks.get.js b/api/api/tasks.get.js index 032ca29a8..0b690a8a9 100644 --- a/api/api/tasks.get.js +++ b/api/api/tasks.get.js @@ -61,6 +61,15 @@ function buildTasksGet (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + tasksGet(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['task_id'] == null && params['taskId'] == null) { return callback( diff --git a/api/api/tasks.list.js b/api/api/tasks.list.js index 2d9362434..f54d77417 100644 --- a/api/api/tasks.list.js +++ b/api/api/tasks.list.js @@ -72,6 +72,15 @@ function buildTasksList (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + tasksList(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/termvectors.js b/api/api/termvectors.js index cb8a10d3e..3e7552f72 100644 --- a/api/api/termvectors.js +++ b/api/api/termvectors.js @@ -86,6 +86,15 @@ function buildTermvectors (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + termvectors(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/update.js b/api/api/update.js index a1bbe0b54..6fa970065 100644 --- a/api/api/update.js +++ b/api/api/update.js @@ -89,6 +89,15 @@ function buildUpdate (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + update(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['id'] == null) { return callback( diff --git a/api/api/update_by_query.js b/api/api/update_by_query.js index a6455a813..1e506f600 100644 --- a/api/api/update_by_query.js +++ b/api/api/update_by_query.js @@ -142,6 +142,15 @@ function buildUpdateByQuery (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + updateByQuery(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/update_by_query_rethrottle.js b/api/api/update_by_query_rethrottle.js index b57d94b40..654ad8cfd 100644 --- a/api/api/update_by_query_rethrottle.js +++ b/api/api/update_by_query_rethrottle.js @@ -59,6 +59,15 @@ function buildUpdateByQueryRethrottle (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + updateByQueryRethrottle(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['task_id'] == null && params['taskId'] == null) { return callback( diff --git a/api/api/xpack.graph.explore.js b/api/api/xpack.graph.explore.js index c991bc53e..5161ab7f0 100644 --- a/api/api/xpack.graph.explore.js +++ b/api/api/xpack.graph.explore.js @@ -56,6 +56,15 @@ function buildXpackGraphExplore (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackGraphExplore(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required url components if (params['type'] != null && (params['index'] == null)) { return callback( diff --git a/api/api/xpack.info.js b/api/api/xpack.info.js index 6881278e2..a5bdbf823 100644 --- a/api/api/xpack.info.js +++ b/api/api/xpack.info.js @@ -51,6 +51,15 @@ function buildXpackInfo (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackInfo(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/xpack.license.delete.js b/api/api/xpack.license.delete.js index 0ba866644..48e1b8898 100644 --- a/api/api/xpack.license.delete.js +++ b/api/api/xpack.license.delete.js @@ -50,6 +50,15 @@ function buildXpackLicenseDelete (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackLicenseDelete(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/xpack.license.get.js b/api/api/xpack.license.get.js index fe2c0a32c..5ed14eb42 100644 --- a/api/api/xpack.license.get.js +++ b/api/api/xpack.license.get.js @@ -51,6 +51,15 @@ function buildXpackLicenseGet (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackLicenseGet(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/xpack.license.get_basic_status.js b/api/api/xpack.license.get_basic_status.js index 0ec25ff6d..f933920ae 100644 --- a/api/api/xpack.license.get_basic_status.js +++ b/api/api/xpack.license.get_basic_status.js @@ -50,6 +50,15 @@ function buildXpackLicenseGetBasicStatus (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackLicenseGetBasicStatus(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/xpack.license.get_trial_status.js b/api/api/xpack.license.get_trial_status.js index 09660966b..49bb6ec4d 100644 --- a/api/api/xpack.license.get_trial_status.js +++ b/api/api/xpack.license.get_trial_status.js @@ -50,6 +50,15 @@ function buildXpackLicenseGetTrialStatus (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackLicenseGetTrialStatus(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/xpack.license.post.js b/api/api/xpack.license.post.js index ebbd77e2d..6c9182099 100644 --- a/api/api/xpack.license.post.js +++ b/api/api/xpack.license.post.js @@ -52,6 +52,15 @@ function buildXpackLicensePost (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackLicensePost(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { return callback( diff --git a/api/api/xpack.license.post_start_basic.js b/api/api/xpack.license.post_start_basic.js index 9e9a6faae..7484f4876 100644 --- a/api/api/xpack.license.post_start_basic.js +++ b/api/api/xpack.license.post_start_basic.js @@ -51,6 +51,15 @@ function buildXpackLicensePostStartBasic (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackLicensePostStartBasic(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/xpack.license.post_start_trial.js b/api/api/xpack.license.post_start_trial.js index ac2c11f3a..ed9d04bf0 100644 --- a/api/api/xpack.license.post_start_trial.js +++ b/api/api/xpack.license.post_start_trial.js @@ -53,6 +53,15 @@ function buildXpackLicensePostStartTrial (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackLicensePostStartTrial(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/xpack.migration.deprecations.js b/api/api/xpack.migration.deprecations.js index e5fbad087..485e4cadb 100644 --- a/api/api/xpack.migration.deprecations.js +++ b/api/api/xpack.migration.deprecations.js @@ -51,6 +51,15 @@ function buildXpackMigrationDeprecations (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMigrationDeprecations(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/xpack.migration.get_assistance.js b/api/api/xpack.migration.get_assistance.js index 1840cdd9b..96c0591cf 100644 --- a/api/api/xpack.migration.get_assistance.js +++ b/api/api/xpack.migration.get_assistance.js @@ -58,6 +58,15 @@ function buildXpackMigrationGetAssistance (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMigrationGetAssistance(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { return callback( diff --git a/api/api/xpack.migration.upgrade.js b/api/api/xpack.migration.upgrade.js index 305428a6c..16062ae81 100644 --- a/api/api/xpack.migration.upgrade.js +++ b/api/api/xpack.migration.upgrade.js @@ -52,6 +52,15 @@ function buildXpackMigrationUpgrade (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackMigrationUpgrade(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/xpack.rollup.delete_job.js b/api/api/xpack.rollup.delete_job.js index 7dc7a4903..d463030c5 100644 --- a/api/api/xpack.rollup.delete_job.js +++ b/api/api/xpack.rollup.delete_job.js @@ -51,6 +51,15 @@ function buildXpackRollupDeleteJob (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackRollupDeleteJob(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['id'] == null) { return callback( diff --git a/api/api/xpack.rollup.get_jobs.js b/api/api/xpack.rollup.get_jobs.js index cdb7b666a..25a150d0e 100644 --- a/api/api/xpack.rollup.get_jobs.js +++ b/api/api/xpack.rollup.get_jobs.js @@ -51,6 +51,15 @@ function buildXpackRollupGetJobs (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackRollupGetJobs(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { return callback( diff --git a/api/api/xpack.rollup.get_rollup_caps.js b/api/api/xpack.rollup.get_rollup_caps.js index cb18eee62..dfe09cce4 100644 --- a/api/api/xpack.rollup.get_rollup_caps.js +++ b/api/api/xpack.rollup.get_rollup_caps.js @@ -51,6 +51,15 @@ function buildXpackRollupGetRollupCaps (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackRollupGetRollupCaps(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { return callback( diff --git a/api/api/xpack.rollup.get_rollup_index_caps.js b/api/api/xpack.rollup.get_rollup_index_caps.js index de4191264..6b7846b72 100644 --- a/api/api/xpack.rollup.get_rollup_index_caps.js +++ b/api/api/xpack.rollup.get_rollup_index_caps.js @@ -51,6 +51,15 @@ function buildXpackRollupGetRollupIndexCaps (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackRollupGetRollupIndexCaps(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/xpack.rollup.put_job.js b/api/api/xpack.rollup.put_job.js index 37de0684b..d76625c51 100644 --- a/api/api/xpack.rollup.put_job.js +++ b/api/api/xpack.rollup.put_job.js @@ -52,6 +52,15 @@ function buildXpackRollupPutJob (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackRollupPutJob(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['id'] == null) { return callback( diff --git a/api/api/xpack.rollup.rollup_search.js b/api/api/xpack.rollup.rollup_search.js index e8bc75395..b006d127f 100644 --- a/api/api/xpack.rollup.rollup_search.js +++ b/api/api/xpack.rollup.rollup_search.js @@ -57,6 +57,15 @@ function buildXpackRollupRollupSearch (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackRollupRollupSearch(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['index'] == null) { return callback( diff --git a/api/api/xpack.rollup.start_job.js b/api/api/xpack.rollup.start_job.js index 33c3ac5fd..3701988c8 100644 --- a/api/api/xpack.rollup.start_job.js +++ b/api/api/xpack.rollup.start_job.js @@ -51,6 +51,15 @@ function buildXpackRollupStartJob (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackRollupStartJob(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['id'] == null) { return callback( diff --git a/api/api/xpack.rollup.stop_job.js b/api/api/xpack.rollup.stop_job.js index 5bcf1373e..4d132b641 100644 --- a/api/api/xpack.rollup.stop_job.js +++ b/api/api/xpack.rollup.stop_job.js @@ -55,6 +55,15 @@ function buildXpackRollupStopJob (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackRollupStopJob(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['id'] == null) { return callback( diff --git a/api/api/xpack.sql.clear_cursor.js b/api/api/xpack.sql.clear_cursor.js index f35f3e363..d1967d400 100644 --- a/api/api/xpack.sql.clear_cursor.js +++ b/api/api/xpack.sql.clear_cursor.js @@ -51,6 +51,15 @@ function buildXpackSqlClearCursor (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSqlClearCursor(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/xpack.sql.query.js b/api/api/xpack.sql.query.js index 125c577f6..80d95b181 100644 --- a/api/api/xpack.sql.query.js +++ b/api/api/xpack.sql.query.js @@ -52,6 +52,15 @@ function buildXpackSqlQuery (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSqlQuery(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/xpack.sql.translate.js b/api/api/xpack.sql.translate.js index c8df293e7..15c544835 100644 --- a/api/api/xpack.sql.translate.js +++ b/api/api/xpack.sql.translate.js @@ -51,6 +51,15 @@ function buildXpackSqlTranslate (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackSqlTranslate(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['body'] == null) { return callback( diff --git a/api/api/xpack.usage.js b/api/api/xpack.usage.js index dd85627f1..61a6b8d86 100644 --- a/api/api/xpack.usage.js +++ b/api/api/xpack.usage.js @@ -51,6 +51,15 @@ function buildXpackUsage (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackUsage(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/xpack.watcher.ack_watch.js b/api/api/xpack.watcher.ack_watch.js index 9a8a450c4..2284c7098 100644 --- a/api/api/xpack.watcher.ack_watch.js +++ b/api/api/xpack.watcher.ack_watch.js @@ -52,6 +52,15 @@ function buildXpackWatcherAckWatch (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackWatcherAckWatch(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['watch_id'] == null && params['watchId'] == null) { return callback( diff --git a/api/api/xpack.watcher.activate_watch.js b/api/api/xpack.watcher.activate_watch.js index 1d114b189..ae5a81497 100644 --- a/api/api/xpack.watcher.activate_watch.js +++ b/api/api/xpack.watcher.activate_watch.js @@ -51,6 +51,15 @@ function buildXpackWatcherActivateWatch (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackWatcherActivateWatch(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['watch_id'] == null && params['watchId'] == null) { return callback( diff --git a/api/api/xpack.watcher.deactivate_watch.js b/api/api/xpack.watcher.deactivate_watch.js index 1e7fe35ac..fa9cdf434 100644 --- a/api/api/xpack.watcher.deactivate_watch.js +++ b/api/api/xpack.watcher.deactivate_watch.js @@ -51,6 +51,15 @@ function buildXpackWatcherDeactivateWatch (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackWatcherDeactivateWatch(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['watch_id'] == null && params['watchId'] == null) { return callback( diff --git a/api/api/xpack.watcher.delete_watch.js b/api/api/xpack.watcher.delete_watch.js index 063788115..cdddf8bd7 100644 --- a/api/api/xpack.watcher.delete_watch.js +++ b/api/api/xpack.watcher.delete_watch.js @@ -51,6 +51,15 @@ function buildXpackWatcherDeleteWatch (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackWatcherDeleteWatch(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['id'] == null) { return callback( diff --git a/api/api/xpack.watcher.execute_watch.js b/api/api/xpack.watcher.execute_watch.js index 8e14f3475..034e2d218 100644 --- a/api/api/xpack.watcher.execute_watch.js +++ b/api/api/xpack.watcher.execute_watch.js @@ -53,6 +53,15 @@ function buildXpackWatcherExecuteWatch (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackWatcherExecuteWatch(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // validate headers object if (options.headers != null && typeof options.headers !== 'object') { return callback( diff --git a/api/api/xpack.watcher.get_watch.js b/api/api/xpack.watcher.get_watch.js index f18fcb992..98f6db827 100644 --- a/api/api/xpack.watcher.get_watch.js +++ b/api/api/xpack.watcher.get_watch.js @@ -51,6 +51,15 @@ function buildXpackWatcherGetWatch (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackWatcherGetWatch(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['id'] == null) { return callback( diff --git a/api/api/xpack.watcher.put_watch.js b/api/api/xpack.watcher.put_watch.js index 269e58d5a..6dd39a603 100644 --- a/api/api/xpack.watcher.put_watch.js +++ b/api/api/xpack.watcher.put_watch.js @@ -60,6 +60,15 @@ function buildXpackWatcherPutWatch (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackWatcherPutWatch(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params['id'] == null) { return callback( diff --git a/api/api/xpack.watcher.start.js b/api/api/xpack.watcher.start.js index e16a81eda..5b4b227cc 100644 --- a/api/api/xpack.watcher.start.js +++ b/api/api/xpack.watcher.start.js @@ -50,6 +50,15 @@ function buildXpackWatcherStart (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackWatcherStart(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/xpack.watcher.stats.js b/api/api/xpack.watcher.stats.js index 6991ec20a..29e68ec6c 100644 --- a/api/api/xpack.watcher.stats.js +++ b/api/api/xpack.watcher.stats.js @@ -54,6 +54,15 @@ function buildXpackWatcherStats (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackWatcherStats(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( diff --git a/api/api/xpack.watcher.stop.js b/api/api/xpack.watcher.stop.js index 17f5c33a3..363f2b2f4 100644 --- a/api/api/xpack.watcher.stop.js +++ b/api/api/xpack.watcher.stop.js @@ -50,6 +50,15 @@ function buildXpackWatcherStop (opts) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + xpackWatcherStop(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + // check required parameters if (params.body != null) { return callback( From a90e9e1fe1eea3faf9be1b8eb48d4aa20dd72721 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 13 Mar 2019 14:13:02 +0100 Subject: [PATCH 02/22] Revert d4d7d0bef5bcefccb41768d5e00e2283c0d6ef10 --- scripts/utils/generate.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/utils/generate.js b/scripts/utils/generate.js index f7c7efede..f4a7ed602 100644 --- a/scripts/utils/generate.js +++ b/scripts/utils/generate.js @@ -106,6 +106,15 @@ function generate (spec, common) { options = {} } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ${safeWords(name)}(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + ${genRequiredChecks()} ${genUrlValidation(paths, api)} From e901b89e35bd242887e80ac01617d03a91e24f06 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 13 Mar 2019 16:12:24 +0100 Subject: [PATCH 03/22] Updated code generation --- scripts/utils/generate.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/utils/generate.js b/scripts/utils/generate.js index f4a7ed602..742c41f64 100644 --- a/scripts/utils/generate.js +++ b/scripts/utils/generate.js @@ -54,7 +54,9 @@ const ndjsonApi = [ 'msearch', 'msearch_template', 'ml.find_file_structure', - 'monitoring.bulk' + 'monitoring.bulk', + 'xpack.ml.find_file_structure', + 'xpack.monitoring.bulk' ] function generate (spec, common) { From c4879203a707b33fd7ec7350cd50d01d08db4bc2 Mon Sep 17 00:00:00 2001 From: delvedor Date: Wed, 13 Mar 2019 17:57:25 +0100 Subject: [PATCH 04/22] Updated CI setup --- ...h-js+next.yml => elastic+elasticsearch-js+6.x.yml} | 8 ++++---- .ci/jobs/elastic+elasticsearch-js+7.x.yml | 11 +++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) rename .ci/jobs/{elastic+elasticsearch-js+next.yml => elastic+elasticsearch-js+6.x.yml} (51%) create mode 100644 .ci/jobs/elastic+elasticsearch-js+7.x.yml diff --git a/.ci/jobs/elastic+elasticsearch-js+next.yml b/.ci/jobs/elastic+elasticsearch-js+6.x.yml similarity index 51% rename from .ci/jobs/elastic+elasticsearch-js+next.yml rename to .ci/jobs/elastic+elasticsearch-js+6.x.yml index 333102322..19ec923a6 100644 --- a/.ci/jobs/elastic+elasticsearch-js+next.yml +++ b/.ci/jobs/elastic+elasticsearch-js+6.x.yml @@ -1,11 +1,11 @@ --- - job: - name: elastic+elasticsearch-js+next - display-name: 'elastic / elasticsearch-js # next' - description: Testing the elasticsearch-js next branch. + name: elastic+elasticsearch-js+6.x + display-name: 'elastic / elasticsearch-js # 6.x' + description: Testing the elasticsearch-js 6.x branch. parameters: - string: name: branch_specifier - default: refs/heads/next + default: refs/heads/6.x description: the Git branch specifier to build (<branchName>, <tagName>, <commitId>, etc.) diff --git a/.ci/jobs/elastic+elasticsearch-js+7.x.yml b/.ci/jobs/elastic+elasticsearch-js+7.x.yml new file mode 100644 index 000000000..2db87f425 --- /dev/null +++ b/.ci/jobs/elastic+elasticsearch-js+7.x.yml @@ -0,0 +1,11 @@ +--- +- job: + name: elastic+elasticsearch-js+7.x + display-name: 'elastic / elasticsearch-js # 7.x' + description: Testing the elasticsearch-js 7.x branch. + parameters: + - string: + name: branch_specifier + default: refs/heads/7.x + description: the Git branch specifier to build (<branchName>, <tagName>, + <commitId>, etc.) From 95acb31dfc2d3e1365d2314b42ccab420accdc0a Mon Sep 17 00:00:00 2001 From: Tomas Della Vedova Date: Wed, 13 Mar 2019 19:12:11 +0100 Subject: [PATCH 05/22] Added pull request and issue templates (#776) --- .github/ISSUE_TEMPLATE.md | 10 ++++++ .github/ISSUE_TEMPLATE/bug.md | 41 ++++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature.md | 22 +++++++++++++ .github/ISSUE_TEMPLATE/question.md | 10 ++++++ .github/ISSUE_TEMPLATE/regression.md | 47 ++++++++++++++++++++++++++++ .github/ISSUE_TEMPLATE/security.md | 6 ++++ .github/PULL_REQUEST_TEMPLATE.md | 11 +++++++ 7 files changed, 147 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/ISSUE_TEMPLATE/bug.md create mode 100644 .github/ISSUE_TEMPLATE/feature.md create mode 100644 .github/ISSUE_TEMPLATE/question.md create mode 100644 .github/ISSUE_TEMPLATE/regression.md create mode 100644 .github/ISSUE_TEMPLATE/security.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 000000000..0a2ad2dec --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,10 @@ +## 👉 [Please follow one of these issue templates](https://github.com/elastic/elasticsearch-js/issues/new/choose) 👈 + +#### You have already researched for similar issues? +It's not uncommon that somebody already opened an issue or in the best case it's already fixed but not merged. That's the reason why you should [search](https://github.com/elastic/elasticsearch-js/issues) at first before submitting a new one. + +#### Are you sure this is an issue with @elastic/elasticsearch or are you just looking for some help? + +Issues should only be posted in this repository after you have been able to reproduce them and confirm that they are a bug or incorrect/missing information in the [docs](https://github.com/elastic/elasticsearch-js/docs). + +If you have a question related to Elasticsearch itself, please consider open a question on [discuss.elastic.co](https://discuss.elastic.co/). diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 000000000..620b6a5ce --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,41 @@ +--- +name: 🐛 Bug report +about: Create a report to help us improve +--- + +It's not uncommon that somebody already opened an issue or in the best case it's already fixed but not merged. That's the reason why you should [search](https://github.com/elastic/elasticsearch-js/issues) at first before submitting a new one. + +**Please read this entire template before posting any issue. If you ignore these instructions +and post an issue here that does not follow the instructions, your issue might be closed, +locked, and assigned the `not reproducible` label.** + +## 🐛 Bug Report + +A clear and concise description of what the bug is. + +## To Reproduce + +Steps to reproduce the behavior: + +Paste your code here: + +```js + +``` + +## Expected behavior + +A clear and concise description of what you expected to happen. + +Paste the results here: + +```js + +``` + +## Your Environment + +- *node version*: 6,8,10 +- *@elastic/elasticsearch version*: >=7.0.0 +- *os*: Mac, Windows, Linux +- *any other relevant information* diff --git a/.github/ISSUE_TEMPLATE/feature.md b/.github/ISSUE_TEMPLATE/feature.md new file mode 100644 index 000000000..2335d551d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature.md @@ -0,0 +1,22 @@ +--- +name: 🚀 Feature Proposal +about: Submit a proposal for a new feature +--- + +It's not uncommon that somebody already opened an issue or in the best case it's already fixed but not merged. That's the reason why you should [search](https://github.com/elastic/elasticsearch-js/issues) at first before submitting a new one. + +**Please read this entire template before posting any issue. If you ignore these instructions +and post an issue here that does not follow the instructions, your issue might be closed, +locked, and assigned the `invalid` label.** + +## 🚀 Feature Proposal + +A clear and concise description of what the feature is. + +## Motivation + +Please outline the motivation for the proposal. + +## Example + +Please provide an example for how this feature would be used. diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 000000000..bbd7143bc --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,10 @@ +--- +name: 💬 Questions / Help +about: If you have questions, please check our Gitter or Help repo +--- + +## 💬 Questions and Help + +### Please note that this issue tracker is not a help forum and this issue may be closed. + +It's not uncommon that somebody already opened an issue or in the best case it's already fixed but not merged. That's the reason why you should [search](https://github.com/elastic/elasticsearch-js/issues) at first before submitting a new one. diff --git a/.github/ISSUE_TEMPLATE/regression.md b/.github/ISSUE_TEMPLATE/regression.md new file mode 100644 index 000000000..079234a36 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/regression.md @@ -0,0 +1,47 @@ +--- +name: 💥 Regression Report +about: Report unexpected behavior that worked in previous versions +--- + +It's not uncommon that somebody already opened an issue or in the best case it's already fixed but not merged. That's the reason why you should [search](https://github.com/elastic/elasticsearch-js/issues) at first before submitting a new one. + +**Please read this entire template before posting any issue. If you ignore these instructions +and post an issue here that does not follow the instructions, your issue might be closed, +locked, and assigned the `invalid` label.** + +## 💥 Regression Report + +A clear and concise description of what the regression is. + +## Last working version + +Worked up to version: + +Stopped working in version: + +## To Reproduce + +Steps to reproduce the behavior: + +Paste your code here: + +```js + +``` + +## Expected behavior + +A clear and concise description of what you expected to happen. + +Paste the results here: + +```js + +``` + +## Your Environment + +- *node version*: 6,8,10 +- *@elastic/elasticsearch version*: >=7.0.0 +- *os*: Mac, Windows, Linux +- *any other relevant information* diff --git a/.github/ISSUE_TEMPLATE/security.md b/.github/ISSUE_TEMPLATE/security.md new file mode 100644 index 000000000..0529296fc --- /dev/null +++ b/.github/ISSUE_TEMPLATE/security.md @@ -0,0 +1,6 @@ +--- +name: 👮 Security Issue +about: Responsible Disclosure +--- + +If you want to report a security issue, please take a look at [elastic/security](https://www.elastic.co/community/security). diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..bd9abd6e6 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,11 @@ + From 925b758418b2043a4394fb2a7a3f39080eaabba1 Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 14 Mar 2019 12:22:20 +0100 Subject: [PATCH 06/22] Added stale bot --- .github/stale.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/stale.yml diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 000000000..9f6c839ea --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,24 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 15 + +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 + +# Issues with these labels will never be considered stale +exemptLabels: + - "discussion" + - "feature request" + - "bug" + +# Label to use when marking an issue as stale +staleLabel: stale + +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: | + We understand that this might be important for you, but this issue has been automatically marked as stale because it has not had recent activity either from our end or yours. + It will be closed if no further activity occurs, please write a comment if you would like to keep this going. + + Note: in the past months we have built a new client, that has just landed in master. If you want to open an issue or a pr for the legacy client, you should do that in https://github.com/elastic/elasticsearch-js-legacy + +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: false From 38157d634e0a8de4dc8a5d008de7459e04df811c Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 14 Mar 2019 14:20:36 +0100 Subject: [PATCH 07/22] Updated pull request template --- .github/PULL_REQUEST_TEMPLATE.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index bd9abd6e6..9ce86a933 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,11 +1,17 @@ From 5aa8226a4c9519b0cacf2530aeafc5733c29952d Mon Sep 17 00:00:00 2001 From: delvedor Date: Thu, 14 Mar 2019 18:32:47 +0100 Subject: [PATCH 08/22] Updated README --- README.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bea340fb2..17d2e8918 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,22 @@ The official Node.js client for Elasticsearch. ``` npm install @elastic/elasticsearch ``` -By default the latest version of the module will be installed, which is the same version of the current release of Elasticsearch.
-If you need to work with older versions of Elasticsearch, you should install the same version of the client as well.
-For example, if you are using Elasticsearch `v6.5.4`, you will need the client `v6`, and you can easily do that with `npm install @elastic/elasticsearch@6`. + +### Compatibility +The library is compatible with all Elasticsearch versions since 5.x, but you should use the same major version of the Elasticsearch instance that you are using. +``` +# Elasticsearch 7.x +@elastic/elasticsearch@7 + +# Elasticsearch 6.x +@elastic/elasticsearch@6 + +# Elasticsearch 5.x +@elastic/elasticsearch@5 +``` ## Usage +You can find the full documentation in the [docs](https://github.com/elastic/elasticsearch-js/tree/master/docs) folder. ```js const { Client } = require('@elastic/elasticsearch') const client = new Client({ node: 'http://localhost:9200' }) @@ -48,6 +59,7 @@ The returned value of **every** API call is formed as follows: statusCode: number headers: object warnings: [string] + meta: object } ``` ### Client options From 9f17f820de155d76dc621c59010be7f756d746c2 Mon Sep 17 00:00:00 2001 From: Tomas Della Vedova Date: Fri, 15 Mar 2019 15:55:34 +0100 Subject: [PATCH 09/22] Added codecov (#777) --- .ci/docker-compose.yml | 3 +++ .ci/jobs/defaults.yml | 4 ++++ .ci/run-tests | 6 ++++++ .codecov.yml | 14 ++++++++++++++ package.json | 6 +++--- 5 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 .codecov.yml diff --git a/.ci/docker-compose.yml b/.ci/docker-compose.yml index ba8b0538e..a030ff93e 100644 --- a/.ci/docker-compose.yml +++ b/.ci/docker-compose.yml @@ -7,6 +7,7 @@ services: dockerfile: .ci/Dockerfile args: NODE_JS_VERSION: ${NODE_JS_VERSION:-10} + CODECOV_TOKEN: ${CODECOV_TOKEN} environment: - "TEST_ES_SERVER=http://elasticsearch-oss:9200" volumes: @@ -54,6 +55,8 @@ services: - esnet-platinum depends_on: - elasticsearch-platinum + # there is not need to run again also the unit test + command: ["npm", "run", "test:integration"] elasticsearch-platinum: image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-7.0.0-beta1} diff --git a/.ci/jobs/defaults.yml b/.ci/jobs/defaults.yml index 3df606402..a293e7c2a 100644 --- a/.ci/jobs/defaults.yml +++ b/.ci/jobs/defaults.yml @@ -30,6 +30,10 @@ wipe-workspace: 'True' triggers: - github + vault: + url: https://secrets.elastic.co:8200 + # vault read auth/approle/role/clients-ci/role-id + role_id: ddbd0d44-0e51-105b-177a-c8fdfd445126 axes: - axis: type: slave diff --git a/.ci/run-tests b/.ci/run-tests index cccda74c3..0a721624b 100755 --- a/.ci/run-tests +++ b/.ci/run-tests @@ -10,6 +10,12 @@ # - $NODE_JS_VERSION # +set +x +export VAULT_TOKEN=$(vault write -field=token auth/approle/login role_id="$VAULT_ROLE_ID" secret_id="$VAULT_SECRET_ID") +export CODECOV_TOKEN=$(vault read -field=token secret/clients-ci/elasticsearch-js/codecov) +unset VAULT_ROLE_ID VAULT_SECRET_ID VAULT_TOKEN +set -x + ELASTICSEARCH_VERSION=${ELASTICSEARCH_VERSION} NODE_JS_VERSION=${NODE_JS_VERSION} docker-compose -f .ci/docker-compose.yml run client-oss ELASTICSEARCH_VERSION=${ELASTICSEARCH_VERSION} NODE_JS_VERSION=${NODE_JS_VERSION} docker-compose -f .ci/docker-compose.yml run client-platinum diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 000000000..eadbe3ef0 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,14 @@ +comment: off + +coverage: + precision: 2 + round: down + range: "90...100" + + status: + project: yes + patch: yes + changes: no + +ignore: + - "api" diff --git a/package.json b/package.json index 8dd66ec47..b2f142858 100644 --- a/package.json +++ b/package.json @@ -22,11 +22,10 @@ "test:integration": "tap test/integration/index.js -T --harmony --no-esm", "test:types": "tsc --project ./test/types/tsconfig.json", "test:benchmarks": "nanobench test/benchmarks/*.bench.js", + "test:coverage": "tap test/unit/*.test.js -J -t 300 --cov --coverage-report=text-lcov && codecov", "lint": "standard", "lint:fix": "standard --fix", - "generate": "node scripts/run.js", - "elasticsearch": "./scripts/es-docker.sh", - "ci": "npm run license-checker && npm test && npm run test:integration", + "ci": "npm run license-checker && npm test && npm run test:integration && npm run test:coverage", "license-checker": "license-checker --production --onlyAllow='MIT;Apache-2.0;Apache1.1;ISC;BSD-3-Clause;BSD-2-Clause'" }, "author": { @@ -39,6 +38,7 @@ }, "devDependencies": { "@types/node": "^10.12.24", + "codecov": "^3.2.0", "convert-hrtime": "^2.0.0", "dedent": "^0.7.0", "deepmerge": "^3.1.0", From c446225f3cc427de0637ef5f9ed7456b5060d8fb Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 15 Mar 2019 16:57:58 +0100 Subject: [PATCH 10/22] Updated ignore files --- .gitignore | 3 +++ .npmignore | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 37e981426..b726b15e7 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,9 @@ lib-cov # Coverage directory used by tools like istanbul coverage +# coverage output +coverage.lcov + # nyc test coverage .nyc_output diff --git a/.npmignore b/.npmignore index dfe6586dc..08e9fdf23 100644 --- a/.npmignore +++ b/.npmignore @@ -14,6 +14,9 @@ lib-cov # Coverage directory used by tools like istanbul coverage +# coverage output +coverage.lcov + # nyc test coverage .nyc_output From d6982d5152675369b4f9644e7ea3995af3ff2137 Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 15 Mar 2019 16:58:13 +0100 Subject: [PATCH 11/22] Added codecov badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 17d2e8918..dd3b119fa 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # @elastic/elasticsearch -[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) [![Build Status](https://clients-ci.elastic.co/job/elastic+elasticsearch-js+master/badge/icon)](https://clients-ci.elastic.co/job/elastic+elasticsearch-js+master/) [![NPM downloads](https://img.shields.io/npm/dm/@elastic/elasticsearch.svg?style=flat)](https://www.npmjs.com/package/@elastic/elasticsearch) +[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) [![Build Status](https://clients-ci.elastic.co/job/elastic+elasticsearch-js+master/badge/icon)](https://clients-ci.elastic.co/job/elastic+elasticsearch-js+master/) [![codecov](https://codecov.io/gh/elastic/elasticsearch-js/branch/master/graph/badge.svg)](https://codecov.io/gh/elastic/elasticsearch-js) [![NPM downloads](https://img.shields.io/npm/dm/@elastic/elasticsearch.svg?style=flat)](https://www.npmjs.com/package/@elastic/elasticsearch) The official Node.js client for Elasticsearch. From 851e839c7050099072f4c938cb5b1ba978296d33 Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 15 Mar 2019 16:58:21 +0100 Subject: [PATCH 12/22] Updated coverage script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b2f142858..44de8821e 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "test:integration": "tap test/integration/index.js -T --harmony --no-esm", "test:types": "tsc --project ./test/types/tsconfig.json", "test:benchmarks": "nanobench test/benchmarks/*.bench.js", - "test:coverage": "tap test/unit/*.test.js -J -t 300 --cov --coverage-report=text-lcov && codecov", + "test:coverage": "nyc npm run test:unit && nyc report --reporter=text-lcov > coverage.lcov && codecov", "lint": "standard", "lint:fix": "standard --fix", "ci": "npm run license-checker && npm test && npm run test:integration && npm run test:coverage", From c53c79889941e885791b469221a1fa1ffca53131 Mon Sep 17 00:00:00 2001 From: Tomas Della Vedova Date: Fri, 15 Mar 2019 18:09:44 +0100 Subject: [PATCH 13/22] feat: add support for querystring in options object (#779) In very few cases, some API uses the same key for both url and query params, such as the bulk method. The client is not designed to handle such cases since accepts both url and query keys in the same object, and the url parameter will always take precedence. This pr fixes this edge case by adding a `querystring` key in the options object. Fixes: https://github.com/elastic/elasticsearch-js/pull/778 ```js client.bulk({ index: 'index', type: '_doc', body: [...] }, { querystring: { type: '_doc' } }, console.log) ``` --- README.md | 4 +- api/api/bulk.js | 1 + api/api/cat.aliases.js | 1 + api/api/cat.allocation.js | 1 + api/api/cat.count.js | 1 + api/api/cat.fielddata.js | 1 + api/api/cat.health.js | 1 + api/api/cat.help.js | 1 + api/api/cat.indices.js | 1 + api/api/cat.master.js | 1 + api/api/cat.nodeattrs.js | 1 + api/api/cat.nodes.js | 1 + api/api/cat.pending_tasks.js | 1 + api/api/cat.plugins.js | 1 + api/api/cat.recovery.js | 1 + api/api/cat.repositories.js | 1 + api/api/cat.segments.js | 1 + api/api/cat.shards.js | 1 + api/api/cat.snapshots.js | 1 + api/api/cat.tasks.js | 1 + api/api/cat.templates.js | 1 + api/api/cat.thread_pool.js | 1 + api/api/ccr.delete_auto_follow_pattern.js | 1 + api/api/ccr.follow.js | 1 + api/api/ccr.follow_info.js | 1 + api/api/ccr.follow_stats.js | 1 + api/api/ccr.get_auto_follow_pattern.js | 1 + api/api/ccr.pause_follow.js | 1 + api/api/ccr.put_auto_follow_pattern.js | 1 + api/api/ccr.resume_follow.js | 1 + api/api/ccr.stats.js | 1 + api/api/ccr.unfollow.js | 1 + api/api/clear_scroll.js | 1 + api/api/cluster.allocation_explain.js | 1 + api/api/cluster.get_settings.js | 1 + api/api/cluster.health.js | 1 + api/api/cluster.pending_tasks.js | 1 + api/api/cluster.put_settings.js | 1 + api/api/cluster.remote_info.js | 1 + api/api/cluster.reroute.js | 1 + api/api/cluster.state.js | 1 + api/api/cluster.stats.js | 1 + api/api/count.js | 1 + api/api/create.js | 1 + api/api/delete.js | 1 + api/api/delete_by_query.js | 1 + api/api/delete_by_query_rethrottle.js | 1 + api/api/delete_script.js | 1 + api/api/exists.js | 1 + api/api/exists_source.js | 1 + api/api/explain.js | 1 + api/api/field_caps.js | 1 + api/api/get.js | 1 + api/api/get_script.js | 1 + api/api/get_source.js | 1 + api/api/ilm.delete_lifecycle.js | 1 + api/api/ilm.explain_lifecycle.js | 1 + api/api/ilm.get_lifecycle.js | 1 + api/api/ilm.get_status.js | 1 + api/api/ilm.move_to_step.js | 1 + api/api/ilm.put_lifecycle.js | 1 + api/api/ilm.remove_policy.js | 1 + api/api/ilm.retry.js | 1 + api/api/ilm.start.js | 1 + api/api/ilm.stop.js | 1 + api/api/index.js | 1 + api/api/indices.analyze.js | 1 + api/api/indices.clear_cache.js | 1 + api/api/indices.close.js | 1 + api/api/indices.create.js | 1 + api/api/indices.delete.js | 1 + api/api/indices.delete_alias.js | 1 + api/api/indices.delete_template.js | 1 + api/api/indices.exists.js | 1 + api/api/indices.exists_alias.js | 1 + api/api/indices.exists_template.js | 1 + api/api/indices.exists_type.js | 1 + api/api/indices.flush.js | 1 + api/api/indices.flush_synced.js | 1 + api/api/indices.forcemerge.js | 1 + api/api/indices.freeze.js | 1 + api/api/indices.get.js | 1 + api/api/indices.get_alias.js | 1 + api/api/indices.get_field_mapping.js | 1 + api/api/indices.get_mapping.js | 1 + api/api/indices.get_settings.js | 1 + api/api/indices.get_template.js | 1 + api/api/indices.get_upgrade.js | 1 + api/api/indices.open.js | 1 + api/api/indices.put_alias.js | 1 + api/api/indices.put_mapping.js | 1 + api/api/indices.put_settings.js | 1 + api/api/indices.put_template.js | 1 + api/api/indices.recovery.js | 1 + api/api/indices.refresh.js | 1 + api/api/indices.rollover.js | 1 + api/api/indices.segments.js | 1 + api/api/indices.shard_stores.js | 1 + api/api/indices.shrink.js | 1 + api/api/indices.split.js | 1 + api/api/indices.stats.js | 1 + api/api/indices.unfreeze.js | 1 + api/api/indices.update_aliases.js | 1 + api/api/indices.upgrade.js | 1 + api/api/indices.validate_query.js | 1 + api/api/info.js | 1 + api/api/ingest.delete_pipeline.js | 1 + api/api/ingest.get_pipeline.js | 1 + api/api/ingest.processor_grok.js | 1 + api/api/ingest.put_pipeline.js | 1 + api/api/ingest.simulate.js | 1 + api/api/mget.js | 1 + api/api/ml.close_job.js | 1 + api/api/ml.delete_calendar.js | 1 + api/api/ml.delete_calendar_event.js | 1 + api/api/ml.delete_calendar_job.js | 1 + api/api/ml.delete_datafeed.js | 1 + api/api/ml.delete_expired_data.js | 1 + api/api/ml.delete_filter.js | 1 + api/api/ml.delete_forecast.js | 1 + api/api/ml.delete_job.js | 1 + api/api/ml.delete_model_snapshot.js | 1 + api/api/ml.find_file_structure.js | 1 + api/api/ml.flush_job.js | 1 + api/api/ml.forecast.js | 1 + api/api/ml.get_buckets.js | 1 + api/api/ml.get_calendar_events.js | 1 + api/api/ml.get_calendars.js | 1 + api/api/ml.get_categories.js | 1 + api/api/ml.get_datafeed_stats.js | 1 + api/api/ml.get_datafeeds.js | 1 + api/api/ml.get_filters.js | 1 + api/api/ml.get_influencers.js | 1 + api/api/ml.get_job_stats.js | 1 + api/api/ml.get_jobs.js | 1 + api/api/ml.get_model_snapshots.js | 1 + api/api/ml.get_overall_buckets.js | 1 + api/api/ml.get_records.js | 1 + api/api/ml.info.js | 1 + api/api/ml.open_job.js | 1 + api/api/ml.post_calendar_events.js | 1 + api/api/ml.post_data.js | 1 + api/api/ml.preview_datafeed.js | 1 + api/api/ml.put_calendar.js | 1 + api/api/ml.put_calendar_job.js | 1 + api/api/ml.put_datafeed.js | 1 + api/api/ml.put_filter.js | 1 + api/api/ml.put_job.js | 1 + api/api/ml.revert_model_snapshot.js | 1 + api/api/ml.set_upgrade_mode.js | 1 + api/api/ml.start_datafeed.js | 1 + api/api/ml.stop_datafeed.js | 1 + api/api/ml.update_datafeed.js | 1 + api/api/ml.update_filter.js | 1 + api/api/ml.update_job.js | 1 + api/api/ml.update_model_snapshot.js | 1 + api/api/ml.validate.js | 1 + api/api/ml.validate_detector.js | 1 + api/api/monitoring.bulk.js | 1 + api/api/msearch.js | 1 + api/api/msearch_template.js | 1 + api/api/mtermvectors.js | 1 + api/api/nodes.hot_threads.js | 1 + api/api/nodes.info.js | 1 + api/api/nodes.reload_secure_settings.js | 1 + api/api/nodes.stats.js | 1 + api/api/nodes.usage.js | 1 + api/api/ping.js | 1 + api/api/put_script.js | 1 + api/api/rank_eval.js | 1 + api/api/reindex.js | 1 + api/api/reindex_rethrottle.js | 1 + api/api/render_search_template.js | 1 + api/api/scripts_painless_execute.js | 1 + api/api/scroll.js | 1 + api/api/search.js | 1 + api/api/search_shards.js | 1 + api/api/search_template.js | 1 + api/api/security.authenticate.js | 1 + api/api/security.change_password.js | 1 + api/api/security.clear_cached_realms.js | 1 + api/api/security.clear_cached_roles.js | 1 + api/api/security.create_api_key.js | 1 + api/api/security.delete_privileges.js | 1 + api/api/security.delete_role.js | 1 + api/api/security.delete_role_mapping.js | 1 + api/api/security.delete_user.js | 1 + api/api/security.disable_user.js | 1 + api/api/security.enable_user.js | 1 + api/api/security.get_api_key.js | 1 + api/api/security.get_privileges.js | 1 + api/api/security.get_role.js | 1 + api/api/security.get_role_mapping.js | 1 + api/api/security.get_token.js | 1 + api/api/security.get_user.js | 1 + api/api/security.get_user_privileges.js | 1 + api/api/security.has_privileges.js | 1 + api/api/security.invalidate_api_key.js | 1 + api/api/security.invalidate_token.js | 1 + api/api/security.put_privileges.js | 1 + api/api/security.put_role.js | 1 + api/api/security.put_role_mapping.js | 1 + api/api/security.put_user.js | 1 + api/api/snapshot.create.js | 1 + api/api/snapshot.create_repository.js | 1 + api/api/snapshot.delete.js | 1 + api/api/snapshot.delete_repository.js | 1 + api/api/snapshot.get.js | 1 + api/api/snapshot.get_repository.js | 1 + api/api/snapshot.restore.js | 1 + api/api/snapshot.status.js | 1 + api/api/snapshot.verify_repository.js | 1 + api/api/ssl.certificates.js | 1 + api/api/tasks.cancel.js | 1 + api/api/tasks.get.js | 1 + api/api/tasks.list.js | 1 + api/api/termvectors.js | 1 + api/api/update.js | 1 + api/api/update_by_query.js | 1 + api/api/update_by_query_rethrottle.js | 1 + api/api/xpack.graph.explore.js | 1 + api/api/xpack.info.js | 1 + api/api/xpack.license.delete.js | 1 + api/api/xpack.license.get.js | 1 + api/api/xpack.license.get_basic_status.js | 1 + api/api/xpack.license.get_trial_status.js | 1 + api/api/xpack.license.post.js | 1 + api/api/xpack.license.post_start_basic.js | 1 + api/api/xpack.license.post_start_trial.js | 1 + api/api/xpack.migration.deprecations.js | 1 + api/api/xpack.migration.get_assistance.js | 1 + api/api/xpack.migration.upgrade.js | 1 + api/api/xpack.rollup.delete_job.js | 1 + api/api/xpack.rollup.get_jobs.js | 1 + api/api/xpack.rollup.get_rollup_caps.js | 1 + api/api/xpack.rollup.get_rollup_index_caps.js | 1 + api/api/xpack.rollup.put_job.js | 1 + api/api/xpack.rollup.rollup_search.js | 1 + api/api/xpack.rollup.start_job.js | 1 + api/api/xpack.rollup.stop_job.js | 1 + api/api/xpack.sql.clear_cursor.js | 1 + api/api/xpack.sql.query.js | 1 + api/api/xpack.sql.translate.js | 1 + api/api/xpack.usage.js | 1 + api/api/xpack.watcher.ack_watch.js | 1 + api/api/xpack.watcher.activate_watch.js | 1 + api/api/xpack.watcher.deactivate_watch.js | 1 + api/api/xpack.watcher.delete_watch.js | 1 + api/api/xpack.watcher.execute_watch.js | 1 + api/api/xpack.watcher.get_watch.js | 1 + api/api/xpack.watcher.put_watch.js | 1 + api/api/xpack.watcher.start.js | 1 + api/api/xpack.watcher.stats.js | 1 + api/api/xpack.watcher.stop.js | 1 + docs/usage.asciidoc | 4 + lib/Transport.d.ts | 7 +- lib/Transport.js | 8 +- scripts/utils/generate.js | 1 + test/types/index.ts | 6 +- test/unit/api.test.js | 26 +++++++ test/unit/transport.test.js | 77 +++++++++++++++++++ 261 files changed, 380 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index dd3b119fa..73bf20b7a 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,9 @@ The supported *request specific options* are: requestTimeout: number, // client default maxRetries: number, // default `5` asStream: boolean, // default `false` - headers: object // default `null` + compression: string, // default `false` + headers: object, // default `null` + querystring: object // default `null` } ``` diff --git a/api/api/bulk.js b/api/api/bulk.js index 419b56196..f1ebde7d1 100644 --- a/api/api/bulk.js +++ b/api/api/bulk.js @@ -149,6 +149,7 @@ function buildBulk (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cat.aliases.js b/api/api/cat.aliases.js index 9b28f6edd..8378c9602 100644 --- a/api/api/cat.aliases.js +++ b/api/api/cat.aliases.js @@ -131,6 +131,7 @@ function buildCatAliases (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cat.allocation.js b/api/api/cat.allocation.js index 98f257d96..2e771d29c 100644 --- a/api/api/cat.allocation.js +++ b/api/api/cat.allocation.js @@ -133,6 +133,7 @@ function buildCatAllocation (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cat.count.js b/api/api/cat.count.js index c57074c9f..443af2669 100644 --- a/api/api/cat.count.js +++ b/api/api/cat.count.js @@ -131,6 +131,7 @@ function buildCatCount (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cat.fielddata.js b/api/api/cat.fielddata.js index 6fb432d58..47332ef7f 100644 --- a/api/api/cat.fielddata.js +++ b/api/api/cat.fielddata.js @@ -135,6 +135,7 @@ function buildCatFielddata (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cat.health.js b/api/api/cat.health.js index 0db6c289b..e9b145928 100644 --- a/api/api/cat.health.js +++ b/api/api/cat.health.js @@ -128,6 +128,7 @@ function buildCatHealth (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cat.help.js b/api/api/cat.help.js index f85171721..5e83855f1 100644 --- a/api/api/cat.help.js +++ b/api/api/cat.help.js @@ -115,6 +115,7 @@ function buildCatHelp (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cat.indices.js b/api/api/cat.indices.js index 62f365588..c84a3e36f 100644 --- a/api/api/cat.indices.js +++ b/api/api/cat.indices.js @@ -137,6 +137,7 @@ function buildCatIndices (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cat.master.js b/api/api/cat.master.js index 31adac93f..ec9ad0df9 100644 --- a/api/api/cat.master.js +++ b/api/api/cat.master.js @@ -126,6 +126,7 @@ function buildCatMaster (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cat.nodeattrs.js b/api/api/cat.nodeattrs.js index 9e97e6a24..41d02a0be 100644 --- a/api/api/cat.nodeattrs.js +++ b/api/api/cat.nodeattrs.js @@ -126,6 +126,7 @@ function buildCatNodeattrs (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cat.nodes.js b/api/api/cat.nodes.js index bcd3c0662..5b2ed0383 100644 --- a/api/api/cat.nodes.js +++ b/api/api/cat.nodes.js @@ -129,6 +129,7 @@ function buildCatNodes (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cat.pending_tasks.js b/api/api/cat.pending_tasks.js index f24bff525..bb2c8113b 100644 --- a/api/api/cat.pending_tasks.js +++ b/api/api/cat.pending_tasks.js @@ -126,6 +126,7 @@ function buildCatPendingTasks (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cat.plugins.js b/api/api/cat.plugins.js index c55fcdd29..50164c6a1 100644 --- a/api/api/cat.plugins.js +++ b/api/api/cat.plugins.js @@ -126,6 +126,7 @@ function buildCatPlugins (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cat.recovery.js b/api/api/cat.recovery.js index 42e0c1e0c..13bb08eb3 100644 --- a/api/api/cat.recovery.js +++ b/api/api/cat.recovery.js @@ -131,6 +131,7 @@ function buildCatRecovery (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cat.repositories.js b/api/api/cat.repositories.js index 8e8b6f6c9..dbbc6ee2d 100644 --- a/api/api/cat.repositories.js +++ b/api/api/cat.repositories.js @@ -126,6 +126,7 @@ function buildCatRepositories (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cat.segments.js b/api/api/cat.segments.js index c10af3b23..9c1b6b5c0 100644 --- a/api/api/cat.segments.js +++ b/api/api/cat.segments.js @@ -128,6 +128,7 @@ function buildCatSegments (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cat.shards.js b/api/api/cat.shards.js index 5ae0d1b18..49b6d41c0 100644 --- a/api/api/cat.shards.js +++ b/api/api/cat.shards.js @@ -133,6 +133,7 @@ function buildCatShards (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cat.snapshots.js b/api/api/cat.snapshots.js index af82bc574..c2c865693 100644 --- a/api/api/cat.snapshots.js +++ b/api/api/cat.snapshots.js @@ -132,6 +132,7 @@ function buildCatSnapshots (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cat.tasks.js b/api/api/cat.tasks.js index c8005d5e7..d51f221a2 100644 --- a/api/api/cat.tasks.js +++ b/api/api/cat.tasks.js @@ -131,6 +131,7 @@ function buildCatTasks (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cat.templates.js b/api/api/cat.templates.js index ff89cb284..0641d29d8 100644 --- a/api/api/cat.templates.js +++ b/api/api/cat.templates.js @@ -131,6 +131,7 @@ function buildCatTemplates (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cat.thread_pool.js b/api/api/cat.thread_pool.js index 0b07b0e0a..5875d9518 100644 --- a/api/api/cat.thread_pool.js +++ b/api/api/cat.thread_pool.js @@ -133,6 +133,7 @@ function buildCatThreadPool (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ccr.delete_auto_follow_pattern.js b/api/api/ccr.delete_auto_follow_pattern.js index d5ebd1cfd..b6712ad90 100644 --- a/api/api/ccr.delete_auto_follow_pattern.js +++ b/api/api/ccr.delete_auto_follow_pattern.js @@ -107,6 +107,7 @@ function buildCcrDeleteAutoFollowPattern (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ccr.follow.js b/api/api/ccr.follow.js index 7c86848bf..ba45eef1f 100644 --- a/api/api/ccr.follow.js +++ b/api/api/ccr.follow.js @@ -115,6 +115,7 @@ function buildCcrFollow (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ccr.follow_info.js b/api/api/ccr.follow_info.js index ec9923b1f..6a9655b0e 100644 --- a/api/api/ccr.follow_info.js +++ b/api/api/ccr.follow_info.js @@ -99,6 +99,7 @@ function buildCcrFollowInfo (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ccr.follow_stats.js b/api/api/ccr.follow_stats.js index 62ee7f266..c887b7f5f 100644 --- a/api/api/ccr.follow_stats.js +++ b/api/api/ccr.follow_stats.js @@ -99,6 +99,7 @@ function buildCcrFollowStats (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ccr.get_auto_follow_pattern.js b/api/api/ccr.get_auto_follow_pattern.js index 261bce9ac..e892c2b93 100644 --- a/api/api/ccr.get_auto_follow_pattern.js +++ b/api/api/ccr.get_auto_follow_pattern.js @@ -103,6 +103,7 @@ function buildCcrGetAutoFollowPattern (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ccr.pause_follow.js b/api/api/ccr.pause_follow.js index 81b0cde7b..5f9427b69 100644 --- a/api/api/ccr.pause_follow.js +++ b/api/api/ccr.pause_follow.js @@ -107,6 +107,7 @@ function buildCcrPauseFollow (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ccr.put_auto_follow_pattern.js b/api/api/ccr.put_auto_follow_pattern.js index 846a29445..b3245095e 100644 --- a/api/api/ccr.put_auto_follow_pattern.js +++ b/api/api/ccr.put_auto_follow_pattern.js @@ -114,6 +114,7 @@ function buildCcrPutAutoFollowPattern (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ccr.resume_follow.js b/api/api/ccr.resume_follow.js index ac47bfac5..542af5bb2 100644 --- a/api/api/ccr.resume_follow.js +++ b/api/api/ccr.resume_follow.js @@ -108,6 +108,7 @@ function buildCcrResumeFollow (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ccr.stats.js b/api/api/ccr.stats.js index 4de395d30..a574bb4b5 100644 --- a/api/api/ccr.stats.js +++ b/api/api/ccr.stats.js @@ -98,6 +98,7 @@ function buildCcrStats (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ccr.unfollow.js b/api/api/ccr.unfollow.js index 5886296b2..ff68fc788 100644 --- a/api/api/ccr.unfollow.js +++ b/api/api/ccr.unfollow.js @@ -107,6 +107,7 @@ function buildCcrUnfollow (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/clear_scroll.js b/api/api/clear_scroll.js index d3e0ec0ac..3a25bcdc0 100644 --- a/api/api/clear_scroll.js +++ b/api/api/clear_scroll.js @@ -109,6 +109,7 @@ function buildClearScroll (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cluster.allocation_explain.js b/api/api/cluster.allocation_explain.js index 2392e61c7..6355100c2 100644 --- a/api/api/cluster.allocation_explain.js +++ b/api/api/cluster.allocation_explain.js @@ -110,6 +110,7 @@ function buildClusterAllocationExplain (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cluster.get_settings.js b/api/api/cluster.get_settings.js index d024742cb..568d5c4f1 100644 --- a/api/api/cluster.get_settings.js +++ b/api/api/cluster.get_settings.js @@ -122,6 +122,7 @@ function buildClusterGetSettings (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cluster.health.js b/api/api/cluster.health.js index f8a75c1f4..6b0bfffae 100644 --- a/api/api/cluster.health.js +++ b/api/api/cluster.health.js @@ -143,6 +143,7 @@ function buildClusterHealth (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cluster.pending_tasks.js b/api/api/cluster.pending_tasks.js index 43ddbf53c..e3052a663 100644 --- a/api/api/cluster.pending_tasks.js +++ b/api/api/cluster.pending_tasks.js @@ -116,6 +116,7 @@ function buildClusterPendingTasks (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cluster.put_settings.js b/api/api/cluster.put_settings.js index 54ec859ed..f50230a39 100644 --- a/api/api/cluster.put_settings.js +++ b/api/api/cluster.put_settings.js @@ -120,6 +120,7 @@ function buildClusterPutSettings (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cluster.remote_info.js b/api/api/cluster.remote_info.js index 95f965c44..97939e755 100644 --- a/api/api/cluster.remote_info.js +++ b/api/api/cluster.remote_info.js @@ -111,6 +111,7 @@ function buildClusterRemoteInfo (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cluster.reroute.js b/api/api/cluster.reroute.js index d106cd13c..40e7b731e 100644 --- a/api/api/cluster.reroute.js +++ b/api/api/cluster.reroute.js @@ -119,6 +119,7 @@ function buildClusterReroute (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cluster.state.js b/api/api/cluster.state.js index a8b350120..6560a3b0d 100644 --- a/api/api/cluster.state.js +++ b/api/api/cluster.state.js @@ -150,6 +150,7 @@ function buildClusterState (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/cluster.stats.js b/api/api/cluster.stats.js index b313c7827..b5e2035eb 100644 --- a/api/api/cluster.stats.js +++ b/api/api/cluster.stats.js @@ -121,6 +121,7 @@ function buildClusterStats (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/count.js b/api/api/count.js index 536c07f62..28966aaeb 100644 --- a/api/api/count.js +++ b/api/api/count.js @@ -156,6 +156,7 @@ function buildCount (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/create.js b/api/api/create.js index 4b7a113da..306a2720f 100644 --- a/api/api/create.js +++ b/api/api/create.js @@ -149,6 +149,7 @@ function buildCreate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/delete.js b/api/api/delete.js index dd78e7c19..b2053515e 100644 --- a/api/api/delete.js +++ b/api/api/delete.js @@ -160,6 +160,7 @@ function buildDelete (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/delete_by_query.js b/api/api/delete_by_query.js index cd0a34e9a..ae798c5fc 100644 --- a/api/api/delete_by_query.js +++ b/api/api/delete_by_query.js @@ -211,6 +211,7 @@ function buildDeleteByQuery (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/delete_by_query_rethrottle.js b/api/api/delete_by_query_rethrottle.js index 089ccf67c..a0b2006bd 100644 --- a/api/api/delete_by_query_rethrottle.js +++ b/api/api/delete_by_query_rethrottle.js @@ -127,6 +127,7 @@ function buildDeleteByQueryRethrottle (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/delete_script.js b/api/api/delete_script.js index 804c4bd3e..29647583b 100644 --- a/api/api/delete_script.js +++ b/api/api/delete_script.js @@ -123,6 +123,7 @@ function buildDeleteScript (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/exists.js b/api/api/exists.js index b9b28eec3..13ff5edbf 100644 --- a/api/api/exists.js +++ b/api/api/exists.js @@ -156,6 +156,7 @@ function buildExists (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/exists_source.js b/api/api/exists_source.js index bd5a93303..b3abeb2eb 100644 --- a/api/api/exists_source.js +++ b/api/api/exists_source.js @@ -166,6 +166,7 @@ function buildExistsSource (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/explain.js b/api/api/explain.js index d37b203ab..206c765bc 100644 --- a/api/api/explain.js +++ b/api/api/explain.js @@ -156,6 +156,7 @@ function buildExplain (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/field_caps.js b/api/api/field_caps.js index b8a091fb2..021412e99 100644 --- a/api/api/field_caps.js +++ b/api/api/field_caps.js @@ -127,6 +127,7 @@ function buildFieldCaps (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/get.js b/api/api/get.js index d59494cc8..aea81e367 100644 --- a/api/api/get.js +++ b/api/api/get.js @@ -162,6 +162,7 @@ function buildGet (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/get_script.js b/api/api/get_script.js index e0c42cfab..bb2eee166 100644 --- a/api/api/get_script.js +++ b/api/api/get_script.js @@ -121,6 +121,7 @@ function buildGetScript (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/get_source.js b/api/api/get_source.js index 1ea12b53d..abbc53ac0 100644 --- a/api/api/get_source.js +++ b/api/api/get_source.js @@ -153,6 +153,7 @@ function buildGetSource (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ilm.delete_lifecycle.js b/api/api/ilm.delete_lifecycle.js index fcab49377..2e84b9e8b 100644 --- a/api/api/ilm.delete_lifecycle.js +++ b/api/api/ilm.delete_lifecycle.js @@ -107,6 +107,7 @@ function buildIlmDeleteLifecycle (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ilm.explain_lifecycle.js b/api/api/ilm.explain_lifecycle.js index 0e25f2fa0..7fbb00519 100644 --- a/api/api/ilm.explain_lifecycle.js +++ b/api/api/ilm.explain_lifecycle.js @@ -108,6 +108,7 @@ function buildIlmExplainLifecycle (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ilm.get_lifecycle.js b/api/api/ilm.get_lifecycle.js index 5b3a25a17..19e44d788 100644 --- a/api/api/ilm.get_lifecycle.js +++ b/api/api/ilm.get_lifecycle.js @@ -111,6 +111,7 @@ function buildIlmGetLifecycle (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ilm.get_status.js b/api/api/ilm.get_status.js index 801ff5275..1592c0804 100644 --- a/api/api/ilm.get_status.js +++ b/api/api/ilm.get_status.js @@ -106,6 +106,7 @@ function buildIlmGetStatus (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ilm.move_to_step.js b/api/api/ilm.move_to_step.js index 392421dbb..7807d5fd0 100644 --- a/api/api/ilm.move_to_step.js +++ b/api/api/ilm.move_to_step.js @@ -100,6 +100,7 @@ function buildIlmMoveToStep (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ilm.put_lifecycle.js b/api/api/ilm.put_lifecycle.js index dfbc27f82..39f91271a 100644 --- a/api/api/ilm.put_lifecycle.js +++ b/api/api/ilm.put_lifecycle.js @@ -100,6 +100,7 @@ function buildIlmPutLifecycle (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ilm.remove_policy.js b/api/api/ilm.remove_policy.js index c0d45128b..ee61c6322 100644 --- a/api/api/ilm.remove_policy.js +++ b/api/api/ilm.remove_policy.js @@ -107,6 +107,7 @@ function buildIlmRemovePolicy (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ilm.retry.js b/api/api/ilm.retry.js index 337f19ecf..ea52a066c 100644 --- a/api/api/ilm.retry.js +++ b/api/api/ilm.retry.js @@ -107,6 +107,7 @@ function buildIlmRetry (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ilm.start.js b/api/api/ilm.start.js index 1b692b3c0..f3b7b7eda 100644 --- a/api/api/ilm.start.js +++ b/api/api/ilm.start.js @@ -106,6 +106,7 @@ function buildIlmStart (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ilm.stop.js b/api/api/ilm.stop.js index be9dfdaef..72c23b41b 100644 --- a/api/api/ilm.stop.js +++ b/api/api/ilm.stop.js @@ -106,6 +106,7 @@ function buildIlmStop (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/index.js b/api/api/index.js index bb15a2ab3..9e39b0773 100644 --- a/api/api/index.js +++ b/api/api/index.js @@ -164,6 +164,7 @@ function buildIndex (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.analyze.js b/api/api/indices.analyze.js index c4ae2ea1f..0bac6eda8 100644 --- a/api/api/indices.analyze.js +++ b/api/api/indices.analyze.js @@ -111,6 +111,7 @@ function buildIndicesAnalyze (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.clear_cache.js b/api/api/indices.clear_cache.js index 55fcf8db1..e2fe21f1f 100644 --- a/api/api/indices.clear_cache.js +++ b/api/api/indices.clear_cache.js @@ -135,6 +135,7 @@ function buildIndicesClearCache (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.close.js b/api/api/indices.close.js index c021ed985..df06e9c9b 100644 --- a/api/api/indices.close.js +++ b/api/api/indices.close.js @@ -132,6 +132,7 @@ function buildIndicesClose (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.create.js b/api/api/indices.create.js index 669e763e0..9b786023a 100644 --- a/api/api/indices.create.js +++ b/api/api/indices.create.js @@ -124,6 +124,7 @@ function buildIndicesCreate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.delete.js b/api/api/indices.delete.js index 8f7521a27..09983e420 100644 --- a/api/api/indices.delete.js +++ b/api/api/indices.delete.js @@ -132,6 +132,7 @@ function buildIndicesDelete (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.delete_alias.js b/api/api/indices.delete_alias.js index 73cdac0f8..7a838ce27 100644 --- a/api/api/indices.delete_alias.js +++ b/api/api/indices.delete_alias.js @@ -142,6 +142,7 @@ function buildIndicesDeleteAlias (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.delete_template.js b/api/api/indices.delete_template.js index 149b731bd..44287ae15 100644 --- a/api/api/indices.delete_template.js +++ b/api/api/indices.delete_template.js @@ -123,6 +123,7 @@ function buildIndicesDeleteTemplate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.exists.js b/api/api/indices.exists.js index 106fe6ecd..a3e8f1d7c 100644 --- a/api/api/indices.exists.js +++ b/api/api/indices.exists.js @@ -135,6 +135,7 @@ function buildIndicesExists (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.exists_alias.js b/api/api/indices.exists_alias.js index 9549b8d45..9b3e63071 100644 --- a/api/api/indices.exists_alias.js +++ b/api/api/indices.exists_alias.js @@ -134,6 +134,7 @@ function buildIndicesExistsAlias (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.exists_template.js b/api/api/indices.exists_template.js index a8c7b5818..75757d155 100644 --- a/api/api/indices.exists_template.js +++ b/api/api/indices.exists_template.js @@ -126,6 +126,7 @@ function buildIndicesExistsTemplate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.exists_type.js b/api/api/indices.exists_type.js index 7c405dd56..cab906314 100644 --- a/api/api/indices.exists_type.js +++ b/api/api/indices.exists_type.js @@ -144,6 +144,7 @@ function buildIndicesExistsType (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.flush.js b/api/api/indices.flush.js index d949c3eb6..4be9c2ff8 100644 --- a/api/api/indices.flush.js +++ b/api/api/indices.flush.js @@ -130,6 +130,7 @@ function buildIndicesFlush (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.flush_synced.js b/api/api/indices.flush_synced.js index a1dae252d..6437db5ae 100644 --- a/api/api/indices.flush_synced.js +++ b/api/api/indices.flush_synced.js @@ -125,6 +125,7 @@ function buildIndicesFlushSynced (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.forcemerge.js b/api/api/indices.forcemerge.js index 455718fcb..2a50ad2fd 100644 --- a/api/api/indices.forcemerge.js +++ b/api/api/indices.forcemerge.js @@ -133,6 +133,7 @@ function buildIndicesForcemerge (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.freeze.js b/api/api/indices.freeze.js index 4e2d6e6c2..f16cff125 100644 --- a/api/api/indices.freeze.js +++ b/api/api/indices.freeze.js @@ -128,6 +128,7 @@ function buildIndicesFreeze (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.get.js b/api/api/indices.get.js index 87597eed6..86631e192 100644 --- a/api/api/indices.get.js +++ b/api/api/indices.get.js @@ -141,6 +141,7 @@ function buildIndicesGet (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.get_alias.js b/api/api/indices.get_alias.js index 454d60580..25607b524 100644 --- a/api/api/indices.get_alias.js +++ b/api/api/indices.get_alias.js @@ -132,6 +132,7 @@ function buildIndicesGetAlias (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.get_field_mapping.js b/api/api/indices.get_field_mapping.js index c3bf09e61..744e364f4 100644 --- a/api/api/indices.get_field_mapping.js +++ b/api/api/indices.get_field_mapping.js @@ -145,6 +145,7 @@ function buildIndicesGetFieldMapping (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.get_mapping.js b/api/api/indices.get_mapping.js index 173d1d7c6..c669d8352 100644 --- a/api/api/indices.get_mapping.js +++ b/api/api/indices.get_mapping.js @@ -138,6 +138,7 @@ function buildIndicesGetMapping (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.get_settings.js b/api/api/indices.get_settings.js index 08f5f7bc7..50e0b2b56 100644 --- a/api/api/indices.get_settings.js +++ b/api/api/indices.get_settings.js @@ -141,6 +141,7 @@ function buildIndicesGetSettings (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.get_template.js b/api/api/indices.get_template.js index 2dfed0419..9d9d2b42d 100644 --- a/api/api/indices.get_template.js +++ b/api/api/indices.get_template.js @@ -127,6 +127,7 @@ function buildIndicesGetTemplate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.get_upgrade.js b/api/api/indices.get_upgrade.js index 6ddbc646d..27f4faed4 100644 --- a/api/api/indices.get_upgrade.js +++ b/api/api/indices.get_upgrade.js @@ -125,6 +125,7 @@ function buildIndicesGetUpgrade (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.open.js b/api/api/indices.open.js index 87e7b1417..3c2fe8b27 100644 --- a/api/api/indices.open.js +++ b/api/api/indices.open.js @@ -135,6 +135,7 @@ function buildIndicesOpen (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.put_alias.js b/api/api/indices.put_alias.js index c6c5a2ee5..6571d9d85 100644 --- a/api/api/indices.put_alias.js +++ b/api/api/indices.put_alias.js @@ -137,6 +137,7 @@ function buildIndicesPutAlias (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.put_mapping.js b/api/api/indices.put_mapping.js index c62fd80a6..96a3356f9 100644 --- a/api/api/indices.put_mapping.js +++ b/api/api/indices.put_mapping.js @@ -147,6 +147,7 @@ function buildIndicesPutMapping (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.put_settings.js b/api/api/indices.put_settings.js index 8cf46293f..721c21600 100644 --- a/api/api/indices.put_settings.js +++ b/api/api/indices.put_settings.js @@ -137,6 +137,7 @@ function buildIndicesPutSettings (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.put_template.js b/api/api/indices.put_template.js index 8f6f1c10e..f7c3eb8aa 100644 --- a/api/api/indices.put_template.js +++ b/api/api/indices.put_template.js @@ -134,6 +134,7 @@ function buildIndicesPutTemplate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.recovery.js b/api/api/indices.recovery.js index 9556b44ee..dfcdcf11e 100644 --- a/api/api/indices.recovery.js +++ b/api/api/indices.recovery.js @@ -121,6 +121,7 @@ function buildIndicesRecovery (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.refresh.js b/api/api/indices.refresh.js index 72298aca3..888ba0721 100644 --- a/api/api/indices.refresh.js +++ b/api/api/indices.refresh.js @@ -125,6 +125,7 @@ function buildIndicesRefresh (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.rollover.js b/api/api/indices.rollover.js index c3bcd699a..ba04aafc6 100644 --- a/api/api/indices.rollover.js +++ b/api/api/indices.rollover.js @@ -140,6 +140,7 @@ function buildIndicesRollover (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.segments.js b/api/api/indices.segments.js index f0058cc6d..07947e0d5 100644 --- a/api/api/indices.segments.js +++ b/api/api/indices.segments.js @@ -127,6 +127,7 @@ function buildIndicesSegments (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.shard_stores.js b/api/api/indices.shard_stores.js index ff22da906..16ab0e17f 100644 --- a/api/api/indices.shard_stores.js +++ b/api/api/indices.shard_stores.js @@ -127,6 +127,7 @@ function buildIndicesShardStores (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.shrink.js b/api/api/indices.shrink.js index 8f3eb332a..6f0dbf7ed 100644 --- a/api/api/indices.shrink.js +++ b/api/api/indices.shrink.js @@ -139,6 +139,7 @@ function buildIndicesShrink (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.split.js b/api/api/indices.split.js index 51e22c94f..2048c5946 100644 --- a/api/api/indices.split.js +++ b/api/api/indices.split.js @@ -139,6 +139,7 @@ function buildIndicesSplit (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.stats.js b/api/api/indices.stats.js index 879ff40ad..7730b4215 100644 --- a/api/api/indices.stats.js +++ b/api/api/indices.stats.js @@ -138,6 +138,7 @@ function buildIndicesStats (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.unfreeze.js b/api/api/indices.unfreeze.js index 58ac257ac..6f8185ec0 100644 --- a/api/api/indices.unfreeze.js +++ b/api/api/indices.unfreeze.js @@ -128,6 +128,7 @@ function buildIndicesUnfreeze (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.update_aliases.js b/api/api/indices.update_aliases.js index 7188e5112..43ead727b 100644 --- a/api/api/indices.update_aliases.js +++ b/api/api/indices.update_aliases.js @@ -117,6 +117,7 @@ function buildIndicesUpdateAliases (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.upgrade.js b/api/api/indices.upgrade.js index a1614f0ff..3ac30c597 100644 --- a/api/api/indices.upgrade.js +++ b/api/api/indices.upgrade.js @@ -131,6 +131,7 @@ function buildIndicesUpgrade (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/indices.validate_query.js b/api/api/indices.validate_query.js index 6088e7d7e..87a0c3331 100644 --- a/api/api/indices.validate_query.js +++ b/api/api/indices.validate_query.js @@ -150,6 +150,7 @@ function buildIndicesValidateQuery (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/info.js b/api/api/info.js index 611a7382c..71393693a 100644 --- a/api/api/info.js +++ b/api/api/info.js @@ -111,6 +111,7 @@ function buildInfo (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ingest.delete_pipeline.js b/api/api/ingest.delete_pipeline.js index 8a567cde5..4f5ead813 100644 --- a/api/api/ingest.delete_pipeline.js +++ b/api/api/ingest.delete_pipeline.js @@ -123,6 +123,7 @@ function buildIngestDeletePipeline (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ingest.get_pipeline.js b/api/api/ingest.get_pipeline.js index 9c6a1f39f..8ecd6a1c7 100644 --- a/api/api/ingest.get_pipeline.js +++ b/api/api/ingest.get_pipeline.js @@ -119,6 +119,7 @@ function buildIngestGetPipeline (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ingest.processor_grok.js b/api/api/ingest.processor_grok.js index 0d040e3e0..711193ce2 100644 --- a/api/api/ingest.processor_grok.js +++ b/api/api/ingest.processor_grok.js @@ -111,6 +111,7 @@ function buildIngestProcessorGrok (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ingest.put_pipeline.js b/api/api/ingest.put_pipeline.js index 2030a6be0..c3d7f2a55 100644 --- a/api/api/ingest.put_pipeline.js +++ b/api/api/ingest.put_pipeline.js @@ -124,6 +124,7 @@ function buildIngestPutPipeline (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ingest.simulate.js b/api/api/ingest.simulate.js index 00caaa44b..990e6b784 100644 --- a/api/api/ingest.simulate.js +++ b/api/api/ingest.simulate.js @@ -119,6 +119,7 @@ function buildIngestSimulate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/mget.js b/api/api/mget.js index 5844be7e5..2551c284a 100644 --- a/api/api/mget.js +++ b/api/api/mget.js @@ -147,6 +147,7 @@ function buildMget (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.close_job.js b/api/api/ml.close_job.js index 729923e0d..e23ae7d6c 100644 --- a/api/api/ml.close_job.js +++ b/api/api/ml.close_job.js @@ -114,6 +114,7 @@ function buildMlCloseJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.delete_calendar.js b/api/api/ml.delete_calendar.js index dd57aed36..61c86a2f1 100644 --- a/api/api/ml.delete_calendar.js +++ b/api/api/ml.delete_calendar.js @@ -113,6 +113,7 @@ function buildMlDeleteCalendar (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.delete_calendar_event.js b/api/api/ml.delete_calendar_event.js index fcda6a576..9a7c31919 100644 --- a/api/api/ml.delete_calendar_event.js +++ b/api/api/ml.delete_calendar_event.js @@ -128,6 +128,7 @@ function buildMlDeleteCalendarEvent (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.delete_calendar_job.js b/api/api/ml.delete_calendar_job.js index 5a7b39f8f..56d28eb2b 100644 --- a/api/api/ml.delete_calendar_job.js +++ b/api/api/ml.delete_calendar_job.js @@ -128,6 +128,7 @@ function buildMlDeleteCalendarJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.delete_datafeed.js b/api/api/ml.delete_datafeed.js index 057949b22..9b03cd943 100644 --- a/api/api/ml.delete_datafeed.js +++ b/api/api/ml.delete_datafeed.js @@ -114,6 +114,7 @@ function buildMlDeleteDatafeed (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.delete_expired_data.js b/api/api/ml.delete_expired_data.js index 62bafbc88..834fb37d6 100644 --- a/api/api/ml.delete_expired_data.js +++ b/api/api/ml.delete_expired_data.js @@ -106,6 +106,7 @@ function buildMlDeleteExpiredData (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.delete_filter.js b/api/api/ml.delete_filter.js index 33ceea713..79277818e 100644 --- a/api/api/ml.delete_filter.js +++ b/api/api/ml.delete_filter.js @@ -113,6 +113,7 @@ function buildMlDeleteFilter (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.delete_forecast.js b/api/api/ml.delete_forecast.js index bfa10cf2e..6d91e5d07 100644 --- a/api/api/ml.delete_forecast.js +++ b/api/api/ml.delete_forecast.js @@ -130,6 +130,7 @@ function buildMlDeleteForecast (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.delete_job.js b/api/api/ml.delete_job.js index af969304e..3f65d0e74 100644 --- a/api/api/ml.delete_job.js +++ b/api/api/ml.delete_job.js @@ -116,6 +116,7 @@ function buildMlDeleteJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.delete_model_snapshot.js b/api/api/ml.delete_model_snapshot.js index 5108169e9..af996d5b4 100644 --- a/api/api/ml.delete_model_snapshot.js +++ b/api/api/ml.delete_model_snapshot.js @@ -128,6 +128,7 @@ function buildMlDeleteModelSnapshot (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.find_file_structure.js b/api/api/ml.find_file_structure.js index 9d9aabbaf..b310b2bd1 100644 --- a/api/api/ml.find_file_structure.js +++ b/api/api/ml.find_file_structure.js @@ -139,6 +139,7 @@ function buildMlFindFileStructure (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.flush_job.js b/api/api/ml.flush_job.js index 0f8c275d9..eb2b8c6cf 100644 --- a/api/api/ml.flush_job.js +++ b/api/api/ml.flush_job.js @@ -119,6 +119,7 @@ function buildMlFlushJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.forecast.js b/api/api/ml.forecast.js index 45e94b8ac..a3b4187ca 100644 --- a/api/api/ml.forecast.js +++ b/api/api/ml.forecast.js @@ -116,6 +116,7 @@ function buildMlForecast (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.get_buckets.js b/api/api/ml.get_buckets.js index a4b9cab22..6fce8b6ce 100644 --- a/api/api/ml.get_buckets.js +++ b/api/api/ml.get_buckets.js @@ -140,6 +140,7 @@ function buildMlGetBuckets (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.get_calendar_events.js b/api/api/ml.get_calendar_events.js index 3c3a4924d..96342cd0c 100644 --- a/api/api/ml.get_calendar_events.js +++ b/api/api/ml.get_calendar_events.js @@ -123,6 +123,7 @@ function buildMlGetCalendarEvents (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.get_calendars.js b/api/api/ml.get_calendars.js index e75331e41..9a83b4527 100644 --- a/api/api/ml.get_calendars.js +++ b/api/api/ml.get_calendars.js @@ -114,6 +114,7 @@ function buildMlGetCalendars (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.get_categories.js b/api/api/ml.get_categories.js index 82b1c3d2f..2fa566eb7 100644 --- a/api/api/ml.get_categories.js +++ b/api/api/ml.get_categories.js @@ -116,6 +116,7 @@ function buildMlGetCategories (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.get_datafeed_stats.js b/api/api/ml.get_datafeed_stats.js index 0775f5b57..7880aa86c 100644 --- a/api/api/ml.get_datafeed_stats.js +++ b/api/api/ml.get_datafeed_stats.js @@ -112,6 +112,7 @@ function buildMlGetDatafeedStats (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.get_datafeeds.js b/api/api/ml.get_datafeeds.js index a6840e049..889b0d3f5 100644 --- a/api/api/ml.get_datafeeds.js +++ b/api/api/ml.get_datafeeds.js @@ -112,6 +112,7 @@ function buildMlGetDatafeeds (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.get_filters.js b/api/api/ml.get_filters.js index aa5db006a..5c215fc50 100644 --- a/api/api/ml.get_filters.js +++ b/api/api/ml.get_filters.js @@ -114,6 +114,7 @@ function buildMlGetFilters (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.get_influencers.js b/api/api/ml.get_influencers.js index 496a313f5..f3c447eda 100644 --- a/api/api/ml.get_influencers.js +++ b/api/api/ml.get_influencers.js @@ -125,6 +125,7 @@ function buildMlGetInfluencers (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.get_job_stats.js b/api/api/ml.get_job_stats.js index 53ac81c06..6cd1cc9ad 100644 --- a/api/api/ml.get_job_stats.js +++ b/api/api/ml.get_job_stats.js @@ -112,6 +112,7 @@ function buildMlGetJobStats (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.get_jobs.js b/api/api/ml.get_jobs.js index dd8a91275..d62975796 100644 --- a/api/api/ml.get_jobs.js +++ b/api/api/ml.get_jobs.js @@ -112,6 +112,7 @@ function buildMlGetJobs (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.get_model_snapshots.js b/api/api/ml.get_model_snapshots.js index 6eeb06ab2..44a11e3c0 100644 --- a/api/api/ml.get_model_snapshots.js +++ b/api/api/ml.get_model_snapshots.js @@ -132,6 +132,7 @@ function buildMlGetModelSnapshots (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.get_overall_buckets.js b/api/api/ml.get_overall_buckets.js index 5c34b0921..e5a0abe59 100644 --- a/api/api/ml.get_overall_buckets.js +++ b/api/api/ml.get_overall_buckets.js @@ -125,6 +125,7 @@ function buildMlGetOverallBuckets (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.get_records.js b/api/api/ml.get_records.js index c8fecd3c7..b26b6c382 100644 --- a/api/api/ml.get_records.js +++ b/api/api/ml.get_records.js @@ -125,6 +125,7 @@ function buildMlGetRecords (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.info.js b/api/api/ml.info.js index 401611802..8fbd22b38 100644 --- a/api/api/ml.info.js +++ b/api/api/ml.info.js @@ -98,6 +98,7 @@ function buildMlInfo (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.open_job.js b/api/api/ml.open_job.js index 5f77f2dbe..ce4ed8a60 100644 --- a/api/api/ml.open_job.js +++ b/api/api/ml.open_job.js @@ -115,6 +115,7 @@ function buildMlOpenJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.post_calendar_events.js b/api/api/ml.post_calendar_events.js index 6d956007d..30c9d0483 100644 --- a/api/api/ml.post_calendar_events.js +++ b/api/api/ml.post_calendar_events.js @@ -114,6 +114,7 @@ function buildMlPostCalendarEvents (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.post_data.js b/api/api/ml.post_data.js index a6964a52d..63e754991 100644 --- a/api/api/ml.post_data.js +++ b/api/api/ml.post_data.js @@ -118,6 +118,7 @@ function buildMlPostData (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.preview_datafeed.js b/api/api/ml.preview_datafeed.js index 562e09331..33eade853 100644 --- a/api/api/ml.preview_datafeed.js +++ b/api/api/ml.preview_datafeed.js @@ -113,6 +113,7 @@ function buildMlPreviewDatafeed (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.put_calendar.js b/api/api/ml.put_calendar.js index 82fd3db68..8d83eeb8e 100644 --- a/api/api/ml.put_calendar.js +++ b/api/api/ml.put_calendar.js @@ -108,6 +108,7 @@ function buildMlPutCalendar (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.put_calendar_job.js b/api/api/ml.put_calendar_job.js index f4882f2ed..a10aa05ea 100644 --- a/api/api/ml.put_calendar_job.js +++ b/api/api/ml.put_calendar_job.js @@ -128,6 +128,7 @@ function buildMlPutCalendarJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.put_datafeed.js b/api/api/ml.put_datafeed.js index 8b0626212..8ebdcaaed 100644 --- a/api/api/ml.put_datafeed.js +++ b/api/api/ml.put_datafeed.js @@ -114,6 +114,7 @@ function buildMlPutDatafeed (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.put_filter.js b/api/api/ml.put_filter.js index 3d637bf22..7b36d7c03 100644 --- a/api/api/ml.put_filter.js +++ b/api/api/ml.put_filter.js @@ -114,6 +114,7 @@ function buildMlPutFilter (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.put_job.js b/api/api/ml.put_job.js index 08d444d1e..ee59f4507 100644 --- a/api/api/ml.put_job.js +++ b/api/api/ml.put_job.js @@ -114,6 +114,7 @@ function buildMlPutJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.revert_model_snapshot.js b/api/api/ml.revert_model_snapshot.js index e3daf24aa..021c14589 100644 --- a/api/api/ml.revert_model_snapshot.js +++ b/api/api/ml.revert_model_snapshot.js @@ -124,6 +124,7 @@ function buildMlRevertModelSnapshot (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.set_upgrade_mode.js b/api/api/ml.set_upgrade_mode.js index eaf40d34f..d83f85798 100644 --- a/api/api/ml.set_upgrade_mode.js +++ b/api/api/ml.set_upgrade_mode.js @@ -109,6 +109,7 @@ function buildMlSetUpgradeMode (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.start_datafeed.js b/api/api/ml.start_datafeed.js index 62c0e24c7..f3d3abda0 100644 --- a/api/api/ml.start_datafeed.js +++ b/api/api/ml.start_datafeed.js @@ -113,6 +113,7 @@ function buildMlStartDatafeed (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.stop_datafeed.js b/api/api/ml.stop_datafeed.js index 693a941b0..e148f50b4 100644 --- a/api/api/ml.stop_datafeed.js +++ b/api/api/ml.stop_datafeed.js @@ -113,6 +113,7 @@ function buildMlStopDatafeed (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.update_datafeed.js b/api/api/ml.update_datafeed.js index 3ab93f76b..2335a79d6 100644 --- a/api/api/ml.update_datafeed.js +++ b/api/api/ml.update_datafeed.js @@ -114,6 +114,7 @@ function buildMlUpdateDatafeed (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.update_filter.js b/api/api/ml.update_filter.js index 470ab31b8..058e037af 100644 --- a/api/api/ml.update_filter.js +++ b/api/api/ml.update_filter.js @@ -114,6 +114,7 @@ function buildMlUpdateFilter (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.update_job.js b/api/api/ml.update_job.js index 56c58a686..d816daa25 100644 --- a/api/api/ml.update_job.js +++ b/api/api/ml.update_job.js @@ -114,6 +114,7 @@ function buildMlUpdateJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.update_model_snapshot.js b/api/api/ml.update_model_snapshot.js index fc83d0ecb..916fcbd38 100644 --- a/api/api/ml.update_model_snapshot.js +++ b/api/api/ml.update_model_snapshot.js @@ -129,6 +129,7 @@ function buildMlUpdateModelSnapshot (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.validate.js b/api/api/ml.validate.js index d7fb5728a..27d73b843 100644 --- a/api/api/ml.validate.js +++ b/api/api/ml.validate.js @@ -107,6 +107,7 @@ function buildMlValidate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ml.validate_detector.js b/api/api/ml.validate_detector.js index 9c1afae6f..fb33bf0f4 100644 --- a/api/api/ml.validate_detector.js +++ b/api/api/ml.validate_detector.js @@ -107,6 +107,7 @@ function buildMlValidateDetector (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/monitoring.bulk.js b/api/api/monitoring.bulk.js index 6b2c1e739..a64e64df1 100644 --- a/api/api/monitoring.bulk.js +++ b/api/api/monitoring.bulk.js @@ -119,6 +119,7 @@ function buildMonitoringBulk (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/msearch.js b/api/api/msearch.js index f411473f2..9bcfa7f59 100644 --- a/api/api/msearch.js +++ b/api/api/msearch.js @@ -149,6 +149,7 @@ function buildMsearch (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/msearch_template.js b/api/api/msearch_template.js index 13a23fa80..6a9742b81 100644 --- a/api/api/msearch_template.js +++ b/api/api/msearch_template.js @@ -143,6 +143,7 @@ function buildMsearchTemplate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/mtermvectors.js b/api/api/mtermvectors.js index c06dafd2c..fe3536d58 100644 --- a/api/api/mtermvectors.js +++ b/api/api/mtermvectors.js @@ -149,6 +149,7 @@ function buildMtermvectors (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/nodes.hot_threads.js b/api/api/nodes.hot_threads.js index a4f70ff12..89525e654 100644 --- a/api/api/nodes.hot_threads.js +++ b/api/api/nodes.hot_threads.js @@ -135,6 +135,7 @@ function buildNodesHotThreads (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/nodes.info.js b/api/api/nodes.info.js index c5a8648aa..c7fa93da0 100644 --- a/api/api/nodes.info.js +++ b/api/api/nodes.info.js @@ -126,6 +126,7 @@ function buildNodesInfo (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/nodes.reload_secure_settings.js b/api/api/nodes.reload_secure_settings.js index 59fa010c3..3d9e0d167 100644 --- a/api/api/nodes.reload_secure_settings.js +++ b/api/api/nodes.reload_secure_settings.js @@ -118,6 +118,7 @@ function buildNodesReloadSecureSettings (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/nodes.stats.js b/api/api/nodes.stats.js index 25f02f5a4..0606d2b2f 100644 --- a/api/api/nodes.stats.js +++ b/api/api/nodes.stats.js @@ -145,6 +145,7 @@ function buildNodesStats (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/nodes.usage.js b/api/api/nodes.usage.js index 9400db998..743486535 100644 --- a/api/api/nodes.usage.js +++ b/api/api/nodes.usage.js @@ -123,6 +123,7 @@ function buildNodesUsage (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ping.js b/api/api/ping.js index fe6acf9af..72ea90bf2 100644 --- a/api/api/ping.js +++ b/api/api/ping.js @@ -111,6 +111,7 @@ function buildPing (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/put_script.js b/api/api/put_script.js index ae5cdce30..8b0d5b07c 100644 --- a/api/api/put_script.js +++ b/api/api/put_script.js @@ -139,6 +139,7 @@ function buildPutScript (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/rank_eval.js b/api/api/rank_eval.js index 2d97a62d2..b109a1aac 100644 --- a/api/api/rank_eval.js +++ b/api/api/rank_eval.js @@ -126,6 +126,7 @@ function buildRankEval (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/reindex.js b/api/api/reindex.js index ced743919..765f76057 100644 --- a/api/api/reindex.js +++ b/api/api/reindex.js @@ -127,6 +127,7 @@ function buildReindex (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/reindex_rethrottle.js b/api/api/reindex_rethrottle.js index eebcc7f1e..b28d2d755 100644 --- a/api/api/reindex_rethrottle.js +++ b/api/api/reindex_rethrottle.js @@ -127,6 +127,7 @@ function buildReindexRethrottle (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/render_search_template.js b/api/api/render_search_template.js index f9b53e3ba..70a36e2e0 100644 --- a/api/api/render_search_template.js +++ b/api/api/render_search_template.js @@ -109,6 +109,7 @@ function buildRenderSearchTemplate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/scripts_painless_execute.js b/api/api/scripts_painless_execute.js index 0bf6379a6..a2af1402f 100644 --- a/api/api/scripts_painless_execute.js +++ b/api/api/scripts_painless_execute.js @@ -104,6 +104,7 @@ function buildScriptsPainlessExecute (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/scroll.js b/api/api/scroll.js index 91cfbb82d..b5b93aa81 100644 --- a/api/api/scroll.js +++ b/api/api/scroll.js @@ -117,6 +117,7 @@ function buildScroll (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/search.js b/api/api/search.js index 6d43f26aa..7606320e2 100644 --- a/api/api/search.js +++ b/api/api/search.js @@ -231,6 +231,7 @@ function buildSearch (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/search_shards.js b/api/api/search_shards.js index a142145a9..9451b2cd7 100644 --- a/api/api/search_shards.js +++ b/api/api/search_shards.js @@ -131,6 +131,7 @@ function buildSearchShards (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/search_template.js b/api/api/search_template.js index 36b832f47..37b72ea8f 100644 --- a/api/api/search_template.js +++ b/api/api/search_template.js @@ -162,6 +162,7 @@ function buildSearchTemplate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.authenticate.js b/api/api/security.authenticate.js index 3603102e0..ecbf4448b 100644 --- a/api/api/security.authenticate.js +++ b/api/api/security.authenticate.js @@ -106,6 +106,7 @@ function buildSecurityAuthenticate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.change_password.js b/api/api/security.change_password.js index f289f027f..d1c59dbed 100644 --- a/api/api/security.change_password.js +++ b/api/api/security.change_password.js @@ -113,6 +113,7 @@ function buildSecurityChangePassword (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.clear_cached_realms.js b/api/api/security.clear_cached_realms.js index 736b06ea6..2af732622 100644 --- a/api/api/security.clear_cached_realms.js +++ b/api/api/security.clear_cached_realms.js @@ -114,6 +114,7 @@ function buildSecurityClearCachedRealms (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.clear_cached_roles.js b/api/api/security.clear_cached_roles.js index 4acd50cb0..67d30b743 100644 --- a/api/api/security.clear_cached_roles.js +++ b/api/api/security.clear_cached_roles.js @@ -113,6 +113,7 @@ function buildSecurityClearCachedRoles (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.create_api_key.js b/api/api/security.create_api_key.js index c1b19ef5b..f96a3a5d5 100644 --- a/api/api/security.create_api_key.js +++ b/api/api/security.create_api_key.js @@ -108,6 +108,7 @@ function buildSecurityCreateApiKey (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.delete_privileges.js b/api/api/security.delete_privileges.js index 934365e50..92f9e36b9 100644 --- a/api/api/security.delete_privileges.js +++ b/api/api/security.delete_privileges.js @@ -129,6 +129,7 @@ function buildSecurityDeletePrivileges (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.delete_role.js b/api/api/security.delete_role.js index 50fc608ac..5901a856f 100644 --- a/api/api/security.delete_role.js +++ b/api/api/security.delete_role.js @@ -114,6 +114,7 @@ function buildSecurityDeleteRole (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.delete_role_mapping.js b/api/api/security.delete_role_mapping.js index af0f32c32..6b546b179 100644 --- a/api/api/security.delete_role_mapping.js +++ b/api/api/security.delete_role_mapping.js @@ -114,6 +114,7 @@ function buildSecurityDeleteRoleMapping (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.delete_user.js b/api/api/security.delete_user.js index 5f6c778ff..198f461fe 100644 --- a/api/api/security.delete_user.js +++ b/api/api/security.delete_user.js @@ -114,6 +114,7 @@ function buildSecurityDeleteUser (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.disable_user.js b/api/api/security.disable_user.js index a07f6f433..d8b6452dc 100644 --- a/api/api/security.disable_user.js +++ b/api/api/security.disable_user.js @@ -108,6 +108,7 @@ function buildSecurityDisableUser (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.enable_user.js b/api/api/security.enable_user.js index aefe27d78..ad2c9dbc3 100644 --- a/api/api/security.enable_user.js +++ b/api/api/security.enable_user.js @@ -108,6 +108,7 @@ function buildSecurityEnableUser (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.get_api_key.js b/api/api/security.get_api_key.js index 231ccd8bc..bbbb4ad74 100644 --- a/api/api/security.get_api_key.js +++ b/api/api/security.get_api_key.js @@ -113,6 +113,7 @@ function buildSecurityGetApiKey (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.get_privileges.js b/api/api/security.get_privileges.js index 3e5f5d5c3..952bacd6b 100644 --- a/api/api/security.get_privileges.js +++ b/api/api/security.get_privileges.js @@ -122,6 +122,7 @@ function buildSecurityGetPrivileges (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.get_role.js b/api/api/security.get_role.js index b3d05555d..ea5b12583 100644 --- a/api/api/security.get_role.js +++ b/api/api/security.get_role.js @@ -111,6 +111,7 @@ function buildSecurityGetRole (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.get_role_mapping.js b/api/api/security.get_role_mapping.js index d760fb184..62915f1c6 100644 --- a/api/api/security.get_role_mapping.js +++ b/api/api/security.get_role_mapping.js @@ -111,6 +111,7 @@ function buildSecurityGetRoleMapping (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.get_token.js b/api/api/security.get_token.js index 407ff5b35..aa19be41d 100644 --- a/api/api/security.get_token.js +++ b/api/api/security.get_token.js @@ -107,6 +107,7 @@ function buildSecurityGetToken (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.get_user.js b/api/api/security.get_user.js index 1de5e97bf..4419b0e08 100644 --- a/api/api/security.get_user.js +++ b/api/api/security.get_user.js @@ -111,6 +111,7 @@ function buildSecurityGetUser (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.get_user_privileges.js b/api/api/security.get_user_privileges.js index 46f1706da..6d812c8db 100644 --- a/api/api/security.get_user_privileges.js +++ b/api/api/security.get_user_privileges.js @@ -106,6 +106,7 @@ function buildSecurityGetUserPrivileges (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.has_privileges.js b/api/api/security.has_privileges.js index d0419c2c2..6f74c21a7 100644 --- a/api/api/security.has_privileges.js +++ b/api/api/security.has_privileges.js @@ -112,6 +112,7 @@ function buildSecurityHasPrivileges (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.invalidate_api_key.js b/api/api/security.invalidate_api_key.js index d02d2148b..0da252564 100644 --- a/api/api/security.invalidate_api_key.js +++ b/api/api/security.invalidate_api_key.js @@ -107,6 +107,7 @@ function buildSecurityInvalidateApiKey (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.invalidate_token.js b/api/api/security.invalidate_token.js index e58a221e4..09e66f50b 100644 --- a/api/api/security.invalidate_token.js +++ b/api/api/security.invalidate_token.js @@ -107,6 +107,7 @@ function buildSecurityInvalidateToken (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.put_privileges.js b/api/api/security.put_privileges.js index d102615b1..dfb90769e 100644 --- a/api/api/security.put_privileges.js +++ b/api/api/security.put_privileges.js @@ -108,6 +108,7 @@ function buildSecurityPutPrivileges (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.put_role.js b/api/api/security.put_role.js index d4e2de603..e417e69b2 100644 --- a/api/api/security.put_role.js +++ b/api/api/security.put_role.js @@ -115,6 +115,7 @@ function buildSecurityPutRole (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.put_role_mapping.js b/api/api/security.put_role_mapping.js index 721d41ca6..45a25fc38 100644 --- a/api/api/security.put_role_mapping.js +++ b/api/api/security.put_role_mapping.js @@ -115,6 +115,7 @@ function buildSecurityPutRoleMapping (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/security.put_user.js b/api/api/security.put_user.js index 4a9dc7467..9e8f46fb7 100644 --- a/api/api/security.put_user.js +++ b/api/api/security.put_user.js @@ -115,6 +115,7 @@ function buildSecurityPutUser (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/snapshot.create.js b/api/api/snapshot.create.js index fb74315c5..b3f3f426e 100644 --- a/api/api/snapshot.create.js +++ b/api/api/snapshot.create.js @@ -134,6 +134,7 @@ function buildSnapshotCreate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/snapshot.create_repository.js b/api/api/snapshot.create_repository.js index 010a3b2b1..b4db9c44c 100644 --- a/api/api/snapshot.create_repository.js +++ b/api/api/snapshot.create_repository.js @@ -126,6 +126,7 @@ function buildSnapshotCreateRepository (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/snapshot.delete.js b/api/api/snapshot.delete.js index ab0e48383..917c26630 100644 --- a/api/api/snapshot.delete.js +++ b/api/api/snapshot.delete.js @@ -136,6 +136,7 @@ function buildSnapshotDelete (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/snapshot.delete_repository.js b/api/api/snapshot.delete_repository.js index 18c4ae4bb..6e6aad2d9 100644 --- a/api/api/snapshot.delete_repository.js +++ b/api/api/snapshot.delete_repository.js @@ -123,6 +123,7 @@ function buildSnapshotDeleteRepository (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/snapshot.get.js b/api/api/snapshot.get.js index fd03f0260..0d1a437c6 100644 --- a/api/api/snapshot.get.js +++ b/api/api/snapshot.get.js @@ -141,6 +141,7 @@ function buildSnapshotGet (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/snapshot.get_repository.js b/api/api/snapshot.get_repository.js index a71c5f723..2998d02da 100644 --- a/api/api/snapshot.get_repository.js +++ b/api/api/snapshot.get_repository.js @@ -121,6 +121,7 @@ function buildSnapshotGetRepository (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/snapshot.restore.js b/api/api/snapshot.restore.js index 5feeaf569..36fe20924 100644 --- a/api/api/snapshot.restore.js +++ b/api/api/snapshot.restore.js @@ -134,6 +134,7 @@ function buildSnapshotRestore (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/snapshot.status.js b/api/api/snapshot.status.js index 6c376244f..08e35c90f 100644 --- a/api/api/snapshot.status.js +++ b/api/api/snapshot.status.js @@ -133,6 +133,7 @@ function buildSnapshotStatus (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/snapshot.verify_repository.js b/api/api/snapshot.verify_repository.js index 27e1df088..8708e5135 100644 --- a/api/api/snapshot.verify_repository.js +++ b/api/api/snapshot.verify_repository.js @@ -123,6 +123,7 @@ function buildSnapshotVerifyRepository (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/ssl.certificates.js b/api/api/ssl.certificates.js index 287edc0df..6a5d68894 100644 --- a/api/api/ssl.certificates.js +++ b/api/api/ssl.certificates.js @@ -106,6 +106,7 @@ function buildSslCertificates (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/tasks.cancel.js b/api/api/tasks.cancel.js index 98e123fcd..33e64738c 100644 --- a/api/api/tasks.cancel.js +++ b/api/api/tasks.cancel.js @@ -123,6 +123,7 @@ function buildTasksCancel (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/tasks.get.js b/api/api/tasks.get.js index 0b690a8a9..d968a6d38 100644 --- a/api/api/tasks.get.js +++ b/api/api/tasks.get.js @@ -123,6 +123,7 @@ function buildTasksGet (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/tasks.list.js b/api/api/tasks.list.js index f54d77417..9b3ec93b6 100644 --- a/api/api/tasks.list.js +++ b/api/api/tasks.list.js @@ -128,6 +128,7 @@ function buildTasksList (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/termvectors.js b/api/api/termvectors.js index 3e7552f72..84d557a5b 100644 --- a/api/api/termvectors.js +++ b/api/api/termvectors.js @@ -150,6 +150,7 @@ function buildTermvectors (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/update.js b/api/api/update.js index 6fa970065..617b42aad 100644 --- a/api/api/update.js +++ b/api/api/update.js @@ -161,6 +161,7 @@ function buildUpdate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/update_by_query.js b/api/api/update_by_query.js index 1e506f600..4e5287958 100644 --- a/api/api/update_by_query.js +++ b/api/api/update_by_query.js @@ -210,6 +210,7 @@ function buildUpdateByQuery (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/update_by_query_rethrottle.js b/api/api/update_by_query_rethrottle.js index 654ad8cfd..c0ebd050b 100644 --- a/api/api/update_by_query_rethrottle.js +++ b/api/api/update_by_query_rethrottle.js @@ -127,6 +127,7 @@ function buildUpdateByQueryRethrottle (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.graph.explore.js b/api/api/xpack.graph.explore.js index 5161ab7f0..1db3bf521 100644 --- a/api/api/xpack.graph.explore.js +++ b/api/api/xpack.graph.explore.js @@ -116,6 +116,7 @@ function buildXpackGraphExplore (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.info.js b/api/api/xpack.info.js index a5bdbf823..36a9c745c 100644 --- a/api/api/xpack.info.js +++ b/api/api/xpack.info.js @@ -107,6 +107,7 @@ function buildXpackInfo (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.license.delete.js b/api/api/xpack.license.delete.js index 48e1b8898..203e5d571 100644 --- a/api/api/xpack.license.delete.js +++ b/api/api/xpack.license.delete.js @@ -106,6 +106,7 @@ function buildXpackLicenseDelete (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.license.get.js b/api/api/xpack.license.get.js index 5ed14eb42..af0ee628b 100644 --- a/api/api/xpack.license.get.js +++ b/api/api/xpack.license.get.js @@ -107,6 +107,7 @@ function buildXpackLicenseGet (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.license.get_basic_status.js b/api/api/xpack.license.get_basic_status.js index f933920ae..35155a724 100644 --- a/api/api/xpack.license.get_basic_status.js +++ b/api/api/xpack.license.get_basic_status.js @@ -106,6 +106,7 @@ function buildXpackLicenseGetBasicStatus (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.license.get_trial_status.js b/api/api/xpack.license.get_trial_status.js index 49bb6ec4d..5b84dfc27 100644 --- a/api/api/xpack.license.get_trial_status.js +++ b/api/api/xpack.license.get_trial_status.js @@ -106,6 +106,7 @@ function buildXpackLicenseGetTrialStatus (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.license.post.js b/api/api/xpack.license.post.js index 6c9182099..ca7dc861f 100644 --- a/api/api/xpack.license.post.js +++ b/api/api/xpack.license.post.js @@ -100,6 +100,7 @@ function buildXpackLicensePost (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.license.post_start_basic.js b/api/api/xpack.license.post_start_basic.js index 7484f4876..63b2cefa1 100644 --- a/api/api/xpack.license.post_start_basic.js +++ b/api/api/xpack.license.post_start_basic.js @@ -107,6 +107,7 @@ function buildXpackLicensePostStartBasic (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.license.post_start_trial.js b/api/api/xpack.license.post_start_trial.js index ed9d04bf0..b16ddd42b 100644 --- a/api/api/xpack.license.post_start_trial.js +++ b/api/api/xpack.license.post_start_trial.js @@ -109,6 +109,7 @@ function buildXpackLicensePostStartTrial (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.migration.deprecations.js b/api/api/xpack.migration.deprecations.js index 485e4cadb..3dbafd5b0 100644 --- a/api/api/xpack.migration.deprecations.js +++ b/api/api/xpack.migration.deprecations.js @@ -111,6 +111,7 @@ function buildXpackMigrationDeprecations (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.migration.get_assistance.js b/api/api/xpack.migration.get_assistance.js index 96c0591cf..088810be2 100644 --- a/api/api/xpack.migration.get_assistance.js +++ b/api/api/xpack.migration.get_assistance.js @@ -110,6 +110,7 @@ function buildXpackMigrationGetAssistance (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.migration.upgrade.js b/api/api/xpack.migration.upgrade.js index 16062ae81..67bd9497b 100644 --- a/api/api/xpack.migration.upgrade.js +++ b/api/api/xpack.migration.upgrade.js @@ -108,6 +108,7 @@ function buildXpackMigrationUpgrade (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.rollup.delete_job.js b/api/api/xpack.rollup.delete_job.js index d463030c5..e2efbaaee 100644 --- a/api/api/xpack.rollup.delete_job.js +++ b/api/api/xpack.rollup.delete_job.js @@ -107,6 +107,7 @@ function buildXpackRollupDeleteJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.rollup.get_jobs.js b/api/api/xpack.rollup.get_jobs.js index 25a150d0e..cb67e3e54 100644 --- a/api/api/xpack.rollup.get_jobs.js +++ b/api/api/xpack.rollup.get_jobs.js @@ -103,6 +103,7 @@ function buildXpackRollupGetJobs (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.rollup.get_rollup_caps.js b/api/api/xpack.rollup.get_rollup_caps.js index dfe09cce4..1e2a1d5b5 100644 --- a/api/api/xpack.rollup.get_rollup_caps.js +++ b/api/api/xpack.rollup.get_rollup_caps.js @@ -103,6 +103,7 @@ function buildXpackRollupGetRollupCaps (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.rollup.get_rollup_index_caps.js b/api/api/xpack.rollup.get_rollup_index_caps.js index 6b7846b72..5b5ad3038 100644 --- a/api/api/xpack.rollup.get_rollup_index_caps.js +++ b/api/api/xpack.rollup.get_rollup_index_caps.js @@ -107,6 +107,7 @@ function buildXpackRollupGetRollupIndexCaps (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.rollup.put_job.js b/api/api/xpack.rollup.put_job.js index d76625c51..cf6ba50d7 100644 --- a/api/api/xpack.rollup.put_job.js +++ b/api/api/xpack.rollup.put_job.js @@ -114,6 +114,7 @@ function buildXpackRollupPutJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.rollup.rollup_search.js b/api/api/xpack.rollup.rollup_search.js index b006d127f..681c803b3 100644 --- a/api/api/xpack.rollup.rollup_search.js +++ b/api/api/xpack.rollup.rollup_search.js @@ -131,6 +131,7 @@ function buildXpackRollupRollupSearch (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.rollup.start_job.js b/api/api/xpack.rollup.start_job.js index 3701988c8..ea8a0e069 100644 --- a/api/api/xpack.rollup.start_job.js +++ b/api/api/xpack.rollup.start_job.js @@ -107,6 +107,7 @@ function buildXpackRollupStartJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.rollup.stop_job.js b/api/api/xpack.rollup.stop_job.js index 4d132b641..5945a7e59 100644 --- a/api/api/xpack.rollup.stop_job.js +++ b/api/api/xpack.rollup.stop_job.js @@ -111,6 +111,7 @@ function buildXpackRollupStopJob (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.sql.clear_cursor.js b/api/api/xpack.sql.clear_cursor.js index d1967d400..7bf825950 100644 --- a/api/api/xpack.sql.clear_cursor.js +++ b/api/api/xpack.sql.clear_cursor.js @@ -107,6 +107,7 @@ function buildXpackSqlClearCursor (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.sql.query.js b/api/api/xpack.sql.query.js index 80d95b181..67087514e 100644 --- a/api/api/xpack.sql.query.js +++ b/api/api/xpack.sql.query.js @@ -108,6 +108,7 @@ function buildXpackSqlQuery (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.sql.translate.js b/api/api/xpack.sql.translate.js index 15c544835..684f57905 100644 --- a/api/api/xpack.sql.translate.js +++ b/api/api/xpack.sql.translate.js @@ -107,6 +107,7 @@ function buildXpackSqlTranslate (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.usage.js b/api/api/xpack.usage.js index 61a6b8d86..90af1be13 100644 --- a/api/api/xpack.usage.js +++ b/api/api/xpack.usage.js @@ -107,6 +107,7 @@ function buildXpackUsage (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.watcher.ack_watch.js b/api/api/xpack.watcher.ack_watch.js index 2284c7098..ede9615ec 100644 --- a/api/api/xpack.watcher.ack_watch.js +++ b/api/api/xpack.watcher.ack_watch.js @@ -126,6 +126,7 @@ function buildXpackWatcherAckWatch (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.watcher.activate_watch.js b/api/api/xpack.watcher.activate_watch.js index ae5a81497..ba22813ca 100644 --- a/api/api/xpack.watcher.activate_watch.js +++ b/api/api/xpack.watcher.activate_watch.js @@ -113,6 +113,7 @@ function buildXpackWatcherActivateWatch (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.watcher.deactivate_watch.js b/api/api/xpack.watcher.deactivate_watch.js index fa9cdf434..6ae2c9712 100644 --- a/api/api/xpack.watcher.deactivate_watch.js +++ b/api/api/xpack.watcher.deactivate_watch.js @@ -113,6 +113,7 @@ function buildXpackWatcherDeactivateWatch (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.watcher.delete_watch.js b/api/api/xpack.watcher.delete_watch.js index cdddf8bd7..66fbba1a4 100644 --- a/api/api/xpack.watcher.delete_watch.js +++ b/api/api/xpack.watcher.delete_watch.js @@ -113,6 +113,7 @@ function buildXpackWatcherDeleteWatch (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.watcher.execute_watch.js b/api/api/xpack.watcher.execute_watch.js index 034e2d218..8c0e7db1f 100644 --- a/api/api/xpack.watcher.execute_watch.js +++ b/api/api/xpack.watcher.execute_watch.js @@ -105,6 +105,7 @@ function buildXpackWatcherExecuteWatch (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.watcher.get_watch.js b/api/api/xpack.watcher.get_watch.js index 98f6db827..e1bfb5b92 100644 --- a/api/api/xpack.watcher.get_watch.js +++ b/api/api/xpack.watcher.get_watch.js @@ -113,6 +113,7 @@ function buildXpackWatcherGetWatch (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.watcher.put_watch.js b/api/api/xpack.watcher.put_watch.js index 6dd39a603..1d4442327 100644 --- a/api/api/xpack.watcher.put_watch.js +++ b/api/api/xpack.watcher.put_watch.js @@ -116,6 +116,7 @@ function buildXpackWatcherPutWatch (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.watcher.start.js b/api/api/xpack.watcher.start.js index 5b4b227cc..c4b8c0ec9 100644 --- a/api/api/xpack.watcher.start.js +++ b/api/api/xpack.watcher.start.js @@ -106,6 +106,7 @@ function buildXpackWatcherStart (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.watcher.stats.js b/api/api/xpack.watcher.stats.js index 29e68ec6c..05882a9b8 100644 --- a/api/api/xpack.watcher.stats.js +++ b/api/api/xpack.watcher.stats.js @@ -114,6 +114,7 @@ function buildXpackWatcherStats (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/api/api/xpack.watcher.stop.js b/api/api/xpack.watcher.stop.js index 363f2b2f4..aec707664 100644 --- a/api/api/xpack.watcher.stop.js +++ b/api/api/xpack.watcher.stop.js @@ -106,6 +106,7 @@ function buildXpackWatcherStop (opts) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/docs/usage.asciidoc b/docs/usage.asciidoc index 5ef2f63df..07441e78d 100644 --- a/docs/usage.asciidoc +++ b/docs/usage.asciidoc @@ -159,6 +159,10 @@ _Default:_ `false` |`headers` |`object` - Custom headers for the request. + _Default:_ `null` + +|`querystring` +|`object` - Custom querystring for the request. + +_Default:_ `null` |=== === Error handling diff --git a/lib/Transport.d.ts b/lib/Transport.d.ts index 8037ae2f9..28033e292 100644 --- a/lib/Transport.d.ts +++ b/lib/Transport.d.ts @@ -80,9 +80,9 @@ declare type anyObject = { export interface TransportRequestParams { method: string; path: string; - body?: anyObject, - bulkBody?: anyObject, - querystring: anyObject + body?: anyObject; + bulkBody?: anyObject; + querystring?: anyObject; } export interface TransportRequestOptions { @@ -91,6 +91,7 @@ export interface TransportRequestOptions { maxRetries?: number; asStream?: boolean; headers?: anyObject; + querystring?: anyObject; compression?: string; warnings?: [string]; } diff --git a/lib/Transport.js b/lib/Transport.js index 61ee70c44..7bbc90412 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -166,7 +166,13 @@ class Transport { params.headers = headers // serializes the querystring - params.querystring = this.serializer.qserialize(params.querystring) + if (options.querystring == null) { + params.querystring = this.serializer.qserialize(params.querystring) + } else { + params.querystring = this.serializer.qserialize( + Object.assign({}, params.querystring, options.querystring) + ) + } meta.request.params = params meta.request.options = options diff --git a/scripts/utils/generate.js b/scripts/utils/generate.js index 742c41f64..865925a48 100644 --- a/scripts/utils/generate.js +++ b/scripts/utils/generate.js @@ -160,6 +160,7 @@ function generate (spec, common) { maxRetries: options.maxRetries || null, asStream: options.asStream || false, headers: options.headers || null, + querystring: options.querystring || null, compression: options.compression || false, warnings } diff --git a/test/types/index.ts b/test/types/index.ts index fd1260bab..20705bad1 100644 --- a/test/types/index.ts +++ b/test/types/index.ts @@ -59,7 +59,11 @@ client.index({ }, { maxRetries: 2, ignore: [404], - requestTimeout: 2000 + requestTimeout: 2000, + headers: { foo: 'bar' }, + querystring: { baz: 'faz' }, + compression: 'gzip', + asStream: false }, (err: Error | null, result: ApiResponse) => {}) // Promises diff --git a/test/unit/api.test.js b/test/unit/api.test.js index 61cc49a01..96e7fa701 100644 --- a/test/unit/api.test.js +++ b/test/unit/api.test.js @@ -269,6 +269,32 @@ test('Pass unknown parameters as query parameters (and get a warning)', t => { }) }) +test('If the API uses the same key for both url and query parameter, the url should win', t => { + t.plan(2) + + function handler (req, res) { + t.strictEqual(req.url, '/index/type/_bulk') + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const client = new Client({ + node: `http://localhost:${port}` + }) + + // bulk has two `type` parameters + client.bulk({ + index: 'index', + type: 'type', + body: [] + }, (err, { body, warnings }) => { + t.error(err) + server.stop() + }) + }) +}) + if (Number(process.version.split('.')[0].slice(1)) >= 8) { require('./api-async')(test) } diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index 7b15c72cc..c7c789950 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -2030,3 +2030,80 @@ test('nodeFilter and nodeSelector', t => { t.deepEqual(body, { hello: 'world' }) }) }) + +test('Should accept custom querystring in the optons object', t => { + t.test('Options object', t => { + t.plan(3) + + function handler (req, res) { + t.strictEqual(req.url, '/hello?foo=bar') + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ Connection }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello' + }, { + querystring: { foo: 'bar' } + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + server.stop() + }) + }) + }) + + t.test('Options object and params', t => { + t.plan(3) + + function handler (req, res) { + t.strictEqual(req.url, '/hello?baz=faz&foo=bar') + res.setHeader('Content-Type', 'application/json;utf=8') + res.end(JSON.stringify({ hello: 'world' })) + } + + buildServer(handler, ({ port }, server) => { + const pool = new ConnectionPool({ Connection }) + pool.addConnection(`http://localhost:${port}`) + + const transport = new Transport({ + emit: () => {}, + connectionPool: pool, + serializer: new Serializer(), + maxRetries: 3, + requestTimeout: 30000, + sniffInterval: false, + sniffOnStart: false + }) + + transport.request({ + method: 'GET', + path: '/hello', + querystring: { baz: 'faz' } + }, { + querystring: { foo: 'bar' } + }, (err, { body }) => { + t.error(err) + t.deepEqual(body, { hello: 'world' }) + server.stop() + }) + }) + }) + + t.end() +}) From 532ded5d5c27a6eb8bc9454b7705d94b11581a49 Mon Sep 17 00:00:00 2001 From: delvedor Date: Mon, 18 Mar 2019 19:01:10 +0100 Subject: [PATCH 14/22] Added a note about the new client --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 73bf20b7a..3d9b24312 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,13 @@ [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) [![Build Status](https://clients-ci.elastic.co/job/elastic+elasticsearch-js+master/badge/icon)](https://clients-ci.elastic.co/job/elastic+elasticsearch-js+master/) [![codecov](https://codecov.io/gh/elastic/elasticsearch-js/branch/master/graph/badge.svg)](https://codecov.io/gh/elastic/elasticsearch-js) [![NPM downloads](https://img.shields.io/npm/dm/@elastic/elasticsearch.svg?style=flat)](https://www.npmjs.com/package/@elastic/elasticsearch) +--- + +**Note:** In the past months we have worked on the new Elasticsearch Node.js client, we will announce it soon! +If you want you can already try it by following the instructions below, while if you're going to use the legacy one or report an issue, please check out [elastic/elasticsearch-js-legacy](https://github.com/elastic/elasticsearch-js-legacy). + +--- + The official Node.js client for Elasticsearch. ## Features @@ -20,6 +27,13 @@ npm install @elastic/elasticsearch ``` ### Compatibility + +--- + +**Warning:** currently on npm you will only find a beta release that works with Elasticsearch 7, we will add the support for Elasticsearch 5, 6, and 7 once we release the final version of this library. + +--- + The library is compatible with all Elasticsearch versions since 5.x, but you should use the same major version of the Elasticsearch instance that you are using. ``` # Elasticsearch 7.x From 3b41c555ae139c7d3e9b9e8411fe209c60a582b4 Mon Sep 17 00:00:00 2001 From: Tomas Della Vedova Date: Tue, 19 Mar 2019 07:50:05 +0100 Subject: [PATCH 15/22] Feat: Support bundlers (#783) With this change, we support code bundlers, such as webpack. Fixes: https://github.com/elastic/elasticsearch-js/issues/781 --- api/index.js | 822 +++++++++++++++++++-------------------- scripts/utils/genMain.js | 8 +- 2 files changed, 416 insertions(+), 414 deletions(-) diff --git a/api/index.js b/api/index.js index ca997bffa..f45a8ccdb 100644 --- a/api/index.js +++ b/api/index.js @@ -27,454 +27,454 @@ function ESAPI (opts) { assert(opts.result, 'Missing default result object') const apis = { - bulk: lazyLoad('./api/bulk.js', opts), + bulk: lazyLoad('bulk', opts), cat: { - aliases: lazyLoad('./api/cat.aliases.js', opts), - allocation: lazyLoad('./api/cat.allocation.js', opts), - count: lazyLoad('./api/cat.count.js', opts), - fielddata: lazyLoad('./api/cat.fielddata.js', opts), - health: lazyLoad('./api/cat.health.js', opts), - help: lazyLoad('./api/cat.help.js', opts), - indices: lazyLoad('./api/cat.indices.js', opts), - master: lazyLoad('./api/cat.master.js', opts), - nodeattrs: lazyLoad('./api/cat.nodeattrs.js', opts), - nodes: lazyLoad('./api/cat.nodes.js', opts), - pending_tasks: lazyLoad('./api/cat.pending_tasks.js', opts), - pendingTasks: lazyLoad('./api/cat.pending_tasks.js', opts), - plugins: lazyLoad('./api/cat.plugins.js', opts), - recovery: lazyLoad('./api/cat.recovery.js', opts), - repositories: lazyLoad('./api/cat.repositories.js', opts), - segments: lazyLoad('./api/cat.segments.js', opts), - shards: lazyLoad('./api/cat.shards.js', opts), - snapshots: lazyLoad('./api/cat.snapshots.js', opts), - tasks: lazyLoad('./api/cat.tasks.js', opts), - templates: lazyLoad('./api/cat.templates.js', opts), - thread_pool: lazyLoad('./api/cat.thread_pool.js', opts), - threadPool: lazyLoad('./api/cat.thread_pool.js', opts) + aliases: lazyLoad('cat.aliases', opts), + allocation: lazyLoad('cat.allocation', opts), + count: lazyLoad('cat.count', opts), + fielddata: lazyLoad('cat.fielddata', opts), + health: lazyLoad('cat.health', opts), + help: lazyLoad('cat.help', opts), + indices: lazyLoad('cat.indices', opts), + master: lazyLoad('cat.master', opts), + nodeattrs: lazyLoad('cat.nodeattrs', opts), + nodes: lazyLoad('cat.nodes', opts), + pending_tasks: lazyLoad('cat.pending_tasks', opts), + pendingTasks: lazyLoad('cat.pending_tasks', opts), + plugins: lazyLoad('cat.plugins', opts), + recovery: lazyLoad('cat.recovery', opts), + repositories: lazyLoad('cat.repositories', opts), + segments: lazyLoad('cat.segments', opts), + shards: lazyLoad('cat.shards', opts), + snapshots: lazyLoad('cat.snapshots', opts), + tasks: lazyLoad('cat.tasks', opts), + templates: lazyLoad('cat.templates', opts), + thread_pool: lazyLoad('cat.thread_pool', opts), + threadPool: lazyLoad('cat.thread_pool', opts) }, ccr: { - delete_auto_follow_pattern: lazyLoad('./api/ccr.delete_auto_follow_pattern.js', opts), - deleteAutoFollowPattern: lazyLoad('./api/ccr.delete_auto_follow_pattern.js', opts), - follow: lazyLoad('./api/ccr.follow.js', opts), - follow_info: lazyLoad('./api/ccr.follow_info.js', opts), - followInfo: lazyLoad('./api/ccr.follow_info.js', opts), - follow_stats: lazyLoad('./api/ccr.follow_stats.js', opts), - followStats: lazyLoad('./api/ccr.follow_stats.js', opts), - get_auto_follow_pattern: lazyLoad('./api/ccr.get_auto_follow_pattern.js', opts), - getAutoFollowPattern: lazyLoad('./api/ccr.get_auto_follow_pattern.js', opts), - pause_follow: lazyLoad('./api/ccr.pause_follow.js', opts), - pauseFollow: lazyLoad('./api/ccr.pause_follow.js', opts), - put_auto_follow_pattern: lazyLoad('./api/ccr.put_auto_follow_pattern.js', opts), - putAutoFollowPattern: lazyLoad('./api/ccr.put_auto_follow_pattern.js', opts), - resume_follow: lazyLoad('./api/ccr.resume_follow.js', opts), - resumeFollow: lazyLoad('./api/ccr.resume_follow.js', opts), - stats: lazyLoad('./api/ccr.stats.js', opts), - unfollow: lazyLoad('./api/ccr.unfollow.js', opts) + delete_auto_follow_pattern: lazyLoad('ccr.delete_auto_follow_pattern', opts), + deleteAutoFollowPattern: lazyLoad('ccr.delete_auto_follow_pattern', opts), + follow: lazyLoad('ccr.follow', opts), + follow_info: lazyLoad('ccr.follow_info', opts), + followInfo: lazyLoad('ccr.follow_info', opts), + follow_stats: lazyLoad('ccr.follow_stats', opts), + followStats: lazyLoad('ccr.follow_stats', opts), + get_auto_follow_pattern: lazyLoad('ccr.get_auto_follow_pattern', opts), + getAutoFollowPattern: lazyLoad('ccr.get_auto_follow_pattern', opts), + pause_follow: lazyLoad('ccr.pause_follow', opts), + pauseFollow: lazyLoad('ccr.pause_follow', opts), + put_auto_follow_pattern: lazyLoad('ccr.put_auto_follow_pattern', opts), + putAutoFollowPattern: lazyLoad('ccr.put_auto_follow_pattern', opts), + resume_follow: lazyLoad('ccr.resume_follow', opts), + resumeFollow: lazyLoad('ccr.resume_follow', opts), + stats: lazyLoad('ccr.stats', opts), + unfollow: lazyLoad('ccr.unfollow', opts) }, - clear_scroll: lazyLoad('./api/clear_scroll.js', opts), - clearScroll: lazyLoad('./api/clear_scroll.js', opts), + clear_scroll: lazyLoad('clear_scroll', opts), + clearScroll: lazyLoad('clear_scroll', opts), cluster: { - allocation_explain: lazyLoad('./api/cluster.allocation_explain.js', opts), - allocationExplain: lazyLoad('./api/cluster.allocation_explain.js', opts), - get_settings: lazyLoad('./api/cluster.get_settings.js', opts), - getSettings: lazyLoad('./api/cluster.get_settings.js', opts), - health: lazyLoad('./api/cluster.health.js', opts), - pending_tasks: lazyLoad('./api/cluster.pending_tasks.js', opts), - pendingTasks: lazyLoad('./api/cluster.pending_tasks.js', opts), - put_settings: lazyLoad('./api/cluster.put_settings.js', opts), - putSettings: lazyLoad('./api/cluster.put_settings.js', opts), - remote_info: lazyLoad('./api/cluster.remote_info.js', opts), - remoteInfo: lazyLoad('./api/cluster.remote_info.js', opts), - reroute: lazyLoad('./api/cluster.reroute.js', opts), - state: lazyLoad('./api/cluster.state.js', opts), - stats: lazyLoad('./api/cluster.stats.js', opts) + allocation_explain: lazyLoad('cluster.allocation_explain', opts), + allocationExplain: lazyLoad('cluster.allocation_explain', opts), + get_settings: lazyLoad('cluster.get_settings', opts), + getSettings: lazyLoad('cluster.get_settings', opts), + health: lazyLoad('cluster.health', opts), + pending_tasks: lazyLoad('cluster.pending_tasks', opts), + pendingTasks: lazyLoad('cluster.pending_tasks', opts), + put_settings: lazyLoad('cluster.put_settings', opts), + putSettings: lazyLoad('cluster.put_settings', opts), + remote_info: lazyLoad('cluster.remote_info', opts), + remoteInfo: lazyLoad('cluster.remote_info', opts), + reroute: lazyLoad('cluster.reroute', opts), + state: lazyLoad('cluster.state', opts), + stats: lazyLoad('cluster.stats', opts) }, - count: lazyLoad('./api/count.js', opts), - create: lazyLoad('./api/create.js', opts), - delete: lazyLoad('./api/delete.js', opts), - delete_by_query: lazyLoad('./api/delete_by_query.js', opts), - deleteByQuery: lazyLoad('./api/delete_by_query.js', opts), - delete_by_query_rethrottle: lazyLoad('./api/delete_by_query_rethrottle.js', opts), - deleteByQueryRethrottle: lazyLoad('./api/delete_by_query_rethrottle.js', opts), - delete_script: lazyLoad('./api/delete_script.js', opts), - deleteScript: lazyLoad('./api/delete_script.js', opts), - exists: lazyLoad('./api/exists.js', opts), - exists_source: lazyLoad('./api/exists_source.js', opts), - existsSource: lazyLoad('./api/exists_source.js', opts), - explain: lazyLoad('./api/explain.js', opts), - field_caps: lazyLoad('./api/field_caps.js', opts), - fieldCaps: lazyLoad('./api/field_caps.js', opts), - get: lazyLoad('./api/get.js', opts), - get_script: lazyLoad('./api/get_script.js', opts), - getScript: lazyLoad('./api/get_script.js', opts), - get_source: lazyLoad('./api/get_source.js', opts), - getSource: lazyLoad('./api/get_source.js', opts), + count: lazyLoad('count', opts), + create: lazyLoad('create', opts), + delete: lazyLoad('delete', opts), + delete_by_query: lazyLoad('delete_by_query', opts), + deleteByQuery: lazyLoad('delete_by_query', opts), + delete_by_query_rethrottle: lazyLoad('delete_by_query_rethrottle', opts), + deleteByQueryRethrottle: lazyLoad('delete_by_query_rethrottle', opts), + delete_script: lazyLoad('delete_script', opts), + deleteScript: lazyLoad('delete_script', opts), + exists: lazyLoad('exists', opts), + exists_source: lazyLoad('exists_source', opts), + existsSource: lazyLoad('exists_source', opts), + explain: lazyLoad('explain', opts), + field_caps: lazyLoad('field_caps', opts), + fieldCaps: lazyLoad('field_caps', opts), + get: lazyLoad('get', opts), + get_script: lazyLoad('get_script', opts), + getScript: lazyLoad('get_script', opts), + get_source: lazyLoad('get_source', opts), + getSource: lazyLoad('get_source', opts), ilm: { - delete_lifecycle: lazyLoad('./api/ilm.delete_lifecycle.js', opts), - deleteLifecycle: lazyLoad('./api/ilm.delete_lifecycle.js', opts), - explain_lifecycle: lazyLoad('./api/ilm.explain_lifecycle.js', opts), - explainLifecycle: lazyLoad('./api/ilm.explain_lifecycle.js', opts), - get_lifecycle: lazyLoad('./api/ilm.get_lifecycle.js', opts), - getLifecycle: lazyLoad('./api/ilm.get_lifecycle.js', opts), - get_status: lazyLoad('./api/ilm.get_status.js', opts), - getStatus: lazyLoad('./api/ilm.get_status.js', opts), - move_to_step: lazyLoad('./api/ilm.move_to_step.js', opts), - moveToStep: lazyLoad('./api/ilm.move_to_step.js', opts), - put_lifecycle: lazyLoad('./api/ilm.put_lifecycle.js', opts), - putLifecycle: lazyLoad('./api/ilm.put_lifecycle.js', opts), - remove_policy: lazyLoad('./api/ilm.remove_policy.js', opts), - removePolicy: lazyLoad('./api/ilm.remove_policy.js', opts), - retry: lazyLoad('./api/ilm.retry.js', opts), - start: lazyLoad('./api/ilm.start.js', opts), - stop: lazyLoad('./api/ilm.stop.js', opts) + delete_lifecycle: lazyLoad('ilm.delete_lifecycle', opts), + deleteLifecycle: lazyLoad('ilm.delete_lifecycle', opts), + explain_lifecycle: lazyLoad('ilm.explain_lifecycle', opts), + explainLifecycle: lazyLoad('ilm.explain_lifecycle', opts), + get_lifecycle: lazyLoad('ilm.get_lifecycle', opts), + getLifecycle: lazyLoad('ilm.get_lifecycle', opts), + get_status: lazyLoad('ilm.get_status', opts), + getStatus: lazyLoad('ilm.get_status', opts), + move_to_step: lazyLoad('ilm.move_to_step', opts), + moveToStep: lazyLoad('ilm.move_to_step', opts), + put_lifecycle: lazyLoad('ilm.put_lifecycle', opts), + putLifecycle: lazyLoad('ilm.put_lifecycle', opts), + remove_policy: lazyLoad('ilm.remove_policy', opts), + removePolicy: lazyLoad('ilm.remove_policy', opts), + retry: lazyLoad('ilm.retry', opts), + start: lazyLoad('ilm.start', opts), + stop: lazyLoad('ilm.stop', opts) }, - index: lazyLoad('./api/index.js', opts), + index: lazyLoad('index', opts), indices: { - analyze: lazyLoad('./api/indices.analyze.js', opts), - clear_cache: lazyLoad('./api/indices.clear_cache.js', opts), - clearCache: lazyLoad('./api/indices.clear_cache.js', opts), - close: lazyLoad('./api/indices.close.js', opts), - create: lazyLoad('./api/indices.create.js', opts), - delete: lazyLoad('./api/indices.delete.js', opts), - delete_alias: lazyLoad('./api/indices.delete_alias.js', opts), - deleteAlias: lazyLoad('./api/indices.delete_alias.js', opts), - delete_template: lazyLoad('./api/indices.delete_template.js', opts), - deleteTemplate: lazyLoad('./api/indices.delete_template.js', opts), - exists: lazyLoad('./api/indices.exists.js', opts), - exists_alias: lazyLoad('./api/indices.exists_alias.js', opts), - existsAlias: lazyLoad('./api/indices.exists_alias.js', opts), - exists_template: lazyLoad('./api/indices.exists_template.js', opts), - existsTemplate: lazyLoad('./api/indices.exists_template.js', opts), - exists_type: lazyLoad('./api/indices.exists_type.js', opts), - existsType: lazyLoad('./api/indices.exists_type.js', opts), - flush: lazyLoad('./api/indices.flush.js', opts), - flush_synced: lazyLoad('./api/indices.flush_synced.js', opts), - flushSynced: lazyLoad('./api/indices.flush_synced.js', opts), - forcemerge: lazyLoad('./api/indices.forcemerge.js', opts), - freeze: lazyLoad('./api/indices.freeze.js', opts), - get: lazyLoad('./api/indices.get.js', opts), - get_alias: lazyLoad('./api/indices.get_alias.js', opts), - getAlias: lazyLoad('./api/indices.get_alias.js', opts), - get_field_mapping: lazyLoad('./api/indices.get_field_mapping.js', opts), - getFieldMapping: lazyLoad('./api/indices.get_field_mapping.js', opts), - get_mapping: lazyLoad('./api/indices.get_mapping.js', opts), - getMapping: lazyLoad('./api/indices.get_mapping.js', opts), - get_settings: lazyLoad('./api/indices.get_settings.js', opts), - getSettings: lazyLoad('./api/indices.get_settings.js', opts), - get_template: lazyLoad('./api/indices.get_template.js', opts), - getTemplate: lazyLoad('./api/indices.get_template.js', opts), - get_upgrade: lazyLoad('./api/indices.get_upgrade.js', opts), - getUpgrade: lazyLoad('./api/indices.get_upgrade.js', opts), - open: lazyLoad('./api/indices.open.js', opts), - put_alias: lazyLoad('./api/indices.put_alias.js', opts), - putAlias: lazyLoad('./api/indices.put_alias.js', opts), - put_mapping: lazyLoad('./api/indices.put_mapping.js', opts), - putMapping: lazyLoad('./api/indices.put_mapping.js', opts), - put_settings: lazyLoad('./api/indices.put_settings.js', opts), - putSettings: lazyLoad('./api/indices.put_settings.js', opts), - put_template: lazyLoad('./api/indices.put_template.js', opts), - putTemplate: lazyLoad('./api/indices.put_template.js', opts), - recovery: lazyLoad('./api/indices.recovery.js', opts), - refresh: lazyLoad('./api/indices.refresh.js', opts), - rollover: lazyLoad('./api/indices.rollover.js', opts), - segments: lazyLoad('./api/indices.segments.js', opts), - shard_stores: lazyLoad('./api/indices.shard_stores.js', opts), - shardStores: lazyLoad('./api/indices.shard_stores.js', opts), - shrink: lazyLoad('./api/indices.shrink.js', opts), - split: lazyLoad('./api/indices.split.js', opts), - stats: lazyLoad('./api/indices.stats.js', opts), - unfreeze: lazyLoad('./api/indices.unfreeze.js', opts), - update_aliases: lazyLoad('./api/indices.update_aliases.js', opts), - updateAliases: lazyLoad('./api/indices.update_aliases.js', opts), - upgrade: lazyLoad('./api/indices.upgrade.js', opts), - validate_query: lazyLoad('./api/indices.validate_query.js', opts), - validateQuery: lazyLoad('./api/indices.validate_query.js', opts) + analyze: lazyLoad('indices.analyze', opts), + clear_cache: lazyLoad('indices.clear_cache', opts), + clearCache: lazyLoad('indices.clear_cache', opts), + close: lazyLoad('indices.close', opts), + create: lazyLoad('indices.create', opts), + delete: lazyLoad('indices.delete', opts), + delete_alias: lazyLoad('indices.delete_alias', opts), + deleteAlias: lazyLoad('indices.delete_alias', opts), + delete_template: lazyLoad('indices.delete_template', opts), + deleteTemplate: lazyLoad('indices.delete_template', opts), + exists: lazyLoad('indices.exists', opts), + exists_alias: lazyLoad('indices.exists_alias', opts), + existsAlias: lazyLoad('indices.exists_alias', opts), + exists_template: lazyLoad('indices.exists_template', opts), + existsTemplate: lazyLoad('indices.exists_template', opts), + exists_type: lazyLoad('indices.exists_type', opts), + existsType: lazyLoad('indices.exists_type', opts), + flush: lazyLoad('indices.flush', opts), + flush_synced: lazyLoad('indices.flush_synced', opts), + flushSynced: lazyLoad('indices.flush_synced', opts), + forcemerge: lazyLoad('indices.forcemerge', opts), + freeze: lazyLoad('indices.freeze', opts), + get: lazyLoad('indices.get', opts), + get_alias: lazyLoad('indices.get_alias', opts), + getAlias: lazyLoad('indices.get_alias', opts), + get_field_mapping: lazyLoad('indices.get_field_mapping', opts), + getFieldMapping: lazyLoad('indices.get_field_mapping', opts), + get_mapping: lazyLoad('indices.get_mapping', opts), + getMapping: lazyLoad('indices.get_mapping', opts), + get_settings: lazyLoad('indices.get_settings', opts), + getSettings: lazyLoad('indices.get_settings', opts), + get_template: lazyLoad('indices.get_template', opts), + getTemplate: lazyLoad('indices.get_template', opts), + get_upgrade: lazyLoad('indices.get_upgrade', opts), + getUpgrade: lazyLoad('indices.get_upgrade', opts), + open: lazyLoad('indices.open', opts), + put_alias: lazyLoad('indices.put_alias', opts), + putAlias: lazyLoad('indices.put_alias', opts), + put_mapping: lazyLoad('indices.put_mapping', opts), + putMapping: lazyLoad('indices.put_mapping', opts), + put_settings: lazyLoad('indices.put_settings', opts), + putSettings: lazyLoad('indices.put_settings', opts), + put_template: lazyLoad('indices.put_template', opts), + putTemplate: lazyLoad('indices.put_template', opts), + recovery: lazyLoad('indices.recovery', opts), + refresh: lazyLoad('indices.refresh', opts), + rollover: lazyLoad('indices.rollover', opts), + segments: lazyLoad('indices.segments', opts), + shard_stores: lazyLoad('indices.shard_stores', opts), + shardStores: lazyLoad('indices.shard_stores', opts), + shrink: lazyLoad('indices.shrink', opts), + split: lazyLoad('indices.split', opts), + stats: lazyLoad('indices.stats', opts), + unfreeze: lazyLoad('indices.unfreeze', opts), + update_aliases: lazyLoad('indices.update_aliases', opts), + updateAliases: lazyLoad('indices.update_aliases', opts), + upgrade: lazyLoad('indices.upgrade', opts), + validate_query: lazyLoad('indices.validate_query', opts), + validateQuery: lazyLoad('indices.validate_query', opts) }, - info: lazyLoad('./api/info.js', opts), + info: lazyLoad('info', opts), ingest: { - delete_pipeline: lazyLoad('./api/ingest.delete_pipeline.js', opts), - deletePipeline: lazyLoad('./api/ingest.delete_pipeline.js', opts), - get_pipeline: lazyLoad('./api/ingest.get_pipeline.js', opts), - getPipeline: lazyLoad('./api/ingest.get_pipeline.js', opts), - processor_grok: lazyLoad('./api/ingest.processor_grok.js', opts), - processorGrok: lazyLoad('./api/ingest.processor_grok.js', opts), - put_pipeline: lazyLoad('./api/ingest.put_pipeline.js', opts), - putPipeline: lazyLoad('./api/ingest.put_pipeline.js', opts), - simulate: lazyLoad('./api/ingest.simulate.js', opts) + delete_pipeline: lazyLoad('ingest.delete_pipeline', opts), + deletePipeline: lazyLoad('ingest.delete_pipeline', opts), + get_pipeline: lazyLoad('ingest.get_pipeline', opts), + getPipeline: lazyLoad('ingest.get_pipeline', opts), + processor_grok: lazyLoad('ingest.processor_grok', opts), + processorGrok: lazyLoad('ingest.processor_grok', opts), + put_pipeline: lazyLoad('ingest.put_pipeline', opts), + putPipeline: lazyLoad('ingest.put_pipeline', opts), + simulate: lazyLoad('ingest.simulate', opts) }, - mget: lazyLoad('./api/mget.js', opts), + mget: lazyLoad('mget', opts), ml: { - close_job: lazyLoad('./api/ml.close_job.js', opts), - closeJob: lazyLoad('./api/ml.close_job.js', opts), - delete_calendar: lazyLoad('./api/ml.delete_calendar.js', opts), - deleteCalendar: lazyLoad('./api/ml.delete_calendar.js', opts), - delete_calendar_event: lazyLoad('./api/ml.delete_calendar_event.js', opts), - deleteCalendarEvent: lazyLoad('./api/ml.delete_calendar_event.js', opts), - delete_calendar_job: lazyLoad('./api/ml.delete_calendar_job.js', opts), - deleteCalendarJob: lazyLoad('./api/ml.delete_calendar_job.js', opts), - delete_datafeed: lazyLoad('./api/ml.delete_datafeed.js', opts), - deleteDatafeed: lazyLoad('./api/ml.delete_datafeed.js', opts), - delete_expired_data: lazyLoad('./api/ml.delete_expired_data.js', opts), - deleteExpiredData: lazyLoad('./api/ml.delete_expired_data.js', opts), - delete_filter: lazyLoad('./api/ml.delete_filter.js', opts), - deleteFilter: lazyLoad('./api/ml.delete_filter.js', opts), - delete_forecast: lazyLoad('./api/ml.delete_forecast.js', opts), - deleteForecast: lazyLoad('./api/ml.delete_forecast.js', opts), - delete_job: lazyLoad('./api/ml.delete_job.js', opts), - deleteJob: lazyLoad('./api/ml.delete_job.js', opts), - delete_model_snapshot: lazyLoad('./api/ml.delete_model_snapshot.js', opts), - deleteModelSnapshot: lazyLoad('./api/ml.delete_model_snapshot.js', opts), - find_file_structure: lazyLoad('./api/ml.find_file_structure.js', opts), - findFileStructure: lazyLoad('./api/ml.find_file_structure.js', opts), - flush_job: lazyLoad('./api/ml.flush_job.js', opts), - flushJob: lazyLoad('./api/ml.flush_job.js', opts), - forecast: lazyLoad('./api/ml.forecast.js', opts), - get_buckets: lazyLoad('./api/ml.get_buckets.js', opts), - getBuckets: lazyLoad('./api/ml.get_buckets.js', opts), - get_calendar_events: lazyLoad('./api/ml.get_calendar_events.js', opts), - getCalendarEvents: lazyLoad('./api/ml.get_calendar_events.js', opts), - get_calendars: lazyLoad('./api/ml.get_calendars.js', opts), - getCalendars: lazyLoad('./api/ml.get_calendars.js', opts), - get_categories: lazyLoad('./api/ml.get_categories.js', opts), - getCategories: lazyLoad('./api/ml.get_categories.js', opts), - get_datafeed_stats: lazyLoad('./api/ml.get_datafeed_stats.js', opts), - getDatafeedStats: lazyLoad('./api/ml.get_datafeed_stats.js', opts), - get_datafeeds: lazyLoad('./api/ml.get_datafeeds.js', opts), - getDatafeeds: lazyLoad('./api/ml.get_datafeeds.js', opts), - get_filters: lazyLoad('./api/ml.get_filters.js', opts), - getFilters: lazyLoad('./api/ml.get_filters.js', opts), - get_influencers: lazyLoad('./api/ml.get_influencers.js', opts), - getInfluencers: lazyLoad('./api/ml.get_influencers.js', opts), - get_job_stats: lazyLoad('./api/ml.get_job_stats.js', opts), - getJobStats: lazyLoad('./api/ml.get_job_stats.js', opts), - get_jobs: lazyLoad('./api/ml.get_jobs.js', opts), - getJobs: lazyLoad('./api/ml.get_jobs.js', opts), - get_model_snapshots: lazyLoad('./api/ml.get_model_snapshots.js', opts), - getModelSnapshots: lazyLoad('./api/ml.get_model_snapshots.js', opts), - get_overall_buckets: lazyLoad('./api/ml.get_overall_buckets.js', opts), - getOverallBuckets: lazyLoad('./api/ml.get_overall_buckets.js', opts), - get_records: lazyLoad('./api/ml.get_records.js', opts), - getRecords: lazyLoad('./api/ml.get_records.js', opts), - info: lazyLoad('./api/ml.info.js', opts), - open_job: lazyLoad('./api/ml.open_job.js', opts), - openJob: lazyLoad('./api/ml.open_job.js', opts), - post_calendar_events: lazyLoad('./api/ml.post_calendar_events.js', opts), - postCalendarEvents: lazyLoad('./api/ml.post_calendar_events.js', opts), - post_data: lazyLoad('./api/ml.post_data.js', opts), - postData: lazyLoad('./api/ml.post_data.js', opts), - preview_datafeed: lazyLoad('./api/ml.preview_datafeed.js', opts), - previewDatafeed: lazyLoad('./api/ml.preview_datafeed.js', opts), - put_calendar: lazyLoad('./api/ml.put_calendar.js', opts), - putCalendar: lazyLoad('./api/ml.put_calendar.js', opts), - put_calendar_job: lazyLoad('./api/ml.put_calendar_job.js', opts), - putCalendarJob: lazyLoad('./api/ml.put_calendar_job.js', opts), - put_datafeed: lazyLoad('./api/ml.put_datafeed.js', opts), - putDatafeed: lazyLoad('./api/ml.put_datafeed.js', opts), - put_filter: lazyLoad('./api/ml.put_filter.js', opts), - putFilter: lazyLoad('./api/ml.put_filter.js', opts), - put_job: lazyLoad('./api/ml.put_job.js', opts), - putJob: lazyLoad('./api/ml.put_job.js', opts), - revert_model_snapshot: lazyLoad('./api/ml.revert_model_snapshot.js', opts), - revertModelSnapshot: lazyLoad('./api/ml.revert_model_snapshot.js', opts), - set_upgrade_mode: lazyLoad('./api/ml.set_upgrade_mode.js', opts), - setUpgradeMode: lazyLoad('./api/ml.set_upgrade_mode.js', opts), - start_datafeed: lazyLoad('./api/ml.start_datafeed.js', opts), - startDatafeed: lazyLoad('./api/ml.start_datafeed.js', opts), - stop_datafeed: lazyLoad('./api/ml.stop_datafeed.js', opts), - stopDatafeed: lazyLoad('./api/ml.stop_datafeed.js', opts), - update_datafeed: lazyLoad('./api/ml.update_datafeed.js', opts), - updateDatafeed: lazyLoad('./api/ml.update_datafeed.js', opts), - update_filter: lazyLoad('./api/ml.update_filter.js', opts), - updateFilter: lazyLoad('./api/ml.update_filter.js', opts), - update_job: lazyLoad('./api/ml.update_job.js', opts), - updateJob: lazyLoad('./api/ml.update_job.js', opts), - update_model_snapshot: lazyLoad('./api/ml.update_model_snapshot.js', opts), - updateModelSnapshot: lazyLoad('./api/ml.update_model_snapshot.js', opts), - validate: lazyLoad('./api/ml.validate.js', opts), - validate_detector: lazyLoad('./api/ml.validate_detector.js', opts), - validateDetector: lazyLoad('./api/ml.validate_detector.js', opts) + close_job: lazyLoad('ml.close_job', opts), + closeJob: lazyLoad('ml.close_job', opts), + delete_calendar: lazyLoad('ml.delete_calendar', opts), + deleteCalendar: lazyLoad('ml.delete_calendar', opts), + delete_calendar_event: lazyLoad('ml.delete_calendar_event', opts), + deleteCalendarEvent: lazyLoad('ml.delete_calendar_event', opts), + delete_calendar_job: lazyLoad('ml.delete_calendar_job', opts), + deleteCalendarJob: lazyLoad('ml.delete_calendar_job', opts), + delete_datafeed: lazyLoad('ml.delete_datafeed', opts), + deleteDatafeed: lazyLoad('ml.delete_datafeed', opts), + delete_expired_data: lazyLoad('ml.delete_expired_data', opts), + deleteExpiredData: lazyLoad('ml.delete_expired_data', opts), + delete_filter: lazyLoad('ml.delete_filter', opts), + deleteFilter: lazyLoad('ml.delete_filter', opts), + delete_forecast: lazyLoad('ml.delete_forecast', opts), + deleteForecast: lazyLoad('ml.delete_forecast', opts), + delete_job: lazyLoad('ml.delete_job', opts), + deleteJob: lazyLoad('ml.delete_job', opts), + delete_model_snapshot: lazyLoad('ml.delete_model_snapshot', opts), + deleteModelSnapshot: lazyLoad('ml.delete_model_snapshot', opts), + find_file_structure: lazyLoad('ml.find_file_structure', opts), + findFileStructure: lazyLoad('ml.find_file_structure', opts), + flush_job: lazyLoad('ml.flush_job', opts), + flushJob: lazyLoad('ml.flush_job', opts), + forecast: lazyLoad('ml.forecast', opts), + get_buckets: lazyLoad('ml.get_buckets', opts), + getBuckets: lazyLoad('ml.get_buckets', opts), + get_calendar_events: lazyLoad('ml.get_calendar_events', opts), + getCalendarEvents: lazyLoad('ml.get_calendar_events', opts), + get_calendars: lazyLoad('ml.get_calendars', opts), + getCalendars: lazyLoad('ml.get_calendars', opts), + get_categories: lazyLoad('ml.get_categories', opts), + getCategories: lazyLoad('ml.get_categories', opts), + get_datafeed_stats: lazyLoad('ml.get_datafeed_stats', opts), + getDatafeedStats: lazyLoad('ml.get_datafeed_stats', opts), + get_datafeeds: lazyLoad('ml.get_datafeeds', opts), + getDatafeeds: lazyLoad('ml.get_datafeeds', opts), + get_filters: lazyLoad('ml.get_filters', opts), + getFilters: lazyLoad('ml.get_filters', opts), + get_influencers: lazyLoad('ml.get_influencers', opts), + getInfluencers: lazyLoad('ml.get_influencers', opts), + get_job_stats: lazyLoad('ml.get_job_stats', opts), + getJobStats: lazyLoad('ml.get_job_stats', opts), + get_jobs: lazyLoad('ml.get_jobs', opts), + getJobs: lazyLoad('ml.get_jobs', opts), + get_model_snapshots: lazyLoad('ml.get_model_snapshots', opts), + getModelSnapshots: lazyLoad('ml.get_model_snapshots', opts), + get_overall_buckets: lazyLoad('ml.get_overall_buckets', opts), + getOverallBuckets: lazyLoad('ml.get_overall_buckets', opts), + get_records: lazyLoad('ml.get_records', opts), + getRecords: lazyLoad('ml.get_records', opts), + info: lazyLoad('ml.info', opts), + open_job: lazyLoad('ml.open_job', opts), + openJob: lazyLoad('ml.open_job', opts), + post_calendar_events: lazyLoad('ml.post_calendar_events', opts), + postCalendarEvents: lazyLoad('ml.post_calendar_events', opts), + post_data: lazyLoad('ml.post_data', opts), + postData: lazyLoad('ml.post_data', opts), + preview_datafeed: lazyLoad('ml.preview_datafeed', opts), + previewDatafeed: lazyLoad('ml.preview_datafeed', opts), + put_calendar: lazyLoad('ml.put_calendar', opts), + putCalendar: lazyLoad('ml.put_calendar', opts), + put_calendar_job: lazyLoad('ml.put_calendar_job', opts), + putCalendarJob: lazyLoad('ml.put_calendar_job', opts), + put_datafeed: lazyLoad('ml.put_datafeed', opts), + putDatafeed: lazyLoad('ml.put_datafeed', opts), + put_filter: lazyLoad('ml.put_filter', opts), + putFilter: lazyLoad('ml.put_filter', opts), + put_job: lazyLoad('ml.put_job', opts), + putJob: lazyLoad('ml.put_job', opts), + revert_model_snapshot: lazyLoad('ml.revert_model_snapshot', opts), + revertModelSnapshot: lazyLoad('ml.revert_model_snapshot', opts), + set_upgrade_mode: lazyLoad('ml.set_upgrade_mode', opts), + setUpgradeMode: lazyLoad('ml.set_upgrade_mode', opts), + start_datafeed: lazyLoad('ml.start_datafeed', opts), + startDatafeed: lazyLoad('ml.start_datafeed', opts), + stop_datafeed: lazyLoad('ml.stop_datafeed', opts), + stopDatafeed: lazyLoad('ml.stop_datafeed', opts), + update_datafeed: lazyLoad('ml.update_datafeed', opts), + updateDatafeed: lazyLoad('ml.update_datafeed', opts), + update_filter: lazyLoad('ml.update_filter', opts), + updateFilter: lazyLoad('ml.update_filter', opts), + update_job: lazyLoad('ml.update_job', opts), + updateJob: lazyLoad('ml.update_job', opts), + update_model_snapshot: lazyLoad('ml.update_model_snapshot', opts), + updateModelSnapshot: lazyLoad('ml.update_model_snapshot', opts), + validate: lazyLoad('ml.validate', opts), + validate_detector: lazyLoad('ml.validate_detector', opts), + validateDetector: lazyLoad('ml.validate_detector', opts) }, monitoring: { - bulk: lazyLoad('./api/monitoring.bulk.js', opts) + bulk: lazyLoad('monitoring.bulk', opts) }, - msearch: lazyLoad('./api/msearch.js', opts), - msearch_template: lazyLoad('./api/msearch_template.js', opts), - msearchTemplate: lazyLoad('./api/msearch_template.js', opts), - mtermvectors: lazyLoad('./api/mtermvectors.js', opts), + msearch: lazyLoad('msearch', opts), + msearch_template: lazyLoad('msearch_template', opts), + msearchTemplate: lazyLoad('msearch_template', opts), + mtermvectors: lazyLoad('mtermvectors', opts), nodes: { - hot_threads: lazyLoad('./api/nodes.hot_threads.js', opts), - hotThreads: lazyLoad('./api/nodes.hot_threads.js', opts), - info: lazyLoad('./api/nodes.info.js', opts), - reload_secure_settings: lazyLoad('./api/nodes.reload_secure_settings.js', opts), - reloadSecureSettings: lazyLoad('./api/nodes.reload_secure_settings.js', opts), - stats: lazyLoad('./api/nodes.stats.js', opts), - usage: lazyLoad('./api/nodes.usage.js', opts) + hot_threads: lazyLoad('nodes.hot_threads', opts), + hotThreads: lazyLoad('nodes.hot_threads', opts), + info: lazyLoad('nodes.info', opts), + reload_secure_settings: lazyLoad('nodes.reload_secure_settings', opts), + reloadSecureSettings: lazyLoad('nodes.reload_secure_settings', opts), + stats: lazyLoad('nodes.stats', opts), + usage: lazyLoad('nodes.usage', opts) }, - ping: lazyLoad('./api/ping.js', opts), - put_script: lazyLoad('./api/put_script.js', opts), - putScript: lazyLoad('./api/put_script.js', opts), - rank_eval: lazyLoad('./api/rank_eval.js', opts), - rankEval: lazyLoad('./api/rank_eval.js', opts), - reindex: lazyLoad('./api/reindex.js', opts), - reindex_rethrottle: lazyLoad('./api/reindex_rethrottle.js', opts), - reindexRethrottle: lazyLoad('./api/reindex_rethrottle.js', opts), - render_search_template: lazyLoad('./api/render_search_template.js', opts), - renderSearchTemplate: lazyLoad('./api/render_search_template.js', opts), - scripts_painless_execute: lazyLoad('./api/scripts_painless_execute.js', opts), - scriptsPainlessExecute: lazyLoad('./api/scripts_painless_execute.js', opts), - scroll: lazyLoad('./api/scroll.js', opts), - search: lazyLoad('./api/search.js', opts), - search_shards: lazyLoad('./api/search_shards.js', opts), - searchShards: lazyLoad('./api/search_shards.js', opts), - search_template: lazyLoad('./api/search_template.js', opts), - searchTemplate: lazyLoad('./api/search_template.js', opts), + ping: lazyLoad('ping', opts), + put_script: lazyLoad('put_script', opts), + putScript: lazyLoad('put_script', opts), + rank_eval: lazyLoad('rank_eval', opts), + rankEval: lazyLoad('rank_eval', opts), + reindex: lazyLoad('reindex', opts), + reindex_rethrottle: lazyLoad('reindex_rethrottle', opts), + reindexRethrottle: lazyLoad('reindex_rethrottle', opts), + render_search_template: lazyLoad('render_search_template', opts), + renderSearchTemplate: lazyLoad('render_search_template', opts), + scripts_painless_execute: lazyLoad('scripts_painless_execute', opts), + scriptsPainlessExecute: lazyLoad('scripts_painless_execute', opts), + scroll: lazyLoad('scroll', opts), + search: lazyLoad('search', opts), + search_shards: lazyLoad('search_shards', opts), + searchShards: lazyLoad('search_shards', opts), + search_template: lazyLoad('search_template', opts), + searchTemplate: lazyLoad('search_template', opts), security: { - authenticate: lazyLoad('./api/security.authenticate.js', opts), - change_password: lazyLoad('./api/security.change_password.js', opts), - changePassword: lazyLoad('./api/security.change_password.js', opts), - clear_cached_realms: lazyLoad('./api/security.clear_cached_realms.js', opts), - clearCachedRealms: lazyLoad('./api/security.clear_cached_realms.js', opts), - clear_cached_roles: lazyLoad('./api/security.clear_cached_roles.js', opts), - clearCachedRoles: lazyLoad('./api/security.clear_cached_roles.js', opts), - create_api_key: lazyLoad('./api/security.create_api_key.js', opts), - createApiKey: lazyLoad('./api/security.create_api_key.js', opts), - delete_privileges: lazyLoad('./api/security.delete_privileges.js', opts), - deletePrivileges: lazyLoad('./api/security.delete_privileges.js', opts), - delete_role: lazyLoad('./api/security.delete_role.js', opts), - deleteRole: lazyLoad('./api/security.delete_role.js', opts), - delete_role_mapping: lazyLoad('./api/security.delete_role_mapping.js', opts), - deleteRoleMapping: lazyLoad('./api/security.delete_role_mapping.js', opts), - delete_user: lazyLoad('./api/security.delete_user.js', opts), - deleteUser: lazyLoad('./api/security.delete_user.js', opts), - disable_user: lazyLoad('./api/security.disable_user.js', opts), - disableUser: lazyLoad('./api/security.disable_user.js', opts), - enable_user: lazyLoad('./api/security.enable_user.js', opts), - enableUser: lazyLoad('./api/security.enable_user.js', opts), - get_api_key: lazyLoad('./api/security.get_api_key.js', opts), - getApiKey: lazyLoad('./api/security.get_api_key.js', opts), - get_privileges: lazyLoad('./api/security.get_privileges.js', opts), - getPrivileges: lazyLoad('./api/security.get_privileges.js', opts), - get_role: lazyLoad('./api/security.get_role.js', opts), - getRole: lazyLoad('./api/security.get_role.js', opts), - get_role_mapping: lazyLoad('./api/security.get_role_mapping.js', opts), - getRoleMapping: lazyLoad('./api/security.get_role_mapping.js', opts), - get_token: lazyLoad('./api/security.get_token.js', opts), - getToken: lazyLoad('./api/security.get_token.js', opts), - get_user: lazyLoad('./api/security.get_user.js', opts), - getUser: lazyLoad('./api/security.get_user.js', opts), - get_user_privileges: lazyLoad('./api/security.get_user_privileges.js', opts), - getUserPrivileges: lazyLoad('./api/security.get_user_privileges.js', opts), - has_privileges: lazyLoad('./api/security.has_privileges.js', opts), - hasPrivileges: lazyLoad('./api/security.has_privileges.js', opts), - invalidate_api_key: lazyLoad('./api/security.invalidate_api_key.js', opts), - invalidateApiKey: lazyLoad('./api/security.invalidate_api_key.js', opts), - invalidate_token: lazyLoad('./api/security.invalidate_token.js', opts), - invalidateToken: lazyLoad('./api/security.invalidate_token.js', opts), - put_privileges: lazyLoad('./api/security.put_privileges.js', opts), - putPrivileges: lazyLoad('./api/security.put_privileges.js', opts), - put_role: lazyLoad('./api/security.put_role.js', opts), - putRole: lazyLoad('./api/security.put_role.js', opts), - put_role_mapping: lazyLoad('./api/security.put_role_mapping.js', opts), - putRoleMapping: lazyLoad('./api/security.put_role_mapping.js', opts), - put_user: lazyLoad('./api/security.put_user.js', opts), - putUser: lazyLoad('./api/security.put_user.js', opts) + authenticate: lazyLoad('security.authenticate', opts), + change_password: lazyLoad('security.change_password', opts), + changePassword: lazyLoad('security.change_password', opts), + clear_cached_realms: lazyLoad('security.clear_cached_realms', opts), + clearCachedRealms: lazyLoad('security.clear_cached_realms', opts), + clear_cached_roles: lazyLoad('security.clear_cached_roles', opts), + clearCachedRoles: lazyLoad('security.clear_cached_roles', opts), + create_api_key: lazyLoad('security.create_api_key', opts), + createApiKey: lazyLoad('security.create_api_key', opts), + delete_privileges: lazyLoad('security.delete_privileges', opts), + deletePrivileges: lazyLoad('security.delete_privileges', opts), + delete_role: lazyLoad('security.delete_role', opts), + deleteRole: lazyLoad('security.delete_role', opts), + delete_role_mapping: lazyLoad('security.delete_role_mapping', opts), + deleteRoleMapping: lazyLoad('security.delete_role_mapping', opts), + delete_user: lazyLoad('security.delete_user', opts), + deleteUser: lazyLoad('security.delete_user', opts), + disable_user: lazyLoad('security.disable_user', opts), + disableUser: lazyLoad('security.disable_user', opts), + enable_user: lazyLoad('security.enable_user', opts), + enableUser: lazyLoad('security.enable_user', opts), + get_api_key: lazyLoad('security.get_api_key', opts), + getApiKey: lazyLoad('security.get_api_key', opts), + get_privileges: lazyLoad('security.get_privileges', opts), + getPrivileges: lazyLoad('security.get_privileges', opts), + get_role: lazyLoad('security.get_role', opts), + getRole: lazyLoad('security.get_role', opts), + get_role_mapping: lazyLoad('security.get_role_mapping', opts), + getRoleMapping: lazyLoad('security.get_role_mapping', opts), + get_token: lazyLoad('security.get_token', opts), + getToken: lazyLoad('security.get_token', opts), + get_user: lazyLoad('security.get_user', opts), + getUser: lazyLoad('security.get_user', opts), + get_user_privileges: lazyLoad('security.get_user_privileges', opts), + getUserPrivileges: lazyLoad('security.get_user_privileges', opts), + has_privileges: lazyLoad('security.has_privileges', opts), + hasPrivileges: lazyLoad('security.has_privileges', opts), + invalidate_api_key: lazyLoad('security.invalidate_api_key', opts), + invalidateApiKey: lazyLoad('security.invalidate_api_key', opts), + invalidate_token: lazyLoad('security.invalidate_token', opts), + invalidateToken: lazyLoad('security.invalidate_token', opts), + put_privileges: lazyLoad('security.put_privileges', opts), + putPrivileges: lazyLoad('security.put_privileges', opts), + put_role: lazyLoad('security.put_role', opts), + putRole: lazyLoad('security.put_role', opts), + put_role_mapping: lazyLoad('security.put_role_mapping', opts), + putRoleMapping: lazyLoad('security.put_role_mapping', opts), + put_user: lazyLoad('security.put_user', opts), + putUser: lazyLoad('security.put_user', opts) }, snapshot: { - create: lazyLoad('./api/snapshot.create.js', opts), - create_repository: lazyLoad('./api/snapshot.create_repository.js', opts), - createRepository: lazyLoad('./api/snapshot.create_repository.js', opts), - delete: lazyLoad('./api/snapshot.delete.js', opts), - delete_repository: lazyLoad('./api/snapshot.delete_repository.js', opts), - deleteRepository: lazyLoad('./api/snapshot.delete_repository.js', opts), - get: lazyLoad('./api/snapshot.get.js', opts), - get_repository: lazyLoad('./api/snapshot.get_repository.js', opts), - getRepository: lazyLoad('./api/snapshot.get_repository.js', opts), - restore: lazyLoad('./api/snapshot.restore.js', opts), - status: lazyLoad('./api/snapshot.status.js', opts), - verify_repository: lazyLoad('./api/snapshot.verify_repository.js', opts), - verifyRepository: lazyLoad('./api/snapshot.verify_repository.js', opts) + create: lazyLoad('snapshot.create', opts), + create_repository: lazyLoad('snapshot.create_repository', opts), + createRepository: lazyLoad('snapshot.create_repository', opts), + delete: lazyLoad('snapshot.delete', opts), + delete_repository: lazyLoad('snapshot.delete_repository', opts), + deleteRepository: lazyLoad('snapshot.delete_repository', opts), + get: lazyLoad('snapshot.get', opts), + get_repository: lazyLoad('snapshot.get_repository', opts), + getRepository: lazyLoad('snapshot.get_repository', opts), + restore: lazyLoad('snapshot.restore', opts), + status: lazyLoad('snapshot.status', opts), + verify_repository: lazyLoad('snapshot.verify_repository', opts), + verifyRepository: lazyLoad('snapshot.verify_repository', opts) }, ssl: { - certificates: lazyLoad('./api/ssl.certificates.js', opts) + certificates: lazyLoad('ssl.certificates', opts) }, tasks: { - cancel: lazyLoad('./api/tasks.cancel.js', opts), - get: lazyLoad('./api/tasks.get.js', opts), - list: lazyLoad('./api/tasks.list.js', opts) + cancel: lazyLoad('tasks.cancel', opts), + get: lazyLoad('tasks.get', opts), + list: lazyLoad('tasks.list', opts) }, - termvectors: lazyLoad('./api/termvectors.js', opts), - update: lazyLoad('./api/update.js', opts), - update_by_query: lazyLoad('./api/update_by_query.js', opts), - updateByQuery: lazyLoad('./api/update_by_query.js', opts), - update_by_query_rethrottle: lazyLoad('./api/update_by_query_rethrottle.js', opts), - updateByQueryRethrottle: lazyLoad('./api/update_by_query_rethrottle.js', opts), + termvectors: lazyLoad('termvectors', opts), + update: lazyLoad('update', opts), + update_by_query: lazyLoad('update_by_query', opts), + updateByQuery: lazyLoad('update_by_query', opts), + update_by_query_rethrottle: lazyLoad('update_by_query_rethrottle', opts), + updateByQueryRethrottle: lazyLoad('update_by_query_rethrottle', opts), xpack: { graph: { - explore: lazyLoad('./api/xpack.graph.explore.js', opts) + explore: lazyLoad('xpack.graph.explore', opts) }, - info: lazyLoad('./api/xpack.info.js', opts), + info: lazyLoad('xpack.info', opts), license: { - delete: lazyLoad('./api/xpack.license.delete.js', opts), - get: lazyLoad('./api/xpack.license.get.js', opts), - get_basic_status: lazyLoad('./api/xpack.license.get_basic_status.js', opts), - getBasicStatus: lazyLoad('./api/xpack.license.get_basic_status.js', opts), - get_trial_status: lazyLoad('./api/xpack.license.get_trial_status.js', opts), - getTrialStatus: lazyLoad('./api/xpack.license.get_trial_status.js', opts), - post: lazyLoad('./api/xpack.license.post.js', opts), - post_start_basic: lazyLoad('./api/xpack.license.post_start_basic.js', opts), - postStartBasic: lazyLoad('./api/xpack.license.post_start_basic.js', opts), - post_start_trial: lazyLoad('./api/xpack.license.post_start_trial.js', opts), - postStartTrial: lazyLoad('./api/xpack.license.post_start_trial.js', opts) + delete: lazyLoad('xpack.license.delete', opts), + get: lazyLoad('xpack.license.get', opts), + get_basic_status: lazyLoad('xpack.license.get_basic_status', opts), + getBasicStatus: lazyLoad('xpack.license.get_basic_status', opts), + get_trial_status: lazyLoad('xpack.license.get_trial_status', opts), + getTrialStatus: lazyLoad('xpack.license.get_trial_status', opts), + post: lazyLoad('xpack.license.post', opts), + post_start_basic: lazyLoad('xpack.license.post_start_basic', opts), + postStartBasic: lazyLoad('xpack.license.post_start_basic', opts), + post_start_trial: lazyLoad('xpack.license.post_start_trial', opts), + postStartTrial: lazyLoad('xpack.license.post_start_trial', opts) }, migration: { - deprecations: lazyLoad('./api/xpack.migration.deprecations.js', opts), - get_assistance: lazyLoad('./api/xpack.migration.get_assistance.js', opts), - getAssistance: lazyLoad('./api/xpack.migration.get_assistance.js', opts), - upgrade: lazyLoad('./api/xpack.migration.upgrade.js', opts) + deprecations: lazyLoad('xpack.migration.deprecations', opts), + get_assistance: lazyLoad('xpack.migration.get_assistance', opts), + getAssistance: lazyLoad('xpack.migration.get_assistance', opts), + upgrade: lazyLoad('xpack.migration.upgrade', opts) }, rollup: { - delete_job: lazyLoad('./api/xpack.rollup.delete_job.js', opts), - deleteJob: lazyLoad('./api/xpack.rollup.delete_job.js', opts), - get_jobs: lazyLoad('./api/xpack.rollup.get_jobs.js', opts), - getJobs: lazyLoad('./api/xpack.rollup.get_jobs.js', opts), - get_rollup_caps: lazyLoad('./api/xpack.rollup.get_rollup_caps.js', opts), - getRollupCaps: lazyLoad('./api/xpack.rollup.get_rollup_caps.js', opts), - get_rollup_index_caps: lazyLoad('./api/xpack.rollup.get_rollup_index_caps.js', opts), - getRollupIndexCaps: lazyLoad('./api/xpack.rollup.get_rollup_index_caps.js', opts), - put_job: lazyLoad('./api/xpack.rollup.put_job.js', opts), - putJob: lazyLoad('./api/xpack.rollup.put_job.js', opts), - rollup_search: lazyLoad('./api/xpack.rollup.rollup_search.js', opts), - rollupSearch: lazyLoad('./api/xpack.rollup.rollup_search.js', opts), - start_job: lazyLoad('./api/xpack.rollup.start_job.js', opts), - startJob: lazyLoad('./api/xpack.rollup.start_job.js', opts), - stop_job: lazyLoad('./api/xpack.rollup.stop_job.js', opts), - stopJob: lazyLoad('./api/xpack.rollup.stop_job.js', opts) + delete_job: lazyLoad('xpack.rollup.delete_job', opts), + deleteJob: lazyLoad('xpack.rollup.delete_job', opts), + get_jobs: lazyLoad('xpack.rollup.get_jobs', opts), + getJobs: lazyLoad('xpack.rollup.get_jobs', opts), + get_rollup_caps: lazyLoad('xpack.rollup.get_rollup_caps', opts), + getRollupCaps: lazyLoad('xpack.rollup.get_rollup_caps', opts), + get_rollup_index_caps: lazyLoad('xpack.rollup.get_rollup_index_caps', opts), + getRollupIndexCaps: lazyLoad('xpack.rollup.get_rollup_index_caps', opts), + put_job: lazyLoad('xpack.rollup.put_job', opts), + putJob: lazyLoad('xpack.rollup.put_job', opts), + rollup_search: lazyLoad('xpack.rollup.rollup_search', opts), + rollupSearch: lazyLoad('xpack.rollup.rollup_search', opts), + start_job: lazyLoad('xpack.rollup.start_job', opts), + startJob: lazyLoad('xpack.rollup.start_job', opts), + stop_job: lazyLoad('xpack.rollup.stop_job', opts), + stopJob: lazyLoad('xpack.rollup.stop_job', opts) }, sql: { - clear_cursor: lazyLoad('./api/xpack.sql.clear_cursor.js', opts), - clearCursor: lazyLoad('./api/xpack.sql.clear_cursor.js', opts), - query: lazyLoad('./api/xpack.sql.query.js', opts), - translate: lazyLoad('./api/xpack.sql.translate.js', opts) + clear_cursor: lazyLoad('xpack.sql.clear_cursor', opts), + clearCursor: lazyLoad('xpack.sql.clear_cursor', opts), + query: lazyLoad('xpack.sql.query', opts), + translate: lazyLoad('xpack.sql.translate', opts) }, - usage: lazyLoad('./api/xpack.usage.js', opts), + usage: lazyLoad('xpack.usage', opts), watcher: { - ack_watch: lazyLoad('./api/xpack.watcher.ack_watch.js', opts), - ackWatch: lazyLoad('./api/xpack.watcher.ack_watch.js', opts), - activate_watch: lazyLoad('./api/xpack.watcher.activate_watch.js', opts), - activateWatch: lazyLoad('./api/xpack.watcher.activate_watch.js', opts), - deactivate_watch: lazyLoad('./api/xpack.watcher.deactivate_watch.js', opts), - deactivateWatch: lazyLoad('./api/xpack.watcher.deactivate_watch.js', opts), - delete_watch: lazyLoad('./api/xpack.watcher.delete_watch.js', opts), - deleteWatch: lazyLoad('./api/xpack.watcher.delete_watch.js', opts), - execute_watch: lazyLoad('./api/xpack.watcher.execute_watch.js', opts), - executeWatch: lazyLoad('./api/xpack.watcher.execute_watch.js', opts), - get_watch: lazyLoad('./api/xpack.watcher.get_watch.js', opts), - getWatch: lazyLoad('./api/xpack.watcher.get_watch.js', opts), - put_watch: lazyLoad('./api/xpack.watcher.put_watch.js', opts), - putWatch: lazyLoad('./api/xpack.watcher.put_watch.js', opts), - start: lazyLoad('./api/xpack.watcher.start.js', opts), - stats: lazyLoad('./api/xpack.watcher.stats.js', opts), - stop: lazyLoad('./api/xpack.watcher.stop.js', opts) + ack_watch: lazyLoad('xpack.watcher.ack_watch', opts), + ackWatch: lazyLoad('xpack.watcher.ack_watch', opts), + activate_watch: lazyLoad('xpack.watcher.activate_watch', opts), + activateWatch: lazyLoad('xpack.watcher.activate_watch', opts), + deactivate_watch: lazyLoad('xpack.watcher.deactivate_watch', opts), + deactivateWatch: lazyLoad('xpack.watcher.deactivate_watch', opts), + delete_watch: lazyLoad('xpack.watcher.delete_watch', opts), + deleteWatch: lazyLoad('xpack.watcher.delete_watch', opts), + execute_watch: lazyLoad('xpack.watcher.execute_watch', opts), + executeWatch: lazyLoad('xpack.watcher.execute_watch', opts), + get_watch: lazyLoad('xpack.watcher.get_watch', opts), + getWatch: lazyLoad('xpack.watcher.get_watch', opts), + put_watch: lazyLoad('xpack.watcher.put_watch', opts), + putWatch: lazyLoad('xpack.watcher.put_watch', opts), + start: lazyLoad('xpack.watcher.start', opts), + stats: lazyLoad('xpack.watcher.stats', opts), + stop: lazyLoad('xpack.watcher.stop', opts) } } } @@ -493,7 +493,7 @@ function lazyLoad (file, opts) { var fn = null return function _lazyLoad (params, options, callback) { if (fn === null) { - fn = require(file)(opts) + fn = require(`./api/${file}.js`)(opts) } return fn(params, options, callback) } diff --git a/scripts/utils/genMain.js b/scripts/utils/genMain.js index 070ba6c00..ba89623bb 100644 --- a/scripts/utils/genMain.js +++ b/scripts/utils/genMain.js @@ -17,6 +17,8 @@ * under the License. */ +/* eslint-disable no-template-curly-in-string */ + 'use strict' const { readdirSync } = require('fs') @@ -63,12 +65,12 @@ function genFactory (folder) { .reduce((acc, val) => { const obj = { [val]: acc === null - ? `lazyLoad('./api/${file}', opts)` // `${name}(opts)` + ? `lazyLoad('${file.slice(0, -3)}', opts)` // `${name}(opts)` : acc } if (isSnakeCased(val)) { obj[camelify(val)] = acc === null - ? `lazyLoad('./api/${file}', opts)` // `${name}(opts)` + ? `lazyLoad('${file.slice(0, -3)}', opts)` // `${name}(opts)` : acc } return obj @@ -138,7 +140,7 @@ function genFactory (folder) { var fn = null return function _lazyLoad (params, options, callback) { if (fn === null) { - fn = require(file)(opts) + fn = require(${'`./api/${file}.js`'})(opts) } return fn(params, options, callback) } From 5c60d981807c119045b6be19f69c43ae532a76a7 Mon Sep 17 00:00:00 2001 From: Tomas Della Vedova Date: Tue, 19 Mar 2019 09:50:36 +0100 Subject: [PATCH 16/22] Inspect Connection (#784) Handles `console.log` and `utils.inspect` invocations for a better debugging experience. `agent` and `ssl` are hidden since they made the logs very hard to read. The user can still access them with `instance.agent` and `instance.ssl`. --- lib/Connection.d.ts | 2 ++ lib/Connection.js | 24 +++++++++++++++++--- test/unit/connection.test.js | 43 ++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 3 deletions(-) diff --git a/lib/Connection.d.ts b/lib/Connection.d.ts index 21c701789..99d9a7ffd 100644 --- a/lib/Connection.d.ts +++ b/lib/Connection.d.ts @@ -20,6 +20,7 @@ /// import { URL } from 'url'; +import { inspect, InspectOptions } from 'util'; import * as http from 'http'; import { SecureContextOptions } from 'tls'; @@ -73,6 +74,7 @@ export default class Connection { setRole(role: string, enabled: boolean): Connection; status: string; buildRequestObject(params: any): http.ClientRequestArgs; + [inspect.custom](object: any, options: InspectOptions): string; } export {}; diff --git a/lib/Connection.js b/lib/Connection.js index 22e570edd..4429e8696 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -20,6 +20,7 @@ 'use strict' const assert = require('assert') +const { inspect } = require('util') const http = require('http') const https = require('https') const debug = require('debug')('elasticsearch') @@ -54,7 +55,7 @@ class Connection { maxSockets: keepAliveFalse ? Infinity : 256, maxFreeSockets: 256 }, opts.agent) - this._agent = this.url.protocol === 'http:' + this.agent = this.url.protocol === 'http:' ? new http.Agent(agentOptions) : new https.Agent(Object.assign({}, agentOptions, this.ssl)) @@ -146,7 +147,7 @@ class Connection { if (this._openRequests > 0) { setTimeout(() => this.close(callback), 1000) } else { - this._agent.destroy() + this.agent.destroy() callback() } } @@ -193,7 +194,7 @@ class Connection { auth: !!url.username === true || !!url.password === true ? `${url.username}:${url.password}` : undefined, - agent: this._agent + agent: this.agent } const paramsKeys = Object.keys(params) @@ -218,6 +219,23 @@ class Connection { return request } + + // Handles console.log and utils.inspect invocations. + // We want to hide `agent` and `ssl` since they made + // the logs very hard to read. The user can still + // access them with `instance.agent` and `instance.ssl`. + [inspect.custom] (depth, options) { + return { + url: this.url, + id: this.id, + headers: this.headers, + deadCount: this.deadCount, + resurrectTimeout: this.resurrectTimeout, + _openRequests: this._openRequests, + status: this.status, + roles: this.roles + } + } } Connection.statuses = { diff --git a/test/unit/connection.test.js b/test/unit/connection.test.js index 1a07ccf45..229e00d04 100644 --- a/test/unit/connection.test.js +++ b/test/unit/connection.test.js @@ -20,6 +20,7 @@ 'use strict' const { test } = require('tap') +const { inspect } = require('util') const { createGzip, createDeflate } = require('zlib') const { URL } = require('url') const intoStream = require('into-stream') @@ -670,3 +671,45 @@ test('setRole', t => { t.end() }) + +test('Util.inspect Connection class should hide agent and ssl', t => { + t.plan(1) + + const connection = new Connection({ + url: new URL('http://localhost:9200'), + id: 'node-id', + headers: { foo: 'bar' } + }) + + // Removes spaces and new lines because + // utils.inspect is handled differently + // between major versions of Node.js + function cleanStr (str) { + return str + .replace(/\s/g, '') + .replace(/(\r\n|\n|\r)/gm, '') + } + + t.strictEqual(cleanStr(inspect(connection)), cleanStr(`{ url: + URL { + href: 'http://localhost:9200/', + origin: 'http://localhost:9200', + protocol: 'http:', + username: '', + password: '', + host: 'localhost:9200', + hostname: 'localhost', + port: '9200', + pathname: '/', + search: '', + searchParams: URLSearchParams {}, + hash: '' }, + id: 'node-id', + headers: { foo: 'bar' }, + deadCount: 0, + resurrectTimeout: 0, + _openRequests: 0, + status: 'alive', + roles: { master: true, data: true, ingest: true, ml: false } }`) + ) +}) From 1c3541a740b923a2aa3af041a3e1a9b13a3768bd Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 19 Mar 2019 11:27:58 +0100 Subject: [PATCH 17/22] Updated ci jobs --- .ci/jobs/elastic+elasticsearch-js+5.x.yml | 13 +++++++++++++ .ci/jobs/elastic+elasticsearch-js+6.x.yml | 2 ++ .ci/jobs/elastic+elasticsearch-js+7.x.yml | 2 ++ 3 files changed, 17 insertions(+) create mode 100644 .ci/jobs/elastic+elasticsearch-js+5.x.yml diff --git a/.ci/jobs/elastic+elasticsearch-js+5.x.yml b/.ci/jobs/elastic+elasticsearch-js+5.x.yml new file mode 100644 index 000000000..88e67c8b0 --- /dev/null +++ b/.ci/jobs/elastic+elasticsearch-js+5.x.yml @@ -0,0 +1,13 @@ +--- +- job: + name: elastic+elasticsearch-js+5.x + display-name: 'elastic / elasticsearch-js # 5.x' + description: Testing the elasticsearch-js 5.x branch. + parameters: + - string: + name: branch_specifier + default: refs/heads/5.x + description: the Git branch specifier to build (<branchName>, <tagName>, + <commitId>, etc.) + triggers: + - timed: '@weekly' diff --git a/.ci/jobs/elastic+elasticsearch-js+6.x.yml b/.ci/jobs/elastic+elasticsearch-js+6.x.yml index 19ec923a6..5d2285996 100644 --- a/.ci/jobs/elastic+elasticsearch-js+6.x.yml +++ b/.ci/jobs/elastic+elasticsearch-js+6.x.yml @@ -9,3 +9,5 @@ default: refs/heads/6.x description: the Git branch specifier to build (<branchName>, <tagName>, <commitId>, etc.) + triggers: + - timed: '@weekly' diff --git a/.ci/jobs/elastic+elasticsearch-js+7.x.yml b/.ci/jobs/elastic+elasticsearch-js+7.x.yml index 2db87f425..827b5018f 100644 --- a/.ci/jobs/elastic+elasticsearch-js+7.x.yml +++ b/.ci/jobs/elastic+elasticsearch-js+7.x.yml @@ -9,3 +9,5 @@ default: refs/heads/7.x description: the Git branch specifier to build (<branchName>, <tagName>, <commitId>, etc.) + triggers: + - timed: '@weekly' From 747a61c7f8ed040653dc6f0b352e38088a57a9a0 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 19 Mar 2019 12:33:43 +0100 Subject: [PATCH 18/22] Updated ci jobs --- .ci/jobs/elastic+elasticsearch-js+5.x.yml | 1 + .ci/jobs/elastic+elasticsearch-js+6.x.yml | 1 + .ci/jobs/elastic+elasticsearch-js+7.x.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/.ci/jobs/elastic+elasticsearch-js+5.x.yml b/.ci/jobs/elastic+elasticsearch-js+5.x.yml index 88e67c8b0..0b422ae31 100644 --- a/.ci/jobs/elastic+elasticsearch-js+5.x.yml +++ b/.ci/jobs/elastic+elasticsearch-js+5.x.yml @@ -10,4 +10,5 @@ description: the Git branch specifier to build (<branchName>, <tagName>, <commitId>, etc.) triggers: + - github - timed: '@weekly' diff --git a/.ci/jobs/elastic+elasticsearch-js+6.x.yml b/.ci/jobs/elastic+elasticsearch-js+6.x.yml index 5d2285996..8f9a02c67 100644 --- a/.ci/jobs/elastic+elasticsearch-js+6.x.yml +++ b/.ci/jobs/elastic+elasticsearch-js+6.x.yml @@ -10,4 +10,5 @@ description: the Git branch specifier to build (<branchName>, <tagName>, <commitId>, etc.) triggers: + - github - timed: '@weekly' diff --git a/.ci/jobs/elastic+elasticsearch-js+7.x.yml b/.ci/jobs/elastic+elasticsearch-js+7.x.yml index 827b5018f..a25c2b5ae 100644 --- a/.ci/jobs/elastic+elasticsearch-js+7.x.yml +++ b/.ci/jobs/elastic+elasticsearch-js+7.x.yml @@ -10,4 +10,5 @@ description: the Git branch specifier to build (<branchName>, <tagName>, <commitId>, etc.) triggers: + - github - timed: '@weekly' From 49b79922e22dbfea7fa08c02e2fb03752dfd8da1 Mon Sep 17 00:00:00 2001 From: delvedor Date: Tue, 19 Mar 2019 14:17:50 +0100 Subject: [PATCH 19/22] Updated ci config --- .ci/docker-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.ci/docker-compose.yml b/.ci/docker-compose.yml index a030ff93e..fe46d5733 100644 --- a/.ci/docker-compose.yml +++ b/.ci/docker-compose.yml @@ -23,7 +23,6 @@ services: elasticsearch-oss: image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-7.0.0-beta1} - - elasticsearch volumes: - esvol:/tmp networks: From 3c912d626c4d28f88ca147c8c41e44056616d331 Mon Sep 17 00:00:00 2001 From: Tomas Della Vedova Date: Thu, 21 Mar 2019 11:02:09 +0100 Subject: [PATCH 20/22] CI config (#786) * Updated ci config * Minor fixes * Minor fixes * Added Node v11 --- .ci/.dockerignore | 2 - .ci/Dockerfile | 2 - .ci/run-tests | 93 ++++++++++++++++++++++++++++++++++++++++++++- .ci/test-matrix.yml | 1 + .dockerignore | 5 +++ 5 files changed, 97 insertions(+), 6 deletions(-) delete mode 100644 .ci/.dockerignore create mode 100644 .dockerignore diff --git a/.ci/.dockerignore b/.ci/.dockerignore deleted file mode 100644 index 93f136199..000000000 --- a/.ci/.dockerignore +++ /dev/null @@ -1,2 +0,0 @@ -node_modules -npm-debug.log diff --git a/.ci/Dockerfile b/.ci/Dockerfile index 695addb3d..b25ea6f66 100644 --- a/.ci/Dockerfile +++ b/.ci/Dockerfile @@ -9,5 +9,3 @@ COPY package*.json ./ RUN npm install COPY . . - -CMD [ "npm", "run", "ci" ] diff --git a/.ci/run-tests b/.ci/run-tests index 0a721624b..3a0394a0c 100755 --- a/.ci/run-tests +++ b/.ci/run-tests @@ -10,12 +10,101 @@ # - $NODE_JS_VERSION # +set -eo pipefail + set +x export VAULT_TOKEN=$(vault write -field=token auth/approle/login role_id="$VAULT_ROLE_ID" secret_id="$VAULT_SECRET_ID") export CODECOV_TOKEN=$(vault read -field=token secret/clients-ci/elasticsearch-js/codecov) unset VAULT_ROLE_ID VAULT_SECRET_ID VAULT_TOKEN set -x -ELASTICSEARCH_VERSION=${ELASTICSEARCH_VERSION} NODE_JS_VERSION=${NODE_JS_VERSION} docker-compose -f .ci/docker-compose.yml run client-oss +function cleanup { + docker container rm --force --volumes elasticsearch-oss > /dev/null 2>&1 || true + docker container rm --force --volumes elasticsearch-platinum > /dev/null 2>&1 || true + docker container rm --force --volumes elasticsearch-js-oss > /dev/null 2>&1 || true + docker container rm --force --volumes elasticsearch-js-platinum > /dev/null 2>&1 || true + docker network rm esnet-oss > /dev/null + docker network rm esnet-platinum > /dev/null +} + +trap cleanup EXIT + +# create network and volume +docker network create esnet-oss +docker network create esnet-platinum + +# create client image +docker build \ + --file .ci/Dockerfile \ + --tag elastic/elasticsearch-js \ + --build-arg NODE_JS_VERSION=${NODE_JS_VERSION} \ + . + +# run elasticsearch oss +docker run \ + --rm \ + --env "node.attr.testattr=test" \ + --env "path.repo=/tmp" \ + --env "repositories.url.allowed_urls=http://snapshot.*" \ + --env "discovery.type=single-node" \ + --network=esnet-oss \ + --name=elasticsearch-oss \ + --detach \ + docker.elastic.co/elasticsearch/elasticsearch-oss:${ELASTICSEARCH_VERSION} + +# run elasticsearch platinum +repo=$(pwd) +testnodecrt="/.ci/certs/testnode.crt" +testnodekey="/.ci/certs/testnode.key" +cacrt="/.ci/certs/ca.crt" + +docker run \ + --rm \ + --env "node.attr.testattr=test" \ + --env "path.repo=/tmp" \ + --env "repositories.url.allowed_urls=http://snapshot.*" \ + --env "discovery.type=single-node" \ + --env "ES_JAVA_OPTS=-Xms1g -Xmx1g" \ + --env "ELASTIC_PASSWORD=changeme" \ + --env "xpack.security.enabled=true" \ + --env "xpack.license.self_generated.type=trial" \ + --env "xpack.security.http.ssl.enabled=true" \ + --env "xpack.security.http.ssl.verification_mode=certificate" \ + --env "xpack.security.http.ssl.key=certs/testnode.key" \ + --env "xpack.security.http.ssl.certificate=certs/testnode.crt" \ + --env "xpack.security.http.ssl.certificate_authorities=certs/ca.crt" \ + --env "xpack.security.transport.ssl.enabled=true" \ + --env "xpack.security.transport.ssl.key=certs/testnode.key" \ + --env "xpack.security.transport.ssl.certificate=certs/testnode.crt" \ + --env "xpack.security.transport.ssl.certificate_authorities=certs/ca.crt" \ + --volume "$repo$testnodecrt:/usr/share/elasticsearch/config/certs/testnode.crt" \ + --volume "$repo$testnodekey:/usr/share/elasticsearch/config/certs/testnode.key" \ + --volume "$repo$cacrt:/usr/share/elasticsearch/config/certs/ca.crt" \ + --network=esnet-platinum \ + --name=elasticsearch-platinum \ + --detach \ + docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION} + +# run the client unit and oss integration test +docker run \ + --network=esnet-oss \ + --env "TEST_ES_SERVER=http://elasticsearch-oss:9200" \ + --env "CODECOV_TOKEN" \ + --volume $repo:/usr/src/app \ + --volume /usr/src/app/node_modules \ + --name elasticsearch-js-oss \ + --rm \ + elastic/elasticsearch-js \ + npm run ci + +# run the client platinium integration test +docker run \ + --network=esnet-platinum \ + --env "TEST_ES_SERVER=https://elastic:changeme@elasticsearch-platinum:9200" \ + --volume $repo:/usr/src/app \ + --volume /usr/src/app/node_modules \ + --name elasticsearch-js-platinum \ + --rm \ + elastic/elasticsearch-js \ + npm run test:integration -ELASTICSEARCH_VERSION=${ELASTICSEARCH_VERSION} NODE_JS_VERSION=${NODE_JS_VERSION} docker-compose -f .ci/docker-compose.yml run client-platinum diff --git a/.ci/test-matrix.yml b/.ci/test-matrix.yml index a23cedf9e..84d69d9e0 100644 --- a/.ci/test-matrix.yml +++ b/.ci/test-matrix.yml @@ -3,6 +3,7 @@ ELASTICSEARCH_VERSION: - 7.0.0-beta1 NODE_JS_VERSION: +- 11 - 10 - 8 - 6 diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..54eb2a95a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +node_modules +npm-debug.log +test/benchmarks +elasticsearch +.git From 7d1c660f4ef8dfbd089b0d17047329fda051e95b Mon Sep 17 00:00:00 2001 From: Chris Koehnke Date: Thu, 21 Mar 2019 11:15:03 -0400 Subject: [PATCH 21/22] Remove url in jenkins job configuration --- .ci/jobs/defaults.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.ci/jobs/defaults.yml b/.ci/jobs/defaults.yml index a293e7c2a..1ccaa8b08 100644 --- a/.ci/jobs/defaults.yml +++ b/.ci/jobs/defaults.yml @@ -31,7 +31,6 @@ triggers: - github vault: - url: https://secrets.elastic.co:8200 # vault read auth/approle/role/clients-ci/role-id role_id: ddbd0d44-0e51-105b-177a-c8fdfd445126 axes: From 46bd14a36c6dd6b1939603d9450ffc42a7d275ff Mon Sep 17 00:00:00 2001 From: Tomas Della Vedova Date: Tue, 26 Mar 2019 12:04:44 +0100 Subject: [PATCH 22/22] Better api error handling (#790) * API generation * Updated code generation * Updated test --- api/api/bulk.js | 29 +++--------- api/api/cat.aliases.js | 23 ++------- api/api/cat.allocation.js | 23 ++------- api/api/cat.count.js | 23 ++------- api/api/cat.fielddata.js | 23 ++------- api/api/cat.health.js | 23 ++------- api/api/cat.help.js | 23 ++------- api/api/cat.indices.js | 23 ++------- api/api/cat.master.js | 23 ++------- api/api/cat.nodeattrs.js | 23 ++------- api/api/cat.nodes.js | 23 ++------- api/api/cat.pending_tasks.js | 23 ++------- api/api/cat.plugins.js | 23 ++------- api/api/cat.recovery.js | 23 ++------- api/api/cat.repositories.js | 23 ++------- api/api/cat.segments.js | 23 ++------- api/api/cat.shards.js | 23 ++------- api/api/cat.snapshots.js | 23 ++------- api/api/cat.tasks.js | 23 ++------- api/api/cat.templates.js | 23 ++------- api/api/cat.thread_pool.js | 23 ++------- api/api/ccr.delete_auto_follow_pattern.js | 23 ++------- api/api/ccr.follow.js | 29 +++--------- api/api/ccr.follow_info.js | 17 ++----- api/api/ccr.follow_stats.js | 17 ++----- api/api/ccr.get_auto_follow_pattern.js | 17 ++----- api/api/ccr.pause_follow.js | 23 ++------- api/api/ccr.put_auto_follow_pattern.js | 29 +++--------- api/api/ccr.resume_follow.js | 23 ++------- api/api/ccr.stats.js | 17 ++----- api/api/ccr.unfollow.js | 23 ++------- api/api/clear_scroll.js | 17 ++----- api/api/cluster.allocation_explain.js | 17 ++----- api/api/cluster.get_settings.js | 23 ++------- api/api/cluster.health.js | 23 ++------- api/api/cluster.pending_tasks.js | 23 ++------- api/api/cluster.put_settings.js | 23 ++------- api/api/cluster.remote_info.js | 23 ++------- api/api/cluster.reroute.js | 17 ++----- api/api/cluster.state.js | 29 +++--------- api/api/cluster.stats.js | 23 ++------- api/api/count.js | 23 ++------- api/api/create.js | 35 ++++---------- api/api/delete.js | 41 +++++----------- api/api/delete_by_query.js | 35 ++++---------- api/api/delete_by_query_rethrottle.js | 35 ++++---------- api/api/delete_script.js | 29 +++--------- api/api/exists.js | 35 ++++---------- api/api/exists_source.js | 47 +++++-------------- api/api/explain.js | 29 +++--------- api/api/field_caps.js | 23 ++------- api/api/get.js | 35 ++++---------- api/api/get_script.js | 29 +++--------- api/api/get_source.js | 35 ++++---------- api/api/ilm.delete_lifecycle.js | 23 ++------- api/api/ilm.explain_lifecycle.js | 23 ++------- api/api/ilm.get_lifecycle.js | 23 ++------- api/api/ilm.get_status.js | 23 ++------- api/api/ilm.move_to_step.js | 17 ++----- api/api/ilm.put_lifecycle.js | 17 ++----- api/api/ilm.remove_policy.js | 23 ++------- api/api/ilm.retry.js | 23 ++------- api/api/ilm.start.js | 23 ++------- api/api/ilm.stop.js | 23 ++------- api/api/index.js | 35 ++++---------- api/api/indices.analyze.js | 17 ++----- api/api/indices.clear_cache.js | 23 ++------- api/api/indices.close.js | 29 +++--------- api/api/indices.create.js | 23 ++------- api/api/indices.delete.js | 29 +++--------- api/api/indices.delete_alias.js | 41 +++++----------- api/api/indices.delete_template.js | 29 +++--------- api/api/indices.exists.js | 29 +++--------- api/api/indices.exists_alias.js | 29 +++--------- api/api/indices.exists_template.js | 29 +++--------- api/api/indices.exists_type.js | 41 +++++----------- api/api/indices.flush.js | 23 ++------- api/api/indices.flush_synced.js | 23 ++------- api/api/indices.forcemerge.js | 23 ++------- api/api/indices.freeze.js | 29 +++--------- api/api/indices.get.js | 29 +++--------- api/api/indices.get_alias.js | 23 ++------- api/api/indices.get_field_mapping.js | 29 +++--------- api/api/indices.get_mapping.js | 23 ++------- api/api/indices.get_settings.js | 23 ++------- api/api/indices.get_template.js | 23 ++------- api/api/indices.get_upgrade.js | 23 ++------- api/api/indices.open.js | 29 +++--------- api/api/indices.put_alias.js | 35 ++++---------- api/api/indices.put_mapping.js | 23 ++------- api/api/indices.put_settings.js | 23 ++------- api/api/indices.put_template.js | 29 +++--------- api/api/indices.recovery.js | 23 ++------- api/api/indices.refresh.js | 23 ++------- api/api/indices.rollover.js | 29 +++--------- api/api/indices.segments.js | 23 ++------- api/api/indices.shard_stores.js | 23 ++------- api/api/indices.shrink.js | 35 ++++---------- api/api/indices.split.js | 35 ++++---------- api/api/indices.stats.js | 23 ++------- api/api/indices.unfreeze.js | 29 +++--------- api/api/indices.update_aliases.js | 23 ++------- api/api/indices.upgrade.js | 23 ++------- api/api/indices.validate_query.js | 23 ++------- api/api/info.js | 23 ++------- api/api/ingest.delete_pipeline.js | 29 +++--------- api/api/ingest.get_pipeline.js | 23 ++------- api/api/ingest.processor_grok.js | 23 ++------- api/api/ingest.put_pipeline.js | 29 +++--------- api/api/ingest.simulate.js | 23 ++------- api/api/mget.js | 29 +++--------- api/api/ml.close_job.js | 23 ++------- api/api/ml.delete_calendar.js | 29 +++--------- api/api/ml.delete_calendar_event.js | 41 +++++----------- api/api/ml.delete_calendar_job.js | 41 +++++----------- api/api/ml.delete_datafeed.js | 29 +++--------- api/api/ml.delete_expired_data.js | 23 ++------- api/api/ml.delete_filter.js | 29 +++--------- api/api/ml.delete_forecast.js | 35 ++++---------- api/api/ml.delete_job.js | 29 +++--------- api/api/ml.delete_model_snapshot.js | 41 +++++----------- api/api/ml.find_file_structure.js | 23 ++------- api/api/ml.flush_job.js | 23 ++------- api/api/ml.forecast.js | 29 +++--------- api/api/ml.get_buckets.js | 29 +++--------- api/api/ml.get_calendar_events.js | 29 +++--------- api/api/ml.get_calendars.js | 23 ++------- api/api/ml.get_categories.js | 23 ++------- api/api/ml.get_datafeed_stats.js | 23 ++------- api/api/ml.get_datafeeds.js | 23 ++------- api/api/ml.get_filters.js | 23 ++------- api/api/ml.get_influencers.js | 23 ++------- api/api/ml.get_job_stats.js | 23 ++------- api/api/ml.get_jobs.js | 23 ++------- api/api/ml.get_model_snapshots.js | 29 +++--------- api/api/ml.get_overall_buckets.js | 23 ++------- api/api/ml.get_records.js | 23 ++------- api/api/ml.info.js | 17 ++----- api/api/ml.open_job.js | 29 +++--------- api/api/ml.post_calendar_events.js | 29 +++--------- api/api/ml.post_data.js | 29 +++--------- api/api/ml.preview_datafeed.js | 29 +++--------- api/api/ml.put_calendar.js | 23 ++------- api/api/ml.put_calendar_job.js | 41 +++++----------- api/api/ml.put_datafeed.js | 29 +++--------- api/api/ml.put_filter.js | 29 +++--------- api/api/ml.put_job.js | 29 +++--------- api/api/ml.revert_model_snapshot.js | 35 ++++---------- api/api/ml.set_upgrade_mode.js | 23 ++------- api/api/ml.start_datafeed.js | 23 ++------- api/api/ml.stop_datafeed.js | 23 ++------- api/api/ml.update_datafeed.js | 29 +++--------- api/api/ml.update_filter.js | 29 +++--------- api/api/ml.update_job.js | 29 +++--------- api/api/ml.update_model_snapshot.js | 41 +++++----------- api/api/ml.validate.js | 23 ++------- api/api/ml.validate_detector.js | 23 ++------- api/api/monitoring.bulk.js | 23 ++------- api/api/msearch.js | 29 +++--------- api/api/msearch_template.js | 29 +++--------- api/api/mtermvectors.js | 23 ++------- api/api/nodes.hot_threads.js | 23 ++------- api/api/nodes.info.js | 23 ++------- api/api/nodes.reload_secure_settings.js | 23 ++------- api/api/nodes.stats.js | 23 ++------- api/api/nodes.usage.js | 23 ++------- api/api/ping.js | 23 ++------- api/api/put_script.js | 35 ++++---------- api/api/rank_eval.js | 23 ++------- api/api/reindex.js | 23 ++------- api/api/reindex_rethrottle.js | 35 ++++---------- api/api/render_search_template.js | 17 ++----- api/api/scripts_painless_execute.js | 17 ++----- api/api/scroll.js | 17 ++----- api/api/search.js | 23 ++------- api/api/search_shards.js | 23 ++------- api/api/search_template.js | 29 +++--------- api/api/security.authenticate.js | 23 ++------- api/api/security.change_password.js | 23 ++------- api/api/security.clear_cached_realms.js | 29 +++--------- api/api/security.clear_cached_roles.js | 29 +++--------- api/api/security.create_api_key.js | 23 ++------- api/api/security.delete_privileges.js | 41 +++++----------- api/api/security.delete_role.js | 29 +++--------- api/api/security.delete_role_mapping.js | 29 +++--------- api/api/security.delete_user.js | 29 +++--------- api/api/security.disable_user.js | 23 ++------- api/api/security.enable_user.js | 23 ++------- api/api/security.get_api_key.js | 23 ++------- api/api/security.get_privileges.js | 29 +++--------- api/api/security.get_role.js | 23 ++------- api/api/security.get_role_mapping.js | 23 ++------- api/api/security.get_token.js | 23 ++------- api/api/security.get_user.js | 23 ++------- api/api/security.get_user_privileges.js | 23 ++------- api/api/security.has_privileges.js | 23 ++------- api/api/security.invalidate_api_key.js | 23 ++------- api/api/security.invalidate_token.js | 23 ++------- api/api/security.put_privileges.js | 23 ++------- api/api/security.put_role.js | 29 +++--------- api/api/security.put_role_mapping.js | 29 +++--------- api/api/security.put_user.js | 29 +++--------- api/api/snapshot.create.js | 35 ++++---------- api/api/snapshot.create_repository.js | 29 +++--------- api/api/snapshot.delete.js | 41 +++++----------- api/api/snapshot.delete_repository.js | 29 +++--------- api/api/snapshot.get.js | 41 +++++----------- api/api/snapshot.get_repository.js | 23 ++------- api/api/snapshot.restore.js | 35 ++++---------- api/api/snapshot.status.js | 29 +++--------- api/api/snapshot.verify_repository.js | 29 +++--------- api/api/ssl.certificates.js | 23 ++------- api/api/tasks.cancel.js | 23 ++------- api/api/tasks.get.js | 29 +++--------- api/api/tasks.list.js | 23 ++------- api/api/termvectors.js | 23 ++------- api/api/update.js | 35 ++++---------- api/api/update_by_query.js | 29 +++--------- api/api/update_by_query_rethrottle.js | 35 ++++---------- api/api/xpack.graph.explore.js | 23 ++------- api/api/xpack.info.js | 23 ++------- api/api/xpack.license.delete.js | 23 ++------- api/api/xpack.license.get.js | 23 ++------- api/api/xpack.license.get_basic_status.js | 23 ++------- api/api/xpack.license.get_trial_status.js | 23 ++------- api/api/xpack.license.post.js | 17 ++----- api/api/xpack.license.post_start_basic.js | 23 ++------- api/api/xpack.license.post_start_trial.js | 23 ++------- api/api/xpack.migration.deprecations.js | 23 ++------- api/api/xpack.migration.get_assistance.js | 17 ++----- api/api/xpack.migration.upgrade.js | 23 ++------- api/api/xpack.rollup.delete_job.js | 23 ++------- api/api/xpack.rollup.get_jobs.js | 17 ++----- api/api/xpack.rollup.get_rollup_caps.js | 17 ++----- api/api/xpack.rollup.get_rollup_index_caps.js | 23 ++------- api/api/xpack.rollup.put_job.js | 29 +++--------- api/api/xpack.rollup.rollup_search.js | 35 ++++---------- api/api/xpack.rollup.start_job.js | 23 ++------- api/api/xpack.rollup.stop_job.js | 23 ++------- api/api/xpack.sql.clear_cursor.js | 23 ++------- api/api/xpack.sql.query.js | 23 ++------- api/api/xpack.sql.translate.js | 23 ++------- api/api/xpack.usage.js | 23 ++------- api/api/xpack.watcher.ack_watch.js | 35 ++++---------- api/api/xpack.watcher.activate_watch.js | 29 +++--------- api/api/xpack.watcher.deactivate_watch.js | 29 +++--------- api/api/xpack.watcher.delete_watch.js | 29 +++--------- api/api/xpack.watcher.execute_watch.js | 17 ++----- api/api/xpack.watcher.get_watch.js | 29 +++--------- api/api/xpack.watcher.put_watch.js | 23 ++------- api/api/xpack.watcher.start.js | 23 ++------- api/api/xpack.watcher.stats.js | 23 ++------- api/api/xpack.watcher.stop.js | 23 ++------- api/index.js | 8 ++++ scripts/utils/genMain.js | 8 ++++ scripts/utils/generate.js | 42 +++++------------ test/unit/api-async.js | 17 ++++++- test/unit/api.test.js | 31 +++++++++++- 258 files changed, 1583 insertions(+), 5074 deletions(-) diff --git a/api/api/bulk.js b/api/api/bulk.js index f1ebde7d1..5322898dc 100644 --- a/api/api/bulk.js +++ b/api/api/bulk.js @@ -24,7 +24,7 @@ function buildBulk (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [bulk](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html) request * @@ -79,37 +79,22 @@ function buildBulk (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - bulk(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // check required url components if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cat.aliases.js b/api/api/cat.aliases.js index 8378c9602..e5738e038 100644 --- a/api/api/cat.aliases.js +++ b/api/api/cat.aliases.js @@ -24,7 +24,7 @@ function buildCatAliases (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cat.aliases](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-alias.html) request * @@ -71,29 +71,16 @@ function buildCatAliases (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catAliases(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cat.allocation.js b/api/api/cat.allocation.js index 2e771d29c..561c02ddb 100644 --- a/api/api/cat.allocation.js +++ b/api/api/cat.allocation.js @@ -24,7 +24,7 @@ function buildCatAllocation (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cat.allocation](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-allocation.html) request * @@ -73,29 +73,16 @@ function buildCatAllocation (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catAllocation(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cat.count.js b/api/api/cat.count.js index 443af2669..2be151d71 100644 --- a/api/api/cat.count.js +++ b/api/api/cat.count.js @@ -24,7 +24,7 @@ function buildCatCount (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cat.count](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-count.html) request * @@ -71,29 +71,16 @@ function buildCatCount (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catCount(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cat.fielddata.js b/api/api/cat.fielddata.js index 47332ef7f..1685acd80 100644 --- a/api/api/cat.fielddata.js +++ b/api/api/cat.fielddata.js @@ -24,7 +24,7 @@ function buildCatFielddata (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cat.fielddata](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-fielddata.html) request * @@ -75,29 +75,16 @@ function buildCatFielddata (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catFielddata(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cat.health.js b/api/api/cat.health.js index e9b145928..6badc3a80 100644 --- a/api/api/cat.health.js +++ b/api/api/cat.health.js @@ -24,7 +24,7 @@ function buildCatHealth (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cat.health](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-health.html) request * @@ -72,29 +72,16 @@ function buildCatHealth (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catHealth(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cat.help.js b/api/api/cat.help.js index 5e83855f1..d776803de 100644 --- a/api/api/cat.help.js +++ b/api/api/cat.help.js @@ -24,7 +24,7 @@ function buildCatHelp (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cat.help](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat.html) request * @@ -59,29 +59,16 @@ function buildCatHelp (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catHelp(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cat.indices.js b/api/api/cat.indices.js index c84a3e36f..aff657648 100644 --- a/api/api/cat.indices.js +++ b/api/api/cat.indices.js @@ -24,7 +24,7 @@ function buildCatIndices (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cat.indices](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-indices.html) request * @@ -77,29 +77,16 @@ function buildCatIndices (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catIndices(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cat.master.js b/api/api/cat.master.js index ec9ad0df9..08528e146 100644 --- a/api/api/cat.master.js +++ b/api/api/cat.master.js @@ -24,7 +24,7 @@ function buildCatMaster (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cat.master](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-master.html) request * @@ -70,29 +70,16 @@ function buildCatMaster (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catMaster(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cat.nodeattrs.js b/api/api/cat.nodeattrs.js index 41d02a0be..65a36356a 100644 --- a/api/api/cat.nodeattrs.js +++ b/api/api/cat.nodeattrs.js @@ -24,7 +24,7 @@ function buildCatNodeattrs (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cat.nodeattrs](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodeattrs.html) request * @@ -70,29 +70,16 @@ function buildCatNodeattrs (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catNodeattrs(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cat.nodes.js b/api/api/cat.nodes.js index 5b2ed0383..d539438c5 100644 --- a/api/api/cat.nodes.js +++ b/api/api/cat.nodes.js @@ -24,7 +24,7 @@ function buildCatNodes (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cat.nodes](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodes.html) request * @@ -73,29 +73,16 @@ function buildCatNodes (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catNodes(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cat.pending_tasks.js b/api/api/cat.pending_tasks.js index bb2c8113b..b13a3d306 100644 --- a/api/api/cat.pending_tasks.js +++ b/api/api/cat.pending_tasks.js @@ -24,7 +24,7 @@ function buildCatPendingTasks (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cat.pending_tasks](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-pending-tasks.html) request * @@ -70,29 +70,16 @@ function buildCatPendingTasks (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catPendingTasks(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cat.plugins.js b/api/api/cat.plugins.js index 50164c6a1..1f3b6cdf3 100644 --- a/api/api/cat.plugins.js +++ b/api/api/cat.plugins.js @@ -24,7 +24,7 @@ function buildCatPlugins (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cat.plugins](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-plugins.html) request * @@ -70,29 +70,16 @@ function buildCatPlugins (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catPlugins(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cat.recovery.js b/api/api/cat.recovery.js index 13bb08eb3..7e631fab3 100644 --- a/api/api/cat.recovery.js +++ b/api/api/cat.recovery.js @@ -24,7 +24,7 @@ function buildCatRecovery (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cat.recovery](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-recovery.html) request * @@ -71,29 +71,16 @@ function buildCatRecovery (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catRecovery(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cat.repositories.js b/api/api/cat.repositories.js index dbbc6ee2d..9e229bfd8 100644 --- a/api/api/cat.repositories.js +++ b/api/api/cat.repositories.js @@ -24,7 +24,7 @@ function buildCatRepositories (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cat.repositories](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-repositories.html) request * @@ -70,29 +70,16 @@ function buildCatRepositories (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catRepositories(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cat.segments.js b/api/api/cat.segments.js index 9c1b6b5c0..adc48ee61 100644 --- a/api/api/cat.segments.js +++ b/api/api/cat.segments.js @@ -24,7 +24,7 @@ function buildCatSegments (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cat.segments](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-segments.html) request * @@ -68,29 +68,16 @@ function buildCatSegments (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catSegments(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cat.shards.js b/api/api/cat.shards.js index 49b6d41c0..4de59a7c9 100644 --- a/api/api/cat.shards.js +++ b/api/api/cat.shards.js @@ -24,7 +24,7 @@ function buildCatShards (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cat.shards](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-shards.html) request * @@ -73,29 +73,16 @@ function buildCatShards (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catShards(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cat.snapshots.js b/api/api/cat.snapshots.js index c2c865693..4db252fe9 100644 --- a/api/api/cat.snapshots.js +++ b/api/api/cat.snapshots.js @@ -24,7 +24,7 @@ function buildCatSnapshots (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cat.snapshots](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-snapshots.html) request * @@ -72,29 +72,16 @@ function buildCatSnapshots (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catSnapshots(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cat.tasks.js b/api/api/cat.tasks.js index d51f221a2..b00e20496 100644 --- a/api/api/cat.tasks.js +++ b/api/api/cat.tasks.js @@ -24,7 +24,7 @@ function buildCatTasks (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cat.tasks](http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html) request * @@ -75,29 +75,16 @@ function buildCatTasks (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catTasks(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cat.templates.js b/api/api/cat.templates.js index 0641d29d8..2f0b6beca 100644 --- a/api/api/cat.templates.js +++ b/api/api/cat.templates.js @@ -24,7 +24,7 @@ function buildCatTemplates (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cat.templates](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-templates.html) request * @@ -71,29 +71,16 @@ function buildCatTemplates (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catTemplates(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cat.thread_pool.js b/api/api/cat.thread_pool.js index 5875d9518..fddeb9256 100644 --- a/api/api/cat.thread_pool.js +++ b/api/api/cat.thread_pool.js @@ -24,7 +24,7 @@ function buildCatThreadPool (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cat.thread_pool](http://www.elastic.co/guide/en/elasticsearch/reference/master/cat-thread-pool.html) request * @@ -73,29 +73,16 @@ function buildCatThreadPool (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - catThreadPool(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ccr.delete_auto_follow_pattern.js b/api/api/ccr.delete_auto_follow_pattern.js index b6712ad90..af0f01987 100644 --- a/api/api/ccr.delete_auto_follow_pattern.js +++ b/api/api/ccr.delete_auto_follow_pattern.js @@ -24,7 +24,7 @@ function buildCcrDeleteAutoFollowPattern (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -51,29 +51,16 @@ function buildCcrDeleteAutoFollowPattern (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ccrDeleteAutoFollowPattern(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['name'] == null) { - return callback( - new ConfigurationError('Missing required parameter: name'), - result - ) + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ccr.follow.js b/api/api/ccr.follow.js index ba45eef1f..ab8d8e255 100644 --- a/api/api/ccr.follow.js +++ b/api/api/ccr.follow.js @@ -24,7 +24,7 @@ function buildCcrFollow (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ccr.follow](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html) request * @@ -53,35 +53,20 @@ function buildCcrFollow (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ccrFollow(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ccr.follow_info.js b/api/api/ccr.follow_info.js index 6a9655b0e..209521757 100644 --- a/api/api/ccr.follow_info.js +++ b/api/api/ccr.follow_info.js @@ -24,7 +24,7 @@ function buildCcrFollowInfo (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -51,21 +51,10 @@ function buildCcrFollowInfo (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ccrFollowInfo(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ccr.follow_stats.js b/api/api/ccr.follow_stats.js index c887b7f5f..5c3806181 100644 --- a/api/api/ccr.follow_stats.js +++ b/api/api/ccr.follow_stats.js @@ -24,7 +24,7 @@ function buildCcrFollowStats (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -51,21 +51,10 @@ function buildCcrFollowStats (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ccrFollowStats(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ccr.get_auto_follow_pattern.js b/api/api/ccr.get_auto_follow_pattern.js index e892c2b93..83b3cbfc8 100644 --- a/api/api/ccr.get_auto_follow_pattern.js +++ b/api/api/ccr.get_auto_follow_pattern.js @@ -24,7 +24,7 @@ function buildCcrGetAutoFollowPattern (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -51,21 +51,10 @@ function buildCcrGetAutoFollowPattern (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ccrGetAutoFollowPattern(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ccr.pause_follow.js b/api/api/ccr.pause_follow.js index 5f9427b69..2862163f1 100644 --- a/api/api/ccr.pause_follow.js +++ b/api/api/ccr.pause_follow.js @@ -24,7 +24,7 @@ function buildCcrPauseFollow (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -51,29 +51,16 @@ function buildCcrPauseFollow (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ccrPauseFollow(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ccr.put_auto_follow_pattern.js b/api/api/ccr.put_auto_follow_pattern.js index b3245095e..6338da352 100644 --- a/api/api/ccr.put_auto_follow_pattern.js +++ b/api/api/ccr.put_auto_follow_pattern.js @@ -24,7 +24,7 @@ function buildCcrPutAutoFollowPattern (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -52,35 +52,20 @@ function buildCcrPutAutoFollowPattern (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ccrPutAutoFollowPattern(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['name'] == null) { - return callback( - new ConfigurationError('Missing required parameter: name'), - result - ) + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ccr.resume_follow.js b/api/api/ccr.resume_follow.js index 542af5bb2..3c857a84a 100644 --- a/api/api/ccr.resume_follow.js +++ b/api/api/ccr.resume_follow.js @@ -24,7 +24,7 @@ function buildCcrResumeFollow (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -52,29 +52,16 @@ function buildCcrResumeFollow (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ccrResumeFollow(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ccr.stats.js b/api/api/ccr.stats.js index a574bb4b5..81f544210 100644 --- a/api/api/ccr.stats.js +++ b/api/api/ccr.stats.js @@ -24,7 +24,7 @@ function buildCcrStats (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ccr.stats](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html) request * @@ -50,21 +50,10 @@ function buildCcrStats (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ccrStats(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ccr.unfollow.js b/api/api/ccr.unfollow.js index ff68fc788..2163e6ad7 100644 --- a/api/api/ccr.unfollow.js +++ b/api/api/ccr.unfollow.js @@ -24,7 +24,7 @@ function buildCcrUnfollow (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ccr.unfollow](http://www.elastic.co/guide/en/elasticsearch/reference/current) request * @@ -51,29 +51,16 @@ function buildCcrUnfollow (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ccrUnfollow(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/clear_scroll.js b/api/api/clear_scroll.js index 3a25bcdc0..552ac23cc 100644 --- a/api/api/clear_scroll.js +++ b/api/api/clear_scroll.js @@ -24,7 +24,7 @@ function buildClearScroll (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [clear_scroll](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-scroll.html) request * @@ -57,21 +57,10 @@ function buildClearScroll (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - clearScroll(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cluster.allocation_explain.js b/api/api/cluster.allocation_explain.js index 6355100c2..3ce754e73 100644 --- a/api/api/cluster.allocation_explain.js +++ b/api/api/cluster.allocation_explain.js @@ -24,7 +24,7 @@ function buildClusterAllocationExplain (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cluster.allocation_explain](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-allocation-explain.html) request * @@ -62,21 +62,10 @@ function buildClusterAllocationExplain (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - clusterAllocationExplain(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cluster.get_settings.js b/api/api/cluster.get_settings.js index 568d5c4f1..8e215e750 100644 --- a/api/api/cluster.get_settings.js +++ b/api/api/cluster.get_settings.js @@ -24,7 +24,7 @@ function buildClusterGetSettings (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cluster.get_settings](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html) request * @@ -66,29 +66,16 @@ function buildClusterGetSettings (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - clusterGetSettings(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cluster.health.js b/api/api/cluster.health.js index 6b0bfffae..327cbbaba 100644 --- a/api/api/cluster.health.js +++ b/api/api/cluster.health.js @@ -24,7 +24,7 @@ function buildClusterHealth (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cluster.health](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-health.html) request * @@ -83,29 +83,16 @@ function buildClusterHealth (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - clusterHealth(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cluster.pending_tasks.js b/api/api/cluster.pending_tasks.js index e3052a663..cc132b7a7 100644 --- a/api/api/cluster.pending_tasks.js +++ b/api/api/cluster.pending_tasks.js @@ -24,7 +24,7 @@ function buildClusterPendingTasks (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cluster.pending_tasks](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-pending.html) request * @@ -60,29 +60,16 @@ function buildClusterPendingTasks (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - clusterPendingTasks(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cluster.put_settings.js b/api/api/cluster.put_settings.js index f50230a39..9064e1670 100644 --- a/api/api/cluster.put_settings.js +++ b/api/api/cluster.put_settings.js @@ -24,7 +24,7 @@ function buildClusterPutSettings (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cluster.put_settings](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html) request * @@ -64,29 +64,16 @@ function buildClusterPutSettings (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - clusterPutSettings(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cluster.remote_info.js b/api/api/cluster.remote_info.js index 97939e755..22a2ca142 100644 --- a/api/api/cluster.remote_info.js +++ b/api/api/cluster.remote_info.js @@ -24,7 +24,7 @@ function buildClusterRemoteInfo (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cluster.remote_info](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-remote-info.html) request * @@ -55,29 +55,16 @@ function buildClusterRemoteInfo (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - clusterRemoteInfo(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cluster.reroute.js b/api/api/cluster.reroute.js index 40e7b731e..5a29ea54d 100644 --- a/api/api/cluster.reroute.js +++ b/api/api/cluster.reroute.js @@ -24,7 +24,7 @@ function buildClusterReroute (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cluster.reroute](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-reroute.html) request * @@ -71,21 +71,10 @@ function buildClusterReroute (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - clusterReroute(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cluster.state.js b/api/api/cluster.state.js index 6560a3b0d..7d6b7c303 100644 --- a/api/api/cluster.state.js +++ b/api/api/cluster.state.js @@ -24,7 +24,7 @@ function buildClusterState (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cluster.state](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-state.html) request * @@ -80,37 +80,22 @@ function buildClusterState (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - clusterState(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) } // check required url components if (params['index'] != null && (params['metric'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: metric'), - result - ) + const err = new ConfigurationError('Missing required parameter of the url: metric') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/cluster.stats.js b/api/api/cluster.stats.js index b5e2035eb..77f634146 100644 --- a/api/api/cluster.stats.js +++ b/api/api/cluster.stats.js @@ -24,7 +24,7 @@ function buildClusterStats (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [cluster.stats](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-stats.html) request * @@ -61,29 +61,16 @@ function buildClusterStats (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - clusterStats(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/count.js b/api/api/count.js index 28966aaeb..ae6816fba 100644 --- a/api/api/count.js +++ b/api/api/count.js @@ -24,7 +24,7 @@ function buildCount (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [count](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-count.html) request * @@ -94,29 +94,16 @@ function buildCount (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - count(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required url components if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/create.js b/api/api/create.js index 306a2720f..0ee306e57 100644 --- a/api/api/create.js +++ b/api/api/create.js @@ -24,7 +24,7 @@ function buildCreate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [create](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html) request * @@ -77,41 +77,24 @@ function buildCreate (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - create(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['id'] == null) { - return callback( - new ConfigurationError('Missing required parameter: id'), - result - ) + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) } if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/delete.js b/api/api/delete.js index b2053515e..35ab29398 100644 --- a/api/api/delete.js +++ b/api/api/delete.js @@ -24,7 +24,7 @@ function buildDelete (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [delete](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete.html) request * @@ -80,49 +80,30 @@ function buildDelete (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - _delete(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['id'] == null) { - return callback( - new ConfigurationError('Missing required parameter: id'), - result - ) + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) } if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) } // check required url components if (params['id'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/delete_by_query.js b/api/api/delete_by_query.js index ae798c5fc..7e3aae9ea 100644 --- a/api/api/delete_by_query.js +++ b/api/api/delete_by_query.js @@ -24,7 +24,7 @@ function buildDeleteByQuery (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [delete_by_query](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html) request * @@ -137,43 +137,26 @@ function buildDeleteByQuery (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - deleteByQuery(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // check required url components if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/delete_by_query_rethrottle.js b/api/api/delete_by_query_rethrottle.js index a0b2006bd..bbeb5094a 100644 --- a/api/api/delete_by_query_rethrottle.js +++ b/api/api/delete_by_query_rethrottle.js @@ -24,7 +24,7 @@ function buildDeleteByQueryRethrottle (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -59,41 +59,24 @@ function buildDeleteByQueryRethrottle (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - deleteByQueryRethrottle(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['task_id'] == null && params['taskId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: task_id or taskId'), - result - ) + const err = new ConfigurationError('Missing required parameter: task_id or taskId') + return handleError(err, callback) } if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) { - return callback( - new ConfigurationError('Missing required parameter: requests_per_second or requestsPerSecond'), - result - ) + const err = new ConfigurationError('Missing required parameter: requests_per_second or requestsPerSecond') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/delete_script.js b/api/api/delete_script.js index 29647583b..6165361bf 100644 --- a/api/api/delete_script.js +++ b/api/api/delete_script.js @@ -24,7 +24,7 @@ function buildDeleteScript (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [delete_script](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html) request * @@ -61,35 +61,20 @@ function buildDeleteScript (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - deleteScript(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['id'] == null) { - return callback( - new ConfigurationError('Missing required parameter: id'), - result - ) + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/exists.js b/api/api/exists.js index 13ff5edbf..ac6e5db8a 100644 --- a/api/api/exists.js +++ b/api/api/exists.js @@ -24,7 +24,7 @@ function buildExists (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [exists](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request * @@ -84,41 +84,24 @@ function buildExists (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - exists(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['id'] == null) { - return callback( - new ConfigurationError('Missing required parameter: id'), - result - ) + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) } if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/exists_source.js b/api/api/exists_source.js index b3abeb2eb..d8111530e 100644 --- a/api/api/exists_source.js +++ b/api/api/exists_source.js @@ -24,7 +24,7 @@ function buildExistsSource (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [exists_source](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request * @@ -81,54 +81,33 @@ function buildExistsSource (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - existsSource(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['id'] == null) { - return callback( - new ConfigurationError('Missing required parameter: id'), - result - ) + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) } if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) } // check required url components if (params['id'] != null && (params['type'] == null || params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: type, index'), - result - ) + const err = new ConfigurationError('Missing required parameter of the url: type, index') + return handleError(err, callback) } else if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/explain.js b/api/api/explain.js index 206c765bc..f59f7a11c 100644 --- a/api/api/explain.js +++ b/api/api/explain.js @@ -24,7 +24,7 @@ function buildExplain (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [explain](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-explain.html) request * @@ -90,35 +90,20 @@ function buildExplain (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - explain(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['id'] == null) { - return callback( - new ConfigurationError('Missing required parameter: id'), - result - ) + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) } if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/field_caps.js b/api/api/field_caps.js index 021412e99..c8a6dec42 100644 --- a/api/api/field_caps.js +++ b/api/api/field_caps.js @@ -24,7 +24,7 @@ function buildFieldCaps (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [field_caps](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html) request * @@ -67,29 +67,16 @@ function buildFieldCaps (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - fieldCaps(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/get.js b/api/api/get.js index aea81e367..ff8e8b032 100644 --- a/api/api/get.js +++ b/api/api/get.js @@ -24,7 +24,7 @@ function buildGet (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [get](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request * @@ -90,41 +90,24 @@ function buildGet (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - get(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['id'] == null) { - return callback( - new ConfigurationError('Missing required parameter: id'), - result - ) + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) } if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/get_script.js b/api/api/get_script.js index bb2eee166..b6659841f 100644 --- a/api/api/get_script.js +++ b/api/api/get_script.js @@ -24,7 +24,7 @@ function buildGetScript (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [get_script](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html) request * @@ -59,35 +59,20 @@ function buildGetScript (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - getScript(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['id'] == null) { - return callback( - new ConfigurationError('Missing required parameter: id'), - result - ) + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/get_source.js b/api/api/get_source.js index abbc53ac0..bcac14deb 100644 --- a/api/api/get_source.js +++ b/api/api/get_source.js @@ -24,7 +24,7 @@ function buildGetSource (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [get_source](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html) request * @@ -81,41 +81,24 @@ function buildGetSource (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - getSource(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['id'] == null) { - return callback( - new ConfigurationError('Missing required parameter: id'), - result - ) + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) } if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ilm.delete_lifecycle.js b/api/api/ilm.delete_lifecycle.js index 2e84b9e8b..7e09289af 100644 --- a/api/api/ilm.delete_lifecycle.js +++ b/api/api/ilm.delete_lifecycle.js @@ -24,7 +24,7 @@ function buildIlmDeleteLifecycle (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ilm.delete_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-delete-lifecycle.html) request * @@ -51,29 +51,16 @@ function buildIlmDeleteLifecycle (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ilmDeleteLifecycle(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ilm.explain_lifecycle.js b/api/api/ilm.explain_lifecycle.js index 7fbb00519..d9a0e2e70 100644 --- a/api/api/ilm.explain_lifecycle.js +++ b/api/api/ilm.explain_lifecycle.js @@ -24,7 +24,7 @@ function buildIlmExplainLifecycle (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ilm.explain_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-explain-lifecycle.html) request * @@ -52,29 +52,16 @@ function buildIlmExplainLifecycle (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ilmExplainLifecycle(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ilm.get_lifecycle.js b/api/api/ilm.get_lifecycle.js index 19e44d788..a01952fa5 100644 --- a/api/api/ilm.get_lifecycle.js +++ b/api/api/ilm.get_lifecycle.js @@ -24,7 +24,7 @@ function buildIlmGetLifecycle (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ilm.get_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-lifecycle.html) request * @@ -51,29 +51,16 @@ function buildIlmGetLifecycle (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ilmGetLifecycle(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ilm.get_status.js b/api/api/ilm.get_status.js index 1592c0804..30c135900 100644 --- a/api/api/ilm.get_status.js +++ b/api/api/ilm.get_status.js @@ -24,7 +24,7 @@ function buildIlmGetStatus (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ilm.get_status](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-status.html) request * @@ -50,29 +50,16 @@ function buildIlmGetStatus (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ilmGetStatus(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ilm.move_to_step.js b/api/api/ilm.move_to_step.js index 7807d5fd0..49f82a8c5 100644 --- a/api/api/ilm.move_to_step.js +++ b/api/api/ilm.move_to_step.js @@ -24,7 +24,7 @@ function buildIlmMoveToStep (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -52,21 +52,10 @@ function buildIlmMoveToStep (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ilmMoveToStep(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ilm.put_lifecycle.js b/api/api/ilm.put_lifecycle.js index 39f91271a..28955b0fe 100644 --- a/api/api/ilm.put_lifecycle.js +++ b/api/api/ilm.put_lifecycle.js @@ -24,7 +24,7 @@ function buildIlmPutLifecycle (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ilm.put_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-put-lifecycle.html) request * @@ -52,21 +52,10 @@ function buildIlmPutLifecycle (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ilmPutLifecycle(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ilm.remove_policy.js b/api/api/ilm.remove_policy.js index ee61c6322..ccfbc8c81 100644 --- a/api/api/ilm.remove_policy.js +++ b/api/api/ilm.remove_policy.js @@ -24,7 +24,7 @@ function buildIlmRemovePolicy (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ilm.remove_policy](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-remove-policy.html) request * @@ -51,29 +51,16 @@ function buildIlmRemovePolicy (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ilmRemovePolicy(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ilm.retry.js b/api/api/ilm.retry.js index ea52a066c..5ea000327 100644 --- a/api/api/ilm.retry.js +++ b/api/api/ilm.retry.js @@ -24,7 +24,7 @@ function buildIlmRetry (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ilm.retry](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-retry-policy.html) request * @@ -51,29 +51,16 @@ function buildIlmRetry (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ilmRetry(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ilm.start.js b/api/api/ilm.start.js index f3b7b7eda..f2461f3ef 100644 --- a/api/api/ilm.start.js +++ b/api/api/ilm.start.js @@ -24,7 +24,7 @@ function buildIlmStart (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ilm.start](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-start.html) request * @@ -50,29 +50,16 @@ function buildIlmStart (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ilmStart(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ilm.stop.js b/api/api/ilm.stop.js index 72c23b41b..ad1607579 100644 --- a/api/api/ilm.stop.js +++ b/api/api/ilm.stop.js @@ -24,7 +24,7 @@ function buildIlmStop (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ilm.stop](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-stop.html) request * @@ -50,29 +50,16 @@ function buildIlmStop (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ilmStop(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/index.js b/api/api/index.js index 9e39b0773..716d8c4cf 100644 --- a/api/api/index.js +++ b/api/api/index.js @@ -24,7 +24,7 @@ function buildIndex (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [index](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html) request * @@ -86,43 +86,26 @@ function buildIndex (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - _index(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // check required url components if (params['id'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.analyze.js b/api/api/indices.analyze.js index 0bac6eda8..4d819f7c0 100644 --- a/api/api/indices.analyze.js +++ b/api/api/indices.analyze.js @@ -24,7 +24,7 @@ function buildIndicesAnalyze (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.analyze](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-analyze.html) request * @@ -59,21 +59,10 @@ function buildIndicesAnalyze (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesAnalyze(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.clear_cache.js b/api/api/indices.clear_cache.js index e2fe21f1f..fa2739c6b 100644 --- a/api/api/indices.clear_cache.js +++ b/api/api/indices.clear_cache.js @@ -24,7 +24,7 @@ function buildIndicesClearCache (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.clear_cache](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clearcache.html) request * @@ -75,29 +75,16 @@ function buildIndicesClearCache (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesClearCache(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.close.js b/api/api/indices.close.js index df06e9c9b..023bc3507 100644 --- a/api/api/indices.close.js +++ b/api/api/indices.close.js @@ -24,7 +24,7 @@ function buildIndicesClose (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.close](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html) request * @@ -70,35 +70,20 @@ function buildIndicesClose (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesClose(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.create.js b/api/api/indices.create.js index 9b786023a..355a7a370 100644 --- a/api/api/indices.create.js +++ b/api/api/indices.create.js @@ -24,7 +24,7 @@ function buildIndicesCreate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.create](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-index.html) request * @@ -68,29 +68,16 @@ function buildIndicesCreate (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesCreate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.delete.js b/api/api/indices.delete.js index 09983e420..bb46902fd 100644 --- a/api/api/indices.delete.js +++ b/api/api/indices.delete.js @@ -24,7 +24,7 @@ function buildIndicesDelete (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.delete](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-index.html) request * @@ -70,35 +70,20 @@ function buildIndicesDelete (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesDelete(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.delete_alias.js b/api/api/indices.delete_alias.js index 7a838ce27..db5091854 100644 --- a/api/api/indices.delete_alias.js +++ b/api/api/indices.delete_alias.js @@ -24,7 +24,7 @@ function buildIndicesDeleteAlias (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.delete_alias](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html) request * @@ -62,49 +62,30 @@ function buildIndicesDeleteAlias (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesDeleteAlias(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params['name'] == null) { - return callback( - new ConfigurationError('Missing required parameter: name'), - result - ) + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) } // check required url components if (params['name'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.delete_template.js b/api/api/indices.delete_template.js index 44287ae15..623ba6933 100644 --- a/api/api/indices.delete_template.js +++ b/api/api/indices.delete_template.js @@ -24,7 +24,7 @@ function buildIndicesDeleteTemplate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.delete_template](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html) request * @@ -61,35 +61,20 @@ function buildIndicesDeleteTemplate (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesDeleteTemplate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['name'] == null) { - return callback( - new ConfigurationError('Missing required parameter: name'), - result - ) + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.exists.js b/api/api/indices.exists.js index a3e8f1d7c..85cc737a4 100644 --- a/api/api/indices.exists.js +++ b/api/api/indices.exists.js @@ -24,7 +24,7 @@ function buildIndicesExists (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.exists](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-exists.html) request * @@ -73,35 +73,20 @@ function buildIndicesExists (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesExists(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.exists_alias.js b/api/api/indices.exists_alias.js index 9b3e63071..d25ddb733 100644 --- a/api/api/indices.exists_alias.js +++ b/api/api/indices.exists_alias.js @@ -24,7 +24,7 @@ function buildIndicesExistsAlias (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.exists_alias](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html) request * @@ -68,35 +68,20 @@ function buildIndicesExistsAlias (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesExistsAlias(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['name'] == null) { - return callback( - new ConfigurationError('Missing required parameter: name'), - result - ) + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.exists_template.js b/api/api/indices.exists_template.js index 75757d155..ea3fb9d35 100644 --- a/api/api/indices.exists_template.js +++ b/api/api/indices.exists_template.js @@ -24,7 +24,7 @@ function buildIndicesExistsTemplate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.exists_template](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html) request * @@ -64,35 +64,20 @@ function buildIndicesExistsTemplate (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesExistsTemplate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['name'] == null) { - return callback( - new ConfigurationError('Missing required parameter: name'), - result - ) + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.exists_type.js b/api/api/indices.exists_type.js index cab906314..4c2573419 100644 --- a/api/api/indices.exists_type.js +++ b/api/api/indices.exists_type.js @@ -24,7 +24,7 @@ function buildIndicesExistsType (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.exists_type](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-types-exists.html) request * @@ -68,49 +68,30 @@ function buildIndicesExistsType (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesExistsType(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params['type'] == null) { - return callback( - new ConfigurationError('Missing required parameter: type'), - result - ) + const err = new ConfigurationError('Missing required parameter: type') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) } // check required url components if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.flush.js b/api/api/indices.flush.js index 4be9c2ff8..1099650fa 100644 --- a/api/api/indices.flush.js +++ b/api/api/indices.flush.js @@ -24,7 +24,7 @@ function buildIndicesFlush (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.flush](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-flush.html) request * @@ -70,29 +70,16 @@ function buildIndicesFlush (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesFlush(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.flush_synced.js b/api/api/indices.flush_synced.js index 6437db5ae..df404cee0 100644 --- a/api/api/indices.flush_synced.js +++ b/api/api/indices.flush_synced.js @@ -24,7 +24,7 @@ function buildIndicesFlushSynced (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.flush_synced](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-synced-flush.html) request * @@ -65,29 +65,16 @@ function buildIndicesFlushSynced (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesFlushSynced(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.forcemerge.js b/api/api/indices.forcemerge.js index 2a50ad2fd..5bf900cc6 100644 --- a/api/api/indices.forcemerge.js +++ b/api/api/indices.forcemerge.js @@ -24,7 +24,7 @@ function buildIndicesForcemerge (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.forcemerge](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-forcemerge.html) request * @@ -73,29 +73,16 @@ function buildIndicesForcemerge (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesForcemerge(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.freeze.js b/api/api/indices.freeze.js index f16cff125..944a9b00a 100644 --- a/api/api/indices.freeze.js +++ b/api/api/indices.freeze.js @@ -24,7 +24,7 @@ function buildIndicesFreeze (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.freeze](https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.html) request * @@ -66,35 +66,20 @@ function buildIndicesFreeze (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesFreeze(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.get.js b/api/api/indices.get.js index 86631e192..6a4047c83 100644 --- a/api/api/indices.get.js +++ b/api/api/indices.get.js @@ -24,7 +24,7 @@ function buildIndicesGet (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.get](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-index.html) request * @@ -79,35 +79,20 @@ function buildIndicesGet (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesGet(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.get_alias.js b/api/api/indices.get_alias.js index 25607b524..fc2f508ef 100644 --- a/api/api/indices.get_alias.js +++ b/api/api/indices.get_alias.js @@ -24,7 +24,7 @@ function buildIndicesGetAlias (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.get_alias](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html) request * @@ -68,29 +68,16 @@ function buildIndicesGetAlias (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesGetAlias(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.get_field_mapping.js b/api/api/indices.get_field_mapping.js index 744e364f4..78dcfcc0c 100644 --- a/api/api/indices.get_field_mapping.js +++ b/api/api/indices.get_field_mapping.js @@ -24,7 +24,7 @@ function buildIndicesGetFieldMapping (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.get_field_mapping](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-field-mapping.html) request * @@ -75,35 +75,20 @@ function buildIndicesGetFieldMapping (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesGetFieldMapping(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['fields'] == null) { - return callback( - new ConfigurationError('Missing required parameter: fields'), - result - ) + const err = new ConfigurationError('Missing required parameter: fields') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.get_mapping.js b/api/api/indices.get_mapping.js index c669d8352..5534a5cec 100644 --- a/api/api/indices.get_mapping.js +++ b/api/api/indices.get_mapping.js @@ -24,7 +24,7 @@ function buildIndicesGetMapping (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.get_mapping](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-mapping.html) request * @@ -74,29 +74,16 @@ function buildIndicesGetMapping (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesGetMapping(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.get_settings.js b/api/api/indices.get_settings.js index 50e0b2b56..5af0ba622 100644 --- a/api/api/indices.get_settings.js +++ b/api/api/indices.get_settings.js @@ -24,7 +24,7 @@ function buildIndicesGetSettings (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.get_settings](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-settings.html) request * @@ -77,29 +77,16 @@ function buildIndicesGetSettings (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesGetSettings(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.get_template.js b/api/api/indices.get_template.js index 9d9d2b42d..315c9d9ad 100644 --- a/api/api/indices.get_template.js +++ b/api/api/indices.get_template.js @@ -24,7 +24,7 @@ function buildIndicesGetTemplate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.get_template](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html) request * @@ -67,29 +67,16 @@ function buildIndicesGetTemplate (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesGetTemplate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.get_upgrade.js b/api/api/indices.get_upgrade.js index 27f4faed4..c5acf2611 100644 --- a/api/api/indices.get_upgrade.js +++ b/api/api/indices.get_upgrade.js @@ -24,7 +24,7 @@ function buildIndicesGetUpgrade (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.get_upgrade](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-upgrade.html) request * @@ -65,29 +65,16 @@ function buildIndicesGetUpgrade (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesGetUpgrade(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.open.js b/api/api/indices.open.js index 3c2fe8b27..ba585f805 100644 --- a/api/api/indices.open.js +++ b/api/api/indices.open.js @@ -24,7 +24,7 @@ function buildIndicesOpen (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.open](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html) request * @@ -73,35 +73,20 @@ function buildIndicesOpen (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesOpen(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.put_alias.js b/api/api/indices.put_alias.js index 6571d9d85..68710d615 100644 --- a/api/api/indices.put_alias.js +++ b/api/api/indices.put_alias.js @@ -24,7 +24,7 @@ function buildIndicesPutAlias (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.put_alias](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html) request * @@ -63,43 +63,26 @@ function buildIndicesPutAlias (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesPutAlias(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params['name'] == null) { - return callback( - new ConfigurationError('Missing required parameter: name'), - result - ) + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) } // check required url components if (params['name'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.put_mapping.js b/api/api/indices.put_mapping.js index 96a3356f9..491ffd2db 100644 --- a/api/api/indices.put_mapping.js +++ b/api/api/indices.put_mapping.js @@ -24,7 +24,7 @@ function buildIndicesPutMapping (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.put_mapping](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-put-mapping.html) request * @@ -75,29 +75,16 @@ function buildIndicesPutMapping (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesPutMapping(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.put_settings.js b/api/api/indices.put_settings.js index 721c21600..c12a1a47d 100644 --- a/api/api/indices.put_settings.js +++ b/api/api/indices.put_settings.js @@ -24,7 +24,7 @@ function buildIndicesPutSettings (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.put_settings](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-update-settings.html) request * @@ -77,29 +77,16 @@ function buildIndicesPutSettings (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesPutSettings(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.put_template.js b/api/api/indices.put_template.js index f7c3eb8aa..2ccc9a5a6 100644 --- a/api/api/indices.put_template.js +++ b/api/api/indices.put_template.js @@ -24,7 +24,7 @@ function buildIndicesPutTemplate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.put_template](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html) request * @@ -72,35 +72,20 @@ function buildIndicesPutTemplate (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesPutTemplate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['name'] == null) { - return callback( - new ConfigurationError('Missing required parameter: name'), - result - ) + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.recovery.js b/api/api/indices.recovery.js index dfcdcf11e..226637439 100644 --- a/api/api/indices.recovery.js +++ b/api/api/indices.recovery.js @@ -24,7 +24,7 @@ function buildIndicesRecovery (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.recovery](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-recovery.html) request * @@ -61,29 +61,16 @@ function buildIndicesRecovery (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesRecovery(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.refresh.js b/api/api/indices.refresh.js index 888ba0721..e246af298 100644 --- a/api/api/indices.refresh.js +++ b/api/api/indices.refresh.js @@ -24,7 +24,7 @@ function buildIndicesRefresh (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.refresh](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-refresh.html) request * @@ -65,29 +65,16 @@ function buildIndicesRefresh (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesRefresh(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.rollover.js b/api/api/indices.rollover.js index ba04aafc6..73ad046be 100644 --- a/api/api/indices.rollover.js +++ b/api/api/indices.rollover.js @@ -24,7 +24,7 @@ function buildIndicesRollover (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.rollover](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-rollover-index.html) request * @@ -72,37 +72,22 @@ function buildIndicesRollover (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesRollover(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['alias'] == null) { - return callback( - new ConfigurationError('Missing required parameter: alias'), - result - ) + const err = new ConfigurationError('Missing required parameter: alias') + return handleError(err, callback) } // check required url components if ((params['new_index'] != null || params['newIndex'] != null) && (params['alias'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: alias'), - result - ) + const err = new ConfigurationError('Missing required parameter of the url: alias') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.segments.js b/api/api/indices.segments.js index 07947e0d5..d571c8c65 100644 --- a/api/api/indices.segments.js +++ b/api/api/indices.segments.js @@ -24,7 +24,7 @@ function buildIndicesSegments (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.segments](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-segments.html) request * @@ -67,29 +67,16 @@ function buildIndicesSegments (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesSegments(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.shard_stores.js b/api/api/indices.shard_stores.js index 16ab0e17f..f835b5975 100644 --- a/api/api/indices.shard_stores.js +++ b/api/api/indices.shard_stores.js @@ -24,7 +24,7 @@ function buildIndicesShardStores (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.shard_stores](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shards-stores.html) request * @@ -67,29 +67,16 @@ function buildIndicesShardStores (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesShardStores(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.shrink.js b/api/api/indices.shrink.js index 6f0dbf7ed..e8dcbe934 100644 --- a/api/api/indices.shrink.js +++ b/api/api/indices.shrink.js @@ -24,7 +24,7 @@ function buildIndicesShrink (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.shrink](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shrink-index.html) request * @@ -69,43 +69,26 @@ function buildIndicesShrink (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesShrink(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params['target'] == null) { - return callback( - new ConfigurationError('Missing required parameter: target'), - result - ) + const err = new ConfigurationError('Missing required parameter: target') + return handleError(err, callback) } // check required url components if (params['target'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.split.js b/api/api/indices.split.js index 2048c5946..fbb062d1f 100644 --- a/api/api/indices.split.js +++ b/api/api/indices.split.js @@ -24,7 +24,7 @@ function buildIndicesSplit (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.split](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-split-index.html) request * @@ -69,43 +69,26 @@ function buildIndicesSplit (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesSplit(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params['target'] == null) { - return callback( - new ConfigurationError('Missing required parameter: target'), - result - ) + const err = new ConfigurationError('Missing required parameter: target') + return handleError(err, callback) } // check required url components if (params['target'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.stats.js b/api/api/indices.stats.js index 7730b4215..e4b811ea5 100644 --- a/api/api/indices.stats.js +++ b/api/api/indices.stats.js @@ -24,7 +24,7 @@ function buildIndicesStats (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.stats](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-stats.html) request * @@ -74,29 +74,16 @@ function buildIndicesStats (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesStats(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.unfreeze.js b/api/api/indices.unfreeze.js index 6f8185ec0..cac430b25 100644 --- a/api/api/indices.unfreeze.js +++ b/api/api/indices.unfreeze.js @@ -24,7 +24,7 @@ function buildIndicesUnfreeze (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.unfreeze](https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.html) request * @@ -66,35 +66,20 @@ function buildIndicesUnfreeze (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesUnfreeze(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.update_aliases.js b/api/api/indices.update_aliases.js index 43ead727b..869bd1e42 100644 --- a/api/api/indices.update_aliases.js +++ b/api/api/indices.update_aliases.js @@ -24,7 +24,7 @@ function buildIndicesUpdateAliases (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.update_aliases](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html) request * @@ -61,29 +61,16 @@ function buildIndicesUpdateAliases (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesUpdateAliases(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.upgrade.js b/api/api/indices.upgrade.js index 3ac30c597..a2b5e25b6 100644 --- a/api/api/indices.upgrade.js +++ b/api/api/indices.upgrade.js @@ -24,7 +24,7 @@ function buildIndicesUpgrade (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.upgrade](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-upgrade.html) request * @@ -71,29 +71,16 @@ function buildIndicesUpgrade (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesUpgrade(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/indices.validate_query.js b/api/api/indices.validate_query.js index 87a0c3331..fca278548 100644 --- a/api/api/indices.validate_query.js +++ b/api/api/indices.validate_query.js @@ -24,7 +24,7 @@ function buildIndicesValidateQuery (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [indices.validate_query](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-validate.html) request * @@ -88,29 +88,16 @@ function buildIndicesValidateQuery (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - indicesValidateQuery(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required url components if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/info.js b/api/api/info.js index 71393693a..681d465a4 100644 --- a/api/api/info.js +++ b/api/api/info.js @@ -24,7 +24,7 @@ function buildInfo (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [info](http://www.elastic.co/guide/) request * @@ -55,29 +55,16 @@ function buildInfo (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - info(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ingest.delete_pipeline.js b/api/api/ingest.delete_pipeline.js index 4f5ead813..98377da51 100644 --- a/api/api/ingest.delete_pipeline.js +++ b/api/api/ingest.delete_pipeline.js @@ -24,7 +24,7 @@ function buildIngestDeletePipeline (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ingest.delete_pipeline](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request * @@ -61,35 +61,20 @@ function buildIngestDeletePipeline (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ingestDeletePipeline(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['id'] == null) { - return callback( - new ConfigurationError('Missing required parameter: id'), - result - ) + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ingest.get_pipeline.js b/api/api/ingest.get_pipeline.js index 8ecd6a1c7..c0cd21726 100644 --- a/api/api/ingest.get_pipeline.js +++ b/api/api/ingest.get_pipeline.js @@ -24,7 +24,7 @@ function buildIngestGetPipeline (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ingest.get_pipeline](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request * @@ -59,29 +59,16 @@ function buildIngestGetPipeline (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ingestGetPipeline(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ingest.processor_grok.js b/api/api/ingest.processor_grok.js index 711193ce2..f3c88aa8f 100644 --- a/api/api/ingest.processor_grok.js +++ b/api/api/ingest.processor_grok.js @@ -24,7 +24,7 @@ function buildIngestProcessorGrok (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ingest.processor_grok](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request * @@ -55,29 +55,16 @@ function buildIngestProcessorGrok (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ingestProcessorGrok(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ingest.put_pipeline.js b/api/api/ingest.put_pipeline.js index c3d7f2a55..1ce8e62b7 100644 --- a/api/api/ingest.put_pipeline.js +++ b/api/api/ingest.put_pipeline.js @@ -24,7 +24,7 @@ function buildIngestPutPipeline (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ingest.put_pipeline](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request * @@ -62,35 +62,20 @@ function buildIngestPutPipeline (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ingestPutPipeline(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['id'] == null) { - return callback( - new ConfigurationError('Missing required parameter: id'), - result - ) + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ingest.simulate.js b/api/api/ingest.simulate.js index 990e6b784..b157763cb 100644 --- a/api/api/ingest.simulate.js +++ b/api/api/ingest.simulate.js @@ -24,7 +24,7 @@ function buildIngestSimulate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ingest.simulate](https://www.elastic.co/guide/en/elasticsearch/plugins/master/ingest.html) request * @@ -59,29 +59,16 @@ function buildIngestSimulate (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ingestSimulate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/mget.js b/api/api/mget.js index 2551c284a..f01283b20 100644 --- a/api/api/mget.js +++ b/api/api/mget.js @@ -24,7 +24,7 @@ function buildMget (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [mget](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-get.html) request * @@ -77,37 +77,22 @@ function buildMget (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mget(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // check required url components if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.close_job.js b/api/api/ml.close_job.js index e23ae7d6c..c5b2fb379 100644 --- a/api/api/ml.close_job.js +++ b/api/api/ml.close_job.js @@ -24,7 +24,7 @@ function buildMlCloseJob (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.close_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-close-job.html) request * @@ -58,29 +58,16 @@ function buildMlCloseJob (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlCloseJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['job_id'] == null && params['jobId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: job_id or jobId'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.delete_calendar.js b/api/api/ml.delete_calendar.js index 61c86a2f1..4d2cd5920 100644 --- a/api/api/ml.delete_calendar.js +++ b/api/api/ml.delete_calendar.js @@ -24,7 +24,7 @@ function buildMlDeleteCalendar (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.delete_calendar](undefined) request * @@ -51,35 +51,20 @@ function buildMlDeleteCalendar (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlDeleteCalendar(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['calendar_id'] == null && params['calendarId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: calendar_id or calendarId'), - result - ) + const err = new ConfigurationError('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.delete_calendar_event.js b/api/api/ml.delete_calendar_event.js index 9a7c31919..4470e735f 100644 --- a/api/api/ml.delete_calendar_event.js +++ b/api/api/ml.delete_calendar_event.js @@ -24,7 +24,7 @@ function buildMlDeleteCalendarEvent (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.delete_calendar_event](undefined) request * @@ -52,49 +52,30 @@ function buildMlDeleteCalendarEvent (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlDeleteCalendarEvent(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['calendar_id'] == null && params['calendarId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: calendar_id or calendarId'), - result - ) + const err = new ConfigurationError('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) } if (params['event_id'] == null && params['eventId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: event_id or eventId'), - result - ) + const err = new ConfigurationError('Missing required parameter: event_id or eventId') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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))) { - return callback( - new ConfigurationError('Missing required parameter of the url: calendar_id'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.delete_calendar_job.js b/api/api/ml.delete_calendar_job.js index 56d28eb2b..3bf8d33b8 100644 --- a/api/api/ml.delete_calendar_job.js +++ b/api/api/ml.delete_calendar_job.js @@ -24,7 +24,7 @@ function buildMlDeleteCalendarJob (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.delete_calendar_job](undefined) request * @@ -52,49 +52,30 @@ function buildMlDeleteCalendarJob (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlDeleteCalendarJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['calendar_id'] == null && params['calendarId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: calendar_id or calendarId'), - result - ) + const err = new ConfigurationError('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) } if (params['job_id'] == null && params['jobId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: job_id or jobId'), - result - ) + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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))) { - return callback( - new ConfigurationError('Missing required parameter of the url: calendar_id'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.delete_datafeed.js b/api/api/ml.delete_datafeed.js index 9b03cd943..1cee977d0 100644 --- a/api/api/ml.delete_datafeed.js +++ b/api/api/ml.delete_datafeed.js @@ -24,7 +24,7 @@ function buildMlDeleteDatafeed (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.delete_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html) request * @@ -52,35 +52,20 @@ function buildMlDeleteDatafeed (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlDeleteDatafeed(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['datafeed_id'] == null && params['datafeedId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: datafeed_id or datafeedId'), - result - ) + const err = new ConfigurationError('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.delete_expired_data.js b/api/api/ml.delete_expired_data.js index 834fb37d6..cf21a2e86 100644 --- a/api/api/ml.delete_expired_data.js +++ b/api/api/ml.delete_expired_data.js @@ -24,7 +24,7 @@ function buildMlDeleteExpiredData (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.delete_expired_data](undefined) request * @@ -50,29 +50,16 @@ function buildMlDeleteExpiredData (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlDeleteExpiredData(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.delete_filter.js b/api/api/ml.delete_filter.js index 79277818e..cdf204830 100644 --- a/api/api/ml.delete_filter.js +++ b/api/api/ml.delete_filter.js @@ -24,7 +24,7 @@ function buildMlDeleteFilter (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.delete_filter](undefined) request * @@ -51,35 +51,20 @@ function buildMlDeleteFilter (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlDeleteFilter(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['filter_id'] == null && params['filterId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: filter_id or filterId'), - result - ) + const err = new ConfigurationError('Missing required parameter: filter_id or filterId') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.delete_forecast.js b/api/api/ml.delete_forecast.js index 6d91e5d07..bb112a9ce 100644 --- a/api/api/ml.delete_forecast.js +++ b/api/api/ml.delete_forecast.js @@ -24,7 +24,7 @@ function buildMlDeleteForecast (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.delete_forecast](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html) request * @@ -56,43 +56,26 @@ function buildMlDeleteForecast (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlDeleteForecast(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['job_id'] == null && params['jobId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: job_id or jobId'), - result - ) + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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))) { - return callback( - new ConfigurationError('Missing required parameter of the url: job_id'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.delete_job.js b/api/api/ml.delete_job.js index 3f65d0e74..7a63de2b5 100644 --- a/api/api/ml.delete_job.js +++ b/api/api/ml.delete_job.js @@ -24,7 +24,7 @@ function buildMlDeleteJob (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.delete_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html) request * @@ -54,35 +54,20 @@ function buildMlDeleteJob (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlDeleteJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['job_id'] == null && params['jobId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: job_id or jobId'), - result - ) + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.delete_model_snapshot.js b/api/api/ml.delete_model_snapshot.js index af996d5b4..62a071ec1 100644 --- a/api/api/ml.delete_model_snapshot.js +++ b/api/api/ml.delete_model_snapshot.js @@ -24,7 +24,7 @@ function buildMlDeleteModelSnapshot (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -52,49 +52,30 @@ function buildMlDeleteModelSnapshot (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlDeleteModelSnapshot(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['job_id'] == null && params['jobId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: job_id or jobId'), - result - ) + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) } if (params['snapshot_id'] == null && params['snapshotId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: snapshot_id or snapshotId'), - result - ) + const err = new ConfigurationError('Missing required parameter: snapshot_id or snapshotId') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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))) { - return callback( - new ConfigurationError('Missing required parameter of the url: job_id'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.find_file_structure.js b/api/api/ml.find_file_structure.js index b310b2bd1..37d2db4dd 100644 --- a/api/api/ml.find_file_structure.js +++ b/api/api/ml.find_file_structure.js @@ -24,7 +24,7 @@ function buildMlFindFileStructure (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.find_file_structure](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-file-structure.html) request * @@ -83,29 +83,16 @@ function buildMlFindFileStructure (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlFindFileStructure(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.flush_job.js b/api/api/ml.flush_job.js index eb2b8c6cf..a2e1dae52 100644 --- a/api/api/ml.flush_job.js +++ b/api/api/ml.flush_job.js @@ -24,7 +24,7 @@ function buildMlFlushJob (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.flush_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-flush-job.html) request * @@ -63,29 +63,16 @@ function buildMlFlushJob (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlFlushJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['job_id'] == null && params['jobId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: job_id or jobId'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.forecast.js b/api/api/ml.forecast.js index a3b4187ca..b623627fb 100644 --- a/api/api/ml.forecast.js +++ b/api/api/ml.forecast.js @@ -24,7 +24,7 @@ function buildMlForecast (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.forecast](undefined) request * @@ -54,35 +54,20 @@ function buildMlForecast (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlForecast(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['job_id'] == null && params['jobId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: job_id or jobId'), - result - ) + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.get_buckets.js b/api/api/ml.get_buckets.js index 6fce8b6ce..80873c653 100644 --- a/api/api/ml.get_buckets.js +++ b/api/api/ml.get_buckets.js @@ -24,7 +24,7 @@ function buildMlGetBuckets (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.get_buckets](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-bucket.html) request * @@ -72,37 +72,22 @@ function buildMlGetBuckets (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetBuckets(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['job_id'] == null && params['jobId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: job_id or jobId'), - result - ) + 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))) { - return callback( - new ConfigurationError('Missing required parameter of the url: job_id'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.get_calendar_events.js b/api/api/ml.get_calendar_events.js index 96342cd0c..c7aa2d77a 100644 --- a/api/api/ml.get_calendar_events.js +++ b/api/api/ml.get_calendar_events.js @@ -24,7 +24,7 @@ function buildMlGetCalendarEvents (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.get_calendar_events](undefined) request * @@ -61,35 +61,20 @@ function buildMlGetCalendarEvents (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetCalendarEvents(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['calendar_id'] == null && params['calendarId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: calendar_id or calendarId'), - result - ) + const err = new ConfigurationError('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.get_calendars.js b/api/api/ml.get_calendars.js index 9a83b4527..365f18942 100644 --- a/api/api/ml.get_calendars.js +++ b/api/api/ml.get_calendars.js @@ -24,7 +24,7 @@ function buildMlGetCalendars (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.get_calendars](undefined) request * @@ -54,29 +54,16 @@ function buildMlGetCalendars (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetCalendars(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.get_categories.js b/api/api/ml.get_categories.js index 2fa566eb7..4ab14462f 100644 --- a/api/api/ml.get_categories.js +++ b/api/api/ml.get_categories.js @@ -24,7 +24,7 @@ function buildMlGetCategories (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.get_categories](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-category.html) request * @@ -56,29 +56,16 @@ function buildMlGetCategories (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetCategories(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['job_id'] == null && params['jobId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: job_id or jobId'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.get_datafeed_stats.js b/api/api/ml.get_datafeed_stats.js index 7880aa86c..e1e61aa33 100644 --- a/api/api/ml.get_datafeed_stats.js +++ b/api/api/ml.get_datafeed_stats.js @@ -24,7 +24,7 @@ function buildMlGetDatafeedStats (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -52,29 +52,16 @@ function buildMlGetDatafeedStats (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetDatafeedStats(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.get_datafeeds.js b/api/api/ml.get_datafeeds.js index 889b0d3f5..4f7fb7d66 100644 --- a/api/api/ml.get_datafeeds.js +++ b/api/api/ml.get_datafeeds.js @@ -24,7 +24,7 @@ function buildMlGetDatafeeds (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.get_datafeeds](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed.html) request * @@ -52,29 +52,16 @@ function buildMlGetDatafeeds (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetDatafeeds(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.get_filters.js b/api/api/ml.get_filters.js index 5c215fc50..f3f4a74e9 100644 --- a/api/api/ml.get_filters.js +++ b/api/api/ml.get_filters.js @@ -24,7 +24,7 @@ function buildMlGetFilters (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.get_filters](undefined) request * @@ -54,29 +54,16 @@ function buildMlGetFilters (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetFilters(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.get_influencers.js b/api/api/ml.get_influencers.js index f3c447eda..591d40e85 100644 --- a/api/api/ml.get_influencers.js +++ b/api/api/ml.get_influencers.js @@ -24,7 +24,7 @@ function buildMlGetInfluencers (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.get_influencers](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-influencer.html) request * @@ -69,29 +69,16 @@ function buildMlGetInfluencers (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetInfluencers(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['job_id'] == null && params['jobId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: job_id or jobId'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.get_job_stats.js b/api/api/ml.get_job_stats.js index 6cd1cc9ad..c0855dc08 100644 --- a/api/api/ml.get_job_stats.js +++ b/api/api/ml.get_job_stats.js @@ -24,7 +24,7 @@ function buildMlGetJobStats (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -52,29 +52,16 @@ function buildMlGetJobStats (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetJobStats(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.get_jobs.js b/api/api/ml.get_jobs.js index d62975796..17d83fec9 100644 --- a/api/api/ml.get_jobs.js +++ b/api/api/ml.get_jobs.js @@ -24,7 +24,7 @@ function buildMlGetJobs (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.get_jobs](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job.html) request * @@ -52,29 +52,16 @@ function buildMlGetJobs (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetJobs(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.get_model_snapshots.js b/api/api/ml.get_model_snapshots.js index 44a11e3c0..466c6829d 100644 --- a/api/api/ml.get_model_snapshots.js +++ b/api/api/ml.get_model_snapshots.js @@ -24,7 +24,7 @@ function buildMlGetModelSnapshots (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -64,37 +64,22 @@ function buildMlGetModelSnapshots (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetModelSnapshots(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['job_id'] == null && params['jobId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: job_id or jobId'), - result - ) + 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))) { - return callback( - new ConfigurationError('Missing required parameter of the url: job_id'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.get_overall_buckets.js b/api/api/ml.get_overall_buckets.js index e5a0abe59..ba1c7c9ac 100644 --- a/api/api/ml.get_overall_buckets.js +++ b/api/api/ml.get_overall_buckets.js @@ -24,7 +24,7 @@ function buildMlGetOverallBuckets (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -69,29 +69,16 @@ function buildMlGetOverallBuckets (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetOverallBuckets(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['job_id'] == null && params['jobId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: job_id or jobId'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.get_records.js b/api/api/ml.get_records.js index b26b6c382..3a3e5335f 100644 --- a/api/api/ml.get_records.js +++ b/api/api/ml.get_records.js @@ -24,7 +24,7 @@ function buildMlGetRecords (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.get_records](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-record.html) request * @@ -69,29 +69,16 @@ function buildMlGetRecords (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlGetRecords(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['job_id'] == null && params['jobId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: job_id or jobId'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.info.js b/api/api/ml.info.js index 8fbd22b38..3e0b95328 100644 --- a/api/api/ml.info.js +++ b/api/api/ml.info.js @@ -24,7 +24,7 @@ function buildMlInfo (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.info](undefined) request * @@ -50,21 +50,10 @@ function buildMlInfo (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlInfo(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.open_job.js b/api/api/ml.open_job.js index ce4ed8a60..72b4ab402 100644 --- a/api/api/ml.open_job.js +++ b/api/api/ml.open_job.js @@ -24,7 +24,7 @@ function buildMlOpenJob (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.open_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html) request * @@ -53,35 +53,20 @@ function buildMlOpenJob (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlOpenJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['job_id'] == null && params['jobId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: job_id or jobId'), - result - ) + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.post_calendar_events.js b/api/api/ml.post_calendar_events.js index 30c9d0483..8ad6e683d 100644 --- a/api/api/ml.post_calendar_events.js +++ b/api/api/ml.post_calendar_events.js @@ -24,7 +24,7 @@ function buildMlPostCalendarEvents (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.post_calendar_events](undefined) request * @@ -52,35 +52,20 @@ function buildMlPostCalendarEvents (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlPostCalendarEvents(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['calendar_id'] == null && params['calendarId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: calendar_id or calendarId'), - result - ) + const err = new ConfigurationError('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.post_data.js b/api/api/ml.post_data.js index 63e754991..4661fc231 100644 --- a/api/api/ml.post_data.js +++ b/api/api/ml.post_data.js @@ -24,7 +24,7 @@ function buildMlPostData (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.post_data](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-data.html) request * @@ -56,35 +56,20 @@ function buildMlPostData (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlPostData(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['job_id'] == null && params['jobId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: job_id or jobId'), - result - ) + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.preview_datafeed.js b/api/api/ml.preview_datafeed.js index 33eade853..0f78bc7dd 100644 --- a/api/api/ml.preview_datafeed.js +++ b/api/api/ml.preview_datafeed.js @@ -24,7 +24,7 @@ function buildMlPreviewDatafeed (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.preview_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html) request * @@ -51,35 +51,20 @@ function buildMlPreviewDatafeed (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlPreviewDatafeed(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['datafeed_id'] == null && params['datafeedId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: datafeed_id or datafeedId'), - result - ) + const err = new ConfigurationError('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.put_calendar.js b/api/api/ml.put_calendar.js index 8d83eeb8e..bcd5d40ac 100644 --- a/api/api/ml.put_calendar.js +++ b/api/api/ml.put_calendar.js @@ -24,7 +24,7 @@ function buildMlPutCalendar (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.put_calendar](undefined) request * @@ -52,29 +52,16 @@ function buildMlPutCalendar (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlPutCalendar(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['calendar_id'] == null && params['calendarId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: calendar_id or calendarId'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.put_calendar_job.js b/api/api/ml.put_calendar_job.js index a10aa05ea..3f160c47d 100644 --- a/api/api/ml.put_calendar_job.js +++ b/api/api/ml.put_calendar_job.js @@ -24,7 +24,7 @@ function buildMlPutCalendarJob (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.put_calendar_job](undefined) request * @@ -52,49 +52,30 @@ function buildMlPutCalendarJob (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlPutCalendarJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['calendar_id'] == null && params['calendarId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: calendar_id or calendarId'), - result - ) + const err = new ConfigurationError('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) } if (params['job_id'] == null && params['jobId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: job_id or jobId'), - result - ) + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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))) { - return callback( - new ConfigurationError('Missing required parameter of the url: calendar_id'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.put_datafeed.js b/api/api/ml.put_datafeed.js index 8ebdcaaed..2de0baa75 100644 --- a/api/api/ml.put_datafeed.js +++ b/api/api/ml.put_datafeed.js @@ -24,7 +24,7 @@ function buildMlPutDatafeed (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.put_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-datafeed.html) request * @@ -52,35 +52,20 @@ function buildMlPutDatafeed (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlPutDatafeed(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['datafeed_id'] == null && params['datafeedId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: datafeed_id or datafeedId'), - result - ) + const err = new ConfigurationError('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.put_filter.js b/api/api/ml.put_filter.js index 7b36d7c03..057f71e1e 100644 --- a/api/api/ml.put_filter.js +++ b/api/api/ml.put_filter.js @@ -24,7 +24,7 @@ function buildMlPutFilter (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.put_filter](undefined) request * @@ -52,35 +52,20 @@ function buildMlPutFilter (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlPutFilter(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['filter_id'] == null && params['filterId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: filter_id or filterId'), - result - ) + const err = new ConfigurationError('Missing required parameter: filter_id or filterId') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.put_job.js b/api/api/ml.put_job.js index ee59f4507..0aa4a256e 100644 --- a/api/api/ml.put_job.js +++ b/api/api/ml.put_job.js @@ -24,7 +24,7 @@ function buildMlPutJob (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.put_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html) request * @@ -52,35 +52,20 @@ function buildMlPutJob (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlPutJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['job_id'] == null && params['jobId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: job_id or jobId'), - result - ) + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.revert_model_snapshot.js b/api/api/ml.revert_model_snapshot.js index 021c14589..41ff3c13b 100644 --- a/api/api/ml.revert_model_snapshot.js +++ b/api/api/ml.revert_model_snapshot.js @@ -24,7 +24,7 @@ function buildMlRevertModelSnapshot (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -54,43 +54,26 @@ function buildMlRevertModelSnapshot (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlRevertModelSnapshot(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['job_id'] == null && params['jobId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: job_id or jobId'), - result - ) + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) } if (params['snapshot_id'] == null && params['snapshotId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: snapshot_id or snapshotId'), - result - ) + 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))) { - return callback( - new ConfigurationError('Missing required parameter of the url: job_id'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.set_upgrade_mode.js b/api/api/ml.set_upgrade_mode.js index d83f85798..57a4df4d1 100644 --- a/api/api/ml.set_upgrade_mode.js +++ b/api/api/ml.set_upgrade_mode.js @@ -24,7 +24,7 @@ function buildMlSetUpgradeMode (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -53,29 +53,16 @@ function buildMlSetUpgradeMode (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlSetUpgradeMode(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.start_datafeed.js b/api/api/ml.start_datafeed.js index f3d3abda0..1c11f9f31 100644 --- a/api/api/ml.start_datafeed.js +++ b/api/api/ml.start_datafeed.js @@ -24,7 +24,7 @@ function buildMlStartDatafeed (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.start_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-start-datafeed.html) request * @@ -57,29 +57,16 @@ function buildMlStartDatafeed (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlStartDatafeed(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['datafeed_id'] == null && params['datafeedId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: datafeed_id or datafeedId'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.stop_datafeed.js b/api/api/ml.stop_datafeed.js index e148f50b4..f845de47a 100644 --- a/api/api/ml.stop_datafeed.js +++ b/api/api/ml.stop_datafeed.js @@ -24,7 +24,7 @@ function buildMlStopDatafeed (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.stop_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-stop-datafeed.html) request * @@ -57,29 +57,16 @@ function buildMlStopDatafeed (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlStopDatafeed(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['datafeed_id'] == null && params['datafeedId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: datafeed_id or datafeedId'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.update_datafeed.js b/api/api/ml.update_datafeed.js index 2335a79d6..486a2b881 100644 --- a/api/api/ml.update_datafeed.js +++ b/api/api/ml.update_datafeed.js @@ -24,7 +24,7 @@ function buildMlUpdateDatafeed (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.update_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-datafeed.html) request * @@ -52,35 +52,20 @@ function buildMlUpdateDatafeed (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlUpdateDatafeed(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['datafeed_id'] == null && params['datafeedId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: datafeed_id or datafeedId'), - result - ) + const err = new ConfigurationError('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.update_filter.js b/api/api/ml.update_filter.js index 058e037af..0b203684d 100644 --- a/api/api/ml.update_filter.js +++ b/api/api/ml.update_filter.js @@ -24,7 +24,7 @@ function buildMlUpdateFilter (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.update_filter](undefined) request * @@ -52,35 +52,20 @@ function buildMlUpdateFilter (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlUpdateFilter(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['filter_id'] == null && params['filterId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: filter_id or filterId'), - result - ) + const err = new ConfigurationError('Missing required parameter: filter_id or filterId') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.update_job.js b/api/api/ml.update_job.js index d816daa25..2e9617666 100644 --- a/api/api/ml.update_job.js +++ b/api/api/ml.update_job.js @@ -24,7 +24,7 @@ function buildMlUpdateJob (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.update_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-job.html) request * @@ -52,35 +52,20 @@ function buildMlUpdateJob (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlUpdateJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['job_id'] == null && params['jobId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: job_id or jobId'), - result - ) + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.update_model_snapshot.js b/api/api/ml.update_model_snapshot.js index 916fcbd38..7e80fa05b 100644 --- a/api/api/ml.update_model_snapshot.js +++ b/api/api/ml.update_model_snapshot.js @@ -24,7 +24,7 @@ function buildMlUpdateModelSnapshot (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -53,49 +53,30 @@ function buildMlUpdateModelSnapshot (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlUpdateModelSnapshot(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['job_id'] == null && params['jobId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: job_id or jobId'), - result - ) + const err = new ConfigurationError('Missing required parameter: job_id or jobId') + return handleError(err, callback) } if (params['snapshot_id'] == null && params['snapshotId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: snapshot_id or snapshotId'), - result - ) + const err = new ConfigurationError('Missing required parameter: snapshot_id or snapshotId') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + 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))) { - return callback( - new ConfigurationError('Missing required parameter of the url: job_id'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.validate.js b/api/api/ml.validate.js index 27d73b843..61b6da7c7 100644 --- a/api/api/ml.validate.js +++ b/api/api/ml.validate.js @@ -24,7 +24,7 @@ function buildMlValidate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.validate](undefined) request * @@ -51,29 +51,16 @@ function buildMlValidate (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlValidate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ml.validate_detector.js b/api/api/ml.validate_detector.js index fb33bf0f4..8b00f4597 100644 --- a/api/api/ml.validate_detector.js +++ b/api/api/ml.validate_detector.js @@ -24,7 +24,7 @@ function buildMlValidateDetector (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ml.validate_detector](undefined) request * @@ -51,29 +51,16 @@ function buildMlValidateDetector (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mlValidateDetector(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/monitoring.bulk.js b/api/api/monitoring.bulk.js index a64e64df1..ff488720b 100644 --- a/api/api/monitoring.bulk.js +++ b/api/api/monitoring.bulk.js @@ -24,7 +24,7 @@ function buildMonitoringBulk (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [monitoring.bulk](http://www.elastic.co/guide/en/monitoring/current/appendix-api-bulk.html) request * @@ -59,29 +59,16 @@ function buildMonitoringBulk (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - monitoringBulk(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/msearch.js b/api/api/msearch.js index 9bcfa7f59..a4615c4fb 100644 --- a/api/api/msearch.js +++ b/api/api/msearch.js @@ -24,7 +24,7 @@ function buildMsearch (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [msearch](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-multi-search.html) request * @@ -79,37 +79,22 @@ function buildMsearch (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - msearch(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // check required url components if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/msearch_template.js b/api/api/msearch_template.js index 6a9742b81..1692f567f 100644 --- a/api/api/msearch_template.js +++ b/api/api/msearch_template.js @@ -24,7 +24,7 @@ function buildMsearchTemplate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [msearch_template](http://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html) request * @@ -73,37 +73,22 @@ function buildMsearchTemplate (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - msearchTemplate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // check required url components if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/mtermvectors.js b/api/api/mtermvectors.js index fe3536d58..fe4c49a6e 100644 --- a/api/api/mtermvectors.js +++ b/api/api/mtermvectors.js @@ -24,7 +24,7 @@ function buildMtermvectors (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [mtermvectors](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-termvectors.html) request * @@ -87,29 +87,16 @@ function buildMtermvectors (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - mtermvectors(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required url components if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/nodes.hot_threads.js b/api/api/nodes.hot_threads.js index 89525e654..12f59399c 100644 --- a/api/api/nodes.hot_threads.js +++ b/api/api/nodes.hot_threads.js @@ -24,7 +24,7 @@ function buildNodesHotThreads (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [nodes.hot_threads](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-hot-threads.html) request * @@ -69,29 +69,16 @@ function buildNodesHotThreads (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - nodesHotThreads(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/nodes.info.js b/api/api/nodes.info.js index c7fa93da0..4179dd155 100644 --- a/api/api/nodes.info.js +++ b/api/api/nodes.info.js @@ -24,7 +24,7 @@ function buildNodesInfo (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [nodes.info](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-info.html) request * @@ -62,29 +62,16 @@ function buildNodesInfo (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - nodesInfo(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/nodes.reload_secure_settings.js b/api/api/nodes.reload_secure_settings.js index 3d9e0d167..53f6a6a1a 100644 --- a/api/api/nodes.reload_secure_settings.js +++ b/api/api/nodes.reload_secure_settings.js @@ -24,7 +24,7 @@ function buildNodesReloadSecureSettings (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -58,29 +58,16 @@ function buildNodesReloadSecureSettings (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - nodesReloadSecureSettings(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/nodes.stats.js b/api/api/nodes.stats.js index 0606d2b2f..4553511fd 100644 --- a/api/api/nodes.stats.js +++ b/api/api/nodes.stats.js @@ -24,7 +24,7 @@ function buildNodesStats (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [nodes.stats](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-stats.html) request * @@ -77,29 +77,16 @@ function buildNodesStats (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - nodesStats(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/nodes.usage.js b/api/api/nodes.usage.js index 743486535..308a6645b 100644 --- a/api/api/nodes.usage.js +++ b/api/api/nodes.usage.js @@ -24,7 +24,7 @@ function buildNodesUsage (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [nodes.usage](http://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html) request * @@ -59,29 +59,16 @@ function buildNodesUsage (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - nodesUsage(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ping.js b/api/api/ping.js index 72ea90bf2..71192c360 100644 --- a/api/api/ping.js +++ b/api/api/ping.js @@ -24,7 +24,7 @@ function buildPing (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ping](http://www.elastic.co/guide/) request * @@ -55,29 +55,16 @@ function buildPing (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ping(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/put_script.js b/api/api/put_script.js index 8b0d5b07c..bad10957b 100644 --- a/api/api/put_script.js +++ b/api/api/put_script.js @@ -24,7 +24,7 @@ function buildPutScript (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [put_script](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html) request * @@ -65,43 +65,26 @@ function buildPutScript (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - putScript(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['id'] == null) { - return callback( - new ConfigurationError('Missing required parameter: id'), - result - ) + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // check required url components if (params['context'] != null && (params['id'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: id'), - result - ) + const err = new ConfigurationError('Missing required parameter of the url: id') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/rank_eval.js b/api/api/rank_eval.js index b109a1aac..a32132466 100644 --- a/api/api/rank_eval.js +++ b/api/api/rank_eval.js @@ -24,7 +24,7 @@ function buildRankEval (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [rank_eval](https://www.elastic.co/guide/en/elasticsearch/reference/master/search-rank-eval.html) request * @@ -66,29 +66,16 @@ function buildRankEval (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - rankEval(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/reindex.js b/api/api/reindex.js index 765f76057..90397417b 100644 --- a/api/api/reindex.js +++ b/api/api/reindex.js @@ -24,7 +24,7 @@ function buildReindex (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [reindex](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html) request * @@ -71,29 +71,16 @@ function buildReindex (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - reindex(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/reindex_rethrottle.js b/api/api/reindex_rethrottle.js index b28d2d755..605a2ea83 100644 --- a/api/api/reindex_rethrottle.js +++ b/api/api/reindex_rethrottle.js @@ -24,7 +24,7 @@ function buildReindexRethrottle (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [reindex_rethrottle](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html) request * @@ -59,41 +59,24 @@ function buildReindexRethrottle (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - reindexRethrottle(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['task_id'] == null && params['taskId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: task_id or taskId'), - result - ) + const err = new ConfigurationError('Missing required parameter: task_id or taskId') + return handleError(err, callback) } if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) { - return callback( - new ConfigurationError('Missing required parameter: requests_per_second or requestsPerSecond'), - result - ) + const err = new ConfigurationError('Missing required parameter: requests_per_second or requestsPerSecond') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/render_search_template.js b/api/api/render_search_template.js index 70a36e2e0..59bcab0b1 100644 --- a/api/api/render_search_template.js +++ b/api/api/render_search_template.js @@ -24,7 +24,7 @@ function buildRenderSearchTemplate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [render_search_template](http://www.elasticsearch.org/guide/en/elasticsearch/reference/master/search-template.html) request * @@ -57,21 +57,10 @@ function buildRenderSearchTemplate (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - renderSearchTemplate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/scripts_painless_execute.js b/api/api/scripts_painless_execute.js index a2af1402f..3a2785063 100644 --- a/api/api/scripts_painless_execute.js +++ b/api/api/scripts_painless_execute.js @@ -24,7 +24,7 @@ function buildScriptsPainlessExecute (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [scripts_painless_execute](https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html) request * @@ -56,21 +56,10 @@ function buildScriptsPainlessExecute (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - scriptsPainlessExecute(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/scroll.js b/api/api/scroll.js index b5b93aa81..0bfd11aff 100644 --- a/api/api/scroll.js +++ b/api/api/scroll.js @@ -24,7 +24,7 @@ function buildScroll (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [scroll](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-scroll.html) request * @@ -65,21 +65,10 @@ function buildScroll (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - scroll(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/search.js b/api/api/search.js index 7606320e2..c7c08cd8d 100644 --- a/api/api/search.js +++ b/api/api/search.js @@ -24,7 +24,7 @@ function buildSearch (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [search](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-search.html) request * @@ -169,29 +169,16 @@ function buildSearch (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - search(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required url components if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/search_shards.js b/api/api/search_shards.js index 9451b2cd7..43eed2ed8 100644 --- a/api/api/search_shards.js +++ b/api/api/search_shards.js @@ -24,7 +24,7 @@ function buildSearchShards (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [search_shards](http://www.elastic.co/guide/en/elasticsearch/reference/master/search-shards.html) request * @@ -71,29 +71,16 @@ function buildSearchShards (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - searchShards(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/search_template.js b/api/api/search_template.js index 37b72ea8f..aadc63aaf 100644 --- a/api/api/search_template.js +++ b/api/api/search_template.js @@ -24,7 +24,7 @@ function buildSearchTemplate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [search_template](http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html) request * @@ -92,37 +92,22 @@ function buildSearchTemplate (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - searchTemplate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // check required url components if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.authenticate.js b/api/api/security.authenticate.js index ecbf4448b..747b7718c 100644 --- a/api/api/security.authenticate.js +++ b/api/api/security.authenticate.js @@ -24,7 +24,7 @@ function buildSecurityAuthenticate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [security.authenticate](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-authenticate.html) request * @@ -50,29 +50,16 @@ function buildSecurityAuthenticate (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityAuthenticate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.change_password.js b/api/api/security.change_password.js index d1c59dbed..b0a9ed5d0 100644 --- a/api/api/security.change_password.js +++ b/api/api/security.change_password.js @@ -24,7 +24,7 @@ function buildSecurityChangePassword (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -53,29 +53,16 @@ function buildSecurityChangePassword (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityChangePassword(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.clear_cached_realms.js b/api/api/security.clear_cached_realms.js index 2af732622..8cd3bf99b 100644 --- a/api/api/security.clear_cached_realms.js +++ b/api/api/security.clear_cached_realms.js @@ -24,7 +24,7 @@ function buildSecurityClearCachedRealms (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -52,35 +52,20 @@ function buildSecurityClearCachedRealms (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityClearCachedRealms(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['realms'] == null) { - return callback( - new ConfigurationError('Missing required parameter: realms'), - result - ) + const err = new ConfigurationError('Missing required parameter: realms') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.clear_cached_roles.js b/api/api/security.clear_cached_roles.js index 67d30b743..41de57377 100644 --- a/api/api/security.clear_cached_roles.js +++ b/api/api/security.clear_cached_roles.js @@ -24,7 +24,7 @@ function buildSecurityClearCachedRoles (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -51,35 +51,20 @@ function buildSecurityClearCachedRoles (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityClearCachedRoles(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['name'] == null) { - return callback( - new ConfigurationError('Missing required parameter: name'), - result - ) + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.create_api_key.js b/api/api/security.create_api_key.js index f96a3a5d5..bb5e69379 100644 --- a/api/api/security.create_api_key.js +++ b/api/api/security.create_api_key.js @@ -24,7 +24,7 @@ function buildSecurityCreateApiKey (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -52,29 +52,16 @@ function buildSecurityCreateApiKey (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityCreateApiKey(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.delete_privileges.js b/api/api/security.delete_privileges.js index 92f9e36b9..9cfd26d1c 100644 --- a/api/api/security.delete_privileges.js +++ b/api/api/security.delete_privileges.js @@ -24,7 +24,7 @@ function buildSecurityDeletePrivileges (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [security.delete_privileges](TODO) request * @@ -53,49 +53,30 @@ function buildSecurityDeletePrivileges (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityDeletePrivileges(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['application'] == null) { - return callback( - new ConfigurationError('Missing required parameter: application'), - result - ) + const err = new ConfigurationError('Missing required parameter: application') + return handleError(err, callback) } if (params['name'] == null) { - return callback( - new ConfigurationError('Missing required parameter: name'), - result - ) + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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)) { - return callback( - new ConfigurationError('Missing required parameter of the url: application'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.delete_role.js b/api/api/security.delete_role.js index 5901a856f..6fb2d0496 100644 --- a/api/api/security.delete_role.js +++ b/api/api/security.delete_role.js @@ -24,7 +24,7 @@ function buildSecurityDeleteRole (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -52,35 +52,20 @@ function buildSecurityDeleteRole (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityDeleteRole(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['name'] == null) { - return callback( - new ConfigurationError('Missing required parameter: name'), - result - ) + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.delete_role_mapping.js b/api/api/security.delete_role_mapping.js index 6b546b179..700d76f4f 100644 --- a/api/api/security.delete_role_mapping.js +++ b/api/api/security.delete_role_mapping.js @@ -24,7 +24,7 @@ function buildSecurityDeleteRoleMapping (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -52,35 +52,20 @@ function buildSecurityDeleteRoleMapping (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityDeleteRoleMapping(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['name'] == null) { - return callback( - new ConfigurationError('Missing required parameter: name'), - result - ) + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.delete_user.js b/api/api/security.delete_user.js index 198f461fe..7fb437fe2 100644 --- a/api/api/security.delete_user.js +++ b/api/api/security.delete_user.js @@ -24,7 +24,7 @@ function buildSecurityDeleteUser (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -52,35 +52,20 @@ function buildSecurityDeleteUser (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityDeleteUser(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['username'] == null) { - return callback( - new ConfigurationError('Missing required parameter: username'), - result - ) + const err = new ConfigurationError('Missing required parameter: username') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.disable_user.js b/api/api/security.disable_user.js index d8b6452dc..d991c4853 100644 --- a/api/api/security.disable_user.js +++ b/api/api/security.disable_user.js @@ -24,7 +24,7 @@ function buildSecurityDisableUser (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -52,29 +52,16 @@ function buildSecurityDisableUser (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityDisableUser(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.enable_user.js b/api/api/security.enable_user.js index ad2c9dbc3..de69556c4 100644 --- a/api/api/security.enable_user.js +++ b/api/api/security.enable_user.js @@ -24,7 +24,7 @@ function buildSecurityEnableUser (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -52,29 +52,16 @@ function buildSecurityEnableUser (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityEnableUser(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.get_api_key.js b/api/api/security.get_api_key.js index bbbb4ad74..9a82ec39e 100644 --- a/api/api/security.get_api_key.js +++ b/api/api/security.get_api_key.js @@ -24,7 +24,7 @@ function buildSecurityGetApiKey (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -57,29 +57,16 @@ function buildSecurityGetApiKey (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityGetApiKey(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.get_privileges.js b/api/api/security.get_privileges.js index 952bacd6b..fd2d39da1 100644 --- a/api/api/security.get_privileges.js +++ b/api/api/security.get_privileges.js @@ -24,7 +24,7 @@ function buildSecurityGetPrivileges (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [security.get_privileges](TODO) request * @@ -52,37 +52,22 @@ function buildSecurityGetPrivileges (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityGetPrivileges(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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)) { - return callback( - new ConfigurationError('Missing required parameter of the url: application'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.get_role.js b/api/api/security.get_role.js index ea5b12583..d2b433f1d 100644 --- a/api/api/security.get_role.js +++ b/api/api/security.get_role.js @@ -24,7 +24,7 @@ function buildSecurityGetRole (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -51,29 +51,16 @@ function buildSecurityGetRole (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityGetRole(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.get_role_mapping.js b/api/api/security.get_role_mapping.js index 62915f1c6..1c3e2287c 100644 --- a/api/api/security.get_role_mapping.js +++ b/api/api/security.get_role_mapping.js @@ -24,7 +24,7 @@ function buildSecurityGetRoleMapping (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -51,29 +51,16 @@ function buildSecurityGetRoleMapping (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityGetRoleMapping(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.get_token.js b/api/api/security.get_token.js index aa19be41d..6e3245b62 100644 --- a/api/api/security.get_token.js +++ b/api/api/security.get_token.js @@ -24,7 +24,7 @@ function buildSecurityGetToken (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -51,29 +51,16 @@ function buildSecurityGetToken (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityGetToken(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.get_user.js b/api/api/security.get_user.js index 4419b0e08..abedf7cc5 100644 --- a/api/api/security.get_user.js +++ b/api/api/security.get_user.js @@ -24,7 +24,7 @@ function buildSecurityGetUser (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -51,29 +51,16 @@ function buildSecurityGetUser (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityGetUser(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.get_user_privileges.js b/api/api/security.get_user_privileges.js index 6d812c8db..4b489297b 100644 --- a/api/api/security.get_user_privileges.js +++ b/api/api/security.get_user_privileges.js @@ -24,7 +24,7 @@ function buildSecurityGetUserPrivileges (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [security.get_user_privileges](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-privileges.html) request * @@ -50,29 +50,16 @@ function buildSecurityGetUserPrivileges (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityGetUserPrivileges(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.has_privileges.js b/api/api/security.has_privileges.js index 6f74c21a7..ba46e6fde 100644 --- a/api/api/security.has_privileges.js +++ b/api/api/security.has_privileges.js @@ -24,7 +24,7 @@ function buildSecurityHasPrivileges (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -52,29 +52,16 @@ function buildSecurityHasPrivileges (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityHasPrivileges(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.invalidate_api_key.js b/api/api/security.invalidate_api_key.js index 0da252564..f32685f97 100644 --- a/api/api/security.invalidate_api_key.js +++ b/api/api/security.invalidate_api_key.js @@ -24,7 +24,7 @@ function buildSecurityInvalidateApiKey (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -51,29 +51,16 @@ function buildSecurityInvalidateApiKey (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityInvalidateApiKey(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.invalidate_token.js b/api/api/security.invalidate_token.js index 09e66f50b..0e891bf38 100644 --- a/api/api/security.invalidate_token.js +++ b/api/api/security.invalidate_token.js @@ -24,7 +24,7 @@ function buildSecurityInvalidateToken (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -51,29 +51,16 @@ function buildSecurityInvalidateToken (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityInvalidateToken(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.put_privileges.js b/api/api/security.put_privileges.js index dfb90769e..c20c25a91 100644 --- a/api/api/security.put_privileges.js +++ b/api/api/security.put_privileges.js @@ -24,7 +24,7 @@ function buildSecurityPutPrivileges (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [security.put_privileges](TODO) request * @@ -52,29 +52,16 @@ function buildSecurityPutPrivileges (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityPutPrivileges(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.put_role.js b/api/api/security.put_role.js index e417e69b2..3becd8b55 100644 --- a/api/api/security.put_role.js +++ b/api/api/security.put_role.js @@ -24,7 +24,7 @@ function buildSecurityPutRole (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -53,35 +53,20 @@ function buildSecurityPutRole (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityPutRole(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['name'] == null) { - return callback( - new ConfigurationError('Missing required parameter: name'), - result - ) + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.put_role_mapping.js b/api/api/security.put_role_mapping.js index 45a25fc38..cd40cbad1 100644 --- a/api/api/security.put_role_mapping.js +++ b/api/api/security.put_role_mapping.js @@ -24,7 +24,7 @@ function buildSecurityPutRoleMapping (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -53,35 +53,20 @@ function buildSecurityPutRoleMapping (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityPutRoleMapping(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['name'] == null) { - return callback( - new ConfigurationError('Missing required parameter: name'), - result - ) + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/security.put_user.js b/api/api/security.put_user.js index 9e8f46fb7..73e1e6722 100644 --- a/api/api/security.put_user.js +++ b/api/api/security.put_user.js @@ -24,7 +24,7 @@ function buildSecurityPutUser (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -53,35 +53,20 @@ function buildSecurityPutUser (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - securityPutUser(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['username'] == null) { - return callback( - new ConfigurationError('Missing required parameter: username'), - result - ) + const err = new ConfigurationError('Missing required parameter: username') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/snapshot.create.js b/api/api/snapshot.create.js index b3f3f426e..e1aa00e93 100644 --- a/api/api/snapshot.create.js +++ b/api/api/snapshot.create.js @@ -24,7 +24,7 @@ function buildSnapshotCreate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [snapshot.create](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request * @@ -64,43 +64,26 @@ function buildSnapshotCreate (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - snapshotCreate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['repository'] == null) { - return callback( - new ConfigurationError('Missing required parameter: repository'), - result - ) + const err = new ConfigurationError('Missing required parameter: repository') + return handleError(err, callback) } if (params['snapshot'] == null) { - return callback( - new ConfigurationError('Missing required parameter: snapshot'), - result - ) + const err = new ConfigurationError('Missing required parameter: snapshot') + return handleError(err, callback) } // check required url components if (params['snapshot'] != null && (params['repository'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: repository'), - result - ) + const err = new ConfigurationError('Missing required parameter of the url: repository') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/snapshot.create_repository.js b/api/api/snapshot.create_repository.js index b4db9c44c..ff1c1f80c 100644 --- a/api/api/snapshot.create_repository.js +++ b/api/api/snapshot.create_repository.js @@ -24,7 +24,7 @@ function buildSnapshotCreateRepository (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [snapshot.create_repository](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request * @@ -64,35 +64,20 @@ function buildSnapshotCreateRepository (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - snapshotCreateRepository(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['repository'] == null) { - return callback( - new ConfigurationError('Missing required parameter: repository'), - result - ) + const err = new ConfigurationError('Missing required parameter: repository') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/snapshot.delete.js b/api/api/snapshot.delete.js index 917c26630..22f309ae7 100644 --- a/api/api/snapshot.delete.js +++ b/api/api/snapshot.delete.js @@ -24,7 +24,7 @@ function buildSnapshotDelete (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [snapshot.delete](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request * @@ -60,49 +60,30 @@ function buildSnapshotDelete (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - snapshotDelete(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['repository'] == null) { - return callback( - new ConfigurationError('Missing required parameter: repository'), - result - ) + const err = new ConfigurationError('Missing required parameter: repository') + return handleError(err, callback) } if (params['snapshot'] == null) { - return callback( - new ConfigurationError('Missing required parameter: snapshot'), - result - ) + const err = new ConfigurationError('Missing required parameter: snapshot') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) } // check required url components if (params['snapshot'] != null && (params['repository'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: repository'), - result - ) + const err = new ConfigurationError('Missing required parameter of the url: repository') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/snapshot.delete_repository.js b/api/api/snapshot.delete_repository.js index 6e6aad2d9..0316765cd 100644 --- a/api/api/snapshot.delete_repository.js +++ b/api/api/snapshot.delete_repository.js @@ -24,7 +24,7 @@ function buildSnapshotDeleteRepository (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [snapshot.delete_repository](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request * @@ -61,35 +61,20 @@ function buildSnapshotDeleteRepository (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - snapshotDeleteRepository(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['repository'] == null) { - return callback( - new ConfigurationError('Missing required parameter: repository'), - result - ) + const err = new ConfigurationError('Missing required parameter: repository') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/snapshot.get.js b/api/api/snapshot.get.js index 0d1a437c6..f3b4243f6 100644 --- a/api/api/snapshot.get.js +++ b/api/api/snapshot.get.js @@ -24,7 +24,7 @@ function buildSnapshotGet (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [snapshot.get](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request * @@ -65,49 +65,30 @@ function buildSnapshotGet (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - snapshotGet(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['repository'] == null) { - return callback( - new ConfigurationError('Missing required parameter: repository'), - result - ) + const err = new ConfigurationError('Missing required parameter: repository') + return handleError(err, callback) } if (params['snapshot'] == null) { - return callback( - new ConfigurationError('Missing required parameter: snapshot'), - result - ) + const err = new ConfigurationError('Missing required parameter: snapshot') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) } // check required url components if (params['snapshot'] != null && (params['repository'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: repository'), - result - ) + const err = new ConfigurationError('Missing required parameter of the url: repository') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/snapshot.get_repository.js b/api/api/snapshot.get_repository.js index 2998d02da..f825b04a0 100644 --- a/api/api/snapshot.get_repository.js +++ b/api/api/snapshot.get_repository.js @@ -24,7 +24,7 @@ function buildSnapshotGetRepository (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [snapshot.get_repository](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request * @@ -61,29 +61,16 @@ function buildSnapshotGetRepository (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - snapshotGetRepository(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/snapshot.restore.js b/api/api/snapshot.restore.js index 36fe20924..7df0ac952 100644 --- a/api/api/snapshot.restore.js +++ b/api/api/snapshot.restore.js @@ -24,7 +24,7 @@ function buildSnapshotRestore (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [snapshot.restore](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request * @@ -64,43 +64,26 @@ function buildSnapshotRestore (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - snapshotRestore(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['repository'] == null) { - return callback( - new ConfigurationError('Missing required parameter: repository'), - result - ) + const err = new ConfigurationError('Missing required parameter: repository') + return handleError(err, callback) } if (params['snapshot'] == null) { - return callback( - new ConfigurationError('Missing required parameter: snapshot'), - result - ) + const err = new ConfigurationError('Missing required parameter: snapshot') + return handleError(err, callback) } // check required url components if (params['snapshot'] != null && (params['repository'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: repository'), - result - ) + const err = new ConfigurationError('Missing required parameter of the url: repository') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/snapshot.status.js b/api/api/snapshot.status.js index 08e35c90f..d0820b6c6 100644 --- a/api/api/snapshot.status.js +++ b/api/api/snapshot.status.js @@ -24,7 +24,7 @@ function buildSnapshotStatus (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [snapshot.status](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request * @@ -63,37 +63,22 @@ function buildSnapshotStatus (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - snapshotStatus(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) } // check required url components if (params['snapshot'] != null && (params['repository'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: repository'), - result - ) + const err = new ConfigurationError('Missing required parameter of the url: repository') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/snapshot.verify_repository.js b/api/api/snapshot.verify_repository.js index 8708e5135..ea23febc8 100644 --- a/api/api/snapshot.verify_repository.js +++ b/api/api/snapshot.verify_repository.js @@ -24,7 +24,7 @@ function buildSnapshotVerifyRepository (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [snapshot.verify_repository](http://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html) request * @@ -61,35 +61,20 @@ function buildSnapshotVerifyRepository (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - snapshotVerifyRepository(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['repository'] == null) { - return callback( - new ConfigurationError('Missing required parameter: repository'), - result - ) + const err = new ConfigurationError('Missing required parameter: repository') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/ssl.certificates.js b/api/api/ssl.certificates.js index 6a5d68894..28f8fc9f7 100644 --- a/api/api/ssl.certificates.js +++ b/api/api/ssl.certificates.js @@ -24,7 +24,7 @@ function buildSslCertificates (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [ssl.certificates](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-ssl.html) request * @@ -50,29 +50,16 @@ function buildSslCertificates (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - sslCertificates(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/tasks.cancel.js b/api/api/tasks.cancel.js index 33e64738c..3d3dd5d3e 100644 --- a/api/api/tasks.cancel.js +++ b/api/api/tasks.cancel.js @@ -24,7 +24,7 @@ function buildTasksCancel (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [tasks.cancel](http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html) request * @@ -63,29 +63,16 @@ function buildTasksCancel (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - tasksCancel(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/tasks.get.js b/api/api/tasks.get.js index d968a6d38..426fe46af 100644 --- a/api/api/tasks.get.js +++ b/api/api/tasks.get.js @@ -24,7 +24,7 @@ function buildTasksGet (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [tasks.get](http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html) request * @@ -61,35 +61,20 @@ function buildTasksGet (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - tasksGet(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['task_id'] == null && params['taskId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: task_id or taskId'), - result - ) + const err = new ConfigurationError('Missing required parameter: task_id or taskId') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/tasks.list.js b/api/api/tasks.list.js index 9b3ec93b6..57f170927 100644 --- a/api/api/tasks.list.js +++ b/api/api/tasks.list.js @@ -24,7 +24,7 @@ function buildTasksList (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [tasks.list](http://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html) request * @@ -72,29 +72,16 @@ function buildTasksList (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - tasksList(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/termvectors.js b/api/api/termvectors.js index 84d557a5b..2571b64fd 100644 --- a/api/api/termvectors.js +++ b/api/api/termvectors.js @@ -24,7 +24,7 @@ function buildTermvectors (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [termvectors](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-termvectors.html) request * @@ -86,29 +86,16 @@ function buildTermvectors (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - termvectors(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/update.js b/api/api/update.js index 617b42aad..3a4f6120d 100644 --- a/api/api/update.js +++ b/api/api/update.js @@ -24,7 +24,7 @@ function buildUpdate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [update](http://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update.html) request * @@ -89,41 +89,24 @@ function buildUpdate (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - update(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['id'] == null) { - return callback( - new ConfigurationError('Missing required parameter: id'), - result - ) + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) } if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/update_by_query.js b/api/api/update_by_query.js index 4e5287958..ab41dcf72 100644 --- a/api/api/update_by_query.js +++ b/api/api/update_by_query.js @@ -24,7 +24,7 @@ function buildUpdateByQuery (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [update_by_query](https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html) request * @@ -142,37 +142,22 @@ function buildUpdateByQuery (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - updateByQuery(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } // check required url components if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/update_by_query_rethrottle.js b/api/api/update_by_query_rethrottle.js index c0ebd050b..2937a00d1 100644 --- a/api/api/update_by_query_rethrottle.js +++ b/api/api/update_by_query_rethrottle.js @@ -24,7 +24,7 @@ function buildUpdateByQueryRethrottle (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + 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 * @@ -59,41 +59,24 @@ function buildUpdateByQueryRethrottle (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - updateByQueryRethrottle(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['task_id'] == null && params['taskId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: task_id or taskId'), - result - ) + const err = new ConfigurationError('Missing required parameter: task_id or taskId') + return handleError(err, callback) } if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) { - return callback( - new ConfigurationError('Missing required parameter: requests_per_second or requestsPerSecond'), - result - ) + const err = new ConfigurationError('Missing required parameter: requests_per_second or requestsPerSecond') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.graph.explore.js b/api/api/xpack.graph.explore.js index 1db3bf521..1217aa335 100644 --- a/api/api/xpack.graph.explore.js +++ b/api/api/xpack.graph.explore.js @@ -24,7 +24,7 @@ function buildXpackGraphExplore (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.graph.explore](https://www.elastic.co/guide/en/elasticsearch/reference/current/graph-explore-api.html) request * @@ -56,29 +56,16 @@ function buildXpackGraphExplore (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackGraphExplore(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required url components if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.info.js b/api/api/xpack.info.js index 36a9c745c..13cefe3b2 100644 --- a/api/api/xpack.info.js +++ b/api/api/xpack.info.js @@ -24,7 +24,7 @@ function buildXpackInfo (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.info](https://www.elastic.co/guide/en/elasticsearch/reference/current/info-api.html) request * @@ -51,29 +51,16 @@ function buildXpackInfo (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackInfo(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.license.delete.js b/api/api/xpack.license.delete.js index 203e5d571..ca14c02bd 100644 --- a/api/api/xpack.license.delete.js +++ b/api/api/xpack.license.delete.js @@ -24,7 +24,7 @@ function buildXpackLicenseDelete (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.license.delete](https://www.elastic.co/guide/en/x-pack/current/license-management.html) request * @@ -50,29 +50,16 @@ function buildXpackLicenseDelete (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackLicenseDelete(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.license.get.js b/api/api/xpack.license.get.js index af0ee628b..c189b2b13 100644 --- a/api/api/xpack.license.get.js +++ b/api/api/xpack.license.get.js @@ -24,7 +24,7 @@ function buildXpackLicenseGet (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.license.get](https://www.elastic.co/guide/en/x-pack/current/license-management.html) request * @@ -51,29 +51,16 @@ function buildXpackLicenseGet (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackLicenseGet(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.license.get_basic_status.js b/api/api/xpack.license.get_basic_status.js index 35155a724..a3f9cd80a 100644 --- a/api/api/xpack.license.get_basic_status.js +++ b/api/api/xpack.license.get_basic_status.js @@ -24,7 +24,7 @@ function buildXpackLicenseGetBasicStatus (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.license.get_basic_status](https://www.elastic.co/guide/en/x-pack/current/license-management.html) request * @@ -50,29 +50,16 @@ function buildXpackLicenseGetBasicStatus (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackLicenseGetBasicStatus(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.license.get_trial_status.js b/api/api/xpack.license.get_trial_status.js index 5b84dfc27..34487dd5c 100644 --- a/api/api/xpack.license.get_trial_status.js +++ b/api/api/xpack.license.get_trial_status.js @@ -24,7 +24,7 @@ function buildXpackLicenseGetTrialStatus (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.license.get_trial_status](https://www.elastic.co/guide/en/x-pack/current/license-management.html) request * @@ -50,29 +50,16 @@ function buildXpackLicenseGetTrialStatus (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackLicenseGetTrialStatus(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.license.post.js b/api/api/xpack.license.post.js index ca7dc861f..f0f81c6c4 100644 --- a/api/api/xpack.license.post.js +++ b/api/api/xpack.license.post.js @@ -24,7 +24,7 @@ function buildXpackLicensePost (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.license.post](https://www.elastic.co/guide/en/x-pack/current/license-management.html) request * @@ -52,21 +52,10 @@ function buildXpackLicensePost (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackLicensePost(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.license.post_start_basic.js b/api/api/xpack.license.post_start_basic.js index 63b2cefa1..c473ceb73 100644 --- a/api/api/xpack.license.post_start_basic.js +++ b/api/api/xpack.license.post_start_basic.js @@ -24,7 +24,7 @@ function buildXpackLicensePostStartBasic (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.license.post_start_basic](https://www.elastic.co/guide/en/x-pack/current/license-management.html) request * @@ -51,29 +51,16 @@ function buildXpackLicensePostStartBasic (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackLicensePostStartBasic(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.license.post_start_trial.js b/api/api/xpack.license.post_start_trial.js index b16ddd42b..67fffcc4e 100644 --- a/api/api/xpack.license.post_start_trial.js +++ b/api/api/xpack.license.post_start_trial.js @@ -24,7 +24,7 @@ function buildXpackLicensePostStartTrial (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.license.post_start_trial](https://www.elastic.co/guide/en/x-pack/current/license-management.html) request * @@ -53,29 +53,16 @@ function buildXpackLicensePostStartTrial (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackLicensePostStartTrial(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.migration.deprecations.js b/api/api/xpack.migration.deprecations.js index 3dbafd5b0..d6d5edef8 100644 --- a/api/api/xpack.migration.deprecations.js +++ b/api/api/xpack.migration.deprecations.js @@ -24,7 +24,7 @@ function buildXpackMigrationDeprecations (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.migration.deprecations](http://www.elastic.co/guide/en/migration/current/migration-api-deprecation.html) request * @@ -51,29 +51,16 @@ function buildXpackMigrationDeprecations (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackMigrationDeprecations(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.migration.get_assistance.js b/api/api/xpack.migration.get_assistance.js index 088810be2..43e6041ac 100644 --- a/api/api/xpack.migration.get_assistance.js +++ b/api/api/xpack.migration.get_assistance.js @@ -24,7 +24,7 @@ function buildXpackMigrationGetAssistance (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.migration.get_assistance](https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-assistance.html) request * @@ -58,21 +58,10 @@ function buildXpackMigrationGetAssistance (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackMigrationGetAssistance(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.migration.upgrade.js b/api/api/xpack.migration.upgrade.js index 67bd9497b..e1663d3e9 100644 --- a/api/api/xpack.migration.upgrade.js +++ b/api/api/xpack.migration.upgrade.js @@ -24,7 +24,7 @@ function buildXpackMigrationUpgrade (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.migration.upgrade](https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-upgrade.html) request * @@ -52,29 +52,16 @@ function buildXpackMigrationUpgrade (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackMigrationUpgrade(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.rollup.delete_job.js b/api/api/xpack.rollup.delete_job.js index e2efbaaee..a4e960daa 100644 --- a/api/api/xpack.rollup.delete_job.js +++ b/api/api/xpack.rollup.delete_job.js @@ -24,7 +24,7 @@ function buildXpackRollupDeleteJob (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.rollup.delete_job]() request * @@ -51,29 +51,16 @@ function buildXpackRollupDeleteJob (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackRollupDeleteJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['id'] == null) { - return callback( - new ConfigurationError('Missing required parameter: id'), - result - ) + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.rollup.get_jobs.js b/api/api/xpack.rollup.get_jobs.js index cb67e3e54..90a58f40f 100644 --- a/api/api/xpack.rollup.get_jobs.js +++ b/api/api/xpack.rollup.get_jobs.js @@ -24,7 +24,7 @@ function buildXpackRollupGetJobs (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.rollup.get_jobs]() request * @@ -51,21 +51,10 @@ function buildXpackRollupGetJobs (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackRollupGetJobs(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.rollup.get_rollup_caps.js b/api/api/xpack.rollup.get_rollup_caps.js index 1e2a1d5b5..712061e83 100644 --- a/api/api/xpack.rollup.get_rollup_caps.js +++ b/api/api/xpack.rollup.get_rollup_caps.js @@ -24,7 +24,7 @@ function buildXpackRollupGetRollupCaps (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.rollup.get_rollup_caps]() request * @@ -51,21 +51,10 @@ function buildXpackRollupGetRollupCaps (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackRollupGetRollupCaps(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.rollup.get_rollup_index_caps.js b/api/api/xpack.rollup.get_rollup_index_caps.js index 5b5ad3038..ceb97b228 100644 --- a/api/api/xpack.rollup.get_rollup_index_caps.js +++ b/api/api/xpack.rollup.get_rollup_index_caps.js @@ -24,7 +24,7 @@ function buildXpackRollupGetRollupIndexCaps (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.rollup.get_rollup_index_caps]() request * @@ -51,29 +51,16 @@ function buildXpackRollupGetRollupIndexCaps (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackRollupGetRollupIndexCaps(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.rollup.put_job.js b/api/api/xpack.rollup.put_job.js index cf6ba50d7..48518f09e 100644 --- a/api/api/xpack.rollup.put_job.js +++ b/api/api/xpack.rollup.put_job.js @@ -24,7 +24,7 @@ function buildXpackRollupPutJob (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.rollup.put_job]() request * @@ -52,35 +52,20 @@ function buildXpackRollupPutJob (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackRollupPutJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['id'] == null) { - return callback( - new ConfigurationError('Missing required parameter: id'), - result - ) + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.rollup.rollup_search.js b/api/api/xpack.rollup.rollup_search.js index 681c803b3..b21faaf22 100644 --- a/api/api/xpack.rollup.rollup_search.js +++ b/api/api/xpack.rollup.rollup_search.js @@ -24,7 +24,7 @@ function buildXpackRollupRollupSearch (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.rollup.rollup_search]() request * @@ -57,43 +57,26 @@ function buildXpackRollupRollupSearch (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackRollupRollupSearch(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['index'] == null) { - return callback( - new ConfigurationError('Missing required parameter: index'), - result - ) + const err = new ConfigurationError('Missing required parameter: index') + return handleError(err, callback) } if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // check required url components if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.rollup.start_job.js b/api/api/xpack.rollup.start_job.js index ea8a0e069..823221c1d 100644 --- a/api/api/xpack.rollup.start_job.js +++ b/api/api/xpack.rollup.start_job.js @@ -24,7 +24,7 @@ function buildXpackRollupStartJob (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.rollup.start_job]() request * @@ -51,29 +51,16 @@ function buildXpackRollupStartJob (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackRollupStartJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['id'] == null) { - return callback( - new ConfigurationError('Missing required parameter: id'), - result - ) + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.rollup.stop_job.js b/api/api/xpack.rollup.stop_job.js index 5945a7e59..ad4683d83 100644 --- a/api/api/xpack.rollup.stop_job.js +++ b/api/api/xpack.rollup.stop_job.js @@ -24,7 +24,7 @@ function buildXpackRollupStopJob (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.rollup.stop_job]() request * @@ -55,29 +55,16 @@ function buildXpackRollupStopJob (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackRollupStopJob(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['id'] == null) { - return callback( - new ConfigurationError('Missing required parameter: id'), - result - ) + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.sql.clear_cursor.js b/api/api/xpack.sql.clear_cursor.js index 7bf825950..79548622c 100644 --- a/api/api/xpack.sql.clear_cursor.js +++ b/api/api/xpack.sql.clear_cursor.js @@ -24,7 +24,7 @@ function buildXpackSqlClearCursor (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.sql.clear_cursor](Clear SQL cursor) request * @@ -51,29 +51,16 @@ function buildXpackSqlClearCursor (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackSqlClearCursor(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.sql.query.js b/api/api/xpack.sql.query.js index 67087514e..923190fef 100644 --- a/api/api/xpack.sql.query.js +++ b/api/api/xpack.sql.query.js @@ -24,7 +24,7 @@ function buildXpackSqlQuery (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.sql.query](Execute SQL) request * @@ -52,29 +52,16 @@ function buildXpackSqlQuery (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackSqlQuery(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.sql.translate.js b/api/api/xpack.sql.translate.js index 684f57905..c5204666e 100644 --- a/api/api/xpack.sql.translate.js +++ b/api/api/xpack.sql.translate.js @@ -24,7 +24,7 @@ function buildXpackSqlTranslate (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.sql.translate](Translate SQL into Elasticsearch queries) request * @@ -51,29 +51,16 @@ function buildXpackSqlTranslate (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackSqlTranslate(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['body'] == null) { - return callback( - new ConfigurationError('Missing required parameter: body'), - result - ) + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.usage.js b/api/api/xpack.usage.js index 90af1be13..50cd02732 100644 --- a/api/api/xpack.usage.js +++ b/api/api/xpack.usage.js @@ -24,7 +24,7 @@ function buildXpackUsage (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.usage](Retrieve information about xpack features usage) request * @@ -51,29 +51,16 @@ function buildXpackUsage (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackUsage(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.watcher.ack_watch.js b/api/api/xpack.watcher.ack_watch.js index ede9615ec..0dc0481b6 100644 --- a/api/api/xpack.watcher.ack_watch.js +++ b/api/api/xpack.watcher.ack_watch.js @@ -24,7 +24,7 @@ function buildXpackWatcherAckWatch (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.watcher.ack_watch](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-ack-watch.html) request * @@ -52,43 +52,26 @@ function buildXpackWatcherAckWatch (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackWatcherAckWatch(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['watch_id'] == null && params['watchId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: watch_id or watchId'), - result - ) + const err = new ConfigurationError('Missing required parameter: watch_id or watchId') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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))) { - return callback( - new ConfigurationError('Missing required parameter of the url: watch_id'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.watcher.activate_watch.js b/api/api/xpack.watcher.activate_watch.js index ba22813ca..cadf57117 100644 --- a/api/api/xpack.watcher.activate_watch.js +++ b/api/api/xpack.watcher.activate_watch.js @@ -24,7 +24,7 @@ function buildXpackWatcherActivateWatch (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.watcher.activate_watch](https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-activate-watch.html) request * @@ -51,35 +51,20 @@ function buildXpackWatcherActivateWatch (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackWatcherActivateWatch(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['watch_id'] == null && params['watchId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: watch_id or watchId'), - result - ) + const err = new ConfigurationError('Missing required parameter: watch_id or watchId') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.watcher.deactivate_watch.js b/api/api/xpack.watcher.deactivate_watch.js index 6ae2c9712..ce5f741bb 100644 --- a/api/api/xpack.watcher.deactivate_watch.js +++ b/api/api/xpack.watcher.deactivate_watch.js @@ -24,7 +24,7 @@ function buildXpackWatcherDeactivateWatch (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.watcher.deactivate_watch](https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-deactivate-watch.html) request * @@ -51,35 +51,20 @@ function buildXpackWatcherDeactivateWatch (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackWatcherDeactivateWatch(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['watch_id'] == null && params['watchId'] == null) { - return callback( - new ConfigurationError('Missing required parameter: watch_id or watchId'), - result - ) + const err = new ConfigurationError('Missing required parameter: watch_id or watchId') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.watcher.delete_watch.js b/api/api/xpack.watcher.delete_watch.js index 66fbba1a4..15d5c2f8e 100644 --- a/api/api/xpack.watcher.delete_watch.js +++ b/api/api/xpack.watcher.delete_watch.js @@ -24,7 +24,7 @@ function buildXpackWatcherDeleteWatch (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.watcher.delete_watch](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-delete-watch.html) request * @@ -51,35 +51,20 @@ function buildXpackWatcherDeleteWatch (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackWatcherDeleteWatch(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['id'] == null) { - return callback( - new ConfigurationError('Missing required parameter: id'), - result - ) + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.watcher.execute_watch.js b/api/api/xpack.watcher.execute_watch.js index 8c0e7db1f..b692e6045 100644 --- a/api/api/xpack.watcher.execute_watch.js +++ b/api/api/xpack.watcher.execute_watch.js @@ -24,7 +24,7 @@ function buildXpackWatcherExecuteWatch (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.watcher.execute_watch](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-execute-watch.html) request * @@ -53,21 +53,10 @@ function buildXpackWatcherExecuteWatch (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackWatcherExecuteWatch(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.watcher.get_watch.js b/api/api/xpack.watcher.get_watch.js index e1bfb5b92..452b03ce8 100644 --- a/api/api/xpack.watcher.get_watch.js +++ b/api/api/xpack.watcher.get_watch.js @@ -24,7 +24,7 @@ function buildXpackWatcherGetWatch (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.watcher.get_watch](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-watch.html) request * @@ -51,35 +51,20 @@ function buildXpackWatcherGetWatch (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackWatcherGetWatch(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['id'] == null) { - return callback( - new ConfigurationError('Missing required parameter: id'), - result - ) + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) } if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.watcher.put_watch.js b/api/api/xpack.watcher.put_watch.js index 1d4442327..35e973534 100644 --- a/api/api/xpack.watcher.put_watch.js +++ b/api/api/xpack.watcher.put_watch.js @@ -24,7 +24,7 @@ function buildXpackWatcherPutWatch (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.watcher.put_watch](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html) request * @@ -60,29 +60,16 @@ function buildXpackWatcherPutWatch (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackWatcherPutWatch(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params['id'] == null) { - return callback( - new ConfigurationError('Missing required parameter: id'), - result - ) + const err = new ConfigurationError('Missing required parameter: id') + return handleError(err, callback) } // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.watcher.start.js b/api/api/xpack.watcher.start.js index c4b8c0ec9..0684c8260 100644 --- a/api/api/xpack.watcher.start.js +++ b/api/api/xpack.watcher.start.js @@ -24,7 +24,7 @@ function buildXpackWatcherStart (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.watcher.start](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-start.html) request * @@ -50,29 +50,16 @@ function buildXpackWatcherStart (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackWatcherStart(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.watcher.stats.js b/api/api/xpack.watcher.stats.js index 05882a9b8..444dfd49b 100644 --- a/api/api/xpack.watcher.stats.js +++ b/api/api/xpack.watcher.stats.js @@ -24,7 +24,7 @@ function buildXpackWatcherStats (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.watcher.stats](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stats.html) request * @@ -54,29 +54,16 @@ function buildXpackWatcherStats (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackWatcherStats(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/api/xpack.watcher.stop.js b/api/api/xpack.watcher.stop.js index aec707664..0490656ac 100644 --- a/api/api/xpack.watcher.stop.js +++ b/api/api/xpack.watcher.stop.js @@ -24,7 +24,7 @@ function buildXpackWatcherStop (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts /** * Perform a [xpack.watcher.stop](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stop.html) request * @@ -50,29 +50,16 @@ function buildXpackWatcherStop (opts) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackWatcherStop(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - // check required parameters if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + 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') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`), - result - ) + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) } var warnings = null diff --git a/api/index.js b/api/index.js index f45a8ccdb..57622d189 100644 --- a/api/index.js +++ b/api/index.js @@ -26,6 +26,9 @@ function ESAPI (opts) { assert(opts.ConfigurationError, 'Missing ConfigurationError class') assert(opts.result, 'Missing default result object') + const { result } = opts + opts.handleError = handleError + const apis = { bulk: lazyLoad('bulk', opts), cat: { @@ -480,6 +483,11 @@ function ESAPI (opts) { } return apis + + function handleError (err, callback) { + if (callback) return callback(err, result) + return Promise.reject(err) + } } // It's unlikely that a user needs all of our APIs, diff --git a/scripts/utils/genMain.js b/scripts/utils/genMain.js index ba89623bb..7f0a5aeda 100644 --- a/scripts/utils/genMain.js +++ b/scripts/utils/genMain.js @@ -123,10 +123,18 @@ function genFactory (folder) { assert(opts.ConfigurationError, 'Missing ConfigurationError class') assert(opts.result, 'Missing default result object') + const { result } = opts + opts.handleError = handleError + const apis = ${apisStr} return apis + + function handleError(err, callback) { + if (callback) return callback(err, result) + return Promise.reject(err) + } } // It's unlikely that a user needs all of our APIs, diff --git a/scripts/utils/generate.js b/scripts/utils/generate.js index 865925a48..33fd4eded 100644 --- a/scripts/utils/generate.js +++ b/scripts/utils/generate.js @@ -108,25 +108,14 @@ function generate (spec, common) { options = {} } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - ${safeWords(name)}(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - ${genRequiredChecks()} ${genUrlValidation(paths, api)} // validate headers object if (options.headers != null && typeof options.headers !== 'object') { - return callback( - new ConfigurationError(\`Headers should be an object, instead got: \${typeof options.headers}\`), - result - ) + const err = new ConfigurationError(\`Headers should be an object, instead got: \${typeof options.headers}\`) + return handleError(err, callback) } var warnings = null @@ -212,7 +201,7 @@ function generate (spec, common) { function build${name[0].toUpperCase() + name.slice(1)} (opts) { // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts + const { makeRequest, ConfigurationError, handleError } = opts ${generateDocumentation(spec[api], api)} const acceptedQuerystring = [ @@ -252,20 +241,16 @@ function generate (spec, common) { if (param === camelCased) { const check = ` if (params['${param}'] == null) { - return callback( - new ConfigurationError('Missing required parameter: ${param}'), - result - ) + const err = new ConfigurationError('Missing required parameter: ${param}') + return handleError(err, callback) } ` return check.trim() } else { const check = ` if (params['${param}'] == null && params['${camelCased}'] == null) { - return callback( - new ConfigurationError('Missing required parameter: ${param} or ${camelCased}'), - result - ) + const err = new ConfigurationError('Missing required parameter: ${param} or ${camelCased}') + return handleError(err, callback) } ` return check.trim() @@ -275,10 +260,8 @@ function generate (spec, common) { function _noBody () { const check = ` if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) + const err = new ConfigurationError('This API does not require a body') + return handleError(err, callback) } ` return spec[api].body === null ? check.trim() : '' @@ -495,10 +478,9 @@ function genUrlValidation (paths, api) { } } code += `)) { - return callback( - new ConfigurationError('Missing required parameter of the url: ${params.join(', ')}'), - result - )` + const err = new ConfigurationError('Missing required parameter of the url: ${params.join(', ')}') + return handleError(err, callback) + ` }) if (chunks.length > 1) { diff --git a/test/unit/api-async.js b/test/unit/api-async.js index 92aa7d9c3..437c00abf 100644 --- a/test/unit/api-async.js +++ b/test/unit/api-async.js @@ -19,7 +19,7 @@ 'use strict' -const { Client } = require('../../index') +const { Client, errors } = require('../../index') const { buildServer } = require('../utils') function runAsyncTest (test) { @@ -75,6 +75,21 @@ function runAsyncTest (test) { server.stop() }) }) + + test('async await (ConfigurationError)', async t => { + t.plan(1) + + const client = new Client({ + node: 'http://localhost:9200' + }) + + try { + await client.index({ body: { foo: 'bar' } }) + t.fail('Should throw') + } catch (err) { + t.ok(err instanceof errors.ConfigurationError) + } + }) } module.exports = runAsyncTest diff --git a/test/unit/api.test.js b/test/unit/api.test.js index 96e7fa701..cf8feb77f 100644 --- a/test/unit/api.test.js +++ b/test/unit/api.test.js @@ -20,7 +20,7 @@ 'use strict' const { test } = require('tap') -const { Client } = require('../../index') +const { Client, errors } = require('../../index') const { buildServer } = require('../utils') test('Basic (callback)', t => { @@ -295,6 +295,35 @@ test('If the API uses the same key for both url and query parameter, the url sho }) }) +test('ConfigurationError (callback)', t => { + t.plan(1) + + const client = new Client({ + node: 'http://localhost:9200' + }) + + client.index({ + body: { foo: 'bar' } + }, (err, { body }) => { + t.ok(err instanceof errors.ConfigurationError) + }) +}) + +test('ConfigurationError (promises)', t => { + t.plan(1) + + const client = new Client({ + node: 'http://localhost:9200' + }) + + client + .index({ body: { foo: 'bar' } }) + .then(t.fail) + .catch(err => { + t.ok(err instanceof errors.ConfigurationError) + }) +}) + if (Number(process.version.split('.')[0].slice(1)) >= 8) { require('./api-async')(test) }