From 3db1bed4bdf45d627891923045469eb07b508844 Mon Sep 17 00:00:00 2001 From: Tomas Della Vedova Date: Wed, 23 Sep 2020 11:31:09 +0200 Subject: [PATCH] Improve child performances (#1314) --- .github/workflows/nodejs.yml | 43 + .gitignore | 4 + api/api/async_search.delete.js | 93 - api/api/async_search.get.js | 97 - api/api/async_search.js | 114 + .../autoscaling.delete_autoscaling_policy.js | 93 - .../autoscaling.get_autoscaling_decision.js | 87 - api/api/autoscaling.get_autoscaling_policy.js | 93 - api/api/autoscaling.js | 147 + api/api/autoscaling.put_autoscaling_policy.js | 97 - api/api/bulk.js | 114 +- api/api/cat.aliases.js | 105 - api/api/cat.allocation.js | 106 - api/api/cat.count.js | 102 - api/api/cat.fielddata.js | 104 - api/api/cat.health.js | 99 - api/api/cat.help.js | 94 - api/api/cat.indices.js | 113 - api/api/cat.js | 648 ++ api/api/cat.master.js | 100 - api/api/cat.ml_data_frame_analytics.js | 100 - api/api/cat.ml_datafeeds.js | 101 - api/api/cat.ml_jobs.js | 102 - api/api/cat.ml_trained_models.js | 102 - api/api/cat.nodeattrs.js | 100 - api/api/cat.pending_tasks.js | 101 - api/api/cat.plugins.js | 100 - api/api/cat.recovery.js | 108 - api/api/cat.repositories.js | 100 - api/api/cat.segments.js | 103 - api/api/cat.shards.js | 107 - api/api/cat.snapshots.js | 107 - api/api/cat.tasks.js | 104 - api/api/cat.templates.js | 105 - api/api/cat.transforms.js | 101 - api/api/ccr.delete_auto_follow_pattern.js | 93 - api/api/ccr.follow.js | 97 - api/api/ccr.follow_info.js | 93 - api/api/ccr.follow_stats.js | 93 - api/api/ccr.forget_follower.js | 97 - api/api/ccr.get_auto_follow_pattern.js | 92 - api/api/ccr.js | 403 + api/api/ccr.pause_auto_follow_pattern.js | 93 - api/api/ccr.pause_follow.js | 93 - api/api/ccr.put_auto_follow_pattern.js | 97 - api/api/ccr.resume_auto_follow_pattern.js | 93 - api/api/ccr.resume_follow.js | 93 - api/api/ccr.stats.js | 87 - api/api/ccr.unfollow.js | 93 - api/api/clear_scroll.js | 90 +- api/api/close_point_in_time.js | 28 +- api/api/cluster.allocation_explain.js | 96 - api/api/cluster.delete_component_template.js | 101 - ...cluster.delete_voting_config_exclusions.js | 94 - api/api/cluster.exists_component_template.js | 101 - api/api/cluster.get_component_template.js | 100 - api/api/cluster.get_settings.js | 99 - api/api/cluster.health.js | 116 - api/api/cluster.js | 420 + api/api/cluster.pending_tasks.js | 96 - .../cluster.post_voting_config_exclusions.js | 97 - api/api/cluster.put_component_template.js | 106 - api/api/cluster.put_settings.js | 103 - api/api/cluster.remote_info.js | 92 - api/api/cluster.reroute.js | 101 - api/api/cluster.state.js | 121 - api/api/cluster.stats.js | 100 - api/api/count.js | 63 +- api/api/create.js | 127 +- .../dangling_indices.delete_dangling_index.js | 103 - .../dangling_indices.import_dangling_index.js | 103 - api/api/dangling_indices.js | 115 + .../dangling_indices.list_dangling_indices.js | 92 - api/api/delete.js | 120 +- api/api/delete_by_query.js | 48 +- api/api/delete_by_query_rethrottle.js | 98 +- api/api/delete_script.js | 91 +- api/api/enrich.delete_policy.js | 93 - api/api/enrich.execute_policy.js | 93 - api/api/enrich.get_policy.js | 92 - api/api/enrich.js | 173 + api/api/enrich.put_policy.js | 97 - api/api/enrich.stats.js | 87 - api/api/eql.delete.js | 93 - api/api/eql.get.js | 95 - api/api/eql.js | 119 + api/api/eql.search.js | 101 - api/api/exists.js | 48 +- api/api/exists_source.js | 122 +- api/api/explain.js | 48 +- api/api/field_caps.js | 99 +- api/api/get.js | 48 +- api/api/get_script.js | 90 +- api/api/get_script_context.js | 82 +- api/api/get_script_languages.js | 82 +- api/api/get_source.js | 48 +- api/api/graph.js | 61 + api/api/ilm.delete_lifecycle.js | 93 - api/api/ilm.explain_lifecycle.js | 95 - api/api/ilm.get_lifecycle.js | 92 - api/api/ilm.get_status.js | 87 - api/api/ilm.js | 295 + api/api/ilm.move_to_step.js | 93 - api/api/ilm.put_lifecycle.js | 93 - api/api/ilm.remove_policy.js | 93 - api/api/ilm.retry.js | 93 - api/api/ilm.start.js | 87 - api/api/ilm.stop.js | 87 - api/api/index.js | 77 +- api/api/indices.add_block.js | 117 - api/api/indices.analyze.js | 98 - api/api/indices.clear_cache.js | 108 - api/api/indices.clone.js | 113 - api/api/indices.close.js | 109 - api/api/indices.create_data_stream.js | 93 - api/api/indices.data_streams_stats.js | 92 - api/api/indices.delete.js | 107 - api/api/indices.delete_alias.js | 116 - api/api/indices.delete_data_stream.js | 93 - api/api/indices.delete_index_template.js | 101 - api/api/indices.delete_template.js | 101 - api/api/indices.exists.js | 109 - api/api/indices.exists_alias.js | 110 - api/api/indices.exists_index_template.js | 103 - api/api/indices.exists_template.js | 103 - api/api/indices.exists_type.js | 115 - api/api/indices.flush.js | 106 - api/api/indices.forcemerge.js | 108 - api/api/indices.freeze.js | 102 - api/api/indices.get_alias.js | 110 - api/api/indices.get_data_stream.js | 92 - api/api/indices.get_index_template.js | 102 - api/api/indices.get_settings.js | 116 - api/api/indices.js | 1588 ++++ api/api/indices.open.js | 109 - api/api/indices.put_alias.js | 116 - api/api/indices.put_index_template.js | 106 - api/api/indices.put_settings.js | 116 - api/api/indices.recovery.js | 100 - api/api/indices.refresh.js | 103 - api/api/indices.reload_search_analyzers.js | 97 - api/api/indices.resolve_index.js | 100 - api/api/indices.segments.js | 104 - api/api/indices.shard_stores.js | 104 - api/api/indices.simulate_index_template.js | 102 - api/api/indices.simulate_template.js | 101 - api/api/indices.stats.js | 119 - api/api/indices.unfreeze.js | 102 - api/api/indices.update_aliases.js | 101 - api/api/indices.validate_query.js | 124 - api/api/info.js | 82 +- api/api/ingest.delete_pipeline.js | 101 - api/api/ingest.get_pipeline.js | 99 - api/api/ingest.js | 178 + api/api/ingest.processor_grok.js | 92 - api/api/ingest.put_pipeline.js | 105 - api/api/ingest.simulate.js | 104 - api/api/license.delete.js | 87 - api/api/license.get.js | 88 - api/api/license.get_basic_status.js | 87 - api/api/license.get_trial_status.js | 87 - api/api/license.js | 188 + api/api/license.post.js | 87 - api/api/license.post_start_basic.js | 87 - api/api/license.post_start_trial.js | 88 - api/api/mget.js | 59 +- api/api/migration.deprecations.js | 92 - api/api/migration.js | 60 + api/api/ml.close_job.js | 98 - api/api/ml.delete_calendar.js | 93 - api/api/ml.delete_calendar_event.js | 103 - api/api/ml.delete_calendar_job.js | 103 - api/api/ml.delete_data_frame_analytics.js | 94 - api/api/ml.delete_datafeed.js | 93 - api/api/ml.delete_expired_data.js | 94 - api/api/ml.delete_filter.js | 93 - api/api/ml.delete_forecast.js | 106 - api/api/ml.delete_job.js | 94 - api/api/ml.delete_model_snapshot.js | 103 - api/api/ml.delete_trained_model.js | 93 - api/api/ml.estimate_model_memory.js | 93 - api/api/ml.evaluate_data_frame.js | 93 - api/api/ml.explain_data_frame_analytics.js | 92 - api/api/ml.find_file_structure.js | 114 - api/api/ml.flush_job.js | 99 - api/api/ml.forecast.js | 96 - api/api/ml.get_buckets.js | 114 - api/api/ml.get_calendar_events.js | 98 - api/api/ml.get_calendars.js | 93 - api/api/ml.get_categories.js | 106 - api/api/ml.get_data_frame_analytics.js | 95 - api/api/ml.get_data_frame_analytics_stats.js | 96 - api/api/ml.get_datafeed_stats.js | 94 - api/api/ml.get_datafeeds.js | 94 - api/api/ml.get_filters.js | 93 - api/api/ml.get_influencers.js | 102 - api/api/ml.get_job_stats.js | 94 - api/api/ml.get_jobs.js | 94 - api/api/ml.get_model_snapshots.js | 109 - api/api/ml.get_overall_buckets.js | 105 - api/api/ml.get_records.js | 102 - api/api/ml.get_trained_models.js | 101 - api/api/ml.get_trained_models_stats.js | 95 - api/api/ml.info.js | 87 - api/api/ml.js | 1842 ++++ api/api/ml.open_job.js | 93 - api/api/ml.post_calendar_events.js | 97 - api/api/ml.post_data.js | 99 - api/api/ml.preview_datafeed.js | 93 - api/api/ml.put_calendar.js | 93 - api/api/ml.put_calendar_job.js | 103 - api/api/ml.put_data_frame_analytics.js | 97 - api/api/ml.put_datafeed.js | 103 - api/api/ml.put_filter.js | 97 - api/api/ml.put_job.js | 97 - api/api/ml.put_trained_model.js | 97 - api/api/ml.revert_model_snapshot.js | 103 - api/api/ml.set_upgrade_mode.js | 88 - api/api/ml.start_data_frame_analytics.js | 93 - api/api/ml.start_datafeed.js | 95 - api/api/ml.stop_data_frame_analytics.js | 96 - api/api/ml.stop_datafeed.js | 98 - api/api/ml.update_data_frame_analytics.js | 97 - api/api/ml.update_datafeed.js | 103 - api/api/ml.update_filter.js | 97 - api/api/ml.update_job.js | 97 - api/api/ml.update_model_snapshot.js | 107 - api/api/ml.validate.js | 93 - api/api/ml.validate_detector.js | 93 - api/api/monitoring.bulk.js | 102 - api/api/monitoring.js | 66 + api/api/msearch.js | 79 +- api/api/msearch_template.js | 75 +- api/api/mtermvectors.js | 56 +- api/api/nodes.info.js | 106 - api/api/nodes.js | 193 + api/api/nodes.reload_secure_settings.js | 98 - api/api/nodes.stats.js | 120 - api/api/nodes.usage.js | 104 - api/api/open_point_in_time.js | 42 +- api/api/ping.js | 82 +- api/api/put_script.js | 126 +- api/api/rank_eval.js | 108 +- api/api/reindex.js | 102 +- api/api/reindex_rethrottle.js | 98 +- api/api/render_search_template.js | 90 +- api/api/rollup.delete_job.js | 93 - api/api/rollup.get_jobs.js | 92 - api/api/rollup.get_rollup_caps.js | 92 - api/api/rollup.get_rollup_index_caps.js | 93 - api/api/rollup.js | 278 + api/api/rollup.put_job.js | 97 - api/api/rollup.rollup_search.js | 110 - api/api/rollup.start_job.js | 93 - api/api/rollup.stop_job.js | 95 - api/api/scripts_painless_execute.js | 82 +- api/api/scroll.js | 95 +- api/api/search.js | 32 +- api/api/search_shards.js | 99 +- api/api/search_template.js | 86 +- api/api/searchable_snapshots.js | 159 + api/api/security.authenticate.js | 87 - api/api/security.change_password.js | 98 - api/api/security.clear_cached_privileges.js | 93 - api/api/security.clear_cached_realms.js | 93 - api/api/security.clear_cached_roles.js | 93 - api/api/security.create_api_key.js | 93 - api/api/security.delete_privileges.js | 103 - api/api/security.delete_role.js | 93 - api/api/security.delete_role_mapping.js | 93 - api/api/security.delete_user.js | 93 - api/api/security.disable_user.js | 93 - api/api/security.enable_user.js | 93 - api/api/security.get_api_key.js | 92 - api/api/security.get_builtin_privileges.js | 87 - api/api/security.get_privileges.js | 101 - api/api/security.get_role.js | 92 - api/api/security.get_role_mapping.js | 92 - api/api/security.get_token.js | 93 - api/api/security.get_user.js | 92 - api/api/security.get_user_privileges.js | 87 - api/api/security.has_privileges.js | 98 - api/api/security.invalidate_api_key.js | 93 - api/api/security.invalidate_token.js | 93 - api/api/security.js | 805 ++ api/api/security.put_privileges.js | 93 - api/api/security.put_role.js | 97 - api/api/security.put_role_mapping.js | 97 - api/api/security.put_user.js | 97 - api/api/slm.delete_lifecycle.js | 93 - api/api/slm.execute_lifecycle.js | 93 - api/api/slm.execute_retention.js | 87 - api/api/slm.get_lifecycle.js | 92 - api/api/slm.get_stats.js | 87 - api/api/slm.get_status.js | 87 - api/api/slm.js | 256 + api/api/slm.put_lifecycle.js | 93 - api/api/slm.start.js | 87 - api/api/slm.stop.js | 87 - api/api/snapshot.cleanup_repository.js | 101 - api/api/snapshot.create.js | 112 - api/api/snapshot.create_repository.js | 106 - api/api/snapshot.delete_repository.js | 101 - api/api/snapshot.get.js | 113 - api/api/snapshot.get_repository.js | 100 - api/api/snapshot.js | 363 + api/api/snapshot.restore.js | 112 - api/api/snapshot.status.js | 110 - api/api/snapshot.verify_repository.js | 101 - api/api/sql.clear_cursor.js | 93 - api/api/sql.js | 119 + api/api/sql.query.js | 93 - api/api/sql.translate.js | 93 - api/api/ssl.certificates.js | 87 - api/api/ssl.js | 55 + api/api/tasks.cancel.js | 103 - api/api/tasks.get.js | 101 - api/api/tasks.js | 108 + api/api/tasks.list.js | 102 - api/api/termvectors.js | 79 +- api/api/transform.delete_transform.js | 93 - api/api/transform.get_transform.js | 94 - api/api/transform.get_transform_stats.js | 95 - api/api/transform.js | 268 + api/api/transform.preview_transform.js | 93 - api/api/transform.put_transform.js | 97 - api/api/transform.start_transform.js | 93 - api/api/transform.stop_transform.js | 99 - api/api/transform.update_transform.js | 97 - api/api/update.js | 110 +- api/api/update_by_query.js | 56 +- api/api/update_by_query_rethrottle.js | 98 +- api/api/watcher.ack_watch.js | 104 - api/api/watcher.activate_watch.js | 93 - api/api/watcher.deactivate_watch.js | 93 - api/api/watcher.delete_watch.js | 93 - api/api/watcher.execute_watch.js | 92 - api/api/watcher.get_watch.js | 93 - api/api/watcher.js | 311 + api/api/watcher.put_watch.js | 97 - api/api/watcher.start.js | 87 - api/api/watcher.stats.js | 93 - api/api/watcher.stop.js | 87 - api/api/xpack.info.js | 88 - api/api/xpack.js | 76 + api/api/xpack.usage.js | 87 - api/index.js | 466 +- api/requestParams.d.ts | 862 +- api/utils.js | 58 + docs/reference.asciidoc | 7833 ++++++++++------- index.js | 99 +- lib/Connection.js | 1 + lib/Transport.js | 14 +- scripts/generate.js | 65 +- scripts/utils/generateApis.js | 270 +- scripts/utils/generateMain.js | 161 +- test/bundlers/parcel-test/index.js | 7 + test/bundlers/parcel-test/package.json | 16 + test/bundlers/rollup-test/index.js | 7 + test/bundlers/rollup-test/package.json | 19 + test/bundlers/rollup-test/rollup.config.js | 13 + test/bundlers/webpack-test/index.js | 7 + test/bundlers/webpack-test/package.json | 17 + test/bundlers/webpack-test/webpack.config.js | 12 + test/integration/test-runner.js | 11 +- test/unit/api.test.js | 27 - test/unit/child.test.js | 38 + test/unit/transport.test.js | 39 - 368 files changed, 17064 insertions(+), 32728 deletions(-) delete mode 100644 api/api/async_search.delete.js delete mode 100644 api/api/async_search.get.js create mode 100644 api/api/async_search.js delete mode 100644 api/api/autoscaling.delete_autoscaling_policy.js delete mode 100644 api/api/autoscaling.get_autoscaling_decision.js delete mode 100644 api/api/autoscaling.get_autoscaling_policy.js create mode 100644 api/api/autoscaling.js delete mode 100644 api/api/autoscaling.put_autoscaling_policy.js delete mode 100644 api/api/cat.aliases.js delete mode 100644 api/api/cat.allocation.js delete mode 100644 api/api/cat.count.js delete mode 100644 api/api/cat.fielddata.js delete mode 100644 api/api/cat.health.js delete mode 100644 api/api/cat.help.js delete mode 100644 api/api/cat.indices.js create mode 100644 api/api/cat.js delete mode 100644 api/api/cat.master.js delete mode 100644 api/api/cat.ml_data_frame_analytics.js delete mode 100644 api/api/cat.ml_datafeeds.js delete mode 100644 api/api/cat.ml_jobs.js delete mode 100644 api/api/cat.ml_trained_models.js delete mode 100644 api/api/cat.nodeattrs.js delete mode 100644 api/api/cat.pending_tasks.js delete mode 100644 api/api/cat.plugins.js delete mode 100644 api/api/cat.recovery.js delete mode 100644 api/api/cat.repositories.js delete mode 100644 api/api/cat.segments.js delete mode 100644 api/api/cat.shards.js delete mode 100644 api/api/cat.snapshots.js delete mode 100644 api/api/cat.tasks.js delete mode 100644 api/api/cat.templates.js delete mode 100644 api/api/cat.transforms.js delete mode 100644 api/api/ccr.delete_auto_follow_pattern.js delete mode 100644 api/api/ccr.follow.js delete mode 100644 api/api/ccr.follow_info.js delete mode 100644 api/api/ccr.follow_stats.js delete mode 100644 api/api/ccr.forget_follower.js delete mode 100644 api/api/ccr.get_auto_follow_pattern.js create mode 100644 api/api/ccr.js delete mode 100644 api/api/ccr.pause_auto_follow_pattern.js delete mode 100644 api/api/ccr.pause_follow.js delete mode 100644 api/api/ccr.put_auto_follow_pattern.js delete mode 100644 api/api/ccr.resume_auto_follow_pattern.js delete mode 100644 api/api/ccr.resume_follow.js delete mode 100644 api/api/ccr.stats.js delete mode 100644 api/api/ccr.unfollow.js delete mode 100644 api/api/cluster.allocation_explain.js delete mode 100644 api/api/cluster.delete_component_template.js delete mode 100644 api/api/cluster.delete_voting_config_exclusions.js delete mode 100644 api/api/cluster.exists_component_template.js delete mode 100644 api/api/cluster.get_component_template.js delete mode 100644 api/api/cluster.get_settings.js delete mode 100644 api/api/cluster.health.js create mode 100644 api/api/cluster.js delete mode 100644 api/api/cluster.pending_tasks.js delete mode 100644 api/api/cluster.post_voting_config_exclusions.js delete mode 100644 api/api/cluster.put_component_template.js delete mode 100644 api/api/cluster.put_settings.js delete mode 100644 api/api/cluster.remote_info.js delete mode 100644 api/api/cluster.reroute.js delete mode 100644 api/api/cluster.state.js delete mode 100644 api/api/cluster.stats.js delete mode 100644 api/api/dangling_indices.delete_dangling_index.js delete mode 100644 api/api/dangling_indices.import_dangling_index.js create mode 100644 api/api/dangling_indices.js delete mode 100644 api/api/dangling_indices.list_dangling_indices.js delete mode 100644 api/api/enrich.delete_policy.js delete mode 100644 api/api/enrich.execute_policy.js delete mode 100644 api/api/enrich.get_policy.js create mode 100644 api/api/enrich.js delete mode 100644 api/api/enrich.put_policy.js delete mode 100644 api/api/enrich.stats.js delete mode 100644 api/api/eql.delete.js delete mode 100644 api/api/eql.get.js create mode 100644 api/api/eql.js delete mode 100644 api/api/eql.search.js create mode 100644 api/api/graph.js delete mode 100644 api/api/ilm.delete_lifecycle.js delete mode 100644 api/api/ilm.explain_lifecycle.js delete mode 100644 api/api/ilm.get_lifecycle.js delete mode 100644 api/api/ilm.get_status.js create mode 100644 api/api/ilm.js delete mode 100644 api/api/ilm.move_to_step.js delete mode 100644 api/api/ilm.put_lifecycle.js delete mode 100644 api/api/ilm.remove_policy.js delete mode 100644 api/api/ilm.retry.js delete mode 100644 api/api/ilm.start.js delete mode 100644 api/api/ilm.stop.js delete mode 100644 api/api/indices.add_block.js delete mode 100644 api/api/indices.analyze.js delete mode 100644 api/api/indices.clear_cache.js delete mode 100644 api/api/indices.clone.js delete mode 100644 api/api/indices.close.js delete mode 100644 api/api/indices.create_data_stream.js delete mode 100644 api/api/indices.data_streams_stats.js delete mode 100644 api/api/indices.delete.js delete mode 100644 api/api/indices.delete_alias.js delete mode 100644 api/api/indices.delete_data_stream.js delete mode 100644 api/api/indices.delete_index_template.js delete mode 100644 api/api/indices.delete_template.js delete mode 100644 api/api/indices.exists.js delete mode 100644 api/api/indices.exists_alias.js delete mode 100644 api/api/indices.exists_index_template.js delete mode 100644 api/api/indices.exists_template.js delete mode 100644 api/api/indices.exists_type.js delete mode 100644 api/api/indices.flush.js delete mode 100644 api/api/indices.forcemerge.js delete mode 100644 api/api/indices.freeze.js delete mode 100644 api/api/indices.get_alias.js delete mode 100644 api/api/indices.get_data_stream.js delete mode 100644 api/api/indices.get_index_template.js delete mode 100644 api/api/indices.get_settings.js create mode 100644 api/api/indices.js delete mode 100644 api/api/indices.open.js delete mode 100644 api/api/indices.put_alias.js delete mode 100644 api/api/indices.put_index_template.js delete mode 100644 api/api/indices.put_settings.js delete mode 100644 api/api/indices.recovery.js delete mode 100644 api/api/indices.refresh.js delete mode 100644 api/api/indices.reload_search_analyzers.js delete mode 100644 api/api/indices.resolve_index.js delete mode 100644 api/api/indices.segments.js delete mode 100644 api/api/indices.shard_stores.js delete mode 100644 api/api/indices.simulate_index_template.js delete mode 100644 api/api/indices.simulate_template.js delete mode 100644 api/api/indices.stats.js delete mode 100644 api/api/indices.unfreeze.js delete mode 100644 api/api/indices.update_aliases.js delete mode 100644 api/api/indices.validate_query.js delete mode 100644 api/api/ingest.delete_pipeline.js delete mode 100644 api/api/ingest.get_pipeline.js create mode 100644 api/api/ingest.js delete mode 100644 api/api/ingest.processor_grok.js delete mode 100644 api/api/ingest.put_pipeline.js delete mode 100644 api/api/ingest.simulate.js delete mode 100644 api/api/license.delete.js delete mode 100644 api/api/license.get.js delete mode 100644 api/api/license.get_basic_status.js delete mode 100644 api/api/license.get_trial_status.js create mode 100644 api/api/license.js delete mode 100644 api/api/license.post.js delete mode 100644 api/api/license.post_start_basic.js delete mode 100644 api/api/license.post_start_trial.js delete mode 100644 api/api/migration.deprecations.js create mode 100644 api/api/migration.js delete mode 100644 api/api/ml.close_job.js delete mode 100644 api/api/ml.delete_calendar.js delete mode 100644 api/api/ml.delete_calendar_event.js delete mode 100644 api/api/ml.delete_calendar_job.js delete mode 100644 api/api/ml.delete_data_frame_analytics.js delete mode 100644 api/api/ml.delete_datafeed.js delete mode 100644 api/api/ml.delete_expired_data.js delete mode 100644 api/api/ml.delete_filter.js delete mode 100644 api/api/ml.delete_forecast.js delete mode 100644 api/api/ml.delete_job.js delete mode 100644 api/api/ml.delete_model_snapshot.js delete mode 100644 api/api/ml.delete_trained_model.js delete mode 100644 api/api/ml.estimate_model_memory.js delete mode 100644 api/api/ml.evaluate_data_frame.js delete mode 100644 api/api/ml.explain_data_frame_analytics.js delete mode 100644 api/api/ml.find_file_structure.js delete mode 100644 api/api/ml.flush_job.js delete mode 100644 api/api/ml.forecast.js delete mode 100644 api/api/ml.get_buckets.js delete mode 100644 api/api/ml.get_calendar_events.js delete mode 100644 api/api/ml.get_calendars.js delete mode 100644 api/api/ml.get_categories.js delete mode 100644 api/api/ml.get_data_frame_analytics.js delete mode 100644 api/api/ml.get_data_frame_analytics_stats.js delete mode 100644 api/api/ml.get_datafeed_stats.js delete mode 100644 api/api/ml.get_datafeeds.js delete mode 100644 api/api/ml.get_filters.js delete mode 100644 api/api/ml.get_influencers.js delete mode 100644 api/api/ml.get_job_stats.js delete mode 100644 api/api/ml.get_jobs.js delete mode 100644 api/api/ml.get_model_snapshots.js delete mode 100644 api/api/ml.get_overall_buckets.js delete mode 100644 api/api/ml.get_records.js delete mode 100644 api/api/ml.get_trained_models.js delete mode 100644 api/api/ml.get_trained_models_stats.js delete mode 100644 api/api/ml.info.js create mode 100644 api/api/ml.js delete mode 100644 api/api/ml.open_job.js delete mode 100644 api/api/ml.post_calendar_events.js delete mode 100644 api/api/ml.post_data.js delete mode 100644 api/api/ml.preview_datafeed.js delete mode 100644 api/api/ml.put_calendar.js delete mode 100644 api/api/ml.put_calendar_job.js delete mode 100644 api/api/ml.put_data_frame_analytics.js delete mode 100644 api/api/ml.put_datafeed.js delete mode 100644 api/api/ml.put_filter.js delete mode 100644 api/api/ml.put_job.js delete mode 100644 api/api/ml.put_trained_model.js delete mode 100644 api/api/ml.revert_model_snapshot.js delete mode 100644 api/api/ml.set_upgrade_mode.js delete mode 100644 api/api/ml.start_data_frame_analytics.js delete mode 100644 api/api/ml.start_datafeed.js delete mode 100644 api/api/ml.stop_data_frame_analytics.js delete mode 100644 api/api/ml.stop_datafeed.js delete mode 100644 api/api/ml.update_data_frame_analytics.js delete mode 100644 api/api/ml.update_datafeed.js delete mode 100644 api/api/ml.update_filter.js delete mode 100644 api/api/ml.update_job.js delete mode 100644 api/api/ml.update_model_snapshot.js delete mode 100644 api/api/ml.validate.js delete mode 100644 api/api/ml.validate_detector.js delete mode 100644 api/api/monitoring.bulk.js create mode 100644 api/api/monitoring.js delete mode 100644 api/api/nodes.info.js create mode 100644 api/api/nodes.js delete mode 100644 api/api/nodes.reload_secure_settings.js delete mode 100644 api/api/nodes.stats.js delete mode 100644 api/api/nodes.usage.js delete mode 100644 api/api/rollup.delete_job.js delete mode 100644 api/api/rollup.get_jobs.js delete mode 100644 api/api/rollup.get_rollup_caps.js delete mode 100644 api/api/rollup.get_rollup_index_caps.js create mode 100644 api/api/rollup.js delete mode 100644 api/api/rollup.put_job.js delete mode 100644 api/api/rollup.rollup_search.js delete mode 100644 api/api/rollup.start_job.js delete mode 100644 api/api/rollup.stop_job.js create mode 100644 api/api/searchable_snapshots.js delete mode 100644 api/api/security.authenticate.js delete mode 100644 api/api/security.change_password.js delete mode 100644 api/api/security.clear_cached_privileges.js delete mode 100644 api/api/security.clear_cached_realms.js delete mode 100644 api/api/security.clear_cached_roles.js delete mode 100644 api/api/security.create_api_key.js delete mode 100644 api/api/security.delete_privileges.js delete mode 100644 api/api/security.delete_role.js delete mode 100644 api/api/security.delete_role_mapping.js delete mode 100644 api/api/security.delete_user.js delete mode 100644 api/api/security.disable_user.js delete mode 100644 api/api/security.enable_user.js delete mode 100644 api/api/security.get_api_key.js delete mode 100644 api/api/security.get_builtin_privileges.js delete mode 100644 api/api/security.get_privileges.js delete mode 100644 api/api/security.get_role.js delete mode 100644 api/api/security.get_role_mapping.js delete mode 100644 api/api/security.get_token.js delete mode 100644 api/api/security.get_user.js delete mode 100644 api/api/security.get_user_privileges.js delete mode 100644 api/api/security.has_privileges.js delete mode 100644 api/api/security.invalidate_api_key.js delete mode 100644 api/api/security.invalidate_token.js create mode 100644 api/api/security.js delete mode 100644 api/api/security.put_privileges.js delete mode 100644 api/api/security.put_role.js delete mode 100644 api/api/security.put_role_mapping.js delete mode 100644 api/api/security.put_user.js delete mode 100644 api/api/slm.delete_lifecycle.js delete mode 100644 api/api/slm.execute_lifecycle.js delete mode 100644 api/api/slm.execute_retention.js delete mode 100644 api/api/slm.get_lifecycle.js delete mode 100644 api/api/slm.get_stats.js delete mode 100644 api/api/slm.get_status.js create mode 100644 api/api/slm.js delete mode 100644 api/api/slm.put_lifecycle.js delete mode 100644 api/api/slm.start.js delete mode 100644 api/api/slm.stop.js delete mode 100644 api/api/snapshot.cleanup_repository.js delete mode 100644 api/api/snapshot.create.js delete mode 100644 api/api/snapshot.create_repository.js delete mode 100644 api/api/snapshot.delete_repository.js delete mode 100644 api/api/snapshot.get.js delete mode 100644 api/api/snapshot.get_repository.js create mode 100644 api/api/snapshot.js delete mode 100644 api/api/snapshot.restore.js delete mode 100644 api/api/snapshot.status.js delete mode 100644 api/api/snapshot.verify_repository.js delete mode 100644 api/api/sql.clear_cursor.js create mode 100644 api/api/sql.js delete mode 100644 api/api/sql.query.js delete mode 100644 api/api/sql.translate.js delete mode 100644 api/api/ssl.certificates.js create mode 100644 api/api/ssl.js delete mode 100644 api/api/tasks.cancel.js delete mode 100644 api/api/tasks.get.js create mode 100644 api/api/tasks.js delete mode 100644 api/api/tasks.list.js delete mode 100644 api/api/transform.delete_transform.js delete mode 100644 api/api/transform.get_transform.js delete mode 100644 api/api/transform.get_transform_stats.js create mode 100644 api/api/transform.js delete mode 100644 api/api/transform.preview_transform.js delete mode 100644 api/api/transform.put_transform.js delete mode 100644 api/api/transform.start_transform.js delete mode 100644 api/api/transform.stop_transform.js delete mode 100644 api/api/transform.update_transform.js delete mode 100644 api/api/watcher.ack_watch.js delete mode 100644 api/api/watcher.activate_watch.js delete mode 100644 api/api/watcher.deactivate_watch.js delete mode 100644 api/api/watcher.delete_watch.js delete mode 100644 api/api/watcher.execute_watch.js delete mode 100644 api/api/watcher.get_watch.js create mode 100644 api/api/watcher.js delete mode 100644 api/api/watcher.put_watch.js delete mode 100644 api/api/watcher.start.js delete mode 100644 api/api/watcher.stats.js delete mode 100644 api/api/watcher.stop.js delete mode 100644 api/api/xpack.info.js create mode 100644 api/api/xpack.js delete mode 100644 api/api/xpack.usage.js create mode 100644 api/utils.js create mode 100644 test/bundlers/parcel-test/index.js create mode 100644 test/bundlers/parcel-test/package.json create mode 100644 test/bundlers/rollup-test/index.js create mode 100644 test/bundlers/rollup-test/package.json create mode 100644 test/bundlers/rollup-test/rollup.config.js create mode 100644 test/bundlers/webpack-test/index.js create mode 100644 test/bundlers/webpack-test/package.json create mode 100644 test/bundlers/webpack-test/webpack.config.js diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 1fafb304e..1e9a2af9f 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -101,6 +101,49 @@ jobs: run: | npm run test:integration:helpers + bundler-support: + name: Bundler support + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Configure sysctl limits + run: | + sudo swapoff -a + sudo sysctl -w vm.swappiness=1 + sudo sysctl -w fs.file-max=262144 + sudo sysctl -w vm.max_map_count=262144 + + - name: Runs Elasticsearch + uses: elastic/elastic-github-actions/elasticsearch@master + with: + stack-version: 8.0.0-SNAPSHOT + + - name: Use Node.js 14.x + uses: actions/setup-node@v1 + with: + node-version: 14.x + + - name: Install + run: | + npm install + npm install --prefix test/bundlers/parcel-test + npm install --prefix test/bundlers/rollup-test + npm install --prefix test/bundlers/webpack-test + + - name: Build + run: | + npm run build --prefix test/bundlers/parcel-test + npm run build --prefix test/bundlers/rollup-test + npm run build --prefix test/bundlers/webpack-test + + - name: Run bundle + run: | + npm start --prefix test/bundlers/parcel-test + npm start --prefix test/bundlers/rollup-test + npm start --prefix test/bundlers/webpack-test + code-coverage: name: Code coverage runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index c610926ce..4e5d66081 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,7 @@ elasticsearch* test/benchmarks/macro/fixtures/* *-junit.xml + +.cache + +test/bundlers/**/bundle.js diff --git a/api/api/async_search.delete.js b/api/api/async_search.delete.js deleted file mode 100644 index a77f1f60d..000000000 --- a/api/api/async_search.delete.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildAsyncSearchDelete (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a async_search.delete request - * Deletes an async search by ID. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html - */ - return function asyncSearchDelete (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_async_search' + '/' + encodeURIComponent(id) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildAsyncSearchDelete diff --git a/api/api/async_search.get.js b/api/api/async_search.get.js deleted file mode 100644 index 163b0aa9f..000000000 --- a/api/api/async_search.get.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildAsyncSearchGet (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'wait_for_completion_timeout', - 'keep_alive', - 'typed_keys' - ] - - const snakeCase = { - waitForCompletionTimeout: 'wait_for_completion_timeout', - keepAlive: 'keep_alive', - typedKeys: 'typed_keys' - } - - /** - * Perform a async_search.get request - * Retrieves the results of a previously submitted async search request given its ID. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/async-search.html - */ - return function asyncSearchGet (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_async_search' + '/' + encodeURIComponent(id) - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildAsyncSearchGet diff --git a/api/api/async_search.js b/api/api/async_search.js new file mode 100644 index 000000000..d7e4ee8e7 --- /dev/null +++ b/api/api/async_search.js @@ -0,0 +1,114 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path', 'wait_for_completion_timeout', 'keep_alive', 'typed_keys', 'keep_on_completion', 'batched_reduce_size', 'request_cache', 'analyzer', 'analyze_wildcard', 'default_operator', 'df', 'explain', 'stored_fields', 'docvalue_fields', 'from', 'ignore_unavailable', 'ignore_throttled', 'allow_no_indices', 'expand_wildcards', 'lenient', 'preference', 'q', 'routing', 'search_type', 'size', 'sort', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'terminate_after', 'stats', 'suggest_field', 'suggest_mode', 'suggest_size', 'suggest_text', 'timeout', 'track_scores', 'track_total_hits', 'allow_partial_search_results', 'version', 'seq_no_primary_term', 'max_concurrent_shard_requests'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path', waitForCompletionTimeout: 'wait_for_completion_timeout', keepAlive: 'keep_alive', typedKeys: 'typed_keys', keepOnCompletion: 'keep_on_completion', batchedReduceSize: 'batched_reduce_size', requestCache: 'request_cache', analyzeWildcard: 'analyze_wildcard', defaultOperator: 'default_operator', storedFields: 'stored_fields', docvalueFields: 'docvalue_fields', ignoreUnavailable: 'ignore_unavailable', ignoreThrottled: 'ignore_throttled', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', searchType: 'search_type', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', terminateAfter: 'terminate_after', suggestField: 'suggest_field', suggestMode: 'suggest_mode', suggestSize: 'suggest_size', suggestText: 'suggest_text', trackScores: 'track_scores', trackTotalHits: 'track_total_hits', allowPartialSearchResults: 'allow_partial_search_results', seqNoPrimaryTerm: 'seq_no_primary_term', maxConcurrentShardRequests: 'max_concurrent_shard_requests' } + +function AsyncSearchApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +AsyncSearchApi.prototype.delete = function asyncSearchDeleteApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_async_search' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +AsyncSearchApi.prototype.get = function asyncSearchGetApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_async_search' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +AsyncSearchApi.prototype.submit = function asyncSearchSubmitApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_async_search' + } else { + if (method == null) method = 'POST' + path = '/' + '_async_search' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +module.exports = AsyncSearchApi diff --git a/api/api/autoscaling.delete_autoscaling_policy.js b/api/api/autoscaling.delete_autoscaling_policy.js deleted file mode 100644 index f0382f1ae..000000000 --- a/api/api/autoscaling.delete_autoscaling_policy.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildAutoscalingDeleteAutoscalingPolicy (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a autoscaling.delete_autoscaling_policy request - * Deletes an autoscaling policy. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-delete-autoscaling-policy.html - */ - return function autoscalingDeleteAutoscalingPolicy (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_autoscaling' + '/' + 'policy' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildAutoscalingDeleteAutoscalingPolicy diff --git a/api/api/autoscaling.get_autoscaling_decision.js b/api/api/autoscaling.get_autoscaling_decision.js deleted file mode 100644 index 268e9f5ed..000000000 --- a/api/api/autoscaling.get_autoscaling_decision.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildAutoscalingGetAutoscalingDecision (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a autoscaling.get_autoscaling_decision request - * Gets the current autoscaling decision based on the configured autoscaling policy, indicating whether or not autoscaling is needed. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-get-autoscaling-decision.html - */ - return function autoscalingGetAutoscalingDecision (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_autoscaling' + '/' + 'decision' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildAutoscalingGetAutoscalingDecision diff --git a/api/api/autoscaling.get_autoscaling_policy.js b/api/api/autoscaling.get_autoscaling_policy.js deleted file mode 100644 index 296ea919f..000000000 --- a/api/api/autoscaling.get_autoscaling_policy.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildAutoscalingGetAutoscalingPolicy (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a autoscaling.get_autoscaling_policy request - * Retrieves an autoscaling policy. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-get-autoscaling-policy.html - */ - return function autoscalingGetAutoscalingPolicy (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_autoscaling' + '/' + 'policy' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildAutoscalingGetAutoscalingPolicy diff --git a/api/api/autoscaling.js b/api/api/autoscaling.js new file mode 100644 index 000000000..7a968b06c --- /dev/null +++ b/api/api/autoscaling.js @@ -0,0 +1,147 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } + +function AutoscalingApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +AutoscalingApi.prototype.deleteAutoscalingPolicy = function autoscalingDeleteAutoscalingPolicyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_autoscaling' + '/' + 'policy' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +AutoscalingApi.prototype.getAutoscalingDecision = function autoscalingGetAutoscalingDecisionApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_autoscaling' + '/' + 'decision' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +AutoscalingApi.prototype.getAutoscalingPolicy = function autoscalingGetAutoscalingPolicyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_autoscaling' + '/' + 'policy' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +AutoscalingApi.prototype.putAutoscalingPolicy = function autoscalingPutAutoscalingPolicyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_autoscaling' + '/' + 'policy' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(AutoscalingApi.prototype, { + delete_autoscaling_policy: { get () { return this.deleteAutoscalingPolicy } }, + get_autoscaling_decision: { get () { return this.getAutoscalingDecision } }, + get_autoscaling_policy: { get () { return this.getAutoscalingPolicy } }, + put_autoscaling_policy: { get () { return this.putAutoscalingPolicy } } +}) + +module.exports = AutoscalingApi diff --git a/api/api/autoscaling.put_autoscaling_policy.js b/api/api/autoscaling.put_autoscaling_policy.js deleted file mode 100644 index f1eee7247..000000000 --- a/api/api/autoscaling.put_autoscaling_policy.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildAutoscalingPutAutoscalingPolicy (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a autoscaling.put_autoscaling_policy request - * Creates a new autoscaling policy. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/autoscaling-put-autoscaling-policy.html - */ - return function autoscalingPutAutoscalingPolicy (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_autoscaling' + '/' + 'policy' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildAutoscalingPutAutoscalingPolicy diff --git a/api/api/bulk.js b/api/api/bulk.js index 100f3e9c0..c6dcdcc5d 100644 --- a/api/api/bulk.js +++ b/api/api/bulk.js @@ -22,10 +22,11 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildBulk (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['wait_for_active_shards', 'refresh', 'routing', 'timeout', 'type', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'pipeline', 'require_alias', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { waitForActiveShards: 'wait_for_active_shards', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', requireAlias: 'require_alias', errorTrace: 'error_trace', filterPath: 'filter_path' } +<<<<<<< HEAD const acceptedQuerystring = [ 'wait_for_active_shards', 'refresh', @@ -51,76 +52,47 @@ function buildBulk (opts) { requireAlias: 'require_alias', errorTrace: 'error_trace', filterPath: 'filter_path' +======= +function bulkApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) +>>>>>>> a064f0f3... Improve child performances (#1314) } - /** - * Perform a bulk request - * Allows to perform multiple index/update/delete operations in a single request. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-bulk.html - */ - return function bulk (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // check required url components - if (params['type'] != null && (params['index'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, type, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null && (type) != null) { - if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_bulk' - } else if ((index) != null) { - if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_bulk' - } else { - if (method == null) method = 'POST' - path = '/' + '_bulk' - } - - // build request object - const request = { - method, - path, - bulkBody: body, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // check required url components + if (params['type'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) } + + var { method, body, index, type, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (type) != null) { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_bulk' + } else if ((index) != null) { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_bulk' + } else { + if (method == null) method = 'POST' + path = '/' + '_bulk' + } + + // build request object + const request = { + method, + path, + bulkBody: body, + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildBulk +module.exports = bulkApi diff --git a/api/api/cat.aliases.js b/api/api/cat.aliases.js deleted file mode 100644 index f6d5a3d67..000000000 --- a/api/api/cat.aliases.js +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatAliases (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'format', - 'local', - 'h', - 'help', - 's', - 'v', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - expandWildcards: 'expand_wildcards', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cat.aliases request - * Shows information about currently configured aliases to indices including filter and routing infos. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-alias.html - */ - return function catAliases (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((name) != null) { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'aliases' + '/' + encodeURIComponent(name) - } else { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'aliases' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatAliases diff --git a/api/api/cat.allocation.js b/api/api/cat.allocation.js deleted file mode 100644 index 00a02a80f..000000000 --- a/api/api/cat.allocation.js +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatAllocation (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'format', - 'bytes', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cat.allocation request - * Provides a snapshot of how many shards are allocated to each data node and how much disk space they are using. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-allocation.html - */ - return function catAllocation (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, nodeId, node_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((node_id || nodeId) != null) { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'allocation' + '/' + encodeURIComponent(node_id || nodeId) - } else { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'allocation' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatAllocation diff --git a/api/api/cat.count.js b/api/api/cat.count.js deleted file mode 100644 index 600dcfaa2..000000000 --- a/api/api/cat.count.js +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatCount (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'format', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cat.count request - * Provides quick access to the document count of the entire cluster, or individual indices. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-count.html - */ - return function catCount (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'count' + '/' + encodeURIComponent(index) - } else { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'count' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatCount diff --git a/api/api/cat.fielddata.js b/api/api/cat.fielddata.js deleted file mode 100644 index cd6aa94c2..000000000 --- a/api/api/cat.fielddata.js +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatFielddata (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'format', - 'bytes', - 'h', - 'help', - 's', - 'v', - 'fields', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cat.fielddata request - * Shows how much heap memory is currently being used by fielddata on every data node in the cluster. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-fielddata.html - */ - return function catFielddata (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, fields, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((fields) != null) { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'fielddata' + '/' + encodeURIComponent(fields) - } else { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'fielddata' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatFielddata diff --git a/api/api/cat.health.js b/api/api/cat.health.js deleted file mode 100644 index ba2274746..000000000 --- a/api/api/cat.health.js +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatHealth (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'format', - 'h', - 'help', - 's', - 'time', - 'ts', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cat.health request - * Returns a concise representation of the cluster health. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-health.html - */ - return function catHealth (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'health' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatHealth diff --git a/api/api/cat.help.js b/api/api/cat.help.js deleted file mode 100644 index 472aee216..000000000 --- a/api/api/cat.help.js +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatHelp (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'help', - 's', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cat.help request - * Returns help for the Cat APIs. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cat.html - */ - return function catHelp (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_cat' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatHelp diff --git a/api/api/cat.indices.js b/api/api/cat.indices.js deleted file mode 100644 index 4b2e7d140..000000000 --- a/api/api/cat.indices.js +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatIndices (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'format', - 'bytes', - 'local', - 'master_timeout', - 'h', - 'health', - 'help', - 'pri', - 's', - 'time', - 'v', - 'include_unloaded_segments', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - includeUnloadedSegments: 'include_unloaded_segments', - expandWildcards: 'expand_wildcards', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cat.indices request - * Returns information about indices: number of primaries and replicas, document counts, disk size, ... - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-indices.html - */ - return function catIndices (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'indices' + '/' + encodeURIComponent(index) - } else { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'indices' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatIndices diff --git a/api/api/cat.js b/api/api/cat.js new file mode 100644 index 000000000..5958aa02b --- /dev/null +++ b/api/api/cat.js @@ -0,0 +1,648 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['format', 'local', 'h', 'help', 's', 'v', 'expand_wildcards', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'bytes', 'master_timeout', 'fields', 'time', 'ts', 'health', 'pri', 'include_unloaded_segments', 'full_id', 'active_only', 'detailed', 'index', 'ignore_unavailable', 'node_id', 'actions', 'parent_task', 'allow_no_match', 'allow_no_datafeeds', 'allow_no_jobs', 'from', 'size'] +const snakeCase = { expandWildcards: 'expand_wildcards', errorTrace: 'error_trace', filterPath: 'filter_path', masterTimeout: 'master_timeout', includeUnloadedSegments: 'include_unloaded_segments', fullId: 'full_id', activeOnly: 'active_only', ignoreUnavailable: 'ignore_unavailable', nodeId: 'node_id', parentTask: 'parent_task', allowNoMatch: 'allow_no_match', allowNoDatafeeds: 'allow_no_datafeeds', allowNoJobs: 'allow_no_jobs' } + +function CatApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +CatApi.prototype.aliases = function catAliasesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'aliases' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'aliases' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.allocation = function catAllocationApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, nodeId, node_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((node_id || nodeId) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'allocation' + '/' + encodeURIComponent(node_id || nodeId) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'allocation' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.count = function catCountApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'count' + '/' + encodeURIComponent(index) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'count' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.fielddata = function catFielddataApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, fields, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((fields) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'fielddata' + '/' + encodeURIComponent(fields) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'fielddata' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.health = function catHealthApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'health' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.help = function catHelpApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cat' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.indices = function catIndicesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'indices' + '/' + encodeURIComponent(index) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'indices' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.master = function catMasterApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'master' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.nodeattrs = function catNodeattrsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'nodeattrs' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.nodes = function catNodesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'nodes' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.pendingTasks = function catPendingTasksApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'pending_tasks' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.plugins = function catPluginsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'plugins' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.recovery = function catRecoveryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'recovery' + '/' + encodeURIComponent(index) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'recovery' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.repositories = function catRepositoriesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'repositories' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.segments = function catSegmentsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'segments' + '/' + encodeURIComponent(index) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'segments' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.shards = function catShardsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'shards' + '/' + encodeURIComponent(index) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'shards' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.snapshots = function catSnapshotsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, repository, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((repository) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'snapshots' + '/' + encodeURIComponent(repository) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'snapshots' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.tasks = function catTasksApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'tasks' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.templates = function catTemplatesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'templates' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'templates' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.threadPool = function catThreadPoolApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, threadPoolPatterns, thread_pool_patterns, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((thread_pool_patterns || threadPoolPatterns) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'thread_pool' + '/' + encodeURIComponent(thread_pool_patterns || threadPoolPatterns) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'thread_pool' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.mlDataFrameAnalytics = function catMlDataFrameAnalyticsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'ml' + '/' + 'data_frame' + '/' + 'analytics' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.mlDatafeeds = function catMlDatafeedsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, datafeedId, datafeed_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((datafeed_id || datafeedId) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'ml' + '/' + 'datafeeds' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.mlJobs = function catMlJobsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((job_id || jobId) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'ml' + '/' + 'anomaly_detectors' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.mlTrainedModels = function catMlTrainedModelsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, modelId, model_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((model_id || modelId) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'ml' + '/' + 'trained_models' + '/' + encodeURIComponent(model_id || modelId) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'ml' + '/' + 'trained_models' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CatApi.prototype.transforms = function catTransformsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, transformId, transform_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((transform_id || transformId) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'transforms' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(CatApi.prototype, { + pending_tasks: { get () { return this.pendingTasks } }, + thread_pool: { get () { return this.threadPool } }, + ml_data_frame_analytics: { get () { return this.mlDataFrameAnalytics } }, + ml_datafeeds: { get () { return this.mlDatafeeds } }, + ml_jobs: { get () { return this.mlJobs } }, + ml_trained_models: { get () { return this.mlTrainedModels } } +}) + +module.exports = CatApi diff --git a/api/api/cat.master.js b/api/api/cat.master.js deleted file mode 100644 index 645f5cffd..000000000 --- a/api/api/cat.master.js +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatMaster (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'format', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cat.master request - * Returns information about the master node. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-master.html - */ - return function catMaster (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'master' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatMaster diff --git a/api/api/cat.ml_data_frame_analytics.js b/api/api/cat.ml_data_frame_analytics.js deleted file mode 100644 index 6bbec58a3..000000000 --- a/api/api/cat.ml_data_frame_analytics.js +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatMlDataFrameAnalytics (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'allow_no_match', - 'bytes', - 'format', - 'h', - 'help', - 's', - 'time', - 'v' - ] - - const snakeCase = { - allowNoMatch: 'allow_no_match' - - } - - /** - * Perform a cat.ml_data_frame_analytics request - * Gets configuration and usage information about data frame analytics jobs. - * http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-dfanalytics.html - */ - return function catMlDataFrameAnalytics (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((id) != null) { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) - } else { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'ml' + '/' + 'data_frame' + '/' + 'analytics' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatMlDataFrameAnalytics diff --git a/api/api/cat.ml_datafeeds.js b/api/api/cat.ml_datafeeds.js deleted file mode 100644 index 4475a1d77..000000000 --- a/api/api/cat.ml_datafeeds.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatMlDatafeeds (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'allow_no_match', - 'allow_no_datafeeds', - 'format', - 'h', - 'help', - 's', - 'time', - 'v' - ] - - const snakeCase = { - allowNoMatch: 'allow_no_match', - allowNoDatafeeds: 'allow_no_datafeeds' - - } - - /** - * Perform a cat.ml_datafeeds request - * Gets configuration and usage information about datafeeds. - * http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-datafeeds.html - */ - return function catMlDatafeeds (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, datafeedId, datafeed_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((datafeed_id || datafeedId) != null) { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) - } else { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'ml' + '/' + 'datafeeds' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatMlDatafeeds diff --git a/api/api/cat.ml_jobs.js b/api/api/cat.ml_jobs.js deleted file mode 100644 index 25ed055c0..000000000 --- a/api/api/cat.ml_jobs.js +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatMlJobs (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'allow_no_match', - 'allow_no_jobs', - 'bytes', - 'format', - 'h', - 'help', - 's', - 'time', - 'v' - ] - - const snakeCase = { - allowNoMatch: 'allow_no_match', - allowNoJobs: 'allow_no_jobs' - - } - - /** - * Perform a cat.ml_jobs request - * Gets configuration and usage information about anomaly detection jobs. - * http://www.elastic.co/guide/en/elasticsearch/reference/current/cat-anomaly-detectors.html - */ - return function catMlJobs (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((job_id || jobId) != null) { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) - } else { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'ml' + '/' + 'anomaly_detectors' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatMlJobs diff --git a/api/api/cat.ml_trained_models.js b/api/api/cat.ml_trained_models.js deleted file mode 100644 index befcdfeb1..000000000 --- a/api/api/cat.ml_trained_models.js +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatMlTrainedModels (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'allow_no_match', - 'from', - 'size', - 'bytes', - 'format', - 'h', - 'help', - 's', - 'time', - 'v' - ] - - const snakeCase = { - allowNoMatch: 'allow_no_match' - - } - - /** - * Perform a cat.ml_trained_models request - * Gets configuration and usage information about inference trained models. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-trained-model.html - */ - return function catMlTrainedModels (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, modelId, model_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((model_id || modelId) != null) { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'ml' + '/' + 'trained_models' + '/' + encodeURIComponent(model_id || modelId) - } else { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'ml' + '/' + 'trained_models' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatMlTrainedModels diff --git a/api/api/cat.nodeattrs.js b/api/api/cat.nodeattrs.js deleted file mode 100644 index b444d2d6d..000000000 --- a/api/api/cat.nodeattrs.js +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatNodeattrs (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'format', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cat.nodeattrs request - * Returns information about custom node attributes. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-nodeattrs.html - */ - return function catNodeattrs (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'nodeattrs' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatNodeattrs diff --git a/api/api/cat.pending_tasks.js b/api/api/cat.pending_tasks.js deleted file mode 100644 index b3686d322..000000000 --- a/api/api/cat.pending_tasks.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatPendingTasks (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'format', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'time', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cat.pending_tasks request - * Returns a concise representation of the cluster pending tasks. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-pending-tasks.html - */ - return function catPendingTasks (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'pending_tasks' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatPendingTasks diff --git a/api/api/cat.plugins.js b/api/api/cat.plugins.js deleted file mode 100644 index fcfc2ba4e..000000000 --- a/api/api/cat.plugins.js +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatPlugins (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'format', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cat.plugins request - * Returns information about installed plugins across nodes node. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-plugins.html - */ - return function catPlugins (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'plugins' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatPlugins diff --git a/api/api/cat.recovery.js b/api/api/cat.recovery.js deleted file mode 100644 index 99ab18507..000000000 --- a/api/api/cat.recovery.js +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatRecovery (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'format', - 'active_only', - 'bytes', - 'detailed', - 'h', - 'help', - 'index', - 's', - 'time', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - activeOnly: 'active_only', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cat.recovery request - * Returns information about index shard recoveries, both on-going completed. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-recovery.html - */ - return function catRecovery (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'recovery' + '/' + encodeURIComponent(index) - } else { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'recovery' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatRecovery diff --git a/api/api/cat.repositories.js b/api/api/cat.repositories.js deleted file mode 100644 index 3998cc7ec..000000000 --- a/api/api/cat.repositories.js +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatRepositories (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'format', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cat.repositories request - * Returns information about snapshot repositories registered in the cluster. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-repositories.html - */ - return function catRepositories (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'repositories' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatRepositories diff --git a/api/api/cat.segments.js b/api/api/cat.segments.js deleted file mode 100644 index b758eb502..000000000 --- a/api/api/cat.segments.js +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatSegments (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'format', - 'bytes', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cat.segments request - * Provides low-level information about the segments in the shards of an index. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-segments.html - */ - return function catSegments (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'segments' + '/' + encodeURIComponent(index) - } else { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'segments' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatSegments diff --git a/api/api/cat.shards.js b/api/api/cat.shards.js deleted file mode 100644 index be4c2b87c..000000000 --- a/api/api/cat.shards.js +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatShards (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'format', - 'bytes', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'time', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cat.shards request - * Provides a detailed view of shard allocation on nodes. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-shards.html - */ - return function catShards (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'shards' + '/' + encodeURIComponent(index) - } else { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'shards' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatShards diff --git a/api/api/cat.snapshots.js b/api/api/cat.snapshots.js deleted file mode 100644 index 03ef0f5f0..000000000 --- a/api/api/cat.snapshots.js +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatSnapshots (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'format', - 'ignore_unavailable', - 'master_timeout', - 'h', - 'help', - 's', - 'time', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cat.snapshots request - * Returns all snapshots in a specific repository. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-snapshots.html - */ - return function catSnapshots (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, repository, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((repository) != null) { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'snapshots' + '/' + encodeURIComponent(repository) - } else { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'snapshots' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatSnapshots diff --git a/api/api/cat.tasks.js b/api/api/cat.tasks.js deleted file mode 100644 index eee249153..000000000 --- a/api/api/cat.tasks.js +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatTasks (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'format', - 'node_id', - 'actions', - 'detailed', - 'parent_task', - 'h', - 'help', - 's', - 'time', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - nodeId: 'node_id', - parentTask: 'parent_task', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cat.tasks request - * Returns information about the tasks currently executing on one or more nodes in the cluster. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html - */ - return function catTasks (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'tasks' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatTasks diff --git a/api/api/cat.templates.js b/api/api/cat.templates.js deleted file mode 100644 index 581ebc411..000000000 --- a/api/api/cat.templates.js +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatTemplates (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'format', - 'local', - 'master_timeout', - 'h', - 'help', - 's', - 'v', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cat.templates request - * Returns information about existing templates. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-templates.html - */ - return function catTemplates (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((name) != null) { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'templates' + '/' + encodeURIComponent(name) - } else { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'templates' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatTemplates diff --git a/api/api/cat.transforms.js b/api/api/cat.transforms.js deleted file mode 100644 index 20bfd88d5..000000000 --- a/api/api/cat.transforms.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCatTransforms (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'from', - 'size', - 'allow_no_match', - 'format', - 'h', - 'help', - 's', - 'time', - 'v' - ] - - const snakeCase = { - allowNoMatch: 'allow_no_match' - - } - - /** - * Perform a cat.transforms request - * Gets configuration and usage information about transforms. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transforms.html - */ - return function catTransforms (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, transformId, transform_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((transform_id || transformId) != null) { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId) - } else { - if (method == null) method = 'GET' - path = '/' + '_cat' + '/' + 'transforms' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCatTransforms diff --git a/api/api/ccr.delete_auto_follow_pattern.js b/api/api/ccr.delete_auto_follow_pattern.js deleted file mode 100644 index b5e2e9a58..000000000 --- a/api/api/ccr.delete_auto_follow_pattern.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCcrDeleteAutoFollowPattern (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ccr.delete_auto_follow_pattern request - * Deletes auto-follow patterns. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html - */ - return function ccrDeleteAutoFollowPattern (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCcrDeleteAutoFollowPattern diff --git a/api/api/ccr.follow.js b/api/api/ccr.follow.js deleted file mode 100644 index cdc66214c..000000000 --- a/api/api/ccr.follow.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCcrFollow (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'wait_for_active_shards' - ] - - const snakeCase = { - waitForActiveShards: 'wait_for_active_shards' - } - - /** - * Perform a ccr.follow request - * Creates a new follower index configured to follow the referenced leader index. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-follow.html - */ - return function ccrFollow (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'follow' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCcrFollow diff --git a/api/api/ccr.follow_info.js b/api/api/ccr.follow_info.js deleted file mode 100644 index fb908d8b7..000000000 --- a/api/api/ccr.follow_info.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCcrFollowInfo (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ccr.follow_info request - * Retrieves information about all follower indices, including parameters and status for each follower index - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-info.html - */ - return function ccrFollowInfo (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'info' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCcrFollowInfo diff --git a/api/api/ccr.follow_stats.js b/api/api/ccr.follow_stats.js deleted file mode 100644 index 7d94cb406..000000000 --- a/api/api/ccr.follow_stats.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCcrFollowStats (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ccr.follow_stats request - * Retrieves follower stats. return shard-level stats about the following tasks associated with each shard for the specified indices. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-follow-stats.html - */ - return function ccrFollowStats (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'stats' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCcrFollowStats diff --git a/api/api/ccr.forget_follower.js b/api/api/ccr.forget_follower.js deleted file mode 100644 index 14679003e..000000000 --- a/api/api/ccr.forget_follower.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCcrForgetFollower (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ccr.forget_follower request - * Removes the follower retention leases from the leader. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-forget-follower.html - */ - return function ccrForgetFollower (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'forget_follower' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCcrForgetFollower diff --git a/api/api/ccr.get_auto_follow_pattern.js b/api/api/ccr.get_auto_follow_pattern.js deleted file mode 100644 index b8e5ff65b..000000000 --- a/api/api/ccr.get_auto_follow_pattern.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCcrGetAutoFollowPattern (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ccr.get_auto_follow_pattern request - * Gets configured auto-follow patterns. Returns the specified auto-follow pattern collection. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-auto-follow-pattern.html - */ - return function ccrGetAutoFollowPattern (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((name) != null) { - if (method == null) method = 'GET' - path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) - } else { - if (method == null) method = 'GET' - path = '/' + '_ccr' + '/' + 'auto_follow' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCcrGetAutoFollowPattern diff --git a/api/api/ccr.js b/api/api/ccr.js new file mode 100644 index 000000000..e832c7491 --- /dev/null +++ b/api/api/ccr.js @@ -0,0 +1,403 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path', 'wait_for_active_shards'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path', waitForActiveShards: 'wait_for_active_shards' } + +function CcrApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +CcrApi.prototype.deleteAutoFollowPattern = function ccrDeleteAutoFollowPatternApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.follow = function ccrFollowApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'follow' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.followInfo = function ccrFollowInfoApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'info' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.followStats = function ccrFollowStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'stats' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.forgetFollower = function ccrForgetFollowerApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'forget_follower' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.getAutoFollowPattern = function ccrGetAutoFollowPatternApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_ccr' + '/' + 'auto_follow' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.pauseAutoFollowPattern = function ccrPauseAutoFollowPatternApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) + '/' + 'pause' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.pauseFollow = function ccrPauseFollowApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'pause_follow' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.putAutoFollowPattern = function ccrPutAutoFollowPatternApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.resumeAutoFollowPattern = function ccrResumeAutoFollowPatternApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) + '/' + 'resume' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.resumeFollow = function ccrResumeFollowApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'resume_follow' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.stats = function ccrStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_ccr' + '/' + 'stats' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +CcrApi.prototype.unfollow = function ccrUnfollowApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'unfollow' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(CcrApi.prototype, { + delete_auto_follow_pattern: { get () { return this.deleteAutoFollowPattern } }, + follow_info: { get () { return this.followInfo } }, + follow_stats: { get () { return this.followStats } }, + forget_follower: { get () { return this.forgetFollower } }, + get_auto_follow_pattern: { get () { return this.getAutoFollowPattern } }, + pause_auto_follow_pattern: { get () { return this.pauseAutoFollowPattern } }, + pause_follow: { get () { return this.pauseFollow } }, + put_auto_follow_pattern: { get () { return this.putAutoFollowPattern } }, + resume_auto_follow_pattern: { get () { return this.resumeAutoFollowPattern } }, + resume_follow: { get () { return this.resumeFollow } } +}) + +module.exports = CcrApi diff --git a/api/api/ccr.pause_auto_follow_pattern.js b/api/api/ccr.pause_auto_follow_pattern.js deleted file mode 100644 index 02e4cdc18..000000000 --- a/api/api/ccr.pause_auto_follow_pattern.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCcrPauseAutoFollowPattern (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ccr.pause_auto_follow_pattern request - * Pauses an auto-follow pattern - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-pause-auto-follow-pattern.html - */ - return function ccrPauseAutoFollowPattern (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) + '/' + 'pause' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCcrPauseAutoFollowPattern diff --git a/api/api/ccr.pause_follow.js b/api/api/ccr.pause_follow.js deleted file mode 100644 index 3f3b3d5a3..000000000 --- a/api/api/ccr.pause_follow.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCcrPauseFollow (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ccr.pause_follow request - * Pauses a follower index. The follower index will not fetch any additional operations from the leader index. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-pause-follow.html - */ - return function ccrPauseFollow (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'pause_follow' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCcrPauseFollow diff --git a/api/api/ccr.put_auto_follow_pattern.js b/api/api/ccr.put_auto_follow_pattern.js deleted file mode 100644 index 62b951c5c..000000000 --- a/api/api/ccr.put_auto_follow_pattern.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCcrPutAutoFollowPattern (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ccr.put_auto_follow_pattern request - * Creates a new named collection of auto-follow patterns against a specified remote cluster. Newly created indices on the remote cluster matching any of the specified patterns will be automatically configured as follower indices. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-put-auto-follow-pattern.html - */ - return function ccrPutAutoFollowPattern (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCcrPutAutoFollowPattern diff --git a/api/api/ccr.resume_auto_follow_pattern.js b/api/api/ccr.resume_auto_follow_pattern.js deleted file mode 100644 index 2e75f9efa..000000000 --- a/api/api/ccr.resume_auto_follow_pattern.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCcrResumeAutoFollowPattern (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ccr.resume_auto_follow_pattern request - * Resumes an auto-follow pattern that has been paused - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-resume-auto-follow-pattern.html - */ - return function ccrResumeAutoFollowPattern (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name) + '/' + 'resume' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCcrResumeAutoFollowPattern diff --git a/api/api/ccr.resume_follow.js b/api/api/ccr.resume_follow.js deleted file mode 100644 index 02c2879b7..000000000 --- a/api/api/ccr.resume_follow.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCcrResumeFollow (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ccr.resume_follow request - * Resumes a follower index that has been paused - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-resume-follow.html - */ - return function ccrResumeFollow (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'resume_follow' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCcrResumeFollow diff --git a/api/api/ccr.stats.js b/api/api/ccr.stats.js deleted file mode 100644 index efc9520cc..000000000 --- a/api/api/ccr.stats.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCcrStats (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ccr.stats request - * Gets all stats related to cross-cluster replication. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-get-stats.html - */ - return function ccrStats (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_ccr' + '/' + 'stats' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCcrStats diff --git a/api/api/ccr.unfollow.js b/api/api/ccr.unfollow.js deleted file mode 100644 index 90402d5a4..000000000 --- a/api/api/ccr.unfollow.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildCcrUnfollow (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ccr.unfollow request - * Stops the following task associated with a follower index and removes index metadata and settings associated with cross-cluster replication. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-post-unfollow.html - */ - return function ccrUnfollow (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_ccr' + '/' + 'unfollow' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildCcrUnfollow diff --git a/api/api/clear_scroll.js b/api/api/clear_scroll.js index 4aa43e5b8..9f8f40e8e 100644 --- a/api/api/clear_scroll.js +++ b/api/api/clear_scroll.js @@ -22,76 +22,34 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildClearScroll (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function clearScrollApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, scrollId, scroll_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((scroll_id || scrollId) != null) { + if (method == null) method = 'DELETE' + path = '/' + '_search' + '/' + 'scroll' + '/' + encodeURIComponent(scroll_id || scrollId) + } else { + if (method == null) method = 'DELETE' + path = '/' + '_search' + '/' + 'scroll' } - /** - * Perform a clear_scroll request - * Explicitly clears the search context for a scroll. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/clear-scroll-api.html - */ - return function clearScroll (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, scrollId, scroll_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((scroll_id || scrollId) != null) { - if (method == null) method = 'DELETE' - path = '/' + '_search' + '/' + 'scroll' + '/' + encodeURIComponent(scroll_id || scrollId) - } else { - if (method == null) method = 'DELETE' - path = '/' + '_search' + '/' + 'scroll' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: body || '', + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildClearScroll +module.exports = clearScrollApi diff --git a/api/api/close_point_in_time.js b/api/api/close_point_in_time.js index 602c084ea..c66305b11 100644 --- a/api/api/close_point_in_time.js +++ b/api/api/close_point_in_time.js @@ -22,18 +22,29 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildClosePointInTime (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ +function closePointInTimeApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - ] + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - const snakeCase = { + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_pit' + // build request object + const request = { + method, + path, + body: body || '', + querystring } +<<<<<<< HEAD /** * Perform a close_point_in_time request * Close a point in time @@ -82,6 +93,9 @@ function buildClosePointInTime (opts) { options.warnings = warnings.length === 0 ? null : warnings return makeRequest(request, options, callback) } +======= + return this.transport.request(request, options, callback) +>>>>>>> a064f0f3... Improve child performances (#1314) } -module.exports = buildClosePointInTime +module.exports = closePointInTimeApi diff --git a/api/api/cluster.allocation_explain.js b/api/api/cluster.allocation_explain.js deleted file mode 100644 index d0d4b2fe5..000000000 --- a/api/api/cluster.allocation_explain.js +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildClusterAllocationExplain (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'include_yes_decisions', - 'include_disk_info', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - includeYesDecisions: 'include_yes_decisions', - includeDiskInfo: 'include_disk_info', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cluster.allocation_explain request - * Provides explanations for shard allocations in the cluster. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-allocation-explain.html - */ - return function clusterAllocationExplain (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_cluster' + '/' + 'allocation' + '/' + 'explain' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildClusterAllocationExplain diff --git a/api/api/cluster.delete_component_template.js b/api/api/cluster.delete_component_template.js deleted file mode 100644 index fe7dc4a72..000000000 --- a/api/api/cluster.delete_component_template.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildClusterDeleteComponentTemplate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cluster.delete_component_template request - * Deletes a component template - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html - */ - return function clusterDeleteComponentTemplate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_component_template' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildClusterDeleteComponentTemplate diff --git a/api/api/cluster.delete_voting_config_exclusions.js b/api/api/cluster.delete_voting_config_exclusions.js deleted file mode 100644 index 6ff5cdbd7..000000000 --- a/api/api/cluster.delete_voting_config_exclusions.js +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildClusterDeleteVotingConfigExclusions (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'wait_for_removal', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - waitForRemoval: 'wait_for_removal', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cluster.delete_voting_config_exclusions request - * Clears cluster voting config exclusions. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/voting-config-exclusions.html - */ - return function clusterDeleteVotingConfigExclusions (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_cluster' + '/' + 'voting_config_exclusions' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildClusterDeleteVotingConfigExclusions diff --git a/api/api/cluster.exists_component_template.js b/api/api/cluster.exists_component_template.js deleted file mode 100644 index 3ce4c5acc..000000000 --- a/api/api/cluster.exists_component_template.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildClusterExistsComponentTemplate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'master_timeout', - 'local', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cluster.exists_component_template request - * Returns information about whether a particular component template exist - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html - */ - return function clusterExistsComponentTemplate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'HEAD' - path = '/' + '_component_template' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildClusterExistsComponentTemplate diff --git a/api/api/cluster.get_component_template.js b/api/api/cluster.get_component_template.js deleted file mode 100644 index 038b64830..000000000 --- a/api/api/cluster.get_component_template.js +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildClusterGetComponentTemplate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'master_timeout', - 'local', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cluster.get_component_template request - * Returns one or more component templates - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html - */ - return function clusterGetComponentTemplate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((name) != null) { - if (method == null) method = 'GET' - path = '/' + '_component_template' + '/' + encodeURIComponent(name) - } else { - if (method == null) method = 'GET' - path = '/' + '_component_template' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildClusterGetComponentTemplate diff --git a/api/api/cluster.get_settings.js b/api/api/cluster.get_settings.js deleted file mode 100644 index a523606a4..000000000 --- a/api/api/cluster.get_settings.js +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildClusterGetSettings (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'flat_settings', - 'master_timeout', - 'timeout', - 'include_defaults', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - flatSettings: 'flat_settings', - masterTimeout: 'master_timeout', - includeDefaults: 'include_defaults', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cluster.get_settings request - * Returns cluster settings. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html - */ - return function clusterGetSettings (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_cluster' + '/' + 'settings' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildClusterGetSettings diff --git a/api/api/cluster.health.js b/api/api/cluster.health.js deleted file mode 100644 index 901b5823c..000000000 --- a/api/api/cluster.health.js +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildClusterHealth (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'expand_wildcards', - 'level', - 'local', - 'master_timeout', - 'timeout', - 'wait_for_active_shards', - 'wait_for_nodes', - 'wait_for_events', - 'wait_for_no_relocating_shards', - 'wait_for_no_initializing_shards', - 'wait_for_status', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - expandWildcards: 'expand_wildcards', - masterTimeout: 'master_timeout', - waitForActiveShards: 'wait_for_active_shards', - waitForNodes: 'wait_for_nodes', - waitForEvents: 'wait_for_events', - waitForNoRelocatingShards: 'wait_for_no_relocating_shards', - waitForNoInitializingShards: 'wait_for_no_initializing_shards', - waitForStatus: 'wait_for_status', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cluster.health request - * Returns basic information about the health of the cluster. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-health.html - */ - return function clusterHealth (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = 'GET' - path = '/' + '_cluster' + '/' + 'health' + '/' + encodeURIComponent(index) - } else { - if (method == null) method = 'GET' - path = '/' + '_cluster' + '/' + 'health' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildClusterHealth diff --git a/api/api/cluster.js b/api/api/cluster.js new file mode 100644 index 000000000..088a74fea --- /dev/null +++ b/api/api/cluster.js @@ -0,0 +1,420 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['include_yes_decisions', 'include_disk_info', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'timeout', 'master_timeout', 'wait_for_removal', 'local', 'flat_settings', 'include_defaults', 'expand_wildcards', 'level', 'wait_for_active_shards', 'wait_for_nodes', 'wait_for_events', 'wait_for_no_relocating_shards', 'wait_for_no_initializing_shards', 'wait_for_status', 'node_ids', 'node_names', 'create', 'dry_run', 'explain', 'retry_failed', 'metric', 'wait_for_metadata_version', 'wait_for_timeout', 'ignore_unavailable', 'allow_no_indices'] +const snakeCase = { includeYesDecisions: 'include_yes_decisions', includeDiskInfo: 'include_disk_info', errorTrace: 'error_trace', filterPath: 'filter_path', masterTimeout: 'master_timeout', waitForRemoval: 'wait_for_removal', flatSettings: 'flat_settings', includeDefaults: 'include_defaults', expandWildcards: 'expand_wildcards', waitForActiveShards: 'wait_for_active_shards', waitForNodes: 'wait_for_nodes', waitForEvents: 'wait_for_events', waitForNoRelocatingShards: 'wait_for_no_relocating_shards', waitForNoInitializingShards: 'wait_for_no_initializing_shards', waitForStatus: 'wait_for_status', nodeIds: 'node_ids', nodeNames: 'node_names', dryRun: 'dry_run', retryFailed: 'retry_failed', waitForMetadataVersion: 'wait_for_metadata_version', waitForTimeout: 'wait_for_timeout', ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices' } + +function ClusterApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +ClusterApi.prototype.allocationExplain = function clusterAllocationExplainApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_cluster' + '/' + 'allocation' + '/' + 'explain' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.deleteComponentTemplate = function clusterDeleteComponentTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_component_template' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.deleteVotingConfigExclusions = function clusterDeleteVotingConfigExclusionsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_cluster' + '/' + 'voting_config_exclusions' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.existsComponentTemplate = function clusterExistsComponentTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'HEAD' + path = '/' + '_component_template' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.getComponentTemplate = function clusterGetComponentTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_component_template' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_component_template' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.getSettings = function clusterGetSettingsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cluster' + '/' + 'settings' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.health = function clusterHealthApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + '_cluster' + '/' + 'health' + '/' + encodeURIComponent(index) + } else { + if (method == null) method = 'GET' + path = '/' + '_cluster' + '/' + 'health' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.pendingTasks = function clusterPendingTasksApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_cluster' + '/' + 'pending_tasks' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.postVotingConfigExclusions = function clusterPostVotingConfigExclusionsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_cluster' + '/' + 'voting_config_exclusions' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.putComponentTemplate = function clusterPutComponentTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_component_template' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.putSettings = function clusterPutSettingsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_cluster' + '/' + 'settings' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.remoteInfo = function clusterRemoteInfoApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_remote' + '/' + 'info' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.reroute = function clusterRerouteApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_cluster' + '/' + 'reroute' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.state = function clusterStateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required url components + if (params['index'] != null && (params['metric'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: metric') + return handleError(err, callback) + } + + var { method, body, metric, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((metric) != null && (index) != null) { + if (method == null) method = 'GET' + path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(metric) + '/' + encodeURIComponent(index) + } else if ((metric) != null) { + if (method == null) method = 'GET' + path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(metric) + } else { + if (method == null) method = 'GET' + path = '/' + '_cluster' + '/' + 'state' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +ClusterApi.prototype.stats = function clusterStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, nodeId, node_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((node_id || nodeId) != null) { + if (method == null) method = 'GET' + path = '/' + '_cluster' + '/' + 'stats' + '/' + 'nodes' + '/' + encodeURIComponent(node_id || nodeId) + } else { + if (method == null) method = 'GET' + path = '/' + '_cluster' + '/' + 'stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(ClusterApi.prototype, { + allocation_explain: { get () { return this.allocationExplain } }, + delete_component_template: { get () { return this.deleteComponentTemplate } }, + delete_voting_config_exclusions: { get () { return this.deleteVotingConfigExclusions } }, + exists_component_template: { get () { return this.existsComponentTemplate } }, + get_component_template: { get () { return this.getComponentTemplate } }, + get_settings: { get () { return this.getSettings } }, + pending_tasks: { get () { return this.pendingTasks } }, + post_voting_config_exclusions: { get () { return this.postVotingConfigExclusions } }, + put_component_template: { get () { return this.putComponentTemplate } }, + put_settings: { get () { return this.putSettings } }, + remote_info: { get () { return this.remoteInfo } } +}) + +module.exports = ClusterApi diff --git a/api/api/cluster.pending_tasks.js b/api/api/cluster.pending_tasks.js deleted file mode 100644 index 0fb4115d1..000000000 --- a/api/api/cluster.pending_tasks.js +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildClusterPendingTasks (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'local', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cluster.pending_tasks request - * Returns a list of any cluster-level changes (e.g. create index, update mapping, -allocate or fail shard) which have not yet been executed. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-pending.html - */ - return function clusterPendingTasks (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_cluster' + '/' + 'pending_tasks' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildClusterPendingTasks diff --git a/api/api/cluster.post_voting_config_exclusions.js b/api/api/cluster.post_voting_config_exclusions.js deleted file mode 100644 index 75561c180..000000000 --- a/api/api/cluster.post_voting_config_exclusions.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildClusterPostVotingConfigExclusions (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'node_ids', - 'node_names', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - nodeIds: 'node_ids', - nodeNames: 'node_names', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cluster.post_voting_config_exclusions request - * Updates the cluster voting config exclusions by node ids or node names. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/voting-config-exclusions.html - */ - return function clusterPostVotingConfigExclusions (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_cluster' + '/' + 'voting_config_exclusions' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildClusterPostVotingConfigExclusions diff --git a/api/api/cluster.put_component_template.js b/api/api/cluster.put_component_template.js deleted file mode 100644 index 4a1c59943..000000000 --- a/api/api/cluster.put_component_template.js +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildClusterPutComponentTemplate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'create', - 'timeout', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cluster.put_component_template request - * Creates or updates a component template - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-template.html - */ - return function clusterPutComponentTemplate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_component_template' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildClusterPutComponentTemplate diff --git a/api/api/cluster.put_settings.js b/api/api/cluster.put_settings.js deleted file mode 100644 index 77dc77195..000000000 --- a/api/api/cluster.put_settings.js +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildClusterPutSettings (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'flat_settings', - 'master_timeout', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - flatSettings: 'flat_settings', - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cluster.put_settings request - * Updates the cluster settings. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html - */ - return function clusterPutSettings (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_cluster' + '/' + 'settings' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildClusterPutSettings diff --git a/api/api/cluster.remote_info.js b/api/api/cluster.remote_info.js deleted file mode 100644 index 8432efbcf..000000000 --- a/api/api/cluster.remote_info.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildClusterRemoteInfo (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cluster.remote_info request - * Returns the information about configured remote clusters. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-remote-info.html - */ - return function clusterRemoteInfo (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_remote' + '/' + 'info' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildClusterRemoteInfo diff --git a/api/api/cluster.reroute.js b/api/api/cluster.reroute.js deleted file mode 100644 index 47072fffb..000000000 --- a/api/api/cluster.reroute.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildClusterReroute (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'dry_run', - 'explain', - 'retry_failed', - 'metric', - 'master_timeout', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - dryRun: 'dry_run', - retryFailed: 'retry_failed', - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cluster.reroute request - * Allows to manually change the allocation of individual shards in the cluster. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-reroute.html - */ - return function clusterReroute (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_cluster' + '/' + 'reroute' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildClusterReroute diff --git a/api/api/cluster.state.js b/api/api/cluster.state.js deleted file mode 100644 index 7c80d9f3f..000000000 --- a/api/api/cluster.state.js +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildClusterState (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'local', - 'master_timeout', - 'flat_settings', - 'wait_for_metadata_version', - 'wait_for_timeout', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - flatSettings: 'flat_settings', - waitForMetadataVersion: 'wait_for_metadata_version', - waitForTimeout: 'wait_for_timeout', - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cluster.state request - * Returns a comprehensive information about the state of the cluster. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-state.html - */ - return function clusterState (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required url components - if (params['index'] != null && (params['metric'] == null)) { - 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') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, metric, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((metric) != null && (index) != null) { - if (method == null) method = 'GET' - path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(metric) + '/' + encodeURIComponent(index) - } else if ((metric) != null) { - if (method == null) method = 'GET' - path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(metric) - } else { - if (method == null) method = 'GET' - path = '/' + '_cluster' + '/' + 'state' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildClusterState diff --git a/api/api/cluster.stats.js b/api/api/cluster.stats.js deleted file mode 100644 index 74106d85d..000000000 --- a/api/api/cluster.stats.js +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildClusterStats (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'flat_settings', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - flatSettings: 'flat_settings', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a cluster.stats request - * Returns high-level overview of cluster statistics. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-stats.html - */ - return function clusterStats (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, nodeId, node_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((node_id || nodeId) != null) { - if (method == null) method = 'GET' - path = '/' + '_cluster' + '/' + 'stats' + '/' + 'nodes' + '/' + encodeURIComponent(node_id || nodeId) - } else { - if (method == null) method = 'GET' - path = '/' + '_cluster' + '/' + 'stats' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildClusterStats diff --git a/api/api/count.js b/api/api/count.js index 8413e0240..c6a1f75b1 100644 --- a/api/api/count.js +++ b/api/api/count.js @@ -22,45 +22,26 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildCount (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['ignore_unavailable', 'ignore_throttled', 'allow_no_indices', 'expand_wildcards', 'min_score', 'preference', 'routing', 'q', 'analyzer', 'analyze_wildcard', 'default_operator', 'df', 'lenient', 'terminate_after', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { ignoreUnavailable: 'ignore_unavailable', ignoreThrottled: 'ignore_throttled', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', minScore: 'min_score', analyzeWildcard: 'analyze_wildcard', defaultOperator: 'default_operator', terminateAfter: 'terminate_after', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'ignore_unavailable', - 'ignore_throttled', - 'allow_no_indices', - 'expand_wildcards', - 'min_score', - 'preference', - 'routing', - 'q', - 'analyzer', - 'analyze_wildcard', - 'default_operator', - 'df', - 'lenient', - 'terminate_after', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function countApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - ignoreThrottled: 'ignore_throttled', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - minScore: 'min_score', - analyzeWildcard: 'analyze_wildcard', - defaultOperator: 'default_operator', - terminateAfter: 'terminate_after', - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_count' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_count' } +<<<<<<< HEAD /** * Perform a count request * Returns number of documents matching a query. @@ -122,7 +103,17 @@ function buildCount (opts) { options.warnings = warnings.length === 0 ? null : warnings return makeRequest(request, options, callback) +======= + // build request object + const request = { + method, + path, + body: body || '', + querystring +>>>>>>> a064f0f3... Improve child performances (#1314) } + + return this.transport.request(request, options, callback) } -module.exports = buildCount +module.exports = countApi diff --git a/api/api/create.js b/api/api/create.js index 0747a5791..5977dd0a4 100644 --- a/api/api/create.js +++ b/api/api/create.js @@ -22,101 +22,48 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildCreate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['wait_for_active_shards', 'refresh', 'routing', 'timeout', 'version', 'version_type', 'pipeline', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { waitForActiveShards: 'wait_for_active_shards', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'wait_for_active_shards', - 'refresh', - 'routing', - 'timeout', - 'version', - 'version_type', - 'pipeline', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function createApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - waitForActiveShards: 'wait_for_active_shards', - versionType: 'version_type', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) } - /** - * Perform a create request - * Creates a new document in the index. + var { method, body, id, index, type, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) -Returns a 409 response when a document with a same ID already exists in the index. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-index_.html - */ - return function create (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, index, type, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null && (type) != null && (id) != null) { - if (method == null) method = 'PUT' - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_create' - } else { - if (method == null) method = 'PUT' - path = '/' + encodeURIComponent(index) + '/' + '_create' + '/' + encodeURIComponent(id) - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + var path = '' + if ((index) != null && (type) != null && (id) != null) { + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_create' + } else { + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_create' + '/' + encodeURIComponent(id) } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildCreate +module.exports = createApi diff --git a/api/api/dangling_indices.delete_dangling_index.js b/api/api/dangling_indices.delete_dangling_index.js deleted file mode 100644 index d836f0ed1..000000000 --- a/api/api/dangling_indices.delete_dangling_index.js +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildDanglingIndicesDeleteDanglingIndex (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'accept_data_loss', - 'timeout', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - acceptDataLoss: 'accept_data_loss', - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a dangling_indices.delete_dangling_index request - * Deletes the specified dangling index - * https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-gateway-dangling-indices.html - */ - return function danglingIndicesDeleteDanglingIndex (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index_uuid'] == null && params['indexUuid'] == null) { - const err = new ConfigurationError('Missing required parameter: index_uuid or indexUuid') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, indexUuid, index_uuid, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_dangling' + '/' + encodeURIComponent(index_uuid || indexUuid) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildDanglingIndicesDeleteDanglingIndex diff --git a/api/api/dangling_indices.import_dangling_index.js b/api/api/dangling_indices.import_dangling_index.js deleted file mode 100644 index f60153af7..000000000 --- a/api/api/dangling_indices.import_dangling_index.js +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildDanglingIndicesImportDanglingIndex (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'accept_data_loss', - 'timeout', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - acceptDataLoss: 'accept_data_loss', - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a dangling_indices.import_dangling_index request - * Imports the specified dangling index - * https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-gateway-dangling-indices.html - */ - return function danglingIndicesImportDanglingIndex (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index_uuid'] == null && params['indexUuid'] == null) { - const err = new ConfigurationError('Missing required parameter: index_uuid or indexUuid') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, indexUuid, index_uuid, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_dangling' + '/' + encodeURIComponent(index_uuid || indexUuid) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildDanglingIndicesImportDanglingIndex diff --git a/api/api/dangling_indices.js b/api/api/dangling_indices.js new file mode 100644 index 000000000..b6475c69b --- /dev/null +++ b/api/api/dangling_indices.js @@ -0,0 +1,115 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['accept_data_loss', 'timeout', 'master_timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { acceptDataLoss: 'accept_data_loss', masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path' } + +function DanglingIndicesApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +DanglingIndicesApi.prototype.deleteDanglingIndex = function danglingIndicesDeleteDanglingIndexApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index_uuid'] == null && params['indexUuid'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index_uuid or indexUuid') + return handleError(err, callback) + } + + var { method, body, indexUuid, index_uuid, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_dangling' + '/' + encodeURIComponent(index_uuid || indexUuid) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +DanglingIndicesApi.prototype.importDanglingIndex = function danglingIndicesImportDanglingIndexApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index_uuid'] == null && params['indexUuid'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index_uuid or indexUuid') + return handleError(err, callback) + } + + var { method, body, indexUuid, index_uuid, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_dangling' + '/' + encodeURIComponent(index_uuid || indexUuid) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +DanglingIndicesApi.prototype.listDanglingIndices = function danglingIndicesListDanglingIndicesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_dangling' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(DanglingIndicesApi.prototype, { + delete_dangling_index: { get () { return this.deleteDanglingIndex } }, + import_dangling_index: { get () { return this.importDanglingIndex } }, + list_dangling_indices: { get () { return this.listDanglingIndices } } +}) + +module.exports = DanglingIndicesApi diff --git a/api/api/dangling_indices.list_dangling_indices.js b/api/api/dangling_indices.list_dangling_indices.js deleted file mode 100644 index c26b3628f..000000000 --- a/api/api/dangling_indices.list_dangling_indices.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildDanglingIndicesListDanglingIndices (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a dangling_indices.list_dangling_indices request - * Returns all dangling indices. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-gateway-dangling-indices.html - */ - return function danglingIndicesListDanglingIndices (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_dangling' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildDanglingIndicesListDanglingIndices diff --git a/api/api/delete.js b/api/api/delete.js index cbf5394bb..bcdb5fe5e 100644 --- a/api/api/delete.js +++ b/api/api/delete.js @@ -22,98 +22,44 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildDelete (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['wait_for_active_shards', 'refresh', 'routing', 'timeout', 'if_seq_no', 'if_primary_term', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { waitForActiveShards: 'wait_for_active_shards', ifSeqNo: 'if_seq_no', ifPrimaryTerm: 'if_primary_term', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'wait_for_active_shards', - 'refresh', - 'routing', - 'timeout', - 'if_seq_no', - 'if_primary_term', - 'version', - 'version_type', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function deleteApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - waitForActiveShards: 'wait_for_active_shards', - ifSeqNo: 'if_seq_no', - ifPrimaryTerm: 'if_primary_term', - versionType: 'version_type', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) } - /** - * Perform a delete request - * Removes a document from the index. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete.html - */ - return function _delete (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, id, index, type, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, index, type, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null && (type) != null && (id) != null) { - if (method == null) method = 'DELETE' - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) - } else { - if (method == null) method = 'DELETE' - path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id) - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + var path = '' + if ((index) != null && (type) != null && (id) != null) { + if (method == null) method = 'DELETE' + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + } else { + if (method == null) method = 'DELETE' + path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id) } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildDelete +module.exports = deleteApi diff --git a/api/api/delete_by_query.js b/api/api/delete_by_query.js index db5a12878..4fc588483 100644 --- a/api/api/delete_by_query.js +++ b/api/api/delete_by_query.js @@ -22,10 +22,11 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildDeleteByQuery (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['analyzer', 'analyze_wildcard', 'default_operator', 'df', 'from', 'ignore_unavailable', 'allow_no_indices', 'conflicts', 'expand_wildcards', 'lenient', 'preference', 'q', 'routing', 'scroll', 'search_type', 'search_timeout', 'max_docs', 'sort', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'terminate_after', 'stats', 'version', 'request_cache', 'refresh', 'timeout', 'wait_for_active_shards', 'scroll_size', 'wait_for_completion', 'requests_per_second', 'slices', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { analyzeWildcard: 'analyze_wildcard', defaultOperator: 'default_operator', ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', searchType: 'search_type', searchTimeout: 'search_timeout', maxDocs: 'max_docs', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', terminateAfter: 'terminate_after', requestCache: 'request_cache', waitForActiveShards: 'wait_for_active_shards', scrollSize: 'scroll_size', waitForCompletion: 'wait_for_completion', requestsPerSecond: 'requests_per_second', errorTrace: 'error_trace', filterPath: 'filter_path' } +<<<<<<< HEAD const acceptedQuerystring = [ 'analyzer', 'analyze_wildcard', @@ -145,18 +146,37 @@ function buildDeleteByQuery (opts) { if (method == null) method = 'POST' path = '/' + encodeURIComponent(index) + '/' + '_delete_by_query' } +======= +function deleteByQueryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +>>>>>>> a064f0f3... Improve child performances (#1314) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_delete_by_query' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildDeleteByQuery +module.exports = deleteByQueryApi diff --git a/api/api/delete_by_query_rethrottle.js b/api/api/delete_by_query_rethrottle.js index 47e60e5cd..6221bbb01 100644 --- a/api/api/delete_by_query_rethrottle.js +++ b/api/api/delete_by_query_rethrottle.js @@ -22,83 +22,39 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildDeleteByQueryRethrottle (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['requests_per_second', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { requestsPerSecond: 'requests_per_second', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'requests_per_second', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function deleteByQueryRethrottleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - requestsPerSecond: 'requests_per_second', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['task_id'] == null && params['taskId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: task_id or taskId') + return handleError(err, callback) + } + if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: requests_per_second or requestsPerSecond') + return handleError(err, callback) } - /** - * Perform a delete_by_query_rethrottle request - * Changes the number of requests per second for a particular Delete By Query operation. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html - */ - return function deleteByQueryRethrottle (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, taskId, task_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - // check required parameters - if (params['task_id'] == null && params['taskId'] == null) { - const err = new ConfigurationError('Missing required parameter: task_id or taskId') - return handleError(err, callback) - } - if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) { - const err = new ConfigurationError('Missing required parameter: requests_per_second or requestsPerSecond') - return handleError(err, callback) - } + var path = '' + if (method == null) method = 'POST' + path = '/' + '_delete_by_query' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_rethrottle' - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, taskId, task_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_delete_by_query' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_rethrottle' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: body || '', + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildDeleteByQueryRethrottle +module.exports = deleteByQueryRethrottleApi diff --git a/api/api/delete_script.js b/api/api/delete_script.js index b43a1ba9e..b583be6b8 100644 --- a/api/api/delete_script.js +++ b/api/api/delete_script.js @@ -22,80 +22,35 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildDeleteScript (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['timeout', 'master_timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function deleteScriptApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) } - /** - * Perform a delete_script request - * Deletes a script. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html - */ - return function deleteScript (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_scripts' + '/' + encodeURIComponent(id) - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_scripts' + '/' + encodeURIComponent(id) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: body || '', + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildDeleteScript +module.exports = deleteScriptApi diff --git a/api/api/enrich.delete_policy.js b/api/api/enrich.delete_policy.js deleted file mode 100644 index d86754473..000000000 --- a/api/api/enrich.delete_policy.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildEnrichDeletePolicy (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a enrich.delete_policy request - * Deletes an existing enrich policy and its enrich index. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-enrich-policy-api.html - */ - return function enrichDeletePolicy (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_enrich' + '/' + 'policy' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildEnrichDeletePolicy diff --git a/api/api/enrich.execute_policy.js b/api/api/enrich.execute_policy.js deleted file mode 100644 index eb0add6e8..000000000 --- a/api/api/enrich.execute_policy.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildEnrichExecutePolicy (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'wait_for_completion' - ] - - const snakeCase = { - waitForCompletion: 'wait_for_completion' - } - - /** - * Perform a enrich.execute_policy request - * Creates the enrich index for an existing enrich policy. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/execute-enrich-policy-api.html - */ - return function enrichExecutePolicy (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_enrich' + '/' + 'policy' + '/' + encodeURIComponent(name) + '/' + '_execute' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildEnrichExecutePolicy diff --git a/api/api/enrich.get_policy.js b/api/api/enrich.get_policy.js deleted file mode 100644 index 345957bf6..000000000 --- a/api/api/enrich.get_policy.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildEnrichGetPolicy (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a enrich.get_policy request - * Gets information about an enrich policy. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/get-enrich-policy-api.html - */ - return function enrichGetPolicy (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((name) != null) { - if (method == null) method = 'GET' - path = '/' + '_enrich' + '/' + 'policy' + '/' + encodeURIComponent(name) - } else { - if (method == null) method = 'GET' - path = '/' + '_enrich' + '/' + 'policy' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildEnrichGetPolicy diff --git a/api/api/enrich.js b/api/api/enrich.js new file mode 100644 index 000000000..780ee943d --- /dev/null +++ b/api/api/enrich.js @@ -0,0 +1,173 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path', 'wait_for_completion'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path', waitForCompletion: 'wait_for_completion' } + +function EnrichApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +EnrichApi.prototype.deletePolicy = function enrichDeletePolicyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_enrich' + '/' + 'policy' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +EnrichApi.prototype.executePolicy = function enrichExecutePolicyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_enrich' + '/' + 'policy' + '/' + encodeURIComponent(name) + '/' + '_execute' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +EnrichApi.prototype.getPolicy = function enrichGetPolicyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_enrich' + '/' + 'policy' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_enrich' + '/' + 'policy' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +EnrichApi.prototype.putPolicy = function enrichPutPolicyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_enrich' + '/' + 'policy' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +EnrichApi.prototype.stats = function enrichStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_enrich' + '/' + '_stats' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(EnrichApi.prototype, { + delete_policy: { get () { return this.deletePolicy } }, + execute_policy: { get () { return this.executePolicy } }, + get_policy: { get () { return this.getPolicy } }, + put_policy: { get () { return this.putPolicy } } +}) + +module.exports = EnrichApi diff --git a/api/api/enrich.put_policy.js b/api/api/enrich.put_policy.js deleted file mode 100644 index f4e92f9e1..000000000 --- a/api/api/enrich.put_policy.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildEnrichPutPolicy (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a enrich.put_policy request - * Creates a new enrich policy. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/put-enrich-policy-api.html - */ - return function enrichPutPolicy (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_enrich' + '/' + 'policy' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildEnrichPutPolicy diff --git a/api/api/enrich.stats.js b/api/api/enrich.stats.js deleted file mode 100644 index 77f43ca43..000000000 --- a/api/api/enrich.stats.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildEnrichStats (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a enrich.stats request - * Gets enrich coordinator statistics and information about enrich policies that are currently executing. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-stats-api.html - */ - return function enrichStats (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_enrich' + '/' + '_stats' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildEnrichStats diff --git a/api/api/eql.delete.js b/api/api/eql.delete.js deleted file mode 100644 index b4dc508b5..000000000 --- a/api/api/eql.delete.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildEqlDelete (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a eql.delete request - * Deletes an async EQL search by ID. If the search is still running, the search request will be cancelled. Otherwise, the saved search results are deleted. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html - */ - return function eqlDelete (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_eql' + '/' + 'search' + '/' + encodeURIComponent(id) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildEqlDelete diff --git a/api/api/eql.get.js b/api/api/eql.get.js deleted file mode 100644 index 65e97dbe8..000000000 --- a/api/api/eql.get.js +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildEqlGet (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'wait_for_completion_timeout', - 'keep_alive' - ] - - const snakeCase = { - waitForCompletionTimeout: 'wait_for_completion_timeout', - keepAlive: 'keep_alive' - } - - /** - * Perform a eql.get request - * Returns async results from previously executed Event Query Language (EQL) search - * https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html - */ - return function eqlGet (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_eql' + '/' + 'search' + '/' + encodeURIComponent(id) - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildEqlGet diff --git a/api/api/eql.js b/api/api/eql.js new file mode 100644 index 000000000..3813a5aff --- /dev/null +++ b/api/api/eql.js @@ -0,0 +1,119 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path', 'wait_for_completion_timeout', 'keep_alive', 'keep_on_completion'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path', waitForCompletionTimeout: 'wait_for_completion_timeout', keepAlive: 'keep_alive', keepOnCompletion: 'keep_on_completion' } + +function EqlApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +EqlApi.prototype.delete = function eqlDeleteApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_eql' + '/' + 'search' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +EqlApi.prototype.get = function eqlGetApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_eql' + '/' + 'search' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +EqlApi.prototype.search = function eqlSearchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_eql' + '/' + 'search' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +module.exports = EqlApi diff --git a/api/api/eql.search.js b/api/api/eql.search.js deleted file mode 100644 index 007a08612..000000000 --- a/api/api/eql.search.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildEqlSearch (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'wait_for_completion_timeout', - 'keep_on_completion', - 'keep_alive' - ] - - const snakeCase = { - waitForCompletionTimeout: 'wait_for_completion_timeout', - keepOnCompletion: 'keep_on_completion', - keepAlive: 'keep_alive' - } - - /** - * Perform a eql.search request - * Returns results matching a query expressed in Event Query Language (EQL) - * https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html - */ - return function eqlSearch (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_eql' + '/' + 'search' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildEqlSearch diff --git a/api/api/exists.js b/api/api/exists.js index 79768379e..5963b6997 100644 --- a/api/api/exists.js +++ b/api/api/exists.js @@ -22,10 +22,11 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildExists (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['stored_fields', 'preference', 'realtime', 'refresh', 'routing', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { storedFields: 'stored_fields', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' } +<<<<<<< HEAD const acceptedQuerystring = [ 'stored_fields', 'preference', @@ -104,18 +105,37 @@ function buildExists (opts) { if (method == null) method = 'HEAD' path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id) } +======= +function existsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) } + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, id, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +>>>>>>> a064f0f3... Improve child performances (#1314) + + var path = '' + if (method == null) method = 'HEAD' + path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildExists +module.exports = existsApi diff --git a/api/api/exists_source.js b/api/api/exists_source.js index a70e0c20a..6b03b96ef 100644 --- a/api/api/exists_source.js +++ b/api/api/exists_source.js @@ -22,10 +22,11 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildExistsSource (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['preference', 'realtime', 'refresh', 'routing', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' } +<<<<<<< HEAD const acceptedQuerystring = [ 'preference', 'realtime', @@ -49,80 +50,51 @@ function buildExistsSource (opts) { versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' +======= +function existsSourceApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) +>>>>>>> a064f0f3... Improve child performances (#1314) } - /** - * Perform a exists_source request - * Returns information about whether a document source exists in an index. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-get.html - */ - return function existsSource (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - - // check required url components - if (params['id'] != null && (params['type'] == null || params['index'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: type, index') - return handleError(err, callback) - } else if (params['type'] != null && (params['index'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, index, type, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null && (type) != null && (id) != null) { - if (method == null) method = 'HEAD' - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source' - } else { - if (method == null) method = 'HEAD' - path = '/' + encodeURIComponent(index) + '/' + '_source' + '/' + encodeURIComponent(id) - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // check required url components + if (params['id'] != null && (params['type'] == null || params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: type, index') + return handleError(err, callback) + } else if (params['type'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) } + + var { method, body, id, index, type, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (type) != null && (id) != null) { + if (method == null) method = 'HEAD' + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_source' + } else { + if (method == null) method = 'HEAD' + path = '/' + encodeURIComponent(index) + '/' + '_source' + '/' + encodeURIComponent(id) + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildExistsSource +module.exports = existsSourceApi diff --git a/api/api/explain.js b/api/api/explain.js index 25882744b..95ddcd7b9 100644 --- a/api/api/explain.js +++ b/api/api/explain.js @@ -22,10 +22,11 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildExplain (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['analyze_wildcard', 'analyzer', 'default_operator', 'df', 'stored_fields', 'lenient', 'preference', 'q', 'routing', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { analyzeWildcard: 'analyze_wildcard', defaultOperator: 'default_operator', storedFields: 'stored_fields', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', errorTrace: 'error_trace', filterPath: 'filter_path' } +<<<<<<< HEAD const acceptedQuerystring = [ 'analyze_wildcard', 'analyzer', @@ -107,18 +108,37 @@ function buildExplain (opts) { if (method == null) method = body == null ? 'GET' : 'POST' path = '/' + encodeURIComponent(index) + '/' + '_explain' + '/' + encodeURIComponent(id) } +======= +function explainApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) } + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, id, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +>>>>>>> a064f0f3... Improve child performances (#1314) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_explain' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildExplain +module.exports = explainApi diff --git a/api/api/field_caps.js b/api/api/field_caps.js index 53bc6b673..fdc2f316c 100644 --- a/api/api/field_caps.js +++ b/api/api/field_caps.js @@ -22,85 +22,34 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildFieldCaps (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['fields', 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', 'include_unmapped', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', includeUnmapped: 'include_unmapped', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'fields', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'include_unmapped', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function fieldCapsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - includeUnmapped: 'include_unmapped', - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_field_caps' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_field_caps' } - /** - * Perform a field_caps request - * Returns the information about the capabilities of fields among multiple indices. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/search-field-caps.html - */ - return function fieldCaps (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_field_caps' - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_field_caps' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: body || '', + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildFieldCaps +module.exports = fieldCapsApi diff --git a/api/api/get.js b/api/api/get.js index 980cd34a4..3535febd3 100644 --- a/api/api/get.js +++ b/api/api/get.js @@ -22,10 +22,11 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildGet (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['stored_fields', 'preference', 'realtime', 'refresh', 'routing', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { storedFields: 'stored_fields', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' } +<<<<<<< HEAD const acceptedQuerystring = [ 'stored_fields', 'preference', @@ -104,18 +105,37 @@ function buildGet (opts) { if (method == null) method = 'GET' path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id) } +======= +function getApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) } + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, id, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +>>>>>>> a064f0f3... Improve child performances (#1314) + + var path = '' + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildGet +module.exports = getApi diff --git a/api/api/get_script.js b/api/api/get_script.js index 363d5799e..0409e82fe 100644 --- a/api/api/get_script.js +++ b/api/api/get_script.js @@ -22,79 +22,35 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildGetScript (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['master_timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function getScriptApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) } - /** - * Perform a get_script request - * Returns a script. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html - */ - return function getScript (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } + var path = '' + if (method == null) method = 'GET' + path = '/' + '_scripts' + '/' + encodeURIComponent(id) - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_scripts' + '/' + encodeURIComponent(id) - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: null, + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildGetScript +module.exports = getScriptApi diff --git a/api/api/get_script_context.js b/api/api/get_script_context.js index c2a9df2f4..7c770f2d1 100644 --- a/api/api/get_script_context.js +++ b/api/api/get_script_context.js @@ -22,71 +22,29 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildGetScriptContext (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function getScriptContextApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_script_context' + + // build request object + const request = { + method, + path, + body: null, + querystring } - /** - * Perform a get_script_context request - * Returns all script contexts. - * https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-contexts.html - */ - return function getScriptContext (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_script_context' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } + return this.transport.request(request, options, callback) } -module.exports = buildGetScriptContext +module.exports = getScriptContextApi diff --git a/api/api/get_script_languages.js b/api/api/get_script_languages.js index f734d358f..455a1ca45 100644 --- a/api/api/get_script_languages.js +++ b/api/api/get_script_languages.js @@ -22,71 +22,29 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildGetScriptLanguages (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function getScriptLanguagesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_script_language' + + // build request object + const request = { + method, + path, + body: null, + querystring } - /** - * Perform a get_script_languages request - * Returns available script types, languages and contexts - * https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html - */ - return function getScriptLanguages (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_script_language' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } + return this.transport.request(request, options, callback) } -module.exports = buildGetScriptLanguages +module.exports = getScriptLanguagesApi diff --git a/api/api/get_source.js b/api/api/get_source.js index 5661c4502..32ab264bd 100644 --- a/api/api/get_source.js +++ b/api/api/get_source.js @@ -22,10 +22,11 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildGetSource (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['preference', 'realtime', 'refresh', 'routing', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' } +<<<<<<< HEAD const acceptedQuerystring = [ 'preference', 'realtime', @@ -102,18 +103,37 @@ function buildGetSource (opts) { if (method == null) method = 'GET' path = '/' + encodeURIComponent(index) + '/' + '_source' + '/' + encodeURIComponent(id) } +======= +function getSourceApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) } + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, id, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +>>>>>>> a064f0f3... Improve child performances (#1314) + + var path = '' + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_source' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildGetSource +module.exports = getSourceApi diff --git a/api/api/graph.js b/api/api/graph.js new file mode 100644 index 000000000..bfbd967cc --- /dev/null +++ b/api/api/graph.js @@ -0,0 +1,61 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['routing', 'timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } + +function GraphApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +GraphApi.prototype.explore = function graphExploreApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_graph' + '/' + 'explore' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +module.exports = GraphApi diff --git a/api/api/ilm.delete_lifecycle.js b/api/api/ilm.delete_lifecycle.js deleted file mode 100644 index c23004d7e..000000000 --- a/api/api/ilm.delete_lifecycle.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIlmDeleteLifecycle (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ilm.delete_lifecycle request - * Deletes the specified lifecycle policy definition. A currently used policy cannot be deleted. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-delete-lifecycle.html - */ - return function ilmDeleteLifecycle (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['policy'] == null) { - const err = new ConfigurationError('Missing required parameter: policy') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, policy, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(policy) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIlmDeleteLifecycle diff --git a/api/api/ilm.explain_lifecycle.js b/api/api/ilm.explain_lifecycle.js deleted file mode 100644 index e8b7b144f..000000000 --- a/api/api/ilm.explain_lifecycle.js +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIlmExplainLifecycle (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'only_managed', - 'only_errors' - ] - - const snakeCase = { - onlyManaged: 'only_managed', - onlyErrors: 'only_errors' - } - - /** - * Perform a ilm.explain_lifecycle request - * Retrieves information about the index's current lifecycle state, such as the currently executing phase, action, and step. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-explain-lifecycle.html - */ - return function ilmExplainLifecycle (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + encodeURIComponent(index) + '/' + '_ilm' + '/' + 'explain' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIlmExplainLifecycle diff --git a/api/api/ilm.get_lifecycle.js b/api/api/ilm.get_lifecycle.js deleted file mode 100644 index 85e124264..000000000 --- a/api/api/ilm.get_lifecycle.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIlmGetLifecycle (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ilm.get_lifecycle request - * Returns the specified policy definition. Includes the policy version and last modified date. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-lifecycle.html - */ - return function ilmGetLifecycle (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, policy, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((policy) != null) { - if (method == null) method = 'GET' - path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(policy) - } else { - if (method == null) method = 'GET' - path = '/' + '_ilm' + '/' + 'policy' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIlmGetLifecycle diff --git a/api/api/ilm.get_status.js b/api/api/ilm.get_status.js deleted file mode 100644 index fdc33cebd..000000000 --- a/api/api/ilm.get_status.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIlmGetStatus (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ilm.get_status request - * Retrieves the current index lifecycle management (ILM) status. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-status.html - */ - return function ilmGetStatus (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_ilm' + '/' + 'status' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIlmGetStatus diff --git a/api/api/ilm.js b/api/api/ilm.js new file mode 100644 index 000000000..55c138c00 --- /dev/null +++ b/api/api/ilm.js @@ -0,0 +1,295 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path', 'only_managed', 'only_errors'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path', onlyManaged: 'only_managed', onlyErrors: 'only_errors' } + +function IlmApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +IlmApi.prototype.deleteLifecycle = function ilmDeleteLifecycleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['policy'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: policy') + return handleError(err, callback) + } + + var { method, body, policy, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(policy) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IlmApi.prototype.explainLifecycle = function ilmExplainLifecycleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_ilm' + '/' + 'explain' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IlmApi.prototype.getLifecycle = function ilmGetLifecycleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, policy, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((policy) != null) { + if (method == null) method = 'GET' + path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(policy) + } else { + if (method == null) method = 'GET' + path = '/' + '_ilm' + '/' + 'policy' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IlmApi.prototype.getStatus = function ilmGetStatusApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_ilm' + '/' + 'status' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IlmApi.prototype.moveToStep = function ilmMoveToStepApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ilm' + '/' + 'move' + '/' + encodeURIComponent(index) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IlmApi.prototype.putLifecycle = function ilmPutLifecycleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['policy'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: policy') + return handleError(err, callback) + } + + var { method, body, policy, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(policy) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IlmApi.prototype.removePolicy = function ilmRemovePolicyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_ilm' + '/' + 'remove' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IlmApi.prototype.retry = function ilmRetryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_ilm' + '/' + 'retry' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IlmApi.prototype.start = function ilmStartApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ilm' + '/' + 'start' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IlmApi.prototype.stop = function ilmStopApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ilm' + '/' + 'stop' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(IlmApi.prototype, { + delete_lifecycle: { get () { return this.deleteLifecycle } }, + explain_lifecycle: { get () { return this.explainLifecycle } }, + get_lifecycle: { get () { return this.getLifecycle } }, + get_status: { get () { return this.getStatus } }, + move_to_step: { get () { return this.moveToStep } }, + put_lifecycle: { get () { return this.putLifecycle } }, + remove_policy: { get () { return this.removePolicy } } +}) + +module.exports = IlmApi diff --git a/api/api/ilm.move_to_step.js b/api/api/ilm.move_to_step.js deleted file mode 100644 index 946d2bae9..000000000 --- a/api/api/ilm.move_to_step.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIlmMoveToStep (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ilm.move_to_step request - * Manually moves an index into the specified step and executes that step. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-move-to-step.html - */ - return function ilmMoveToStep (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ilm' + '/' + 'move' + '/' + encodeURIComponent(index) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIlmMoveToStep diff --git a/api/api/ilm.put_lifecycle.js b/api/api/ilm.put_lifecycle.js deleted file mode 100644 index e3885c69f..000000000 --- a/api/api/ilm.put_lifecycle.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIlmPutLifecycle (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ilm.put_lifecycle request - * Creates a lifecycle policy - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-put-lifecycle.html - */ - return function ilmPutLifecycle (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['policy'] == null) { - const err = new ConfigurationError('Missing required parameter: policy') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, policy, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(policy) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIlmPutLifecycle diff --git a/api/api/ilm.remove_policy.js b/api/api/ilm.remove_policy.js deleted file mode 100644 index c6696d588..000000000 --- a/api/api/ilm.remove_policy.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIlmRemovePolicy (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ilm.remove_policy request - * Removes the assigned lifecycle policy and stops managing the specified index - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-remove-policy.html - */ - return function ilmRemovePolicy (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_ilm' + '/' + 'remove' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIlmRemovePolicy diff --git a/api/api/ilm.retry.js b/api/api/ilm.retry.js deleted file mode 100644 index 76f4b9914..000000000 --- a/api/api/ilm.retry.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIlmRetry (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ilm.retry request - * Retries executing the policy for an index that is in the ERROR step. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-retry-policy.html - */ - return function ilmRetry (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_ilm' + '/' + 'retry' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIlmRetry diff --git a/api/api/ilm.start.js b/api/api/ilm.start.js deleted file mode 100644 index 4fec9bc97..000000000 --- a/api/api/ilm.start.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIlmStart (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ilm.start request - * Start the index lifecycle management (ILM) plugin. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-start.html - */ - return function ilmStart (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ilm' + '/' + 'start' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIlmStart diff --git a/api/api/ilm.stop.js b/api/api/ilm.stop.js deleted file mode 100644 index 734725e8a..000000000 --- a/api/api/ilm.stop.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIlmStop (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ilm.stop request - * Halts all lifecycle management operations and stops the index lifecycle management (ILM) plugin - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-stop.html - */ - return function ilmStop (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ilm' + '/' + 'stop' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIlmStop diff --git a/api/api/index.js b/api/api/index.js index 8daec8383..e93a7c559 100644 --- a/api/api/index.js +++ b/api/api/index.js @@ -22,40 +22,24 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildIndex (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['wait_for_active_shards', 'op_type', 'refresh', 'routing', 'timeout', 'version', 'version_type', 'if_seq_no', 'if_primary_term', 'pipeline', 'require_alias', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { waitForActiveShards: 'wait_for_active_shards', opType: 'op_type', versionType: 'version_type', ifSeqNo: 'if_seq_no', ifPrimaryTerm: 'if_primary_term', requireAlias: 'require_alias', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'wait_for_active_shards', - 'op_type', - 'refresh', - 'routing', - 'timeout', - 'version', - 'version_type', - 'if_seq_no', - 'if_primary_term', - 'pipeline', - 'require_alias', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function indexApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - waitForActiveShards: 'wait_for_active_shards', - opType: 'op_type', - versionType: 'version_type', - ifSeqNo: 'if_seq_no', - ifPrimaryTerm: 'if_primary_term', - requireAlias: 'require_alias', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) } +<<<<<<< HEAD /** * Perform a index request * Creates or updates a document in an index. @@ -113,18 +97,29 @@ function buildIndex (opts) { if (method == null) method = 'POST' path = '/' + encodeURIComponent(index) + '/' + '_doc' } +======= + var { method, body, id, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +>>>>>>> a064f0f3... Improve child performances (#1314) - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + var path = '' + if ((index) != null && (id) != null) { + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_doc' + '/' + encodeURIComponent(id) + } else { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_doc' } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildIndex +module.exports = indexApi diff --git a/api/api/indices.add_block.js b/api/api/indices.add_block.js deleted file mode 100644 index 2adea3b83..000000000 --- a/api/api/indices.add_block.js +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesAddBlock (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.add_block request - * Adds a block to an index. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/index-modules-blocks.html - */ - return function indicesAddBlock (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - if (params['block'] == null) { - const err = new ConfigurationError('Missing required parameter: block') - return handleError(err, callback) - } - - // check required url components - if (params['block'] != null && (params['index'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, block, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + encodeURIComponent(index) + '/' + '_block' + '/' + encodeURIComponent(block) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesAddBlock diff --git a/api/api/indices.analyze.js b/api/api/indices.analyze.js deleted file mode 100644 index 63e0a71ed..000000000 --- a/api/api/indices.analyze.js +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesAnalyze (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'index', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.analyze request - * Performs the analysis process on a text and return the tokens breakdown of the text. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-analyze.html - */ - return function indicesAnalyze (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_analyze' - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_analyze' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesAnalyze diff --git a/api/api/indices.clear_cache.js b/api/api/indices.clear_cache.js deleted file mode 100644 index e43b81303..000000000 --- a/api/api/indices.clear_cache.js +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesClearCache (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'fielddata', - 'fields', - 'query', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'index', - 'request', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.clear_cache request - * Clears all or specific caches for one or more indices. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clearcache.html - */ - return function indicesClearCache (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_cache' + '/' + 'clear' - } else { - if (method == null) method = 'POST' - path = '/' + '_cache' + '/' + 'clear' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesClearCache diff --git a/api/api/indices.clone.js b/api/api/indices.clone.js deleted file mode 100644 index f8c4ba04f..000000000 --- a/api/api/indices.clone.js +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesClone (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'wait_for_active_shards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - waitForActiveShards: 'wait_for_active_shards', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.clone request - * Clones an index - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clone-index.html - */ - return function indicesClone (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - if (params['target'] == null) { - const err = new ConfigurationError('Missing required parameter: target') - return handleError(err, callback) - } - - // check required url components - if (params['target'] != null && (params['index'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, target, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + encodeURIComponent(index) + '/' + '_clone' + '/' + encodeURIComponent(target) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesClone diff --git a/api/api/indices.close.js b/api/api/indices.close.js deleted file mode 100644 index 0c08d65fa..000000000 --- a/api/api/indices.close.js +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesClose (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'wait_for_active_shards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - waitForActiveShards: 'wait_for_active_shards', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.close request - * Closes an index. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html - */ - return function indicesClose (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_close' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesClose diff --git a/api/api/indices.create_data_stream.js b/api/api/indices.create_data_stream.js deleted file mode 100644 index c83938c27..000000000 --- a/api/api/indices.create_data_stream.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesCreateDataStream (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a indices.create_data_stream request - * Creates a data stream - * https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html - */ - return function indicesCreateDataStream (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_data_stream' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesCreateDataStream diff --git a/api/api/indices.data_streams_stats.js b/api/api/indices.data_streams_stats.js deleted file mode 100644 index 364312829..000000000 --- a/api/api/indices.data_streams_stats.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesDataStreamsStats (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a indices.data_streams_stats request - * Provides statistics on operations happening in a data stream. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html - */ - return function indicesDataStreamsStats (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((name) != null) { - if (method == null) method = 'GET' - path = '/' + '_data_stream' + '/' + encodeURIComponent(name) + '/' + '_stats' - } else { - if (method == null) method = 'GET' - path = '/' + '_data_stream' + '/' + '_stats' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesDataStreamsStats diff --git a/api/api/indices.delete.js b/api/api/indices.delete.js deleted file mode 100644 index 6447b3c7f..000000000 --- a/api/api/indices.delete.js +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesDelete (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.delete request - * Deletes an index. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-delete-index.html - */ - return function indicesDelete (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + encodeURIComponent(index) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesDelete diff --git a/api/api/indices.delete_alias.js b/api/api/indices.delete_alias.js deleted file mode 100644 index 2a3bbe34f..000000000 --- a/api/api/indices.delete_alias.js +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesDeleteAlias (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.delete_alias request - * Deletes an alias. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html - */ - return function indicesDeleteAlias (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // check required url components - if (params['name'] != null && (params['index'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null && (name) != null) { - if (method == null) method = 'DELETE' - path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name) - } else { - if (method == null) method = 'DELETE' - path = '/' + encodeURIComponent(index) + '/' + '_aliases' + '/' + encodeURIComponent(name) - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesDeleteAlias diff --git a/api/api/indices.delete_data_stream.js b/api/api/indices.delete_data_stream.js deleted file mode 100644 index 1910544b6..000000000 --- a/api/api/indices.delete_data_stream.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesDeleteDataStream (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a indices.delete_data_stream request - * Deletes a data stream. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html - */ - return function indicesDeleteDataStream (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_data_stream' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesDeleteDataStream diff --git a/api/api/indices.delete_index_template.js b/api/api/indices.delete_index_template.js deleted file mode 100644 index a07bf8365..000000000 --- a/api/api/indices.delete_index_template.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesDeleteIndexTemplate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.delete_index_template request - * Deletes an index template. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html - */ - return function indicesDeleteIndexTemplate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_index_template' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesDeleteIndexTemplate diff --git a/api/api/indices.delete_template.js b/api/api/indices.delete_template.js deleted file mode 100644 index aa8976e0f..000000000 --- a/api/api/indices.delete_template.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesDeleteTemplate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.delete_template request - * Deletes an index template. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html - */ - return function indicesDeleteTemplate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_template' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesDeleteTemplate diff --git a/api/api/indices.exists.js b/api/api/indices.exists.js deleted file mode 100644 index 2f4826d3e..000000000 --- a/api/api/indices.exists.js +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesExists (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'local', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'flat_settings', - 'include_defaults', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - flatSettings: 'flat_settings', - includeDefaults: 'include_defaults', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.exists request - * Returns information about whether a particular index exists. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-exists.html - */ - return function indicesExists (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'HEAD' - path = '/' + encodeURIComponent(index) - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesExists diff --git a/api/api/indices.exists_alias.js b/api/api/indices.exists_alias.js deleted file mode 100644 index a10e91168..000000000 --- a/api/api/indices.exists_alias.js +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesExistsAlias (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'local', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.exists_alias request - * Returns information about whether a particular alias exists. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html - */ - return function indicesExistsAlias (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null && (name) != null) { - if (method == null) method = 'HEAD' - path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name) - } else { - if (method == null) method = 'HEAD' - path = '/' + '_alias' + '/' + encodeURIComponent(name) - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesExistsAlias diff --git a/api/api/indices.exists_index_template.js b/api/api/indices.exists_index_template.js deleted file mode 100644 index 97b474ab3..000000000 --- a/api/api/indices.exists_index_template.js +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesExistsIndexTemplate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'flat_settings', - 'master_timeout', - 'local', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - flatSettings: 'flat_settings', - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.exists_index_template request - * Returns information about whether a particular index template exists. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html - */ - return function indicesExistsIndexTemplate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'HEAD' - path = '/' + '_index_template' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesExistsIndexTemplate diff --git a/api/api/indices.exists_template.js b/api/api/indices.exists_template.js deleted file mode 100644 index beea46706..000000000 --- a/api/api/indices.exists_template.js +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesExistsTemplate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'flat_settings', - 'master_timeout', - 'local', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - flatSettings: 'flat_settings', - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.exists_template request - * Returns information about whether a particular index template exists. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html - */ - return function indicesExistsTemplate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'HEAD' - path = '/' + '_template' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesExistsTemplate diff --git a/api/api/indices.exists_type.js b/api/api/indices.exists_type.js deleted file mode 100644 index 6cadd760c..000000000 --- a/api/api/indices.exists_type.js +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesExistsType (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'local', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.exists_type request - * Returns information about whether a particular document type exists. (DEPRECATED) - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-types-exists.html - */ - return function indicesExistsType (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - if (params['type'] == null) { - const err = new ConfigurationError('Missing required parameter: type') - return handleError(err, callback) - } - - // check required url components - if (params['type'] != null && (params['index'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, type, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'HEAD' - path = '/' + encodeURIComponent(index) + '/' + '_mapping' + '/' + encodeURIComponent(type) - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesExistsType diff --git a/api/api/indices.flush.js b/api/api/indices.flush.js deleted file mode 100644 index dc8ff30d3..000000000 --- a/api/api/indices.flush.js +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesFlush (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'force', - 'wait_if_ongoing', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - waitIfOngoing: 'wait_if_ongoing', - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.flush request - * Performs the flush operation on one or more indices. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-flush.html - */ - return function indicesFlush (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_flush' - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_flush' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesFlush diff --git a/api/api/indices.forcemerge.js b/api/api/indices.forcemerge.js deleted file mode 100644 index d45820017..000000000 --- a/api/api/indices.forcemerge.js +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesForcemerge (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'flush', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'max_num_segments', - 'only_expunge_deletes', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - maxNumSegments: 'max_num_segments', - onlyExpungeDeletes: 'only_expunge_deletes', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.forcemerge request - * Performs the force merge operation on one or more indices. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-forcemerge.html - */ - return function indicesForcemerge (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_forcemerge' - } else { - if (method == null) method = 'POST' - path = '/' + '_forcemerge' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesForcemerge diff --git a/api/api/indices.freeze.js b/api/api/indices.freeze.js deleted file mode 100644 index d20f5e46e..000000000 --- a/api/api/indices.freeze.js +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesFreeze (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'wait_for_active_shards' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - waitForActiveShards: 'wait_for_active_shards' - } - - /** - * Perform a indices.freeze request - * Freezes an index. A frozen index has almost no overhead on the cluster (except for maintaining its metadata in memory) and is read-only. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/freeze-index-api.html - */ - return function indicesFreeze (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_freeze' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesFreeze diff --git a/api/api/indices.get_alias.js b/api/api/indices.get_alias.js deleted file mode 100644 index e0ac9495c..000000000 --- a/api/api/indices.get_alias.js +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesGetAlias (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'local', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.get_alias request - * Returns an alias. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html - */ - return function indicesGetAlias (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null && (name) != null) { - if (method == null) method = 'GET' - path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name) - } else if ((name) != null) { - if (method == null) method = 'GET' - path = '/' + '_alias' + '/' + encodeURIComponent(name) - } else if ((index) != null) { - if (method == null) method = 'GET' - path = '/' + encodeURIComponent(index) + '/' + '_alias' - } else { - if (method == null) method = 'GET' - path = '/' + '_alias' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesGetAlias diff --git a/api/api/indices.get_data_stream.js b/api/api/indices.get_data_stream.js deleted file mode 100644 index dc10d2b4b..000000000 --- a/api/api/indices.get_data_stream.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesGetDataStream (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a indices.get_data_stream request - * Returns data streams. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html - */ - return function indicesGetDataStream (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((name) != null) { - if (method == null) method = 'GET' - path = '/' + '_data_stream' + '/' + encodeURIComponent(name) - } else { - if (method == null) method = 'GET' - path = '/' + '_data_stream' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesGetDataStream diff --git a/api/api/indices.get_index_template.js b/api/api/indices.get_index_template.js deleted file mode 100644 index a315ec3b9..000000000 --- a/api/api/indices.get_index_template.js +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesGetIndexTemplate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'flat_settings', - 'master_timeout', - 'local', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - flatSettings: 'flat_settings', - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.get_index_template request - * Returns an index template. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html - */ - return function indicesGetIndexTemplate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((name) != null) { - if (method == null) method = 'GET' - path = '/' + '_index_template' + '/' + encodeURIComponent(name) - } else { - if (method == null) method = 'GET' - path = '/' + '_index_template' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesGetIndexTemplate diff --git a/api/api/indices.get_settings.js b/api/api/indices.get_settings.js deleted file mode 100644 index e63433c66..000000000 --- a/api/api/indices.get_settings.js +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesGetSettings (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'master_timeout', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'flat_settings', - 'local', - 'include_defaults', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - flatSettings: 'flat_settings', - includeDefaults: 'include_defaults', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.get_settings request - * Returns settings for one or more indices. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-get-settings.html - */ - return function indicesGetSettings (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null && (name) != null) { - if (method == null) method = 'GET' - path = '/' + encodeURIComponent(index) + '/' + '_settings' + '/' + encodeURIComponent(name) - } else if ((index) != null) { - if (method == null) method = 'GET' - path = '/' + encodeURIComponent(index) + '/' + '_settings' - } else if ((name) != null) { - if (method == null) method = 'GET' - path = '/' + '_settings' + '/' + encodeURIComponent(name) - } else { - if (method == null) method = 'GET' - path = '/' + '_settings' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesGetSettings diff --git a/api/api/indices.js b/api/api/indices.js new file mode 100644 index 000000000..05ba8d352 --- /dev/null +++ b/api/api/indices.js @@ -0,0 +1,1588 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['timeout', 'master_timeout', 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'index', 'fielddata', 'fields', 'query', 'request', 'wait_for_active_shards', 'local', 'flat_settings', 'include_defaults', 'force', 'wait_if_ongoing', 'flush', 'max_num_segments', 'only_expunge_deletes', 'create', 'cause', 'write_index_only', 'preserve_existing', 'order', 'detailed', 'active_only', 'dry_run', 'verbose', 'status', 'completion_fields', 'fielddata_fields', 'groups', 'level', 'types', 'include_segment_file_sizes', 'include_unloaded_segments', 'forbid_closed_indices', 'wait_for_completion', 'only_ancient_segments', 'explain', 'q', 'analyzer', 'analyze_wildcard', 'default_operator', 'df', 'lenient', 'rewrite', 'all_shards'] +const snakeCase = { masterTimeout: 'master_timeout', ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', errorTrace: 'error_trace', filterPath: 'filter_path', waitForActiveShards: 'wait_for_active_shards', flatSettings: 'flat_settings', includeDefaults: 'include_defaults', waitIfOngoing: 'wait_if_ongoing', maxNumSegments: 'max_num_segments', onlyExpungeDeletes: 'only_expunge_deletes', writeIndexOnly: 'write_index_only', preserveExisting: 'preserve_existing', activeOnly: 'active_only', dryRun: 'dry_run', completionFields: 'completion_fields', fielddataFields: 'fielddata_fields', includeSegmentFileSizes: 'include_segment_file_sizes', includeUnloadedSegments: 'include_unloaded_segments', forbidClosedIndices: 'forbid_closed_indices', waitForCompletion: 'wait_for_completion', onlyAncientSegments: 'only_ancient_segments', analyzeWildcard: 'analyze_wildcard', defaultOperator: 'default_operator', allShards: 'all_shards' } + +function IndicesApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +IndicesApi.prototype.addBlock = function indicesAddBlockApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['block'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: block') + return handleError(err, callback) + } + + // check required url components + if (params['block'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) + } + + var { method, body, index, block, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_block' + '/' + encodeURIComponent(block) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.analyze = function indicesAnalyzeApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_analyze' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_analyze' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.clearCache = function indicesClearCacheApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_cache' + '/' + 'clear' + } else { + if (method == null) method = 'POST' + path = '/' + '_cache' + '/' + 'clear' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.clone = function indicesCloneApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['target'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: target') + return handleError(err, callback) + } + + // check required url components + if (params['target'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) + } + + var { method, body, index, target, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_clone' + '/' + encodeURIComponent(target) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.close = function indicesCloseApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_close' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.create = function indicesCreateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.delete = function indicesDeleteApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + encodeURIComponent(index) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.deleteAlias = function indicesDeleteAliasApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + // check required url components + if (params['name'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) + } + + var { method, body, index, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (name) != null) { + if (method == null) method = 'DELETE' + path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'DELETE' + path = '/' + encodeURIComponent(index) + '/' + '_aliases' + '/' + encodeURIComponent(name) + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.deleteIndexTemplate = function indicesDeleteIndexTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_index_template' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.deleteTemplate = function indicesDeleteTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_template' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.exists = function indicesExistsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'HEAD' + path = '/' + encodeURIComponent(index) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.existsAlias = function indicesExistsAliasApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (name) != null) { + if (method == null) method = 'HEAD' + path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'HEAD' + path = '/' + '_alias' + '/' + encodeURIComponent(name) + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.existsIndexTemplate = function indicesExistsIndexTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'HEAD' + path = '/' + '_index_template' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.existsTemplate = function indicesExistsTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'HEAD' + path = '/' + '_template' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.existsType = function indicesExistsTypeApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['type'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: type') + return handleError(err, callback) + } + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) + } + + var { method, body, index, type, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'HEAD' + path = '/' + encodeURIComponent(index) + '/' + '_mapping' + '/' + encodeURIComponent(type) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.flush = function indicesFlushApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_flush' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_flush' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.forcemerge = function indicesForcemergeApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_forcemerge' + } else { + if (method == null) method = 'POST' + path = '/' + '_forcemerge' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.get = function indicesGetApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.getAlias = function indicesGetAliasApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (name) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name) + } else if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_alias' + '/' + encodeURIComponent(name) + } else if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_alias' + } else { + if (method == null) method = 'GET' + path = '/' + '_alias' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.getFieldMapping = function indicesGetFieldMappingApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['fields'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: fields') + return handleError(err, callback) + } + + var { method, body, fields, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (fields) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_mapping' + '/' + 'field' + '/' + encodeURIComponent(fields) + } else { + if (method == null) method = 'GET' + path = '/' + '_mapping' + '/' + 'field' + '/' + encodeURIComponent(fields) + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.getIndexTemplate = function indicesGetIndexTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_index_template' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_index_template' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.getMapping = function indicesGetMappingApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_mapping' + } else { + if (method == null) method = 'GET' + path = '/' + '_mapping' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.getSettings = function indicesGetSettingsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (name) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_settings' + '/' + encodeURIComponent(name) + } else if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_settings' + } else if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_settings' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_settings' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.getTemplate = function indicesGetTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_template' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_template' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.getUpgrade = function indicesGetUpgradeApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_upgrade' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.open = function indicesOpenApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_open' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.putAlias = function indicesPutAliasApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + // check required url components + if (params['name'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) + } + + var { method, body, index, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (name) != null) { + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_aliases' + '/' + encodeURIComponent(name) + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.putIndexTemplate = function indicesPutIndexTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_index_template' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.putMapping = function indicesPutMappingApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_mapping' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.putSettings = function indicesPutSettingsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_settings' + } else { + if (method == null) method = 'PUT' + path = '/' + '_settings' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.putTemplate = function indicesPutTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_template' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.recovery = function indicesRecoveryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_recovery' + } else { + if (method == null) method = 'GET' + path = '/' + '_recovery' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.refresh = function indicesRefreshApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_refresh' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_refresh' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.resolveIndex = function indicesResolveIndexApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_resolve' + '/' + 'index' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.rollover = function indicesRolloverApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['alias'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: alias') + return handleError(err, callback) + } + + // check required url components + if ((params['new_index'] != null || params['newIndex'] != null) && (params['alias'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: alias') + return handleError(err, callback) + } + + var { method, body, alias, newIndex, new_index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((alias) != null && (new_index || newIndex) != null) { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(alias) + '/' + '_rollover' + '/' + encodeURIComponent(new_index || newIndex) + } else { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(alias) + '/' + '_rollover' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.segments = function indicesSegmentsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_segments' + } else { + if (method == null) method = 'GET' + path = '/' + '_segments' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.shardStores = function indicesShardStoresApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_shard_stores' + } else { + if (method == null) method = 'GET' + path = '/' + '_shard_stores' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.shrink = function indicesShrinkApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['target'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: target') + return handleError(err, callback) + } + + // check required url components + if (params['target'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) + } + + var { method, body, index, target, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_shrink' + '/' + encodeURIComponent(target) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.simulateIndexTemplate = function indicesSimulateIndexTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_index_template' + '/' + '_simulate_index' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.simulateTemplate = function indicesSimulateTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'POST' + path = '/' + '_index_template' + '/' + '_simulate' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'POST' + path = '/' + '_index_template' + '/' + '_simulate' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.split = function indicesSplitApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['target'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: target') + return handleError(err, callback) + } + + // check required url components + if (params['target'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) + } + + var { method, body, index, target, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + encodeURIComponent(index) + '/' + '_split' + '/' + encodeURIComponent(target) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.stats = function indicesStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, metric, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (metric) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_stats' + '/' + encodeURIComponent(metric) + } else if ((metric) != null) { + if (method == null) method = 'GET' + path = '/' + '_stats' + '/' + encodeURIComponent(metric) + } else if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_stats' + } else { + if (method == null) method = 'GET' + path = '/' + '_stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.updateAliases = function indicesUpdateAliasesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_aliases' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.upgrade = function indicesUpgradeApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_upgrade' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.validateQuery = function indicesValidateQueryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) + } + + var { method, body, index, type, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (type) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_validate' + '/' + 'query' + } else if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_validate' + '/' + 'query' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_validate' + '/' + 'query' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.createDataStream = function indicesCreateDataStreamApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_data_stream' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.dataStreamsStats = function indicesDataStreamsStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_data_stream' + '/' + encodeURIComponent(name) + '/' + '_stats' + } else { + if (method == null) method = 'GET' + path = '/' + '_data_stream' + '/' + '_stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.deleteDataStream = function indicesDeleteDataStreamApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_data_stream' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.freeze = function indicesFreezeApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_freeze' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.getDataStream = function indicesGetDataStreamApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_data_stream' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_data_stream' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.reloadSearchAnalyzers = function indicesReloadSearchAnalyzersApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_reload_search_analyzers' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IndicesApi.prototype.unfreeze = function indicesUnfreezeApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_unfreeze' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(IndicesApi.prototype, { + add_block: { get () { return this.addBlock } }, + clear_cache: { get () { return this.clearCache } }, + delete_alias: { get () { return this.deleteAlias } }, + delete_index_template: { get () { return this.deleteIndexTemplate } }, + delete_template: { get () { return this.deleteTemplate } }, + exists_alias: { get () { return this.existsAlias } }, + exists_index_template: { get () { return this.existsIndexTemplate } }, + exists_template: { get () { return this.existsTemplate } }, + exists_type: { get () { return this.existsType } }, + get_alias: { get () { return this.getAlias } }, + get_field_mapping: { get () { return this.getFieldMapping } }, + get_index_template: { get () { return this.getIndexTemplate } }, + get_mapping: { get () { return this.getMapping } }, + get_settings: { get () { return this.getSettings } }, + get_template: { get () { return this.getTemplate } }, + get_upgrade: { get () { return this.getUpgrade } }, + put_alias: { get () { return this.putAlias } }, + put_index_template: { get () { return this.putIndexTemplate } }, + put_mapping: { get () { return this.putMapping } }, + put_settings: { get () { return this.putSettings } }, + put_template: { get () { return this.putTemplate } }, + resolve_index: { get () { return this.resolveIndex } }, + shard_stores: { get () { return this.shardStores } }, + simulate_index_template: { get () { return this.simulateIndexTemplate } }, + simulate_template: { get () { return this.simulateTemplate } }, + update_aliases: { get () { return this.updateAliases } }, + validate_query: { get () { return this.validateQuery } }, + create_data_stream: { get () { return this.createDataStream } }, + data_streams_stats: { get () { return this.dataStreamsStats } }, + delete_data_stream: { get () { return this.deleteDataStream } }, + get_data_stream: { get () { return this.getDataStream } }, + reload_search_analyzers: { get () { return this.reloadSearchAnalyzers } } +}) + +module.exports = IndicesApi diff --git a/api/api/indices.open.js b/api/api/indices.open.js deleted file mode 100644 index 1dcf1f830..000000000 --- a/api/api/indices.open.js +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesOpen (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'wait_for_active_shards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - waitForActiveShards: 'wait_for_active_shards', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.open request - * Opens an index. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-open-close.html - */ - return function indicesOpen (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_open' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesOpen diff --git a/api/api/indices.put_alias.js b/api/api/indices.put_alias.js deleted file mode 100644 index 36547da06..000000000 --- a/api/api/indices.put_alias.js +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesPutAlias (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.put_alias request - * Creates or updates an alias. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html - */ - return function indicesPutAlias (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // check required url components - if (params['name'] != null && (params['index'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null && (name) != null) { - if (method == null) method = 'PUT' - path = '/' + encodeURIComponent(index) + '/' + '_alias' + '/' + encodeURIComponent(name) - } else { - if (method == null) method = 'PUT' - path = '/' + encodeURIComponent(index) + '/' + '_aliases' + '/' + encodeURIComponent(name) - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesPutAlias diff --git a/api/api/indices.put_index_template.js b/api/api/indices.put_index_template.js deleted file mode 100644 index 6a02d7396..000000000 --- a/api/api/indices.put_index_template.js +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesPutIndexTemplate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'create', - 'cause', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.put_index_template request - * Creates or updates an index template. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html - */ - return function indicesPutIndexTemplate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_index_template' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesPutIndexTemplate diff --git a/api/api/indices.put_settings.js b/api/api/indices.put_settings.js deleted file mode 100644 index c2b579511..000000000 --- a/api/api/indices.put_settings.js +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesPutSettings (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'master_timeout', - 'timeout', - 'preserve_existing', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'flat_settings', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - preserveExisting: 'preserve_existing', - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - flatSettings: 'flat_settings', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.put_settings request - * Updates the index settings. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-update-settings.html - */ - return function indicesPutSettings (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = 'PUT' - path = '/' + encodeURIComponent(index) + '/' + '_settings' - } else { - if (method == null) method = 'PUT' - path = '/' + '_settings' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesPutSettings diff --git a/api/api/indices.recovery.js b/api/api/indices.recovery.js deleted file mode 100644 index 5637add83..000000000 --- a/api/api/indices.recovery.js +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesRecovery (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'detailed', - 'active_only', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - activeOnly: 'active_only', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.recovery request - * Returns information about ongoing index shard recoveries. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-recovery.html - */ - return function indicesRecovery (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = 'GET' - path = '/' + encodeURIComponent(index) + '/' + '_recovery' - } else { - if (method == null) method = 'GET' - path = '/' + '_recovery' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesRecovery diff --git a/api/api/indices.refresh.js b/api/api/indices.refresh.js deleted file mode 100644 index 6328152ac..000000000 --- a/api/api/indices.refresh.js +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesRefresh (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.refresh request - * Performs the refresh operation in one or more indices. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-refresh.html - */ - return function indicesRefresh (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_refresh' - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_refresh' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesRefresh diff --git a/api/api/indices.reload_search_analyzers.js b/api/api/indices.reload_search_analyzers.js deleted file mode 100644 index eb651ad11..000000000 --- a/api/api/indices.reload_search_analyzers.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesReloadSearchAnalyzers (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards' - ] - - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards' - } - - /** - * Perform a indices.reload_search_analyzers request - * Reloads an index's search analyzers and their resources. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-reload-analyzers.html - */ - return function indicesReloadSearchAnalyzers (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_reload_search_analyzers' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesReloadSearchAnalyzers diff --git a/api/api/indices.resolve_index.js b/api/api/indices.resolve_index.js deleted file mode 100644 index f5b31cb7a..000000000 --- a/api/api/indices.resolve_index.js +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesResolveIndex (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - expandWildcards: 'expand_wildcards', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.resolve_index request - * Returns information about any matching indices, aliases, and data streams - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-resolve-index-api.html - */ - return function indicesResolveIndex (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_resolve' + '/' + 'index' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesResolveIndex diff --git a/api/api/indices.segments.js b/api/api/indices.segments.js deleted file mode 100644 index 70d384094..000000000 --- a/api/api/indices.segments.js +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesSegments (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'verbose', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.segments request - * Provides low-level information about segments in a Lucene index. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-segments.html - */ - return function indicesSegments (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = 'GET' - path = '/' + encodeURIComponent(index) + '/' + '_segments' - } else { - if (method == null) method = 'GET' - path = '/' + '_segments' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesSegments diff --git a/api/api/indices.shard_stores.js b/api/api/indices.shard_stores.js deleted file mode 100644 index 1882739a6..000000000 --- a/api/api/indices.shard_stores.js +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesShardStores (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'status', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.shard_stores request - * Provides store information for shard copies of indices. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-shards-stores.html - */ - return function indicesShardStores (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = 'GET' - path = '/' + encodeURIComponent(index) + '/' + '_shard_stores' - } else { - if (method == null) method = 'GET' - path = '/' + '_shard_stores' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesShardStores diff --git a/api/api/indices.simulate_index_template.js b/api/api/indices.simulate_index_template.js deleted file mode 100644 index fd303037b..000000000 --- a/api/api/indices.simulate_index_template.js +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesSimulateIndexTemplate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'create', - 'cause', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.simulate_index_template request - * Simulate matching the given index name against the index templates in the system - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html - */ - return function indicesSimulateIndexTemplate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_index_template' + '/' + '_simulate_index' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesSimulateIndexTemplate diff --git a/api/api/indices.simulate_template.js b/api/api/indices.simulate_template.js deleted file mode 100644 index d3b2d81e2..000000000 --- a/api/api/indices.simulate_template.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesSimulateTemplate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'create', - 'cause', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.simulate_template request - * Simulate resolving the given template name or body - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-templates.html - */ - return function indicesSimulateTemplate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((name) != null) { - if (method == null) method = 'POST' - path = '/' + '_index_template' + '/' + '_simulate' + '/' + encodeURIComponent(name) - } else { - if (method == null) method = 'POST' - path = '/' + '_index_template' + '/' + '_simulate' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesSimulateTemplate diff --git a/api/api/indices.stats.js b/api/api/indices.stats.js deleted file mode 100644 index 746a5f0ec..000000000 --- a/api/api/indices.stats.js +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesStats (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'completion_fields', - 'fielddata_fields', - 'fields', - 'groups', - 'level', - 'types', - 'include_segment_file_sizes', - 'include_unloaded_segments', - 'expand_wildcards', - 'forbid_closed_indices', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - completionFields: 'completion_fields', - fielddataFields: 'fielddata_fields', - includeSegmentFileSizes: 'include_segment_file_sizes', - includeUnloadedSegments: 'include_unloaded_segments', - expandWildcards: 'expand_wildcards', - forbidClosedIndices: 'forbid_closed_indices', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.stats request - * Provides statistics on operations happening in an index. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-stats.html - */ - return function indicesStats (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, metric, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null && (metric) != null) { - if (method == null) method = 'GET' - path = '/' + encodeURIComponent(index) + '/' + '_stats' + '/' + encodeURIComponent(metric) - } else if ((metric) != null) { - if (method == null) method = 'GET' - path = '/' + '_stats' + '/' + encodeURIComponent(metric) - } else if ((index) != null) { - if (method == null) method = 'GET' - path = '/' + encodeURIComponent(index) + '/' + '_stats' - } else { - if (method == null) method = 'GET' - path = '/' + '_stats' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesStats diff --git a/api/api/indices.unfreeze.js b/api/api/indices.unfreeze.js deleted file mode 100644 index a57d2edda..000000000 --- a/api/api/indices.unfreeze.js +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesUnfreeze (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'wait_for_active_shards' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - waitForActiveShards: 'wait_for_active_shards' - } - - /** - * Perform a indices.unfreeze request - * Unfreezes an index. When a frozen index is unfrozen, the index goes through the normal recovery process and becomes writeable again. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/unfreeze-index-api.html - */ - return function indicesUnfreeze (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_unfreeze' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesUnfreeze diff --git a/api/api/indices.update_aliases.js b/api/api/indices.update_aliases.js deleted file mode 100644 index 4903afe09..000000000 --- a/api/api/indices.update_aliases.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesUpdateAliases (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.update_aliases request - * Updates index aliases. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-aliases.html - */ - return function indicesUpdateAliases (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_aliases' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesUpdateAliases diff --git a/api/api/indices.validate_query.js b/api/api/indices.validate_query.js deleted file mode 100644 index 753cee0b6..000000000 --- a/api/api/indices.validate_query.js +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIndicesValidateQuery (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'explain', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'q', - 'analyzer', - 'analyze_wildcard', - 'default_operator', - 'df', - 'lenient', - 'rewrite', - 'all_shards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - analyzeWildcard: 'analyze_wildcard', - defaultOperator: 'default_operator', - allShards: 'all_shards', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a indices.validate_query request - * Allows a user to validate a potentially expensive query without executing it. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/search-validate.html - */ - return function indicesValidateQuery (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required url components - if (params['type'] != null && (params['index'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, type, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null && (type) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_validate' + '/' + 'query' - } else if ((index) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_validate' + '/' + 'query' - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_validate' + '/' + 'query' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIndicesValidateQuery diff --git a/api/api/info.js b/api/api/info.js index 97ad8e67a..518dfaaef 100644 --- a/api/api/info.js +++ b/api/api/info.js @@ -22,71 +22,29 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildInfo (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function infoApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + + // build request object + const request = { + method, + path, + body: null, + querystring } - /** - * Perform a info request - * Returns basic information about the cluster. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html - */ - return function info (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } + return this.transport.request(request, options, callback) } -module.exports = buildInfo +module.exports = infoApi diff --git a/api/api/ingest.delete_pipeline.js b/api/api/ingest.delete_pipeline.js deleted file mode 100644 index 800d88478..000000000 --- a/api/api/ingest.delete_pipeline.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIngestDeletePipeline (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'master_timeout', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a ingest.delete_pipeline request - * Deletes a pipeline. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-pipeline-api.html - */ - return function ingestDeletePipeline (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIngestDeletePipeline diff --git a/api/api/ingest.get_pipeline.js b/api/api/ingest.get_pipeline.js deleted file mode 100644 index 2d14b9c61..000000000 --- a/api/api/ingest.get_pipeline.js +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIngestGetPipeline (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'master_timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a ingest.get_pipeline request - * Returns a pipeline. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/get-pipeline-api.html - */ - return function ingestGetPipeline (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((id) != null) { - if (method == null) method = 'GET' - path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id) - } else { - if (method == null) method = 'GET' - path = '/' + '_ingest' + '/' + 'pipeline' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIngestGetPipeline diff --git a/api/api/ingest.js b/api/api/ingest.js new file mode 100644 index 000000000..5763190ea --- /dev/null +++ b/api/api/ingest.js @@ -0,0 +1,178 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['master_timeout', 'timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'verbose'] +const snakeCase = { masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path' } + +function IngestApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +IngestApi.prototype.deletePipeline = function ingestDeletePipelineApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IngestApi.prototype.getPipeline = function ingestGetPipelineApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null) { + if (method == null) method = 'GET' + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id) + } else { + if (method == null) method = 'GET' + path = '/' + '_ingest' + '/' + 'pipeline' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IngestApi.prototype.processorGrok = function ingestProcessorGrokApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_ingest' + '/' + 'processor' + '/' + 'grok' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +IngestApi.prototype.putPipeline = function ingestPutPipelineApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +IngestApi.prototype.simulate = function ingestSimulateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id) + '/' + '_simulate' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + '_simulate' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(IngestApi.prototype, { + delete_pipeline: { get () { return this.deletePipeline } }, + get_pipeline: { get () { return this.getPipeline } }, + processor_grok: { get () { return this.processorGrok } }, + put_pipeline: { get () { return this.putPipeline } } +}) + +module.exports = IngestApi diff --git a/api/api/ingest.processor_grok.js b/api/api/ingest.processor_grok.js deleted file mode 100644 index 5939f6920..000000000 --- a/api/api/ingest.processor_grok.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIngestProcessorGrok (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a ingest.processor_grok request - * Returns a list of the built-in patterns. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/grok-processor.html#grok-processor-rest-get - */ - return function ingestProcessorGrok (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_ingest' + '/' + 'processor' + '/' + 'grok' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIngestProcessorGrok diff --git a/api/api/ingest.put_pipeline.js b/api/api/ingest.put_pipeline.js deleted file mode 100644 index 80d71f5d6..000000000 --- a/api/api/ingest.put_pipeline.js +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIngestPutPipeline (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'master_timeout', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a ingest.put_pipeline request - * Creates or updates a pipeline. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/put-pipeline-api.html - */ - return function ingestPutPipeline (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIngestPutPipeline diff --git a/api/api/ingest.simulate.js b/api/api/ingest.simulate.js deleted file mode 100644 index 6bb34e43a..000000000 --- a/api/api/ingest.simulate.js +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildIngestSimulate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'verbose', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a ingest.simulate request - * Allows to simulate a pipeline with example documents. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/simulate-pipeline-api.html - */ - return function ingestSimulate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((id) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(id) + '/' + '_simulate' - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_ingest' + '/' + 'pipeline' + '/' + '_simulate' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildIngestSimulate diff --git a/api/api/license.delete.js b/api/api/license.delete.js deleted file mode 100644 index 512ec6493..000000000 --- a/api/api/license.delete.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildLicenseDelete (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a license.delete request - * Deletes licensing information for the cluster - * https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-license.html - */ - return function licenseDelete (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_license' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildLicenseDelete diff --git a/api/api/license.get.js b/api/api/license.get.js deleted file mode 100644 index e3211de88..000000000 --- a/api/api/license.get.js +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildLicenseGet (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'local', - 'accept_enterprise' - ] - - const snakeCase = { - acceptEnterprise: 'accept_enterprise' - } - - /** - * Perform a license.get request - * Retrieves licensing information for the cluster - * https://www.elastic.co/guide/en/elasticsearch/reference/master/get-license.html - */ - return function licenseGet (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_license' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildLicenseGet diff --git a/api/api/license.get_basic_status.js b/api/api/license.get_basic_status.js deleted file mode 100644 index 102749294..000000000 --- a/api/api/license.get_basic_status.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildLicenseGetBasicStatus (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a license.get_basic_status request - * Retrieves information about the status of the basic license. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/get-basic-status.html - */ - return function licenseGetBasicStatus (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_license' + '/' + 'basic_status' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildLicenseGetBasicStatus diff --git a/api/api/license.get_trial_status.js b/api/api/license.get_trial_status.js deleted file mode 100644 index 63ad25501..000000000 --- a/api/api/license.get_trial_status.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildLicenseGetTrialStatus (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a license.get_trial_status request - * Retrieves information about the status of the trial license. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/get-trial-status.html - */ - return function licenseGetTrialStatus (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_license' + '/' + 'trial_status' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildLicenseGetTrialStatus diff --git a/api/api/license.js b/api/api/license.js new file mode 100644 index 000000000..6bc197c6a --- /dev/null +++ b/api/api/license.js @@ -0,0 +1,188 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path', 'local', 'accept_enterprise', 'acknowledge', 'type'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path', acceptEnterprise: 'accept_enterprise' } + +function LicenseApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +LicenseApi.prototype.delete = function licenseDeleteApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_license' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +LicenseApi.prototype.get = function licenseGetApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_license' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +LicenseApi.prototype.getBasicStatus = function licenseGetBasicStatusApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_license' + '/' + 'basic_status' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +LicenseApi.prototype.getTrialStatus = function licenseGetTrialStatusApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_license' + '/' + 'trial_status' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +LicenseApi.prototype.post = function licensePostApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_license' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +LicenseApi.prototype.postStartBasic = function licensePostStartBasicApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_license' + '/' + 'start_basic' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +LicenseApi.prototype.postStartTrial = function licensePostStartTrialApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_license' + '/' + 'start_trial' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(LicenseApi.prototype, { + get_basic_status: { get () { return this.getBasicStatus } }, + get_trial_status: { get () { return this.getTrialStatus } }, + post_start_basic: { get () { return this.postStartBasic } }, + post_start_trial: { get () { return this.postStartTrial } } +}) + +module.exports = LicenseApi diff --git a/api/api/license.post.js b/api/api/license.post.js deleted file mode 100644 index 1589b397b..000000000 --- a/api/api/license.post.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildLicensePost (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'acknowledge' - ] - - const snakeCase = { - - } - - /** - * Perform a license.post request - * Updates the license for the cluster. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/update-license.html - */ - return function licensePost (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_license' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildLicensePost diff --git a/api/api/license.post_start_basic.js b/api/api/license.post_start_basic.js deleted file mode 100644 index 045d3d084..000000000 --- a/api/api/license.post_start_basic.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildLicensePostStartBasic (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'acknowledge' - ] - - const snakeCase = { - - } - - /** - * Perform a license.post_start_basic request - * Starts an indefinite basic license. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/start-basic.html - */ - return function licensePostStartBasic (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_license' + '/' + 'start_basic' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildLicensePostStartBasic diff --git a/api/api/license.post_start_trial.js b/api/api/license.post_start_trial.js deleted file mode 100644 index 03afd1b7d..000000000 --- a/api/api/license.post_start_trial.js +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildLicensePostStartTrial (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'type', - 'acknowledge' - ] - - const snakeCase = { - - } - - /** - * Perform a license.post_start_trial request - * starts a limited time trial license. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/start-trial.html - */ - return function licensePostStartTrial (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_license' + '/' + 'start_trial' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildLicensePostStartTrial diff --git a/api/api/mget.js b/api/api/mget.js index 26f90cd4c..2490e0978 100644 --- a/api/api/mget.js +++ b/api/api/mget.js @@ -22,10 +22,11 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildMget (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['stored_fields', 'preference', 'realtime', 'refresh', 'routing', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { storedFields: 'stored_fields', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', errorTrace: 'error_trace', filterPath: 'filter_path' } +<<<<<<< HEAD const acceptedQuerystring = [ 'stored_fields', 'preference', @@ -48,25 +49,21 @@ function buildMget (opts) { _sourceIncludes: '_source_includes', errorTrace: 'error_trace', filterPath: 'filter_path' +======= +function mgetApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) +>>>>>>> a064f0f3... Improve child performances (#1314) } - /** - * Perform a mget request - * Allows to get multiple documents in one request. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-multi-get.html - */ - return function mget (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +<<<<<<< HEAD // check required parameters if (params['body'] == null) { const err = new ConfigurationError('Missing required parameter: body') @@ -114,10 +111,26 @@ function buildMget (opts) { body: body || '', querystring } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) +======= + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_mget' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_mget' } +>>>>>>> a064f0f3... Improve child performances (#1314) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildMget +module.exports = mgetApi diff --git a/api/api/migration.deprecations.js b/api/api/migration.deprecations.js deleted file mode 100644 index f3d95f5e1..000000000 --- a/api/api/migration.deprecations.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMigrationDeprecations (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a migration.deprecations request - * Retrieves information about different cluster, node, and index level settings that use deprecated features that will be removed or changed in the next major version. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-deprecation.html - */ - return function migrationDeprecations (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = 'GET' - path = '/' + encodeURIComponent(index) + '/' + '_migration' + '/' + 'deprecations' - } else { - if (method == null) method = 'GET' - path = '/' + '_migration' + '/' + 'deprecations' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMigrationDeprecations diff --git a/api/api/migration.js b/api/api/migration.js new file mode 100644 index 000000000..f77baf7e5 --- /dev/null +++ b/api/api/migration.js @@ -0,0 +1,60 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } + +function MigrationApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +MigrationApi.prototype.deprecations = function migrationDeprecationsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_migration' + '/' + 'deprecations' + } else { + if (method == null) method = 'GET' + path = '/' + '_migration' + '/' + 'deprecations' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +module.exports = MigrationApi diff --git a/api/api/ml.close_job.js b/api/api/ml.close_job.js deleted file mode 100644 index b1d961cf6..000000000 --- a/api/api/ml.close_job.js +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlCloseJob (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'allow_no_match', - 'allow_no_jobs', - 'force', - 'timeout' - ] - - const snakeCase = { - allowNoMatch: 'allow_no_match', - allowNoJobs: 'allow_no_jobs' - - } - - /** - * Perform a ml.close_job request - * Closes one or more anomaly detection jobs. A job can be opened and closed multiple times throughout its lifecycle. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-close-job.html - */ - return function mlCloseJob (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['job_id'] == null && params['jobId'] == null) { - const err = new ConfigurationError('Missing required parameter: job_id or jobId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_close' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlCloseJob diff --git a/api/api/ml.delete_calendar.js b/api/api/ml.delete_calendar.js deleted file mode 100644 index 56836df19..000000000 --- a/api/api/ml.delete_calendar.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlDeleteCalendar (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.delete_calendar request - * Deletes a calendar. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-calendar.html - */ - return function mlDeleteCalendar (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['calendar_id'] == null && params['calendarId'] == null) { - const err = new ConfigurationError('Missing required parameter: calendar_id or calendarId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, calendarId, calendar_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlDeleteCalendar diff --git a/api/api/ml.delete_calendar_event.js b/api/api/ml.delete_calendar_event.js deleted file mode 100644 index 245454ef4..000000000 --- a/api/api/ml.delete_calendar_event.js +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlDeleteCalendarEvent (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.delete_calendar_event request - * Deletes scheduled events from a calendar. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-calendar-event.html - */ - return function mlDeleteCalendarEvent (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['calendar_id'] == null && params['calendarId'] == null) { - const err = new ConfigurationError('Missing required parameter: calendar_id or calendarId') - return handleError(err, callback) - } - if (params['event_id'] == null && params['eventId'] == null) { - const err = new ConfigurationError('Missing required parameter: event_id or eventId') - return handleError(err, callback) - } - - // check required url components - if ((params['event_id'] != null || params['eventId'] != null) && ((params['calendar_id'] == null && params['calendarId'] == null))) { - const err = new ConfigurationError('Missing required parameter of the url: calendar_id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, calendarId, calendar_id, eventId, event_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'events' + '/' + encodeURIComponent(event_id || eventId) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlDeleteCalendarEvent diff --git a/api/api/ml.delete_calendar_job.js b/api/api/ml.delete_calendar_job.js deleted file mode 100644 index 8b7779e16..000000000 --- a/api/api/ml.delete_calendar_job.js +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlDeleteCalendarJob (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.delete_calendar_job request - * Deletes anomaly detection jobs from a calendar. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-calendar-job.html - */ - return function mlDeleteCalendarJob (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['calendar_id'] == null && params['calendarId'] == null) { - const err = new ConfigurationError('Missing required parameter: calendar_id or calendarId') - return handleError(err, callback) - } - if (params['job_id'] == null && params['jobId'] == null) { - const err = new ConfigurationError('Missing required parameter: job_id or jobId') - return handleError(err, callback) - } - - // check required url components - if ((params['job_id'] != null || params['jobId'] != null) && ((params['calendar_id'] == null && params['calendarId'] == null))) { - const err = new ConfigurationError('Missing required parameter of the url: calendar_id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, calendarId, calendar_id, jobId, job_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'jobs' + '/' + encodeURIComponent(job_id || jobId) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlDeleteCalendarJob diff --git a/api/api/ml.delete_data_frame_analytics.js b/api/api/ml.delete_data_frame_analytics.js deleted file mode 100644 index e8f7681f4..000000000 --- a/api/api/ml.delete_data_frame_analytics.js +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlDeleteDataFrameAnalytics (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'force', - 'timeout' - ] - - const snakeCase = { - - } - - /** - * Perform a ml.delete_data_frame_analytics request - * Deletes an existing data frame analytics job. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-dfanalytics.html - */ - return function mlDeleteDataFrameAnalytics (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlDeleteDataFrameAnalytics diff --git a/api/api/ml.delete_datafeed.js b/api/api/ml.delete_datafeed.js deleted file mode 100644 index bca96e80a..000000000 --- a/api/api/ml.delete_datafeed.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlDeleteDatafeed (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'force' - ] - - const snakeCase = { - - } - - /** - * Perform a ml.delete_datafeed request - * Deletes an existing datafeed. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html - */ - return function mlDeleteDatafeed (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['datafeed_id'] == null && params['datafeedId'] == null) { - const err = new ConfigurationError('Missing required parameter: datafeed_id or datafeedId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, datafeedId, datafeed_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlDeleteDatafeed diff --git a/api/api/ml.delete_expired_data.js b/api/api/ml.delete_expired_data.js deleted file mode 100644 index eb33a8169..000000000 --- a/api/api/ml.delete_expired_data.js +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlDeleteExpiredData (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'requests_per_second', - 'timeout' - ] - - const snakeCase = { - requestsPerSecond: 'requests_per_second' - - } - - /** - * Perform a ml.delete_expired_data request - * Deletes expired and unused machine learning data. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-expired-data.html - */ - return function mlDeleteExpiredData (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((job_id || jobId) != null) { - if (method == null) method = 'DELETE' - path = '/' + '_ml' + '/' + '_delete_expired_data' + '/' + encodeURIComponent(job_id || jobId) - } else { - if (method == null) method = 'DELETE' - path = '/' + '_ml' + '/' + '_delete_expired_data' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlDeleteExpiredData diff --git a/api/api/ml.delete_filter.js b/api/api/ml.delete_filter.js deleted file mode 100644 index b04449b41..000000000 --- a/api/api/ml.delete_filter.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlDeleteFilter (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.delete_filter request - * Deletes a filter. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-filter.html - */ - return function mlDeleteFilter (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['filter_id'] == null && params['filterId'] == null) { - const err = new ConfigurationError('Missing required parameter: filter_id or filterId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, filterId, filter_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(filter_id || filterId) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlDeleteFilter diff --git a/api/api/ml.delete_forecast.js b/api/api/ml.delete_forecast.js deleted file mode 100644 index 083fcf063..000000000 --- a/api/api/ml.delete_forecast.js +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlDeleteForecast (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'allow_no_forecasts', - 'timeout' - ] - - const snakeCase = { - allowNoForecasts: 'allow_no_forecasts' - - } - - /** - * Perform a ml.delete_forecast request - * Deletes forecasts from a machine learning job. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html - */ - return function mlDeleteForecast (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['job_id'] == null && params['jobId'] == null) { - const err = new ConfigurationError('Missing required parameter: job_id or jobId') - return handleError(err, callback) - } - - // check required url components - if ((params['forecast_id'] != null || params['forecastId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { - const err = new ConfigurationError('Missing required parameter of the url: job_id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, forecastId, forecast_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((job_id || jobId) != null && (forecast_id || forecastId) != null) { - if (method == null) method = 'DELETE' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_forecast' + '/' + encodeURIComponent(forecast_id || forecastId) - } else { - if (method == null) method = 'DELETE' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_forecast' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlDeleteForecast diff --git a/api/api/ml.delete_job.js b/api/api/ml.delete_job.js deleted file mode 100644 index 0a326cb8a..000000000 --- a/api/api/ml.delete_job.js +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlDeleteJob (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'force', - 'wait_for_completion' - ] - - const snakeCase = { - waitForCompletion: 'wait_for_completion' - } - - /** - * Perform a ml.delete_job request - * Deletes an existing anomaly detection job. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html - */ - return function mlDeleteJob (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['job_id'] == null && params['jobId'] == null) { - const err = new ConfigurationError('Missing required parameter: job_id or jobId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlDeleteJob diff --git a/api/api/ml.delete_model_snapshot.js b/api/api/ml.delete_model_snapshot.js deleted file mode 100644 index 6bcfe8350..000000000 --- a/api/api/ml.delete_model_snapshot.js +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlDeleteModelSnapshot (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.delete_model_snapshot request - * Deletes an existing model snapshot. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-snapshot.html - */ - return function mlDeleteModelSnapshot (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['job_id'] == null && params['jobId'] == null) { - const err = new ConfigurationError('Missing required parameter: job_id or jobId') - return handleError(err, callback) - } - if (params['snapshot_id'] == null && params['snapshotId'] == null) { - const err = new ConfigurationError('Missing required parameter: snapshot_id or snapshotId') - return handleError(err, callback) - } - - // check required url components - if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { - const err = new ConfigurationError('Missing required parameter of the url: job_id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, snapshotId, snapshot_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + '/' + encodeURIComponent(snapshot_id || snapshotId) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlDeleteModelSnapshot diff --git a/api/api/ml.delete_trained_model.js b/api/api/ml.delete_trained_model.js deleted file mode 100644 index f91a9ae6d..000000000 --- a/api/api/ml.delete_trained_model.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlDeleteTrainedModel (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.delete_trained_model request - * Deletes an existing trained inference model that is currently not referenced by an ingest pipeline. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-inference.html - */ - return function mlDeleteTrainedModel (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['model_id'] == null && params['modelId'] == null) { - const err = new ConfigurationError('Missing required parameter: model_id or modelId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, modelId, model_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_ml' + '/' + 'inference' + '/' + encodeURIComponent(model_id || modelId) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlDeleteTrainedModel diff --git a/api/api/ml.estimate_model_memory.js b/api/api/ml.estimate_model_memory.js deleted file mode 100644 index ad6503afe..000000000 --- a/api/api/ml.estimate_model_memory.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlEstimateModelMemory (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.estimate_model_memory request - * Estimates the model memory - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-apis.html - */ - return function mlEstimateModelMemory (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_estimate_model_memory' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlEstimateModelMemory diff --git a/api/api/ml.evaluate_data_frame.js b/api/api/ml.evaluate_data_frame.js deleted file mode 100644 index 340174469..000000000 --- a/api/api/ml.evaluate_data_frame.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlEvaluateDataFrame (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.evaluate_data_frame request - * Evaluates the data frame analytics for an annotated index. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/evaluate-dfanalytics.html - */ - return function mlEvaluateDataFrame (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'data_frame' + '/' + '_evaluate' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlEvaluateDataFrame diff --git a/api/api/ml.explain_data_frame_analytics.js b/api/api/ml.explain_data_frame_analytics.js deleted file mode 100644 index 91968aebb..000000000 --- a/api/api/ml.explain_data_frame_analytics.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlExplainDataFrameAnalytics (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.explain_data_frame_analytics request - * Explains a data frame analytics config. - * http://www.elastic.co/guide/en/elasticsearch/reference/current/explain-dfanalytics.html - */ - return function mlExplainDataFrameAnalytics (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((id) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + '/' + '_explain' - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + '_explain' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlExplainDataFrameAnalytics diff --git a/api/api/ml.find_file_structure.js b/api/api/ml.find_file_structure.js deleted file mode 100644 index 244bf367d..000000000 --- a/api/api/ml.find_file_structure.js +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlFindFileStructure (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'lines_to_sample', - 'line_merge_size_limit', - 'timeout', - 'charset', - 'format', - 'has_header_row', - 'column_names', - 'delimiter', - 'quote', - 'should_trim_fields', - 'grok_pattern', - 'timestamp_field', - 'timestamp_format', - 'explain' - ] - - const snakeCase = { - linesToSample: 'lines_to_sample', - lineMergeSizeLimit: 'line_merge_size_limit', - hasHeaderRow: 'has_header_row', - columnNames: 'column_names', - shouldTrimFields: 'should_trim_fields', - grokPattern: 'grok_pattern', - timestampField: 'timestamp_field', - timestampFormat: 'timestamp_format' - - } - - /** - * Perform a ml.find_file_structure request - * Finds the structure of a text file. The text file must contain data that is suitable to be ingested into Elasticsearch. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-find-file-structure.html - */ - return function mlFindFileStructure (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'find_file_structure' - - // build request object - const request = { - method, - path, - bulkBody: body, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlFindFileStructure diff --git a/api/api/ml.flush_job.js b/api/api/ml.flush_job.js deleted file mode 100644 index 59acb4e3d..000000000 --- a/api/api/ml.flush_job.js +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlFlushJob (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'calc_interim', - 'start', - 'end', - 'advance_time', - 'skip_time' - ] - - const snakeCase = { - calcInterim: 'calc_interim', - advanceTime: 'advance_time', - skipTime: 'skip_time' - } - - /** - * Perform a ml.flush_job request - * Forces any buffered data to be processed by the job. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-flush-job.html - */ - return function mlFlushJob (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['job_id'] == null && params['jobId'] == null) { - const err = new ConfigurationError('Missing required parameter: job_id or jobId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_flush' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlFlushJob diff --git a/api/api/ml.forecast.js b/api/api/ml.forecast.js deleted file mode 100644 index 3d013827f..000000000 --- a/api/api/ml.forecast.js +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlForecast (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'duration', - 'expires_in', - 'max_model_memory' - ] - - const snakeCase = { - expiresIn: 'expires_in', - maxModelMemory: 'max_model_memory' - } - - /** - * Perform a ml.forecast request - * Predicts the future behavior of a time series by using its historical behavior. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-forecast.html - */ - return function mlForecast (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['job_id'] == null && params['jobId'] == null) { - const err = new ConfigurationError('Missing required parameter: job_id or jobId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_forecast' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlForecast diff --git a/api/api/ml.get_buckets.js b/api/api/ml.get_buckets.js deleted file mode 100644 index 50fd3d93b..000000000 --- a/api/api/ml.get_buckets.js +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlGetBuckets (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'expand', - 'exclude_interim', - 'from', - 'size', - 'start', - 'end', - 'anomaly_score', - 'sort', - 'desc' - ] - - const snakeCase = { - excludeInterim: 'exclude_interim', - anomalyScore: 'anomaly_score' - - } - - /** - * Perform a ml.get_buckets request - * Retrieves anomaly detection job results for one or more buckets. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-bucket.html - */ - return function mlGetBuckets (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['job_id'] == null && params['jobId'] == null) { - const err = new ConfigurationError('Missing required parameter: job_id or jobId') - return handleError(err, callback) - } - - // check required url components - if (params['timestamp'] != null && ((params['job_id'] == null && params['jobId'] == null))) { - const err = new ConfigurationError('Missing required parameter of the url: job_id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, timestamp, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((job_id || jobId) != null && (timestamp) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'buckets' + '/' + encodeURIComponent(timestamp) - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'buckets' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlGetBuckets diff --git a/api/api/ml.get_calendar_events.js b/api/api/ml.get_calendar_events.js deleted file mode 100644 index 96cee1ae8..000000000 --- a/api/api/ml.get_calendar_events.js +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlGetCalendarEvents (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'job_id', - 'start', - 'end', - 'from', - 'size' - ] - - const snakeCase = { - jobId: 'job_id' - - } - - /** - * Perform a ml.get_calendar_events request - * Retrieves information about the scheduled events in calendars. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-calendar-event.html - */ - return function mlGetCalendarEvents (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['calendar_id'] == null && params['calendarId'] == null) { - const err = new ConfigurationError('Missing required parameter: calendar_id or calendarId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, calendarId, calendar_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'events' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlGetCalendarEvents diff --git a/api/api/ml.get_calendars.js b/api/api/ml.get_calendars.js deleted file mode 100644 index 6d21ec955..000000000 --- a/api/api/ml.get_calendars.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlGetCalendars (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'from', - 'size' - ] - - const snakeCase = { - - } - - /** - * Perform a ml.get_calendars request - * Retrieves configuration information for calendars. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-calendar.html - */ - return function mlGetCalendars (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, calendarId, calendar_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((calendar_id || calendarId) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_ml' + '/' + 'calendars' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlGetCalendars diff --git a/api/api/ml.get_categories.js b/api/api/ml.get_categories.js deleted file mode 100644 index 48f0ffee2..000000000 --- a/api/api/ml.get_categories.js +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlGetCategories (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'from', - 'size', - 'partition_field_value' - ] - - const snakeCase = { - partitionFieldValue: 'partition_field_value' - } - - /** - * Perform a ml.get_categories request - * Retrieves anomaly detection job results for one or more categories. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-category.html - */ - return function mlGetCategories (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['job_id'] == null && params['jobId'] == null) { - const err = new ConfigurationError('Missing required parameter: job_id or jobId') - return handleError(err, callback) - } - - // check required url components - if ((params['category_id'] != null || params['categoryId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { - const err = new ConfigurationError('Missing required parameter of the url: job_id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, categoryId, category_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((job_id || jobId) != null && (category_id || categoryId) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'categories' + '/' + encodeURIComponent(category_id || categoryId) - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'categories' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlGetCategories diff --git a/api/api/ml.get_data_frame_analytics.js b/api/api/ml.get_data_frame_analytics.js deleted file mode 100644 index f5af1325f..000000000 --- a/api/api/ml.get_data_frame_analytics.js +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlGetDataFrameAnalytics (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'allow_no_match', - 'from', - 'size' - ] - - const snakeCase = { - allowNoMatch: 'allow_no_match' - - } - - /** - * Perform a ml.get_data_frame_analytics request - * Retrieves configuration information for data frame analytics jobs. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/get-dfanalytics.html - */ - return function mlGetDataFrameAnalytics (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((id) != null) { - if (method == null) method = 'GET' - path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) - } else { - if (method == null) method = 'GET' - path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlGetDataFrameAnalytics diff --git a/api/api/ml.get_data_frame_analytics_stats.js b/api/api/ml.get_data_frame_analytics_stats.js deleted file mode 100644 index 172fd3a09..000000000 --- a/api/api/ml.get_data_frame_analytics_stats.js +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlGetDataFrameAnalyticsStats (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'allow_no_match', - 'from', - 'size', - 'verbose' - ] - - const snakeCase = { - allowNoMatch: 'allow_no_match' - - } - - /** - * Perform a ml.get_data_frame_analytics_stats request - * Retrieves usage information for data frame analytics jobs. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/get-dfanalytics-stats.html - */ - return function mlGetDataFrameAnalyticsStats (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((id) != null) { - if (method == null) method = 'GET' - path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + '/' + '_stats' - } else { - if (method == null) method = 'GET' - path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + '_stats' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlGetDataFrameAnalyticsStats diff --git a/api/api/ml.get_datafeed_stats.js b/api/api/ml.get_datafeed_stats.js deleted file mode 100644 index 0c38f8c14..000000000 --- a/api/api/ml.get_datafeed_stats.js +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlGetDatafeedStats (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'allow_no_match', - 'allow_no_datafeeds' - ] - - const snakeCase = { - allowNoMatch: 'allow_no_match', - allowNoDatafeeds: 'allow_no_datafeeds' - } - - /** - * Perform a ml.get_datafeed_stats request - * Retrieves usage information for datafeeds. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed-stats.html - */ - return function mlGetDatafeedStats (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, datafeedId, datafeed_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((datafeed_id || datafeedId) != null) { - if (method == null) method = 'GET' - path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_stats' - } else { - if (method == null) method = 'GET' - path = '/' + '_ml' + '/' + 'datafeeds' + '/' + '_stats' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlGetDatafeedStats diff --git a/api/api/ml.get_datafeeds.js b/api/api/ml.get_datafeeds.js deleted file mode 100644 index e3bde8f09..000000000 --- a/api/api/ml.get_datafeeds.js +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlGetDatafeeds (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'allow_no_match', - 'allow_no_datafeeds' - ] - - const snakeCase = { - allowNoMatch: 'allow_no_match', - allowNoDatafeeds: 'allow_no_datafeeds' - } - - /** - * Perform a ml.get_datafeeds request - * Retrieves configuration information for datafeeds. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed.html - */ - return function mlGetDatafeeds (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, datafeedId, datafeed_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((datafeed_id || datafeedId) != null) { - if (method == null) method = 'GET' - path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) - } else { - if (method == null) method = 'GET' - path = '/' + '_ml' + '/' + 'datafeeds' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlGetDatafeeds diff --git a/api/api/ml.get_filters.js b/api/api/ml.get_filters.js deleted file mode 100644 index 0c51f6a4c..000000000 --- a/api/api/ml.get_filters.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlGetFilters (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'from', - 'size' - ] - - const snakeCase = { - - } - - /** - * Perform a ml.get_filters request - * Retrieves filters. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-filter.html - */ - return function mlGetFilters (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, filterId, filter_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((filter_id || filterId) != null) { - if (method == null) method = 'GET' - path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(filter_id || filterId) - } else { - if (method == null) method = 'GET' - path = '/' + '_ml' + '/' + 'filters' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlGetFilters diff --git a/api/api/ml.get_influencers.js b/api/api/ml.get_influencers.js deleted file mode 100644 index b2ec85a79..000000000 --- a/api/api/ml.get_influencers.js +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlGetInfluencers (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'exclude_interim', - 'from', - 'size', - 'start', - 'end', - 'influencer_score', - 'sort', - 'desc' - ] - - const snakeCase = { - excludeInterim: 'exclude_interim', - influencerScore: 'influencer_score' - - } - - /** - * Perform a ml.get_influencers request - * Retrieves anomaly detection job results for one or more influencers. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-influencer.html - */ - return function mlGetInfluencers (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['job_id'] == null && params['jobId'] == null) { - const err = new ConfigurationError('Missing required parameter: job_id or jobId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'influencers' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlGetInfluencers diff --git a/api/api/ml.get_job_stats.js b/api/api/ml.get_job_stats.js deleted file mode 100644 index 10759b68b..000000000 --- a/api/api/ml.get_job_stats.js +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlGetJobStats (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'allow_no_match', - 'allow_no_jobs' - ] - - const snakeCase = { - allowNoMatch: 'allow_no_match', - allowNoJobs: 'allow_no_jobs' - } - - /** - * Perform a ml.get_job_stats request - * Retrieves usage information for anomaly detection jobs. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-stats.html - */ - return function mlGetJobStats (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((job_id || jobId) != null) { - if (method == null) method = 'GET' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_stats' - } else { - if (method == null) method = 'GET' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_stats' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlGetJobStats diff --git a/api/api/ml.get_jobs.js b/api/api/ml.get_jobs.js deleted file mode 100644 index d49486d0c..000000000 --- a/api/api/ml.get_jobs.js +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlGetJobs (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'allow_no_match', - 'allow_no_jobs' - ] - - const snakeCase = { - allowNoMatch: 'allow_no_match', - allowNoJobs: 'allow_no_jobs' - } - - /** - * Perform a ml.get_jobs request - * Retrieves configuration information for anomaly detection jobs. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job.html - */ - return function mlGetJobs (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((job_id || jobId) != null) { - if (method == null) method = 'GET' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) - } else { - if (method == null) method = 'GET' - path = '/' + '_ml' + '/' + 'anomaly_detectors' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlGetJobs diff --git a/api/api/ml.get_model_snapshots.js b/api/api/ml.get_model_snapshots.js deleted file mode 100644 index 35a04122e..000000000 --- a/api/api/ml.get_model_snapshots.js +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlGetModelSnapshots (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'from', - 'size', - 'start', - 'end', - 'sort', - 'desc' - ] - - const snakeCase = { - - } - - /** - * Perform a ml.get_model_snapshots request - * Retrieves information about model snapshots. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-snapshot.html - */ - return function mlGetModelSnapshots (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['job_id'] == null && params['jobId'] == null) { - const err = new ConfigurationError('Missing required parameter: job_id or jobId') - return handleError(err, callback) - } - - // check required url components - if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { - const err = new ConfigurationError('Missing required parameter of the url: job_id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, snapshotId, snapshot_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((job_id || jobId) != null && (snapshot_id || snapshotId) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + '/' + encodeURIComponent(snapshot_id || snapshotId) - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlGetModelSnapshots diff --git a/api/api/ml.get_overall_buckets.js b/api/api/ml.get_overall_buckets.js deleted file mode 100644 index 9b40879d0..000000000 --- a/api/api/ml.get_overall_buckets.js +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlGetOverallBuckets (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'top_n', - 'bucket_span', - 'overall_score', - 'exclude_interim', - 'start', - 'end', - 'allow_no_match', - 'allow_no_jobs' - ] - - const snakeCase = { - topN: 'top_n', - bucketSpan: 'bucket_span', - overallScore: 'overall_score', - excludeInterim: 'exclude_interim', - allowNoMatch: 'allow_no_match', - allowNoJobs: 'allow_no_jobs' - } - - /** - * Perform a ml.get_overall_buckets request - * Retrieves overall bucket results that summarize the bucket results of multiple anomaly detection jobs. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-overall-buckets.html - */ - return function mlGetOverallBuckets (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['job_id'] == null && params['jobId'] == null) { - const err = new ConfigurationError('Missing required parameter: job_id or jobId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'overall_buckets' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlGetOverallBuckets diff --git a/api/api/ml.get_records.js b/api/api/ml.get_records.js deleted file mode 100644 index 6b705f197..000000000 --- a/api/api/ml.get_records.js +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlGetRecords (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'exclude_interim', - 'from', - 'size', - 'start', - 'end', - 'record_score', - 'sort', - 'desc' - ] - - const snakeCase = { - excludeInterim: 'exclude_interim', - recordScore: 'record_score' - - } - - /** - * Perform a ml.get_records request - * Retrieves anomaly records for an anomaly detection job. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-record.html - */ - return function mlGetRecords (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['job_id'] == null && params['jobId'] == null) { - const err = new ConfigurationError('Missing required parameter: job_id or jobId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'records' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlGetRecords diff --git a/api/api/ml.get_trained_models.js b/api/api/ml.get_trained_models.js deleted file mode 100644 index 68e94f6d5..000000000 --- a/api/api/ml.get_trained_models.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlGetTrainedModels (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'allow_no_match', - 'include_model_definition', - 'decompress_definition', - 'from', - 'size', - 'tags', - 'for_export' - ] - - const snakeCase = { - allowNoMatch: 'allow_no_match', - includeModelDefinition: 'include_model_definition', - decompressDefinition: 'decompress_definition', - forExport: 'for_export' - } - - /** - * Perform a ml.get_trained_models request - * Retrieves configuration information for a trained inference model. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/get-inference.html - */ - return function mlGetTrainedModels (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, modelId, model_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((model_id || modelId) != null) { - if (method == null) method = 'GET' - path = '/' + '_ml' + '/' + 'inference' + '/' + encodeURIComponent(model_id || modelId) - } else { - if (method == null) method = 'GET' - path = '/' + '_ml' + '/' + 'inference' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlGetTrainedModels diff --git a/api/api/ml.get_trained_models_stats.js b/api/api/ml.get_trained_models_stats.js deleted file mode 100644 index b5769a5cb..000000000 --- a/api/api/ml.get_trained_models_stats.js +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlGetTrainedModelsStats (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'allow_no_match', - 'from', - 'size' - ] - - const snakeCase = { - allowNoMatch: 'allow_no_match' - - } - - /** - * Perform a ml.get_trained_models_stats request - * Retrieves usage information for trained inference models. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/get-inference-stats.html - */ - return function mlGetTrainedModelsStats (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, modelId, model_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((model_id || modelId) != null) { - if (method == null) method = 'GET' - path = '/' + '_ml' + '/' + 'inference' + '/' + encodeURIComponent(model_id || modelId) + '/' + '_stats' - } else { - if (method == null) method = 'GET' - path = '/' + '_ml' + '/' + 'inference' + '/' + '_stats' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlGetTrainedModelsStats diff --git a/api/api/ml.info.js b/api/api/ml.info.js deleted file mode 100644 index 58b36f195..000000000 --- a/api/api/ml.info.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlInfo (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.info request - * Returns defaults and limits used by machine learning. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/get-ml-info.html - */ - return function mlInfo (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_ml' + '/' + 'info' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlInfo diff --git a/api/api/ml.js b/api/api/ml.js new file mode 100644 index 000000000..1943cb0a7 --- /dev/null +++ b/api/api/ml.js @@ -0,0 +1,1842 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['allow_no_match', 'allow_no_jobs', 'force', 'timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'requests_per_second', 'allow_no_forecasts', 'wait_for_completion', 'lines_to_sample', 'line_merge_size_limit', 'charset', 'format', 'has_header_row', 'column_names', 'delimiter', 'quote', 'should_trim_fields', 'grok_pattern', 'timestamp_field', 'timestamp_format', 'explain', 'calc_interim', 'start', 'end', 'advance_time', 'skip_time', 'duration', 'expires_in', 'max_model_memory', 'expand', 'exclude_interim', 'from', 'size', 'anomaly_score', 'sort', 'desc', 'job_id', 'partition_field_value', 'verbose', 'allow_no_datafeeds', 'influencer_score', 'top_n', 'bucket_span', 'overall_score', 'record_score', 'include', 'decompress_definition', 'tags', 'for_export', 'reset_start', 'reset_end', 'ignore_unavailable', 'allow_no_indices', 'ignore_throttled', 'expand_wildcards', 'delete_intervening_results', 'enabled'] +const snakeCase = { allowNoMatch: 'allow_no_match', allowNoJobs: 'allow_no_jobs', errorTrace: 'error_trace', filterPath: 'filter_path', requestsPerSecond: 'requests_per_second', allowNoForecasts: 'allow_no_forecasts', waitForCompletion: 'wait_for_completion', linesToSample: 'lines_to_sample', lineMergeSizeLimit: 'line_merge_size_limit', hasHeaderRow: 'has_header_row', columnNames: 'column_names', shouldTrimFields: 'should_trim_fields', grokPattern: 'grok_pattern', timestampField: 'timestamp_field', timestampFormat: 'timestamp_format', calcInterim: 'calc_interim', advanceTime: 'advance_time', skipTime: 'skip_time', expiresIn: 'expires_in', maxModelMemory: 'max_model_memory', excludeInterim: 'exclude_interim', anomalyScore: 'anomaly_score', jobId: 'job_id', partitionFieldValue: 'partition_field_value', allowNoDatafeeds: 'allow_no_datafeeds', influencerScore: 'influencer_score', topN: 'top_n', bucketSpan: 'bucket_span', overallScore: 'overall_score', recordScore: 'record_score', decompressDefinition: 'decompress_definition', forExport: 'for_export', resetStart: 'reset_start', resetEnd: 'reset_end', ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', ignoreThrottled: 'ignore_throttled', expandWildcards: 'expand_wildcards', deleteInterveningResults: 'delete_intervening_results' } + +function MlApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +MlApi.prototype.closeJob = function mlCloseJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_close' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteCalendar = function mlDeleteCalendarApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) + } + + var { method, body, calendarId, calendar_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteCalendarEvent = function mlDeleteCalendarEventApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) + } + if (params['event_id'] == null && params['eventId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: event_id or eventId') + return handleError(err, callback) + } + + // check required url components + if ((params['event_id'] != null || params['eventId'] != null) && ((params['calendar_id'] == null && params['calendarId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: calendar_id') + return handleError(err, callback) + } + + var { method, body, calendarId, calendar_id, eventId, event_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'events' + '/' + encodeURIComponent(event_id || eventId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteCalendarJob = function mlDeleteCalendarJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) + } + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + // check required url components + if ((params['job_id'] != null || params['jobId'] != null) && ((params['calendar_id'] == null && params['calendarId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: calendar_id') + return handleError(err, callback) + } + + var { method, body, calendarId, calendar_id, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'jobs' + '/' + encodeURIComponent(job_id || jobId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteDataFrameAnalytics = function mlDeleteDataFrameAnalyticsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteDatafeed = function mlDeleteDatafeedApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) + } + + var { method, body, datafeedId, datafeed_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteExpiredData = function mlDeleteExpiredDataApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((job_id || jobId) != null) { + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + '_delete_expired_data' + '/' + encodeURIComponent(job_id || jobId) + } else { + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + '_delete_expired_data' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteFilter = function mlDeleteFilterApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['filter_id'] == null && params['filterId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: filter_id or filterId') + return handleError(err, callback) + } + + var { method, body, filterId, filter_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(filter_id || filterId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteForecast = function mlDeleteForecastApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + // check required url components + if ((params['forecast_id'] != null || params['forecastId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: job_id') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, forecastId, forecast_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((job_id || jobId) != null && (forecast_id || forecastId) != null) { + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_forecast' + '/' + encodeURIComponent(forecast_id || forecastId) + } else { + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_forecast' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteJob = function mlDeleteJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteModelSnapshot = function mlDeleteModelSnapshotApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params['snapshot_id'] == null && params['snapshotId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: snapshot_id or snapshotId') + return handleError(err, callback) + } + + // check required url components + if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: job_id') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, snapshotId, snapshot_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + '/' + encodeURIComponent(snapshot_id || snapshotId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.deleteTrainedModel = function mlDeleteTrainedModelApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['model_id'] == null && params['modelId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: model_id or modelId') + return handleError(err, callback) + } + + var { method, body, modelId, model_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_ml' + '/' + 'inference' + '/' + encodeURIComponent(model_id || modelId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.estimateModelMemory = function mlEstimateModelMemoryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_estimate_model_memory' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.evaluateDataFrame = function mlEvaluateDataFrameApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + '_evaluate' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.explainDataFrameAnalytics = function mlExplainDataFrameAnalyticsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + '/' + '_explain' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + '_explain' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.findFileStructure = function mlFindFileStructureApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'find_file_structure' + + // build request object + const request = { + method, + path, + bulkBody: body, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.flushJob = function mlFlushJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_flush' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.forecast = function mlForecastApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_forecast' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getBuckets = function mlGetBucketsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + // check required url components + if (params['timestamp'] != null && ((params['job_id'] == null && params['jobId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: job_id') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, timestamp, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((job_id || jobId) != null && (timestamp) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'buckets' + '/' + encodeURIComponent(timestamp) + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'buckets' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getCalendarEvents = function mlGetCalendarEventsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) + } + + var { method, body, calendarId, calendar_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'events' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getCalendars = function mlGetCalendarsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, calendarId, calendar_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((calendar_id || calendarId) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'calendars' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getCategories = function mlGetCategoriesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + // check required url components + if ((params['category_id'] != null || params['categoryId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: job_id') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, categoryId, category_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((job_id || jobId) != null && (category_id || categoryId) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'categories' + '/' + encodeURIComponent(category_id || categoryId) + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'categories' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getDataFrameAnalytics = function mlGetDataFrameAnalyticsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null) { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + } else { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getDataFrameAnalyticsStats = function mlGetDataFrameAnalyticsStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null) { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + '/' + '_stats' + } else { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + '_stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getDatafeedStats = function mlGetDatafeedStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, datafeedId, datafeed_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((datafeed_id || datafeedId) != null) { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_stats' + } else { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + '_stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getDatafeeds = function mlGetDatafeedsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, datafeedId, datafeed_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((datafeed_id || datafeedId) != null) { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + } else { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'datafeeds' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getFilters = function mlGetFiltersApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, filterId, filter_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((filter_id || filterId) != null) { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(filter_id || filterId) + } else { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'filters' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getInfluencers = function mlGetInfluencersApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'influencers' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getJobStats = function mlGetJobStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((job_id || jobId) != null) { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_stats' + } else { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getJobs = function mlGetJobsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((job_id || jobId) != null) { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + } else { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getModelSnapshots = function mlGetModelSnapshotsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + // check required url components + if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: job_id') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, snapshotId, snapshot_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((job_id || jobId) != null && (snapshot_id || snapshotId) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + '/' + encodeURIComponent(snapshot_id || snapshotId) + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getOverallBuckets = function mlGetOverallBucketsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'overall_buckets' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getRecords = function mlGetRecordsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'results' + '/' + 'records' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getTrainedModels = function mlGetTrainedModelsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, modelId, model_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((model_id || modelId) != null) { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'inference' + '/' + encodeURIComponent(model_id || modelId) + } else { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'inference' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.getTrainedModelsStats = function mlGetTrainedModelsStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, modelId, model_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((model_id || modelId) != null) { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'inference' + '/' + encodeURIComponent(model_id || modelId) + '/' + '_stats' + } else { + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'inference' + '/' + '_stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.info = function mlInfoApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'info' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.openJob = function mlOpenJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_open' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.postCalendarEvents = function mlPostCalendarEventsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, calendarId, calendar_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'events' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.postData = function mlPostDataApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_data' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.previewDatafeed = function mlPreviewDatafeedApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) + } + + var { method, body, datafeedId, datafeed_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_preview' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.putCalendar = function mlPutCalendarApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) + } + + var { method, body, calendarId, calendar_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.putCalendarJob = function mlPutCalendarJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['calendar_id'] == null && params['calendarId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: calendar_id or calendarId') + return handleError(err, callback) + } + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + + // check required url components + if ((params['job_id'] != null || params['jobId'] != null) && ((params['calendar_id'] == null && params['calendarId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: calendar_id') + return handleError(err, callback) + } + + var { method, body, calendarId, calendar_id, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'jobs' + '/' + encodeURIComponent(job_id || jobId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.putDataFrameAnalytics = function mlPutDataFrameAnalyticsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.putDatafeed = function mlPutDatafeedApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, datafeedId, datafeed_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.putFilter = function mlPutFilterApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['filter_id'] == null && params['filterId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: filter_id or filterId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, filterId, filter_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(filter_id || filterId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.putJob = function mlPutJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.putTrainedModel = function mlPutTrainedModelApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['model_id'] == null && params['modelId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: model_id or modelId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, modelId, model_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_ml' + '/' + 'inference' + '/' + encodeURIComponent(model_id || modelId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.revertModelSnapshot = function mlRevertModelSnapshotApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params['snapshot_id'] == null && params['snapshotId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: snapshot_id or snapshotId') + return handleError(err, callback) + } + + // check required url components + if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: job_id') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, snapshotId, snapshot_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + '/' + encodeURIComponent(snapshot_id || snapshotId) + '/' + '_revert' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.setUpgradeMode = function mlSetUpgradeModeApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'set_upgrade_mode' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.startDataFrameAnalytics = function mlStartDataFrameAnalyticsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + '/' + '_start' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.startDatafeed = function mlStartDatafeedApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) + } + + var { method, body, datafeedId, datafeed_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_start' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.stopDataFrameAnalytics = function mlStopDataFrameAnalyticsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + '/' + '_stop' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.stopDatafeed = function mlStopDatafeedApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) + } + + var { method, body, datafeedId, datafeed_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_stop' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.updateDataFrameAnalytics = function mlUpdateDataFrameAnalyticsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + '/' + '_update' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.updateDatafeed = function mlUpdateDatafeedApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['datafeed_id'] == null && params['datafeedId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: datafeed_id or datafeedId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, datafeedId, datafeed_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_update' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.updateFilter = function mlUpdateFilterApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['filter_id'] == null && params['filterId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: filter_id or filterId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, filterId, filter_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(filter_id || filterId) + '/' + '_update' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.updateJob = function mlUpdateJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_update' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.updateModelSnapshot = function mlUpdateModelSnapshotApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['job_id'] == null && params['jobId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: job_id or jobId') + return handleError(err, callback) + } + if (params['snapshot_id'] == null && params['snapshotId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: snapshot_id or snapshotId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + // check required url components + if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: job_id') + return handleError(err, callback) + } + + var { method, body, jobId, job_id, snapshotId, snapshot_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + '/' + encodeURIComponent(snapshot_id || snapshotId) + '/' + '_update' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.validate = function mlValidateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_validate' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +MlApi.prototype.validateDetector = function mlValidateDetectorApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_validate' + '/' + 'detector' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(MlApi.prototype, { + close_job: { get () { return this.closeJob } }, + delete_calendar: { get () { return this.deleteCalendar } }, + delete_calendar_event: { get () { return this.deleteCalendarEvent } }, + delete_calendar_job: { get () { return this.deleteCalendarJob } }, + delete_data_frame_analytics: { get () { return this.deleteDataFrameAnalytics } }, + delete_datafeed: { get () { return this.deleteDatafeed } }, + delete_expired_data: { get () { return this.deleteExpiredData } }, + delete_filter: { get () { return this.deleteFilter } }, + delete_forecast: { get () { return this.deleteForecast } }, + delete_job: { get () { return this.deleteJob } }, + delete_model_snapshot: { get () { return this.deleteModelSnapshot } }, + delete_trained_model: { get () { return this.deleteTrainedModel } }, + estimate_model_memory: { get () { return this.estimateModelMemory } }, + evaluate_data_frame: { get () { return this.evaluateDataFrame } }, + explain_data_frame_analytics: { get () { return this.explainDataFrameAnalytics } }, + find_file_structure: { get () { return this.findFileStructure } }, + flush_job: { get () { return this.flushJob } }, + get_buckets: { get () { return this.getBuckets } }, + get_calendar_events: { get () { return this.getCalendarEvents } }, + get_calendars: { get () { return this.getCalendars } }, + get_categories: { get () { return this.getCategories } }, + get_data_frame_analytics: { get () { return this.getDataFrameAnalytics } }, + get_data_frame_analytics_stats: { get () { return this.getDataFrameAnalyticsStats } }, + get_datafeed_stats: { get () { return this.getDatafeedStats } }, + get_datafeeds: { get () { return this.getDatafeeds } }, + get_filters: { get () { return this.getFilters } }, + get_influencers: { get () { return this.getInfluencers } }, + get_job_stats: { get () { return this.getJobStats } }, + get_jobs: { get () { return this.getJobs } }, + get_model_snapshots: { get () { return this.getModelSnapshots } }, + get_overall_buckets: { get () { return this.getOverallBuckets } }, + get_records: { get () { return this.getRecords } }, + get_trained_models: { get () { return this.getTrainedModels } }, + get_trained_models_stats: { get () { return this.getTrainedModelsStats } }, + open_job: { get () { return this.openJob } }, + post_calendar_events: { get () { return this.postCalendarEvents } }, + post_data: { get () { return this.postData } }, + preview_datafeed: { get () { return this.previewDatafeed } }, + put_calendar: { get () { return this.putCalendar } }, + put_calendar_job: { get () { return this.putCalendarJob } }, + put_data_frame_analytics: { get () { return this.putDataFrameAnalytics } }, + put_datafeed: { get () { return this.putDatafeed } }, + put_filter: { get () { return this.putFilter } }, + put_job: { get () { return this.putJob } }, + put_trained_model: { get () { return this.putTrainedModel } }, + revert_model_snapshot: { get () { return this.revertModelSnapshot } }, + set_upgrade_mode: { get () { return this.setUpgradeMode } }, + start_data_frame_analytics: { get () { return this.startDataFrameAnalytics } }, + start_datafeed: { get () { return this.startDatafeed } }, + stop_data_frame_analytics: { get () { return this.stopDataFrameAnalytics } }, + stop_datafeed: { get () { return this.stopDatafeed } }, + update_data_frame_analytics: { get () { return this.updateDataFrameAnalytics } }, + update_datafeed: { get () { return this.updateDatafeed } }, + update_filter: { get () { return this.updateFilter } }, + update_job: { get () { return this.updateJob } }, + update_model_snapshot: { get () { return this.updateModelSnapshot } }, + validate_detector: { get () { return this.validateDetector } } +}) + +module.exports = MlApi diff --git a/api/api/ml.open_job.js b/api/api/ml.open_job.js deleted file mode 100644 index bcfeeab87..000000000 --- a/api/api/ml.open_job.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlOpenJob (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.open_job request - * Opens one or more anomaly detection jobs. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html - */ - return function mlOpenJob (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['job_id'] == null && params['jobId'] == null) { - const err = new ConfigurationError('Missing required parameter: job_id or jobId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_open' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlOpenJob diff --git a/api/api/ml.post_calendar_events.js b/api/api/ml.post_calendar_events.js deleted file mode 100644 index 36d4f5555..000000000 --- a/api/api/ml.post_calendar_events.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlPostCalendarEvents (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.post_calendar_events request - * Posts scheduled events in a calendar. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-calendar-event.html - */ - return function mlPostCalendarEvents (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['calendar_id'] == null && params['calendarId'] == null) { - const err = new ConfigurationError('Missing required parameter: calendar_id or calendarId') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, calendarId, calendar_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'events' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlPostCalendarEvents diff --git a/api/api/ml.post_data.js b/api/api/ml.post_data.js deleted file mode 100644 index add1be8b9..000000000 --- a/api/api/ml.post_data.js +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlPostData (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'reset_start', - 'reset_end' - ] - - const snakeCase = { - resetStart: 'reset_start', - resetEnd: 'reset_end' - } - - /** - * Perform a ml.post_data request - * Sends data to an anomaly detection job for analysis. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-data.html - */ - return function mlPostData (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['job_id'] == null && params['jobId'] == null) { - const err = new ConfigurationError('Missing required parameter: job_id or jobId') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_data' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlPostData diff --git a/api/api/ml.preview_datafeed.js b/api/api/ml.preview_datafeed.js deleted file mode 100644 index 81fe13333..000000000 --- a/api/api/ml.preview_datafeed.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlPreviewDatafeed (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.preview_datafeed request - * Previews a datafeed. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html - */ - return function mlPreviewDatafeed (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['datafeed_id'] == null && params['datafeedId'] == null) { - const err = new ConfigurationError('Missing required parameter: datafeed_id or datafeedId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, datafeedId, datafeed_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_preview' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlPreviewDatafeed diff --git a/api/api/ml.put_calendar.js b/api/api/ml.put_calendar.js deleted file mode 100644 index 439e94bba..000000000 --- a/api/api/ml.put_calendar.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlPutCalendar (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.put_calendar request - * Instantiates a calendar. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-calendar.html - */ - return function mlPutCalendar (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['calendar_id'] == null && params['calendarId'] == null) { - const err = new ConfigurationError('Missing required parameter: calendar_id or calendarId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, calendarId, calendar_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlPutCalendar diff --git a/api/api/ml.put_calendar_job.js b/api/api/ml.put_calendar_job.js deleted file mode 100644 index 8e95b0c0f..000000000 --- a/api/api/ml.put_calendar_job.js +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlPutCalendarJob (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.put_calendar_job request - * Adds an anomaly detection job to a calendar. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-calendar-job.html - */ - return function mlPutCalendarJob (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['calendar_id'] == null && params['calendarId'] == null) { - const err = new ConfigurationError('Missing required parameter: calendar_id or calendarId') - return handleError(err, callback) - } - if (params['job_id'] == null && params['jobId'] == null) { - const err = new ConfigurationError('Missing required parameter: job_id or jobId') - return handleError(err, callback) - } - - // check required url components - if ((params['job_id'] != null || params['jobId'] != null) && ((params['calendar_id'] == null && params['calendarId'] == null))) { - const err = new ConfigurationError('Missing required parameter of the url: calendar_id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, calendarId, calendar_id, jobId, job_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(calendar_id || calendarId) + '/' + 'jobs' + '/' + encodeURIComponent(job_id || jobId) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlPutCalendarJob diff --git a/api/api/ml.put_data_frame_analytics.js b/api/api/ml.put_data_frame_analytics.js deleted file mode 100644 index 58b2f9d15..000000000 --- a/api/api/ml.put_data_frame_analytics.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlPutDataFrameAnalytics (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.put_data_frame_analytics request - * Instantiates a data frame analytics job. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/put-dfanalytics.html - */ - return function mlPutDataFrameAnalytics (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlPutDataFrameAnalytics diff --git a/api/api/ml.put_datafeed.js b/api/api/ml.put_datafeed.js deleted file mode 100644 index f6daf211f..000000000 --- a/api/api/ml.put_datafeed.js +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlPutDatafeed (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'ignore_unavailable', - 'allow_no_indices', - 'ignore_throttled', - 'expand_wildcards' - ] - - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - ignoreThrottled: 'ignore_throttled', - expandWildcards: 'expand_wildcards' - } - - /** - * Perform a ml.put_datafeed request - * Instantiates a datafeed. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-datafeed.html - */ - return function mlPutDatafeed (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['datafeed_id'] == null && params['datafeedId'] == null) { - const err = new ConfigurationError('Missing required parameter: datafeed_id or datafeedId') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, datafeedId, datafeed_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlPutDatafeed diff --git a/api/api/ml.put_filter.js b/api/api/ml.put_filter.js deleted file mode 100644 index b86b0a90f..000000000 --- a/api/api/ml.put_filter.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlPutFilter (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.put_filter request - * Instantiates a filter. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-filter.html - */ - return function mlPutFilter (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['filter_id'] == null && params['filterId'] == null) { - const err = new ConfigurationError('Missing required parameter: filter_id or filterId') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, filterId, filter_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(filter_id || filterId) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlPutFilter diff --git a/api/api/ml.put_job.js b/api/api/ml.put_job.js deleted file mode 100644 index 25561f777..000000000 --- a/api/api/ml.put_job.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlPutJob (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.put_job request - * Instantiates an anomaly detection job. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html - */ - return function mlPutJob (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['job_id'] == null && params['jobId'] == null) { - const err = new ConfigurationError('Missing required parameter: job_id or jobId') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlPutJob diff --git a/api/api/ml.put_trained_model.js b/api/api/ml.put_trained_model.js deleted file mode 100644 index 28b2e4061..000000000 --- a/api/api/ml.put_trained_model.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlPutTrainedModel (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.put_trained_model request - * Creates an inference trained model. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/put-inference.html - */ - return function mlPutTrainedModel (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['model_id'] == null && params['modelId'] == null) { - const err = new ConfigurationError('Missing required parameter: model_id or modelId') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, modelId, model_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_ml' + '/' + 'inference' + '/' + encodeURIComponent(model_id || modelId) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlPutTrainedModel diff --git a/api/api/ml.revert_model_snapshot.js b/api/api/ml.revert_model_snapshot.js deleted file mode 100644 index 26b7cd038..000000000 --- a/api/api/ml.revert_model_snapshot.js +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlRevertModelSnapshot (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'delete_intervening_results' - ] - - const snakeCase = { - deleteInterveningResults: 'delete_intervening_results' - } - - /** - * Perform a ml.revert_model_snapshot request - * Reverts to a specific snapshot. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-revert-snapshot.html - */ - return function mlRevertModelSnapshot (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['job_id'] == null && params['jobId'] == null) { - const err = new ConfigurationError('Missing required parameter: job_id or jobId') - return handleError(err, callback) - } - if (params['snapshot_id'] == null && params['snapshotId'] == null) { - const err = new ConfigurationError('Missing required parameter: snapshot_id or snapshotId') - return handleError(err, callback) - } - - // check required url components - if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { - const err = new ConfigurationError('Missing required parameter of the url: job_id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, snapshotId, snapshot_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + '/' + encodeURIComponent(snapshot_id || snapshotId) + '/' + '_revert' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlRevertModelSnapshot diff --git a/api/api/ml.set_upgrade_mode.js b/api/api/ml.set_upgrade_mode.js deleted file mode 100644 index 1fe6038d5..000000000 --- a/api/api/ml.set_upgrade_mode.js +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlSetUpgradeMode (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'enabled', - 'timeout' - ] - - const snakeCase = { - - } - - /** - * Perform a ml.set_upgrade_mode request - * Sets a cluster wide upgrade_mode setting that prepares machine learning indices for an upgrade. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-set-upgrade-mode.html - */ - return function mlSetUpgradeMode (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'set_upgrade_mode' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlSetUpgradeMode diff --git a/api/api/ml.start_data_frame_analytics.js b/api/api/ml.start_data_frame_analytics.js deleted file mode 100644 index 605d89de3..000000000 --- a/api/api/ml.start_data_frame_analytics.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlStartDataFrameAnalytics (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'timeout' - ] - - const snakeCase = { - - } - - /** - * Perform a ml.start_data_frame_analytics request - * Starts a data frame analytics job. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/start-dfanalytics.html - */ - return function mlStartDataFrameAnalytics (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + '/' + '_start' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlStartDataFrameAnalytics diff --git a/api/api/ml.start_datafeed.js b/api/api/ml.start_datafeed.js deleted file mode 100644 index 815ddf9ac..000000000 --- a/api/api/ml.start_datafeed.js +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlStartDatafeed (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'start', - 'end', - 'timeout' - ] - - const snakeCase = { - - } - - /** - * Perform a ml.start_datafeed request - * Starts one or more datafeeds. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-start-datafeed.html - */ - return function mlStartDatafeed (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['datafeed_id'] == null && params['datafeedId'] == null) { - const err = new ConfigurationError('Missing required parameter: datafeed_id or datafeedId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, datafeedId, datafeed_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_start' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlStartDatafeed diff --git a/api/api/ml.stop_data_frame_analytics.js b/api/api/ml.stop_data_frame_analytics.js deleted file mode 100644 index 5c61d4968..000000000 --- a/api/api/ml.stop_data_frame_analytics.js +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlStopDataFrameAnalytics (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'allow_no_match', - 'force', - 'timeout' - ] - - const snakeCase = { - allowNoMatch: 'allow_no_match' - - } - - /** - * Perform a ml.stop_data_frame_analytics request - * Stops one or more data frame analytics jobs. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-dfanalytics.html - */ - return function mlStopDataFrameAnalytics (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + '/' + '_stop' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlStopDataFrameAnalytics diff --git a/api/api/ml.stop_datafeed.js b/api/api/ml.stop_datafeed.js deleted file mode 100644 index 022be927b..000000000 --- a/api/api/ml.stop_datafeed.js +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlStopDatafeed (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'allow_no_match', - 'allow_no_datafeeds', - 'force', - 'timeout' - ] - - const snakeCase = { - allowNoMatch: 'allow_no_match', - allowNoDatafeeds: 'allow_no_datafeeds' - - } - - /** - * Perform a ml.stop_datafeed request - * Stops one or more datafeeds. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-stop-datafeed.html - */ - return function mlStopDatafeed (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['datafeed_id'] == null && params['datafeedId'] == null) { - const err = new ConfigurationError('Missing required parameter: datafeed_id or datafeedId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, datafeedId, datafeed_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_stop' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlStopDatafeed diff --git a/api/api/ml.update_data_frame_analytics.js b/api/api/ml.update_data_frame_analytics.js deleted file mode 100644 index 27afffea7..000000000 --- a/api/api/ml.update_data_frame_analytics.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlUpdateDataFrameAnalytics (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.update_data_frame_analytics request - * Updates certain properties of a data frame analytics job. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/update-dfanalytics.html - */ - return function mlUpdateDataFrameAnalytics (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'data_frame' + '/' + 'analytics' + '/' + encodeURIComponent(id) + '/' + '_update' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlUpdateDataFrameAnalytics diff --git a/api/api/ml.update_datafeed.js b/api/api/ml.update_datafeed.js deleted file mode 100644 index 2eaba2c35..000000000 --- a/api/api/ml.update_datafeed.js +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlUpdateDatafeed (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'ignore_unavailable', - 'allow_no_indices', - 'ignore_throttled', - 'expand_wildcards' - ] - - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - ignoreThrottled: 'ignore_throttled', - expandWildcards: 'expand_wildcards' - } - - /** - * Perform a ml.update_datafeed request - * Updates certain properties of a datafeed. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-datafeed.html - */ - return function mlUpdateDatafeed (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['datafeed_id'] == null && params['datafeedId'] == null) { - const err = new ConfigurationError('Missing required parameter: datafeed_id or datafeedId') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, datafeedId, datafeed_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(datafeed_id || datafeedId) + '/' + '_update' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlUpdateDatafeed diff --git a/api/api/ml.update_filter.js b/api/api/ml.update_filter.js deleted file mode 100644 index e0954ac6e..000000000 --- a/api/api/ml.update_filter.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlUpdateFilter (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.update_filter request - * Updates the description of a filter, adds items, or removes items. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-filter.html - */ - return function mlUpdateFilter (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['filter_id'] == null && params['filterId'] == null) { - const err = new ConfigurationError('Missing required parameter: filter_id or filterId') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, filterId, filter_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(filter_id || filterId) + '/' + '_update' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlUpdateFilter diff --git a/api/api/ml.update_job.js b/api/api/ml.update_job.js deleted file mode 100644 index 09a465834..000000000 --- a/api/api/ml.update_job.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlUpdateJob (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.update_job request - * Updates certain properties of an anomaly detection job. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-job.html - */ - return function mlUpdateJob (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['job_id'] == null && params['jobId'] == null) { - const err = new ConfigurationError('Missing required parameter: job_id or jobId') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + '_update' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlUpdateJob diff --git a/api/api/ml.update_model_snapshot.js b/api/api/ml.update_model_snapshot.js deleted file mode 100644 index 5b42e5bfe..000000000 --- a/api/api/ml.update_model_snapshot.js +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlUpdateModelSnapshot (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.update_model_snapshot request - * Updates certain properties of a snapshot. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-snapshot.html - */ - return function mlUpdateModelSnapshot (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['job_id'] == null && params['jobId'] == null) { - const err = new ConfigurationError('Missing required parameter: job_id or jobId') - return handleError(err, callback) - } - if (params['snapshot_id'] == null && params['snapshotId'] == null) { - const err = new ConfigurationError('Missing required parameter: snapshot_id or snapshotId') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // check required url components - if ((params['snapshot_id'] != null || params['snapshotId'] != null) && ((params['job_id'] == null && params['jobId'] == null))) { - const err = new ConfigurationError('Missing required parameter of the url: job_id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, jobId, job_id, snapshotId, snapshot_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + '/' + 'model_snapshots' + '/' + encodeURIComponent(snapshot_id || snapshotId) + '/' + '_update' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlUpdateModelSnapshot diff --git a/api/api/ml.validate.js b/api/api/ml.validate.js deleted file mode 100644 index afb91108a..000000000 --- a/api/api/ml.validate.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlValidate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.validate request - * Validates an anomaly detection job. - * https://www.elastic.co/guide/en/machine-learning/current/ml-jobs.html - */ - return function mlValidate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_validate' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlValidate diff --git a/api/api/ml.validate_detector.js b/api/api/ml.validate_detector.js deleted file mode 100644 index f75c5d7d9..000000000 --- a/api/api/ml.validate_detector.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMlValidateDetector (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ml.validate_detector request - * Validates an anomaly detection detector. - * https://www.elastic.co/guide/en/machine-learning/current/ml-jobs.html - */ - return function mlValidateDetector (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_validate' + '/' + 'detector' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMlValidateDetector diff --git a/api/api/monitoring.bulk.js b/api/api/monitoring.bulk.js deleted file mode 100644 index ca0e6da01..000000000 --- a/api/api/monitoring.bulk.js +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildMonitoringBulk (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'system_id', - 'system_api_version', - 'interval' - ] - - const snakeCase = { - systemId: 'system_id', - systemApiVersion: 'system_api_version' - - } - - /** - * Perform a monitoring.bulk request - * Used by the monitoring features to send monitoring data. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/monitor-elasticsearch-cluster.html - */ - return function monitoringBulk (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, type, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((type) != null) { - if (method == null) method = 'POST' - path = '/' + '_monitoring' + '/' + encodeURIComponent(type) + '/' + 'bulk' - } else { - if (method == null) method = 'POST' - path = '/' + '_monitoring' + '/' + 'bulk' - } - - // build request object - const request = { - method, - path, - bulkBody: body, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildMonitoringBulk diff --git a/api/api/monitoring.js b/api/api/monitoring.js new file mode 100644 index 000000000..db24d5d4e --- /dev/null +++ b/api/api/monitoring.js @@ -0,0 +1,66 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['system_id', 'system_api_version', 'interval', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { systemId: 'system_id', systemApiVersion: 'system_api_version', errorTrace: 'error_trace', filterPath: 'filter_path' } + +function MonitoringApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +MonitoringApi.prototype.bulk = function monitoringBulkApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, type, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((type) != null) { + if (method == null) method = 'POST' + path = '/' + '_monitoring' + '/' + encodeURIComponent(type) + '/' + 'bulk' + } else { + if (method == null) method = 'POST' + path = '/' + '_monitoring' + '/' + 'bulk' + } + + // build request object + const request = { + method, + path, + bulkBody: body, + querystring + } + + return this.transport.request(request, options, callback) +} + +module.exports = MonitoringApi diff --git a/api/api/msearch.js b/api/api/msearch.js index 4afc1ea8e..b3b6ee13c 100644 --- a/api/api/msearch.js +++ b/api/api/msearch.js @@ -22,54 +22,23 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildMsearch (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['search_type', 'max_concurrent_searches', 'typed_keys', 'pre_filter_shard_size', 'max_concurrent_shard_requests', 'rest_total_hits_as_int', 'ccs_minimize_roundtrips', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { searchType: 'search_type', maxConcurrentSearches: 'max_concurrent_searches', typedKeys: 'typed_keys', preFilterShardSize: 'pre_filter_shard_size', maxConcurrentShardRequests: 'max_concurrent_shard_requests', restTotalHitsAsInt: 'rest_total_hits_as_int', ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'search_type', - 'max_concurrent_searches', - 'typed_keys', - 'pre_filter_shard_size', - 'max_concurrent_shard_requests', - 'rest_total_hits_as_int', - 'ccs_minimize_roundtrips', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function msearchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - searchType: 'search_type', - maxConcurrentSearches: 'max_concurrent_searches', - typedKeys: 'typed_keys', - preFilterShardSize: 'pre_filter_shard_size', - maxConcurrentShardRequests: 'max_concurrent_shard_requests', - restTotalHitsAsInt: 'rest_total_hits_as_int', - ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) } - /** - * Perform a msearch request - * Allows to execute several search operations in one request. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/search-multi-search.html - */ - return function msearch (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +<<<<<<< HEAD // check required parameters if (params['body'] == null) { const err = new ConfigurationError('Missing required parameter: body') @@ -117,10 +86,26 @@ function buildMsearch (opts) { bulkBody: body, querystring } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) +======= + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_msearch' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_msearch' } +>>>>>>> a064f0f3... Improve child performances (#1314) + + // build request object + const request = { + method, + path, + bulkBody: body, + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildMsearch +module.exports = msearchApi diff --git a/api/api/msearch_template.js b/api/api/msearch_template.js index 7617b9ee1..54dda4c77 100644 --- a/api/api/msearch_template.js +++ b/api/api/msearch_template.js @@ -22,50 +22,23 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildMsearchTemplate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['search_type', 'typed_keys', 'max_concurrent_searches', 'rest_total_hits_as_int', 'ccs_minimize_roundtrips', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { searchType: 'search_type', typedKeys: 'typed_keys', maxConcurrentSearches: 'max_concurrent_searches', restTotalHitsAsInt: 'rest_total_hits_as_int', ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'search_type', - 'typed_keys', - 'max_concurrent_searches', - 'rest_total_hits_as_int', - 'ccs_minimize_roundtrips', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function msearchTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - searchType: 'search_type', - typedKeys: 'typed_keys', - maxConcurrentSearches: 'max_concurrent_searches', - restTotalHitsAsInt: 'rest_total_hits_as_int', - ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) } - /** - * Perform a msearch_template request - * Allows to execute several search template operations in one request. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html - */ - return function msearchTemplate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +<<<<<<< HEAD // check required parameters if (params['body'] == null) { const err = new ConfigurationError('Missing required parameter: body') @@ -113,10 +86,26 @@ function buildMsearchTemplate (opts) { bulkBody: body, querystring } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) +======= + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_msearch' + '/' + 'template' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_msearch' + '/' + 'template' } +>>>>>>> a064f0f3... Improve child performances (#1314) + + // build request object + const request = { + method, + path, + bulkBody: body, + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildMsearchTemplate +module.exports = msearchTemplateApi diff --git a/api/api/mtermvectors.js b/api/api/mtermvectors.js index aa3df4e4e..369672a52 100644 --- a/api/api/mtermvectors.js +++ b/api/api/mtermvectors.js @@ -22,38 +22,26 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildMtermvectors (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['ids', 'term_statistics', 'field_statistics', 'fields', 'offsets', 'positions', 'payloads', 'preference', 'routing', 'realtime', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { termStatistics: 'term_statistics', fieldStatistics: 'field_statistics', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'ids', - 'term_statistics', - 'field_statistics', - 'fields', - 'offsets', - 'positions', - 'payloads', - 'preference', - 'routing', - 'realtime', - 'version', - 'version_type', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function mtermvectorsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - termStatistics: 'term_statistics', - fieldStatistics: 'field_statistics', - versionType: 'version_type', - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_mtermvectors' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_mtermvectors' } +<<<<<<< HEAD /** * Perform a mtermvectors request * Returns multiple termvectors in one request. @@ -115,7 +103,17 @@ function buildMtermvectors (opts) { options.warnings = warnings.length === 0 ? null : warnings return makeRequest(request, options, callback) +======= + // build request object + const request = { + method, + path, + body: body || '', + querystring +>>>>>>> a064f0f3... Improve child performances (#1314) } + + return this.transport.request(request, options, callback) } -module.exports = buildMtermvectors +module.exports = mtermvectorsApi diff --git a/api/api/nodes.info.js b/api/api/nodes.info.js deleted file mode 100644 index deac12082..000000000 --- a/api/api/nodes.info.js +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildNodesInfo (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'flat_settings', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - flatSettings: 'flat_settings', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a nodes.info request - * Returns information about nodes in the cluster. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-info.html - */ - return function nodesInfo (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, nodeId, node_id, metric, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((node_id || nodeId) != null && (metric) != null) { - if (method == null) method = 'GET' - path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + encodeURIComponent(metric) - } else if ((node_id || nodeId) != null) { - if (method == null) method = 'GET' - path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) - } else if ((metric) != null) { - if (method == null) method = 'GET' - path = '/' + '_nodes' + '/' + encodeURIComponent(metric) - } else { - if (method == null) method = 'GET' - path = '/' + '_nodes' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildNodesInfo diff --git a/api/api/nodes.js b/api/api/nodes.js new file mode 100644 index 000000000..4fb496114 --- /dev/null +++ b/api/api/nodes.js @@ -0,0 +1,193 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['interval', 'snapshots', 'threads', 'ignore_idle_threads', 'type', 'timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'flat_settings', 'completion_fields', 'fielddata_fields', 'fields', 'groups', 'level', 'types', 'include_segment_file_sizes'] +const snakeCase = { ignoreIdleThreads: 'ignore_idle_threads', errorTrace: 'error_trace', filterPath: 'filter_path', flatSettings: 'flat_settings', completionFields: 'completion_fields', fielddataFields: 'fielddata_fields', includeSegmentFileSizes: 'include_segment_file_sizes' } + +function NodesApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +NodesApi.prototype.hotThreads = function nodesHotThreadsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, nodeId, node_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((node_id || nodeId) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'hot_threads' + } else { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + 'hot_threads' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +NodesApi.prototype.info = function nodesInfoApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, nodeId, node_id, metric, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((node_id || nodeId) != null && (metric) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + encodeURIComponent(metric) + } else if ((node_id || nodeId) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + } else if ((metric) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + encodeURIComponent(metric) + } else { + if (method == null) method = 'GET' + path = '/' + '_nodes' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +NodesApi.prototype.reloadSecureSettings = function nodesReloadSecureSettingsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, nodeId, node_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((node_id || nodeId) != null) { + if (method == null) method = 'POST' + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'reload_secure_settings' + } else { + if (method == null) method = 'POST' + path = '/' + '_nodes' + '/' + 'reload_secure_settings' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +NodesApi.prototype.stats = function nodesStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, nodeId, node_id, metric, indexMetric, index_metric, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((node_id || nodeId) != null && (metric) != null && (index_metric || indexMetric) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'stats' + '/' + encodeURIComponent(metric) + '/' + encodeURIComponent(index_metric || indexMetric) + } else if ((node_id || nodeId) != null && (metric) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'stats' + '/' + encodeURIComponent(metric) + } else if ((metric) != null && (index_metric || indexMetric) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + 'stats' + '/' + encodeURIComponent(metric) + '/' + encodeURIComponent(index_metric || indexMetric) + } else if ((node_id || nodeId) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'stats' + } else if ((metric) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + 'stats' + '/' + encodeURIComponent(metric) + } else { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + 'stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +NodesApi.prototype.usage = function nodesUsageApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, nodeId, node_id, metric, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((node_id || nodeId) != null && (metric) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'usage' + '/' + encodeURIComponent(metric) + } else if ((node_id || nodeId) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'usage' + } else if ((metric) != null) { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + 'usage' + '/' + encodeURIComponent(metric) + } else { + if (method == null) method = 'GET' + path = '/' + '_nodes' + '/' + 'usage' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(NodesApi.prototype, { + hot_threads: { get () { return this.hotThreads } }, + reload_secure_settings: { get () { return this.reloadSecureSettings } } +}) + +module.exports = NodesApi diff --git a/api/api/nodes.reload_secure_settings.js b/api/api/nodes.reload_secure_settings.js deleted file mode 100644 index 388beb720..000000000 --- a/api/api/nodes.reload_secure_settings.js +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildNodesReloadSecureSettings (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a nodes.reload_secure_settings request - * Reloads secure settings. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/secure-settings.html#reloadable-secure-settings - */ - return function nodesReloadSecureSettings (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, nodeId, node_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((node_id || nodeId) != null) { - if (method == null) method = 'POST' - path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'reload_secure_settings' - } else { - if (method == null) method = 'POST' - path = '/' + '_nodes' + '/' + 'reload_secure_settings' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildNodesReloadSecureSettings diff --git a/api/api/nodes.stats.js b/api/api/nodes.stats.js deleted file mode 100644 index 6c62da5ba..000000000 --- a/api/api/nodes.stats.js +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildNodesStats (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'completion_fields', - 'fielddata_fields', - 'fields', - 'groups', - 'level', - 'types', - 'timeout', - 'include_segment_file_sizes', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - completionFields: 'completion_fields', - fielddataFields: 'fielddata_fields', - includeSegmentFileSizes: 'include_segment_file_sizes', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a nodes.stats request - * Returns statistical information about nodes in the cluster. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-stats.html - */ - return function nodesStats (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, nodeId, node_id, metric, indexMetric, index_metric, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((node_id || nodeId) != null && (metric) != null && (index_metric || indexMetric) != null) { - if (method == null) method = 'GET' - path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'stats' + '/' + encodeURIComponent(metric) + '/' + encodeURIComponent(index_metric || indexMetric) - } else if ((node_id || nodeId) != null && (metric) != null) { - if (method == null) method = 'GET' - path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'stats' + '/' + encodeURIComponent(metric) - } else if ((metric) != null && (index_metric || indexMetric) != null) { - if (method == null) method = 'GET' - path = '/' + '_nodes' + '/' + 'stats' + '/' + encodeURIComponent(metric) + '/' + encodeURIComponent(index_metric || indexMetric) - } else if ((node_id || nodeId) != null) { - if (method == null) method = 'GET' - path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'stats' - } else if ((metric) != null) { - if (method == null) method = 'GET' - path = '/' + '_nodes' + '/' + 'stats' + '/' + encodeURIComponent(metric) - } else { - if (method == null) method = 'GET' - path = '/' + '_nodes' + '/' + 'stats' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildNodesStats diff --git a/api/api/nodes.usage.js b/api/api/nodes.usage.js deleted file mode 100644 index bfa3f9d07..000000000 --- a/api/api/nodes.usage.js +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildNodesUsage (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a nodes.usage request - * Returns low-level information about REST actions usage on nodes. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-nodes-usage.html - */ - return function nodesUsage (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, nodeId, node_id, metric, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((node_id || nodeId) != null && (metric) != null) { - if (method == null) method = 'GET' - path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'usage' + '/' + encodeURIComponent(metric) - } else if ((node_id || nodeId) != null) { - if (method == null) method = 'GET' - path = '/' + '_nodes' + '/' + encodeURIComponent(node_id || nodeId) + '/' + 'usage' - } else if ((metric) != null) { - if (method == null) method = 'GET' - path = '/' + '_nodes' + '/' + 'usage' + '/' + encodeURIComponent(metric) - } else { - if (method == null) method = 'GET' - path = '/' + '_nodes' + '/' + 'usage' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildNodesUsage diff --git a/api/api/open_point_in_time.js b/api/api/open_point_in_time.js index d98e81cff..b45581834 100644 --- a/api/api/open_point_in_time.js +++ b/api/api/open_point_in_time.js @@ -22,24 +22,26 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildOpenPointInTime (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['preference', 'routing', 'ignore_unavailable', 'expand_wildcards', 'keep_alive', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { ignoreUnavailable: 'ignore_unavailable', expandWildcards: 'expand_wildcards', keepAlive: 'keep_alive', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'preference', - 'routing', - 'ignore_unavailable', - 'expand_wildcards', - 'keep_alive' - ] +function openPointInTimeApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - expandWildcards: 'expand_wildcards', - keepAlive: 'keep_alive' + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_pit' + } else { + if (method == null) method = 'POST' + path = '/' + '_pit' } +<<<<<<< HEAD /** * Perform a open_point_in_time request * Open a point in time that can be used in subsequent searches @@ -92,7 +94,17 @@ function buildOpenPointInTime (opts) { options.warnings = warnings.length === 0 ? null : warnings return makeRequest(request, options, callback) +======= + // build request object + const request = { + method, + path, + body: body || '', + querystring +>>>>>>> a064f0f3... Improve child performances (#1314) } + + return this.transport.request(request, options, callback) } -module.exports = buildOpenPointInTime +module.exports = openPointInTimeApi diff --git a/api/api/ping.js b/api/api/ping.js index 2ec5843d3..54906b201 100644 --- a/api/api/ping.js +++ b/api/api/ping.js @@ -22,71 +22,29 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildPing (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function pingApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'HEAD' + path = '/' + + // build request object + const request = { + method, + path, + body: null, + querystring } - /** - * Perform a ping request - * Returns whether the cluster is running. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html - */ - return function ping (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'HEAD' - path = '/' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } + return this.transport.request(request, options, callback) } -module.exports = buildPing +module.exports = pingApi diff --git a/api/api/put_script.js b/api/api/put_script.js index 306017ad2..cf039eaae 100644 --- a/api/api/put_script.js +++ b/api/api/put_script.js @@ -22,96 +22,50 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildPutScript (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['timeout', 'master_timeout', 'context', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'timeout', - 'master_timeout', - 'context', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function putScriptApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) } - /** - * Perform a put_script request - * Creates or updates a script. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html - */ - return function putScript (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // check required url components - if (params['context'] != null && (params['id'] == null)) { - 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') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, context, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((id) != null && (context) != null) { - if (method == null) method = 'PUT' - path = '/' + '_scripts' + '/' + encodeURIComponent(id) + '/' + encodeURIComponent(context) - } else { - if (method == null) method = 'PUT' - path = '/' + '_scripts' + '/' + encodeURIComponent(id) - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // check required url components + if (params['context'] != null && (params['id'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: id') + return handleError(err, callback) } + + var { method, body, id, context, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null && (context) != null) { + if (method == null) method = 'PUT' + path = '/' + '_scripts' + '/' + encodeURIComponent(id) + '/' + encodeURIComponent(context) + } else { + if (method == null) method = 'PUT' + path = '/' + '_scripts' + '/' + encodeURIComponent(id) + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildPutScript +module.exports = putScriptApi diff --git a/api/api/rank_eval.js b/api/api/rank_eval.js index f068f888a..13dd35188 100644 --- a/api/api/rank_eval.js +++ b/api/api/rank_eval.js @@ -22,90 +22,40 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildRankEval (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['ignore_unavailable', 'allow_no_indices', 'expand_wildcards', 'search_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', searchType: 'search_type', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'search_type', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function rankEvalApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - searchType: 'search_type', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) } - /** - * Perform a rank_eval request - * Allows to evaluate the quality of ranked search results over a set of typical search queries - * https://www.elastic.co/guide/en/elasticsearch/reference/master/search-rank-eval.html - */ - return function rankEval (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_rank_eval' - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_rank_eval' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_rank_eval' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_rank_eval' } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildRankEval +module.exports = rankEvalApi diff --git a/api/api/reindex.js b/api/api/reindex.js index 99ef2b3e2..251bef8ad 100644 --- a/api/api/reindex.js +++ b/api/api/reindex.js @@ -22,91 +22,35 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildReindex (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['refresh', 'timeout', 'wait_for_active_shards', 'wait_for_completion', 'requests_per_second', 'scroll', 'slices', 'max_docs', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { waitForActiveShards: 'wait_for_active_shards', waitForCompletion: 'wait_for_completion', requestsPerSecond: 'requests_per_second', maxDocs: 'max_docs', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'refresh', - 'timeout', - 'wait_for_active_shards', - 'wait_for_completion', - 'requests_per_second', - 'scroll', - 'slices', - 'max_docs', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function reindexApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - waitForActiveShards: 'wait_for_active_shards', - waitForCompletion: 'wait_for_completion', - requestsPerSecond: 'requests_per_second', - maxDocs: 'max_docs', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) } - /** - * Perform a reindex request - * Allows to copy documents from one index to another, optionally filtering the source -documents by a query, changing the destination index settings, or fetching the -documents from a remote cluster. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html - */ - return function reindex (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } + var path = '' + if (method == null) method = 'POST' + path = '/' + '_reindex' - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_reindex' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: body || '', + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildReindex +module.exports = reindexApi diff --git a/api/api/reindex_rethrottle.js b/api/api/reindex_rethrottle.js index 4e482a33b..afcf87295 100644 --- a/api/api/reindex_rethrottle.js +++ b/api/api/reindex_rethrottle.js @@ -22,83 +22,39 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildReindexRethrottle (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['requests_per_second', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { requestsPerSecond: 'requests_per_second', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'requests_per_second', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function reindexRethrottleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - requestsPerSecond: 'requests_per_second', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['task_id'] == null && params['taskId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: task_id or taskId') + return handleError(err, callback) + } + if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: requests_per_second or requestsPerSecond') + return handleError(err, callback) } - /** - * Perform a reindex_rethrottle request - * Changes the number of requests per second for a particular Reindex operation. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-reindex.html - */ - return function reindexRethrottle (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, taskId, task_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - // check required parameters - if (params['task_id'] == null && params['taskId'] == null) { - const err = new ConfigurationError('Missing required parameter: task_id or taskId') - return handleError(err, callback) - } - if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) { - const err = new ConfigurationError('Missing required parameter: requests_per_second or requestsPerSecond') - return handleError(err, callback) - } + var path = '' + if (method == null) method = 'POST' + path = '/' + '_reindex' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_rethrottle' - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, taskId, task_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_reindex' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_rethrottle' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: body || '', + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildReindexRethrottle +module.exports = reindexRethrottleApi diff --git a/api/api/render_search_template.js b/api/api/render_search_template.js index a0422a0ab..c5455701c 100644 --- a/api/api/render_search_template.js +++ b/api/api/render_search_template.js @@ -22,76 +22,34 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildRenderSearchTemplate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function renderSearchTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_render' + '/' + 'template' + '/' + encodeURIComponent(id) + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_render' + '/' + 'template' } - /** - * Perform a render_search_template request - * Allows to use the Mustache language to pre-render a search definition. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html#_validating_templates - */ - return function renderSearchTemplate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((id) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_render' + '/' + 'template' + '/' + encodeURIComponent(id) - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_render' + '/' + 'template' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: body || '', + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildRenderSearchTemplate +module.exports = renderSearchTemplateApi diff --git a/api/api/rollup.delete_job.js b/api/api/rollup.delete_job.js deleted file mode 100644 index 5adcfb7e7..000000000 --- a/api/api/rollup.delete_job.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildRollupDeleteJob (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a rollup.delete_job request - * Deletes an existing rollup job. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-delete-job.html - */ - return function rollupDeleteJob (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildRollupDeleteJob diff --git a/api/api/rollup.get_jobs.js b/api/api/rollup.get_jobs.js deleted file mode 100644 index ba0c13dc7..000000000 --- a/api/api/rollup.get_jobs.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildRollupGetJobs (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a rollup.get_jobs request - * Retrieves the configuration, stats, and status of rollup jobs. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-get-job.html - */ - return function rollupGetJobs (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((id) != null) { - if (method == null) method = 'GET' - path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) - } else { - if (method == null) method = 'GET' - path = '/' + '_rollup' + '/' + 'job' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildRollupGetJobs diff --git a/api/api/rollup.get_rollup_caps.js b/api/api/rollup.get_rollup_caps.js deleted file mode 100644 index 087ced128..000000000 --- a/api/api/rollup.get_rollup_caps.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildRollupGetRollupCaps (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a rollup.get_rollup_caps request - * Returns the capabilities of any rollup jobs that have been configured for a specific index or index pattern. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-get-rollup-caps.html - */ - return function rollupGetRollupCaps (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((id) != null) { - if (method == null) method = 'GET' - path = '/' + '_rollup' + '/' + 'data' + '/' + encodeURIComponent(id) - } else { - if (method == null) method = 'GET' - path = '/' + '_rollup' + '/' + 'data' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildRollupGetRollupCaps diff --git a/api/api/rollup.get_rollup_index_caps.js b/api/api/rollup.get_rollup_index_caps.js deleted file mode 100644 index 1599e1e22..000000000 --- a/api/api/rollup.get_rollup_index_caps.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildRollupGetRollupIndexCaps (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a rollup.get_rollup_index_caps request - * Returns the rollup capabilities of all jobs inside of a rollup index (e.g. the index where rollup data is stored). - * https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-get-rollup-index-caps.html - */ - return function rollupGetRollupIndexCaps (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + encodeURIComponent(index) + '/' + '_rollup' + '/' + 'data' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildRollupGetRollupIndexCaps diff --git a/api/api/rollup.js b/api/api/rollup.js new file mode 100644 index 000000000..fc4a2793b --- /dev/null +++ b/api/api/rollup.js @@ -0,0 +1,278 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path', 'typed_keys', 'rest_total_hits_as_int', 'wait_for_completion', 'timeout'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path', typedKeys: 'typed_keys', restTotalHitsAsInt: 'rest_total_hits_as_int', waitForCompletion: 'wait_for_completion' } + +function RollupApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +RollupApi.prototype.deleteJob = function rollupDeleteJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +RollupApi.prototype.getJobs = function rollupGetJobsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null) { + if (method == null) method = 'GET' + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) + } else { + if (method == null) method = 'GET' + path = '/' + '_rollup' + '/' + 'job' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +RollupApi.prototype.getRollupCaps = function rollupGetRollupCapsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null) { + if (method == null) method = 'GET' + path = '/' + '_rollup' + '/' + 'data' + '/' + encodeURIComponent(id) + } else { + if (method == null) method = 'GET' + path = '/' + '_rollup' + '/' + 'data' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +RollupApi.prototype.getRollupIndexCaps = function rollupGetRollupIndexCapsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_rollup' + '/' + 'data' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +RollupApi.prototype.putJob = function rollupPutJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +RollupApi.prototype.rollupSearch = function rollupRollupSearchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + // check required url components + if (params['type'] != null && (params['index'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: index') + return handleError(err, callback) + } + + var { method, body, index, type, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null && (type) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_rollup_search' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_rollup_search' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +RollupApi.prototype.startJob = function rollupStartJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) + '/' + '_start' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +RollupApi.prototype.stopJob = function rollupStopJobApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) + '/' + '_stop' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(RollupApi.prototype, { + delete_job: { get () { return this.deleteJob } }, + get_jobs: { get () { return this.getJobs } }, + get_rollup_caps: { get () { return this.getRollupCaps } }, + get_rollup_index_caps: { get () { return this.getRollupIndexCaps } }, + put_job: { get () { return this.putJob } }, + rollup_search: { get () { return this.rollupSearch } }, + start_job: { get () { return this.startJob } }, + stop_job: { get () { return this.stopJob } } +}) + +module.exports = RollupApi diff --git a/api/api/rollup.put_job.js b/api/api/rollup.put_job.js deleted file mode 100644 index 74ad711ea..000000000 --- a/api/api/rollup.put_job.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildRollupPutJob (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a rollup.put_job request - * Creates a rollup job. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-put-job.html - */ - return function rollupPutJob (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildRollupPutJob diff --git a/api/api/rollup.rollup_search.js b/api/api/rollup.rollup_search.js deleted file mode 100644 index b50bb4a21..000000000 --- a/api/api/rollup.rollup_search.js +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildRollupRollupSearch (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'typed_keys', - 'rest_total_hits_as_int' - ] - - const snakeCase = { - typedKeys: 'typed_keys', - restTotalHitsAsInt: 'rest_total_hits_as_int' - } - - /** - * Perform a rollup.rollup_search request - * Enables searching rolled-up data using the standard query DSL. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-search.html - */ - return function rollupRollupSearch (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // check required url components - if (params['type'] != null && (params['index'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: index') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, type, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null && (type) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + '_rollup_search' - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_rollup_search' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildRollupRollupSearch diff --git a/api/api/rollup.start_job.js b/api/api/rollup.start_job.js deleted file mode 100644 index 7e99e2c41..000000000 --- a/api/api/rollup.start_job.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildRollupStartJob (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a rollup.start_job request - * Starts an existing, stopped rollup job. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-start-job.html - */ - return function rollupStartJob (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) + '/' + '_start' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildRollupStartJob diff --git a/api/api/rollup.stop_job.js b/api/api/rollup.stop_job.js deleted file mode 100644 index f4d9b64b7..000000000 --- a/api/api/rollup.stop_job.js +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildRollupStopJob (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'wait_for_completion', - 'timeout' - ] - - const snakeCase = { - waitForCompletion: 'wait_for_completion' - - } - - /** - * Perform a rollup.stop_job request - * Stops an existing, started rollup job. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/rollup-stop-job.html - */ - return function rollupStopJob (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(id) + '/' + '_stop' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildRollupStopJob diff --git a/api/api/scripts_painless_execute.js b/api/api/scripts_painless_execute.js index 693d3a4eb..b08c6d14a 100644 --- a/api/api/scripts_painless_execute.js +++ b/api/api/scripts_painless_execute.js @@ -22,71 +22,29 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildScriptsPainlessExecute (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function scriptsPainlessExecuteApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_scripts' + '/' + 'painless' + '/' + '_execute' + + // build request object + const request = { + method, + path, + body: body || '', + querystring } - /** - * Perform a scripts_painless_execute request - * Allows an arbitrary script to be executed and a result to be returned - * https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html - */ - return function scriptsPainlessExecute (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_scripts' + '/' + 'painless' + '/' + '_execute' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } + return this.transport.request(request, options, callback) } -module.exports = buildScriptsPainlessExecute +module.exports = scriptsPainlessExecuteApi diff --git a/api/api/scroll.js b/api/api/scroll.js index f2d66911a..7ec1f059f 100644 --- a/api/api/scroll.js +++ b/api/api/scroll.js @@ -22,81 +22,34 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildScroll (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['scroll', 'scroll_id', 'rest_total_hits_as_int', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { scrollId: 'scroll_id', restTotalHitsAsInt: 'rest_total_hits_as_int', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'scroll', - 'scroll_id', - 'rest_total_hits_as_int', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function scrollApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - scrollId: 'scroll_id', - restTotalHitsAsInt: 'rest_total_hits_as_int', - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, scrollId, scroll_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((scroll_id || scrollId) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_search' + '/' + 'scroll' + '/' + encodeURIComponent(scroll_id || scrollId) + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_search' + '/' + 'scroll' } - /** - * Perform a scroll request - * Allows to retrieve a large numbers of results from a single search request. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/search-request-body.html#request-body-search-scroll - */ - return function scroll (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, scrollId, scroll_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((scroll_id || scrollId) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_search' + '/' + 'scroll' + '/' + encodeURIComponent(scroll_id || scrollId) - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_search' + '/' + 'scroll' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: body || '', + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildScroll +module.exports = scrollApi diff --git a/api/api/search.js b/api/api/search.js index 2621c0dbd..331119fe8 100644 --- a/api/api/search.js +++ b/api/api/search.js @@ -22,6 +22,7 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ +<<<<<<< HEAD function buildSearch (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts @@ -169,7 +170,36 @@ function buildSearch (opts) { options.warnings = warnings.length === 0 ? null : warnings return makeRequest(request, options, callback) +======= +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['analyzer', 'analyze_wildcard', 'ccs_minimize_roundtrips', 'default_operator', 'df', 'explain', 'stored_fields', 'docvalue_fields', 'from', 'ignore_unavailable', 'ignore_throttled', 'allow_no_indices', 'expand_wildcards', 'lenient', 'preference', 'q', 'routing', 'scroll', 'search_type', 'size', 'sort', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'terminate_after', 'stats', 'suggest_field', 'suggest_mode', 'suggest_size', 'suggest_text', 'timeout', 'track_scores', 'track_total_hits', 'allow_partial_search_results', 'typed_keys', 'version', 'seq_no_primary_term', 'request_cache', 'batched_reduce_size', 'max_concurrent_shard_requests', 'pre_filter_shard_size', 'rest_total_hits_as_int', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { analyzeWildcard: 'analyze_wildcard', ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', defaultOperator: 'default_operator', storedFields: 'stored_fields', docvalueFields: 'docvalue_fields', ignoreUnavailable: 'ignore_unavailable', ignoreThrottled: 'ignore_throttled', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', searchType: 'search_type', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', terminateAfter: 'terminate_after', suggestField: 'suggest_field', suggestMode: 'suggest_mode', suggestSize: 'suggest_size', suggestText: 'suggest_text', trackScores: 'track_scores', trackTotalHits: 'track_total_hits', allowPartialSearchResults: 'allow_partial_search_results', typedKeys: 'typed_keys', seqNoPrimaryTerm: 'seq_no_primary_term', requestCache: 'request_cache', batchedReduceSize: 'batched_reduce_size', maxConcurrentShardRequests: 'max_concurrent_shard_requests', preFilterShardSize: 'pre_filter_shard_size', restTotalHitsAsInt: 'rest_total_hits_as_int', errorTrace: 'error_trace', filterPath: 'filter_path' } + +function searchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_search' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_search' } + + // build request object + const request = { + method, + path, + body: body || '', + querystring +>>>>>>> a064f0f3... Improve child performances (#1314) + } + + return this.transport.request(request, options, callback) } -module.exports = buildSearch +module.exports = searchApi diff --git a/api/api/search_shards.js b/api/api/search_shards.js index 4b2d46424..7059004db 100644 --- a/api/api/search_shards.js +++ b/api/api/search_shards.js @@ -22,85 +22,34 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildSearchShards (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['preference', 'routing', 'local', 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'preference', - 'routing', - 'local', - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function searchShardsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - errorTrace: 'error_trace', - filterPath: 'filter_path' + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_search_shards' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_search_shards' } - /** - * Perform a search_shards request - * Returns information about the indices and shards that a search request would be executed against. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/search-shards.html - */ - return function searchShards (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, index, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_search_shards' - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_search_shards' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: body || '', + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildSearchShards +module.exports = searchShardsApi diff --git a/api/api/search_template.js b/api/api/search_template.js index 12d96a588..801b5d01d 100644 --- a/api/api/search_template.js +++ b/api/api/search_template.js @@ -22,61 +22,23 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildSearchTemplate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['ignore_unavailable', 'ignore_throttled', 'allow_no_indices', 'expand_wildcards', 'preference', 'routing', 'scroll', 'search_type', 'explain', 'profile', 'typed_keys', 'rest_total_hits_as_int', 'ccs_minimize_roundtrips', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { ignoreUnavailable: 'ignore_unavailable', ignoreThrottled: 'ignore_throttled', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', searchType: 'search_type', typedKeys: 'typed_keys', restTotalHitsAsInt: 'rest_total_hits_as_int', ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'ignore_unavailable', - 'ignore_throttled', - 'allow_no_indices', - 'expand_wildcards', - 'preference', - 'routing', - 'scroll', - 'search_type', - 'explain', - 'profile', - 'typed_keys', - 'rest_total_hits_as_int', - 'ccs_minimize_roundtrips', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function searchTemplateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - ignoreThrottled: 'ignore_throttled', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - searchType: 'search_type', - typedKeys: 'typed_keys', - restTotalHitsAsInt: 'rest_total_hits_as_int', - ccsMinimizeRoundtrips: 'ccs_minimize_roundtrips', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) } - /** - * Perform a search_template request - * Allows to use the Mustache language to pre-render a search definition. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html - */ - return function searchTemplate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +<<<<<<< HEAD // check required parameters if (params['body'] == null) { const err = new ConfigurationError('Missing required parameter: body') @@ -124,10 +86,26 @@ function buildSearchTemplate (opts) { body: body || '', querystring } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) +======= + var path = '' + if ((index) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_search' + '/' + 'template' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_search' + '/' + 'template' } +>>>>>>> a064f0f3... Improve child performances (#1314) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildSearchTemplate +module.exports = searchTemplateApi diff --git a/api/api/searchable_snapshots.js b/api/api/searchable_snapshots.js new file mode 100644 index 000000000..38f857cac --- /dev/null +++ b/api/api/searchable_snapshots.js @@ -0,0 +1,159 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['ignore_unavailable', 'allow_no_indices', 'expand_wildcards', 'index', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'master_timeout', 'wait_for_completion'] +const snakeCase = { ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', errorTrace: 'error_trace', filterPath: 'filter_path', masterTimeout: 'master_timeout', waitForCompletion: 'wait_for_completion' } + +function SearchableSnapshotsApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +SearchableSnapshotsApi.prototype.clearCache = function searchableSnapshotsClearCacheApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_searchable_snapshots' + '/' + 'cache' + '/' + 'clear' + } else { + if (method == null) method = 'POST' + path = '/' + '_searchable_snapshots' + '/' + 'cache' + '/' + 'clear' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SearchableSnapshotsApi.prototype.mount = function searchableSnapshotsMountApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['repository'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: repository') + return handleError(err, callback) + } + if (params['snapshot'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: snapshot') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + // check required url components + if (params['snapshot'] != null && (params['repository'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: repository') + return handleError(err, callback) + } + + var { method, body, repository, snapshot, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) + '/' + '_mount' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SearchableSnapshotsApi.prototype.repositoryStats = function searchableSnapshotsRepositoryStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['repository'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: repository') + return handleError(err, callback) + } + + var { method, body, repository, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + '_stats' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SearchableSnapshotsApi.prototype.stats = function searchableSnapshotsStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((index) != null) { + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_searchable_snapshots' + '/' + 'stats' + } else { + if (method == null) method = 'GET' + path = '/' + '_searchable_snapshots' + '/' + 'stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(SearchableSnapshotsApi.prototype, { + clear_cache: { get () { return this.clearCache } }, + repository_stats: { get () { return this.repositoryStats } } +}) + +module.exports = SearchableSnapshotsApi diff --git a/api/api/security.authenticate.js b/api/api/security.authenticate.js deleted file mode 100644 index adf3d0969..000000000 --- a/api/api/security.authenticate.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityAuthenticate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a security.authenticate request - * Enables authentication as a user and retrieve information about the authenticated user. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-authenticate.html - */ - return function securityAuthenticate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_security' + '/' + '_authenticate' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityAuthenticate diff --git a/api/api/security.change_password.js b/api/api/security.change_password.js deleted file mode 100644 index e5cebad94..000000000 --- a/api/api/security.change_password.js +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityChangePassword (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'refresh' - ] - - const snakeCase = { - - } - - /** - * Perform a security.change_password request - * Changes the passwords of users in the native realm and built-in users. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-change-password.html - */ - return function securityChangePassword (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, username, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((username) != null) { - if (method == null) method = 'PUT' - path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + '/' + '_password' - } else { - if (method == null) method = 'PUT' - path = '/' + '_security' + '/' + 'user' + '/' + '_password' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityChangePassword diff --git a/api/api/security.clear_cached_privileges.js b/api/api/security.clear_cached_privileges.js deleted file mode 100644 index 8c7ea4411..000000000 --- a/api/api/security.clear_cached_privileges.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityClearCachedPrivileges (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a security.clear_cached_privileges request - * Evicts application privileges from the native application privileges cache. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-privilege-cache.html - */ - return function securityClearCachedPrivileges (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['application'] == null) { - const err = new ConfigurationError('Missing required parameter: application') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, application, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(application) + '/' + '_clear_cache' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityClearCachedPrivileges diff --git a/api/api/security.clear_cached_realms.js b/api/api/security.clear_cached_realms.js deleted file mode 100644 index 07541f6cf..000000000 --- a/api/api/security.clear_cached_realms.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityClearCachedRealms (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'usernames' - ] - - const snakeCase = { - - } - - /** - * Perform a security.clear_cached_realms request - * Evicts users from the user cache. Can completely clear the cache or evict specific users. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-cache.html - */ - return function securityClearCachedRealms (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['realms'] == null) { - const err = new ConfigurationError('Missing required parameter: realms') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, realms, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_security' + '/' + 'realm' + '/' + encodeURIComponent(realms) + '/' + '_clear_cache' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityClearCachedRealms diff --git a/api/api/security.clear_cached_roles.js b/api/api/security.clear_cached_roles.js deleted file mode 100644 index cec426546..000000000 --- a/api/api/security.clear_cached_roles.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityClearCachedRoles (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a security.clear_cached_roles request - * Evicts roles from the native role cache. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-role-cache.html - */ - return function securityClearCachedRoles (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(name) + '/' + '_clear_cache' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityClearCachedRoles diff --git a/api/api/security.create_api_key.js b/api/api/security.create_api_key.js deleted file mode 100644 index d2d3fe907..000000000 --- a/api/api/security.create_api_key.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityCreateApiKey (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'refresh' - ] - - const snakeCase = { - - } - - /** - * Perform a security.create_api_key request - * Creates an API key for access without requiring basic authentication. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html - */ - return function securityCreateApiKey (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_security' + '/' + 'api_key' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityCreateApiKey diff --git a/api/api/security.delete_privileges.js b/api/api/security.delete_privileges.js deleted file mode 100644 index 6cb2f074f..000000000 --- a/api/api/security.delete_privileges.js +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityDeletePrivileges (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'refresh' - ] - - const snakeCase = { - - } - - /** - * Perform a security.delete_privileges request - * Removes application privileges. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-privilege.html - */ - return function securityDeletePrivileges (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['application'] == null) { - const err = new ConfigurationError('Missing required parameter: application') - return handleError(err, callback) - } - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // check required url components - if (params['name'] != null && (params['application'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: application') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, application, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(application) + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityDeletePrivileges diff --git a/api/api/security.delete_role.js b/api/api/security.delete_role.js deleted file mode 100644 index 5367bd78f..000000000 --- a/api/api/security.delete_role.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityDeleteRole (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'refresh' - ] - - const snakeCase = { - - } - - /** - * Perform a security.delete_role request - * Removes roles in the native realm. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role.html - */ - return function securityDeleteRole (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityDeleteRole diff --git a/api/api/security.delete_role_mapping.js b/api/api/security.delete_role_mapping.js deleted file mode 100644 index 3716059e5..000000000 --- a/api/api/security.delete_role_mapping.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityDeleteRoleMapping (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'refresh' - ] - - const snakeCase = { - - } - - /** - * Perform a security.delete_role_mapping request - * Removes role mappings. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role-mapping.html - */ - return function securityDeleteRoleMapping (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityDeleteRoleMapping diff --git a/api/api/security.delete_user.js b/api/api/security.delete_user.js deleted file mode 100644 index dc23dc215..000000000 --- a/api/api/security.delete_user.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityDeleteUser (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'refresh' - ] - - const snakeCase = { - - } - - /** - * Perform a security.delete_user request - * Deletes users from the native realm. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-user.html - */ - return function securityDeleteUser (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['username'] == null) { - const err = new ConfigurationError('Missing required parameter: username') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, username, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityDeleteUser diff --git a/api/api/security.disable_user.js b/api/api/security.disable_user.js deleted file mode 100644 index 5f2d2e49c..000000000 --- a/api/api/security.disable_user.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityDisableUser (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'refresh' - ] - - const snakeCase = { - - } - - /** - * Perform a security.disable_user request - * Disables users in the native realm. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-disable-user.html - */ - return function securityDisableUser (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['username'] == null) { - const err = new ConfigurationError('Missing required parameter: username') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, username, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + '/' + '_disable' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityDisableUser diff --git a/api/api/security.enable_user.js b/api/api/security.enable_user.js deleted file mode 100644 index d3040ad4b..000000000 --- a/api/api/security.enable_user.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityEnableUser (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'refresh' - ] - - const snakeCase = { - - } - - /** - * Perform a security.enable_user request - * Enables users in the native realm. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-enable-user.html - */ - return function securityEnableUser (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['username'] == null) { - const err = new ConfigurationError('Missing required parameter: username') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, username, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + '/' + '_enable' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityEnableUser diff --git a/api/api/security.get_api_key.js b/api/api/security.get_api_key.js deleted file mode 100644 index d0d7d0ab3..000000000 --- a/api/api/security.get_api_key.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityGetApiKey (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'id', - 'name', - 'username', - 'realm_name', - 'owner' - ] - - const snakeCase = { - realmName: 'realm_name' - - } - - /** - * Perform a security.get_api_key request - * Retrieves information for one or more API keys. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-api-key.html - */ - return function securityGetApiKey (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_security' + '/' + 'api_key' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityGetApiKey diff --git a/api/api/security.get_builtin_privileges.js b/api/api/security.get_builtin_privileges.js deleted file mode 100644 index 04d8c77e5..000000000 --- a/api/api/security.get_builtin_privileges.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityGetBuiltinPrivileges (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a security.get_builtin_privileges request - * Retrieves the list of cluster privileges and index privileges that are available in this version of Elasticsearch. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-builtin-privileges.html - */ - return function securityGetBuiltinPrivileges (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_security' + '/' + 'privilege' + '/' + '_builtin' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityGetBuiltinPrivileges diff --git a/api/api/security.get_privileges.js b/api/api/security.get_privileges.js deleted file mode 100644 index 1d972e04c..000000000 --- a/api/api/security.get_privileges.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityGetPrivileges (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a security.get_privileges request - * Retrieves application privileges. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-privileges.html - */ - return function securityGetPrivileges (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required url components - if (params['name'] != null && (params['application'] == null)) { - const err = new ConfigurationError('Missing required parameter of the url: application') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, application, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((application) != null && (name) != null) { - if (method == null) method = 'GET' - path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(application) + '/' + encodeURIComponent(name) - } else if ((application) != null) { - if (method == null) method = 'GET' - path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(application) - } else { - if (method == null) method = 'GET' - path = '/' + '_security' + '/' + 'privilege' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityGetPrivileges diff --git a/api/api/security.get_role.js b/api/api/security.get_role.js deleted file mode 100644 index bd3c49a11..000000000 --- a/api/api/security.get_role.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityGetRole (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a security.get_role request - * Retrieves roles in the native realm. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html - */ - return function securityGetRole (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((name) != null) { - if (method == null) method = 'GET' - path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(name) - } else { - if (method == null) method = 'GET' - path = '/' + '_security' + '/' + 'role' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityGetRole diff --git a/api/api/security.get_role_mapping.js b/api/api/security.get_role_mapping.js deleted file mode 100644 index eb11d3923..000000000 --- a/api/api/security.get_role_mapping.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityGetRoleMapping (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a security.get_role_mapping request - * Retrieves role mappings. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role-mapping.html - */ - return function securityGetRoleMapping (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((name) != null) { - if (method == null) method = 'GET' - path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(name) - } else { - if (method == null) method = 'GET' - path = '/' + '_security' + '/' + 'role_mapping' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityGetRoleMapping diff --git a/api/api/security.get_token.js b/api/api/security.get_token.js deleted file mode 100644 index 6dabe8633..000000000 --- a/api/api/security.get_token.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityGetToken (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a security.get_token request - * Creates a bearer token for access without requiring basic authentication. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html - */ - return function securityGetToken (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_security' + '/' + 'oauth2' + '/' + 'token' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityGetToken diff --git a/api/api/security.get_user.js b/api/api/security.get_user.js deleted file mode 100644 index 0bc9e5d8b..000000000 --- a/api/api/security.get_user.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityGetUser (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a security.get_user request - * Retrieves information about users in the native realm and built-in users. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user.html - */ - return function securityGetUser (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, username, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((username) != null) { - if (method == null) method = 'GET' - path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) - } else { - if (method == null) method = 'GET' - path = '/' + '_security' + '/' + 'user' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityGetUser diff --git a/api/api/security.get_user_privileges.js b/api/api/security.get_user_privileges.js deleted file mode 100644 index 954c3b850..000000000 --- a/api/api/security.get_user_privileges.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityGetUserPrivileges (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a security.get_user_privileges request - * Retrieves application privileges. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-privileges.html - */ - return function securityGetUserPrivileges (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_security' + '/' + 'user' + '/' + '_privileges' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityGetUserPrivileges diff --git a/api/api/security.has_privileges.js b/api/api/security.has_privileges.js deleted file mode 100644 index 70a678657..000000000 --- a/api/api/security.has_privileges.js +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityHasPrivileges (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a security.has_privileges request - * Determines whether the specified user has a specified list of privileges. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html - */ - return function securityHasPrivileges (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, user, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((user) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(user) + '/' + '_has_privileges' - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_security' + '/' + 'user' + '/' + '_has_privileges' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityHasPrivileges diff --git a/api/api/security.invalidate_api_key.js b/api/api/security.invalidate_api_key.js deleted file mode 100644 index 2a738c518..000000000 --- a/api/api/security.invalidate_api_key.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityInvalidateApiKey (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a security.invalidate_api_key request - * Invalidates one or more API keys. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-api-key.html - */ - return function securityInvalidateApiKey (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_security' + '/' + 'api_key' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityInvalidateApiKey diff --git a/api/api/security.invalidate_token.js b/api/api/security.invalidate_token.js deleted file mode 100644 index 1334aaf9e..000000000 --- a/api/api/security.invalidate_token.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityInvalidateToken (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a security.invalidate_token request - * Invalidates one or more access tokens or refresh tokens. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html - */ - return function securityInvalidateToken (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_security' + '/' + 'oauth2' + '/' + 'token' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityInvalidateToken diff --git a/api/api/security.js b/api/api/security.js new file mode 100644 index 000000000..f63a42c5c --- /dev/null +++ b/api/api/security.js @@ -0,0 +1,805 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path', 'refresh', 'usernames', 'id', 'name', 'username', 'realm_name', 'owner'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path', realmName: 'realm_name' } + +function SecurityApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +SecurityApi.prototype.authenticate = function securityAuthenticateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + '_authenticate' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.changePassword = function securityChangePasswordApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, username, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((username) != null) { + if (method == null) method = 'PUT' + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + '/' + '_password' + } else { + if (method == null) method = 'PUT' + path = '/' + '_security' + '/' + 'user' + '/' + '_password' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.clearCachedPrivileges = function securityClearCachedPrivilegesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['application'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: application') + return handleError(err, callback) + } + + var { method, body, application, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(application) + '/' + '_clear_cache' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.clearCachedRealms = function securityClearCachedRealmsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['realms'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: realms') + return handleError(err, callback) + } + + var { method, body, realms, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_security' + '/' + 'realm' + '/' + encodeURIComponent(realms) + '/' + '_clear_cache' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.clearCachedRoles = function securityClearCachedRolesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(name) + '/' + '_clear_cache' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.createApiKey = function securityCreateApiKeyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_security' + '/' + 'api_key' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.deletePrivileges = function securityDeletePrivilegesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['application'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: application') + return handleError(err, callback) + } + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + // check required url components + if (params['name'] != null && (params['application'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: application') + return handleError(err, callback) + } + + var { method, body, application, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(application) + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.deleteRole = function securityDeleteRoleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.deleteRoleMapping = function securityDeleteRoleMappingApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.deleteUser = function securityDeleteUserApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['username'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: username') + return handleError(err, callback) + } + + var { method, body, username, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.disableUser = function securityDisableUserApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['username'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: username') + return handleError(err, callback) + } + + var { method, body, username, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + '/' + '_disable' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.enableUser = function securityEnableUserApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['username'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: username') + return handleError(err, callback) + } + + var { method, body, username, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + '/' + '_enable' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.getApiKey = function securityGetApiKeyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'api_key' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.getBuiltinPrivileges = function securityGetBuiltinPrivilegesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'privilege' + '/' + '_builtin' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.getPrivileges = function securityGetPrivilegesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required url components + if (params['name'] != null && (params['application'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: application') + return handleError(err, callback) + } + + var { method, body, application, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((application) != null && (name) != null) { + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(application) + '/' + encodeURIComponent(name) + } else if ((application) != null) { + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(application) + } else { + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'privilege' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.getRole = function securityGetRoleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'role' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.getRoleMapping = function securityGetRoleMappingApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'role_mapping' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.getToken = function securityGetTokenApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_security' + '/' + 'oauth2' + '/' + 'token' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.getUser = function securityGetUserApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, username, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((username) != null) { + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + } else { + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'user' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.getUserPrivileges = function securityGetUserPrivilegesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_security' + '/' + 'user' + '/' + '_privileges' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.hasPrivileges = function securityHasPrivilegesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, user, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((user) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(user) + '/' + '_has_privileges' + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_security' + '/' + 'user' + '/' + '_has_privileges' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.invalidateApiKey = function securityInvalidateApiKeyApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_security' + '/' + 'api_key' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.invalidateToken = function securityInvalidateTokenApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_security' + '/' + 'oauth2' + '/' + 'token' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.putPrivileges = function securityPutPrivilegesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_security' + '/' + 'privilege' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.putRole = function securityPutRoleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.putRoleMapping = function securityPutRoleMappingApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['name'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: name') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SecurityApi.prototype.putUser = function securityPutUserApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['username'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: username') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, username, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(SecurityApi.prototype, { + change_password: { get () { return this.changePassword } }, + clear_cached_privileges: { get () { return this.clearCachedPrivileges } }, + clear_cached_realms: { get () { return this.clearCachedRealms } }, + clear_cached_roles: { get () { return this.clearCachedRoles } }, + create_api_key: { get () { return this.createApiKey } }, + delete_privileges: { get () { return this.deletePrivileges } }, + delete_role: { get () { return this.deleteRole } }, + delete_role_mapping: { get () { return this.deleteRoleMapping } }, + delete_user: { get () { return this.deleteUser } }, + disable_user: { get () { return this.disableUser } }, + enable_user: { get () { return this.enableUser } }, + get_api_key: { get () { return this.getApiKey } }, + get_builtin_privileges: { get () { return this.getBuiltinPrivileges } }, + get_privileges: { get () { return this.getPrivileges } }, + get_role: { get () { return this.getRole } }, + get_role_mapping: { get () { return this.getRoleMapping } }, + get_token: { get () { return this.getToken } }, + get_user: { get () { return this.getUser } }, + get_user_privileges: { get () { return this.getUserPrivileges } }, + has_privileges: { get () { return this.hasPrivileges } }, + invalidate_api_key: { get () { return this.invalidateApiKey } }, + invalidate_token: { get () { return this.invalidateToken } }, + put_privileges: { get () { return this.putPrivileges } }, + put_role: { get () { return this.putRole } }, + put_role_mapping: { get () { return this.putRoleMapping } }, + put_user: { get () { return this.putUser } } +}) + +module.exports = SecurityApi diff --git a/api/api/security.put_privileges.js b/api/api/security.put_privileges.js deleted file mode 100644 index 04af04e28..000000000 --- a/api/api/security.put_privileges.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityPutPrivileges (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'refresh' - ] - - const snakeCase = { - - } - - /** - * Perform a security.put_privileges request - * Adds or updates application privileges. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-privileges.html - */ - return function securityPutPrivileges (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_security' + '/' + 'privilege' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityPutPrivileges diff --git a/api/api/security.put_role.js b/api/api/security.put_role.js deleted file mode 100644 index dc392a087..000000000 --- a/api/api/security.put_role.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityPutRole (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'refresh' - ] - - const snakeCase = { - - } - - /** - * Perform a security.put_role request - * Adds and updates roles in the native realm. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html - */ - return function securityPutRole (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityPutRole diff --git a/api/api/security.put_role_mapping.js b/api/api/security.put_role_mapping.js deleted file mode 100644 index 9a4e13d17..000000000 --- a/api/api/security.put_role_mapping.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityPutRoleMapping (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'refresh' - ] - - const snakeCase = { - - } - - /** - * Perform a security.put_role_mapping request - * Creates and updates role mappings. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role-mapping.html - */ - return function securityPutRoleMapping (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['name'] == null) { - const err = new ConfigurationError('Missing required parameter: name') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, name, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(name) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityPutRoleMapping diff --git a/api/api/security.put_user.js b/api/api/security.put_user.js deleted file mode 100644 index 36b9b76da..000000000 --- a/api/api/security.put_user.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSecurityPutUser (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'refresh' - ] - - const snakeCase = { - - } - - /** - * Perform a security.put_user request - * Adds and updates users in the native realm. These users are commonly referred to as native users. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html - */ - return function securityPutUser (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['username'] == null) { - const err = new ConfigurationError('Missing required parameter: username') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, username, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(username) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSecurityPutUser diff --git a/api/api/slm.delete_lifecycle.js b/api/api/slm.delete_lifecycle.js deleted file mode 100644 index 3527de75c..000000000 --- a/api/api/slm.delete_lifecycle.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSlmDeleteLifecycle (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a slm.delete_lifecycle request - * Deletes an existing snapshot lifecycle policy. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete-policy.html - */ - return function slmDeleteLifecycle (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['policy_id'] == null && params['policyId'] == null) { - const err = new ConfigurationError('Missing required parameter: policy_id or policyId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, policyId, policy_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_slm' + '/' + 'policy' + '/' + encodeURIComponent(policy_id || policyId) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSlmDeleteLifecycle diff --git a/api/api/slm.execute_lifecycle.js b/api/api/slm.execute_lifecycle.js deleted file mode 100644 index aa2ca8f46..000000000 --- a/api/api/slm.execute_lifecycle.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSlmExecuteLifecycle (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a slm.execute_lifecycle request - * Immediately creates a snapshot according to the lifecycle policy, without waiting for the scheduled time. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute-lifecycle.html - */ - return function slmExecuteLifecycle (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['policy_id'] == null && params['policyId'] == null) { - const err = new ConfigurationError('Missing required parameter: policy_id or policyId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, policyId, policy_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_slm' + '/' + 'policy' + '/' + encodeURIComponent(policy_id || policyId) + '/' + '_execute' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSlmExecuteLifecycle diff --git a/api/api/slm.execute_retention.js b/api/api/slm.execute_retention.js deleted file mode 100644 index 6d05dd544..000000000 --- a/api/api/slm.execute_retention.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSlmExecuteRetention (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a slm.execute_retention request - * Deletes any snapshots that are expired according to the policy's retention rules. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute-retention.html - */ - return function slmExecuteRetention (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_slm' + '/' + '_execute_retention' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSlmExecuteRetention diff --git a/api/api/slm.get_lifecycle.js b/api/api/slm.get_lifecycle.js deleted file mode 100644 index 55ad88afa..000000000 --- a/api/api/slm.get_lifecycle.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSlmGetLifecycle (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a slm.get_lifecycle request - * Retrieves one or more snapshot lifecycle policy definitions and information about the latest snapshot attempts. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get-policy.html - */ - return function slmGetLifecycle (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, policyId, policy_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((policy_id || policyId) != null) { - if (method == null) method = 'GET' - path = '/' + '_slm' + '/' + 'policy' + '/' + encodeURIComponent(policy_id || policyId) - } else { - if (method == null) method = 'GET' - path = '/' + '_slm' + '/' + 'policy' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSlmGetLifecycle diff --git a/api/api/slm.get_stats.js b/api/api/slm.get_stats.js deleted file mode 100644 index 0301494c3..000000000 --- a/api/api/slm.get_stats.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSlmGetStats (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a slm.get_stats request - * Returns global and policy-level statistics about actions taken by snapshot lifecycle management. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/slm-api-get-stats.html - */ - return function slmGetStats (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_slm' + '/' + 'stats' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSlmGetStats diff --git a/api/api/slm.get_status.js b/api/api/slm.get_status.js deleted file mode 100644 index 88dadc8c0..000000000 --- a/api/api/slm.get_status.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSlmGetStatus (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a slm.get_status request - * Retrieves the status of snapshot lifecycle management (SLM). - * https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get-status.html - */ - return function slmGetStatus (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_slm' + '/' + 'status' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSlmGetStatus diff --git a/api/api/slm.js b/api/api/slm.js new file mode 100644 index 000000000..3947dc365 --- /dev/null +++ b/api/api/slm.js @@ -0,0 +1,256 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } + +function SlmApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +SlmApi.prototype.deleteLifecycle = function slmDeleteLifecycleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['policy_id'] == null && params['policyId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: policy_id or policyId') + return handleError(err, callback) + } + + var { method, body, policyId, policy_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_slm' + '/' + 'policy' + '/' + encodeURIComponent(policy_id || policyId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SlmApi.prototype.executeLifecycle = function slmExecuteLifecycleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['policy_id'] == null && params['policyId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: policy_id or policyId') + return handleError(err, callback) + } + + var { method, body, policyId, policy_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_slm' + '/' + 'policy' + '/' + encodeURIComponent(policy_id || policyId) + '/' + '_execute' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SlmApi.prototype.executeRetention = function slmExecuteRetentionApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_slm' + '/' + '_execute_retention' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SlmApi.prototype.getLifecycle = function slmGetLifecycleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, policyId, policy_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((policy_id || policyId) != null) { + if (method == null) method = 'GET' + path = '/' + '_slm' + '/' + 'policy' + '/' + encodeURIComponent(policy_id || policyId) + } else { + if (method == null) method = 'GET' + path = '/' + '_slm' + '/' + 'policy' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SlmApi.prototype.getStats = function slmGetStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_slm' + '/' + 'stats' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SlmApi.prototype.getStatus = function slmGetStatusApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_slm' + '/' + 'status' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SlmApi.prototype.putLifecycle = function slmPutLifecycleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['policy_id'] == null && params['policyId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: policy_id or policyId') + return handleError(err, callback) + } + + var { method, body, policyId, policy_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_slm' + '/' + 'policy' + '/' + encodeURIComponent(policy_id || policyId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SlmApi.prototype.start = function slmStartApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_slm' + '/' + 'start' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SlmApi.prototype.stop = function slmStopApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_slm' + '/' + 'stop' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(SlmApi.prototype, { + delete_lifecycle: { get () { return this.deleteLifecycle } }, + execute_lifecycle: { get () { return this.executeLifecycle } }, + execute_retention: { get () { return this.executeRetention } }, + get_lifecycle: { get () { return this.getLifecycle } }, + get_stats: { get () { return this.getStats } }, + get_status: { get () { return this.getStatus } }, + put_lifecycle: { get () { return this.putLifecycle } } +}) + +module.exports = SlmApi diff --git a/api/api/slm.put_lifecycle.js b/api/api/slm.put_lifecycle.js deleted file mode 100644 index 899b82d39..000000000 --- a/api/api/slm.put_lifecycle.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSlmPutLifecycle (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a slm.put_lifecycle request - * Creates or updates a snapshot lifecycle policy. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put-policy.html - */ - return function slmPutLifecycle (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['policy_id'] == null && params['policyId'] == null) { - const err = new ConfigurationError('Missing required parameter: policy_id or policyId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, policyId, policy_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_slm' + '/' + 'policy' + '/' + encodeURIComponent(policy_id || policyId) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSlmPutLifecycle diff --git a/api/api/slm.start.js b/api/api/slm.start.js deleted file mode 100644 index 2046817a3..000000000 --- a/api/api/slm.start.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSlmStart (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a slm.start request - * Turns on snapshot lifecycle management (SLM). - * https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-start.html - */ - return function slmStart (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_slm' + '/' + 'start' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSlmStart diff --git a/api/api/slm.stop.js b/api/api/slm.stop.js deleted file mode 100644 index 00050dd01..000000000 --- a/api/api/slm.stop.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSlmStop (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a slm.stop request - * Turns off snapshot lifecycle management (SLM). - * https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-stop.html - */ - return function slmStop (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_slm' + '/' + 'stop' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSlmStop diff --git a/api/api/snapshot.cleanup_repository.js b/api/api/snapshot.cleanup_repository.js deleted file mode 100644 index 1f0a922c3..000000000 --- a/api/api/snapshot.cleanup_repository.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSnapshotCleanupRepository (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'master_timeout', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a snapshot.cleanup_repository request - * Removes stale data from repository. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/clean-up-snapshot-repo-api.html - */ - return function snapshotCleanupRepository (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['repository'] == null) { - const err = new ConfigurationError('Missing required parameter: repository') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, repository, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + '_cleanup' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSnapshotCleanupRepository diff --git a/api/api/snapshot.create.js b/api/api/snapshot.create.js deleted file mode 100644 index 4356e32bf..000000000 --- a/api/api/snapshot.create.js +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSnapshotCreate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'master_timeout', - 'wait_for_completion', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - waitForCompletion: 'wait_for_completion', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a snapshot.create request - * Creates a snapshot in a repository. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html - */ - return function snapshotCreate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['repository'] == null) { - const err = new ConfigurationError('Missing required parameter: repository') - return handleError(err, callback) - } - if (params['snapshot'] == null) { - const err = new ConfigurationError('Missing required parameter: snapshot') - return handleError(err, callback) - } - - // check required url components - if (params['snapshot'] != null && (params['repository'] == null)) { - 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') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, repository, snapshot, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSnapshotCreate diff --git a/api/api/snapshot.create_repository.js b/api/api/snapshot.create_repository.js deleted file mode 100644 index d8932b491..000000000 --- a/api/api/snapshot.create_repository.js +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSnapshotCreateRepository (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'master_timeout', - 'timeout', - 'verify', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a snapshot.create_repository request - * Creates a repository. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html - */ - return function snapshotCreateRepository (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['repository'] == null) { - const err = new ConfigurationError('Missing required parameter: repository') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, repository, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSnapshotCreateRepository diff --git a/api/api/snapshot.delete_repository.js b/api/api/snapshot.delete_repository.js deleted file mode 100644 index cc42a2331..000000000 --- a/api/api/snapshot.delete_repository.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSnapshotDeleteRepository (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'master_timeout', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a snapshot.delete_repository request - * Deletes a repository. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html - */ - return function snapshotDeleteRepository (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['repository'] == null) { - const err = new ConfigurationError('Missing required parameter: repository') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, repository, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSnapshotDeleteRepository diff --git a/api/api/snapshot.get.js b/api/api/snapshot.get.js deleted file mode 100644 index cbd79df5a..000000000 --- a/api/api/snapshot.get.js +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSnapshotGet (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'master_timeout', - 'ignore_unavailable', - 'verbose', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - ignoreUnavailable: 'ignore_unavailable', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a snapshot.get request - * Returns information about a snapshot. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html - */ - return function snapshotGet (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['repository'] == null) { - const err = new ConfigurationError('Missing required parameter: repository') - return handleError(err, callback) - } - if (params['snapshot'] == null) { - const err = new ConfigurationError('Missing required parameter: snapshot') - return handleError(err, callback) - } - - // check required url components - if (params['snapshot'] != null && (params['repository'] == null)) { - 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') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, repository, snapshot, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSnapshotGet diff --git a/api/api/snapshot.get_repository.js b/api/api/snapshot.get_repository.js deleted file mode 100644 index cf5a7e183..000000000 --- a/api/api/snapshot.get_repository.js +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSnapshotGetRepository (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'master_timeout', - 'local', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a snapshot.get_repository request - * Returns information about a repository. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html - */ - return function snapshotGetRepository (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, repository, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((repository) != null) { - if (method == null) method = 'GET' - path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) - } else { - if (method == null) method = 'GET' - path = '/' + '_snapshot' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSnapshotGetRepository diff --git a/api/api/snapshot.js b/api/api/snapshot.js new file mode 100644 index 000000000..377fd016b --- /dev/null +++ b/api/api/snapshot.js @@ -0,0 +1,363 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['master_timeout', 'timeout', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'wait_for_completion', 'verify', 'ignore_unavailable', 'verbose', 'local'] +const snakeCase = { masterTimeout: 'master_timeout', errorTrace: 'error_trace', filterPath: 'filter_path', waitForCompletion: 'wait_for_completion', ignoreUnavailable: 'ignore_unavailable' } + +function SnapshotApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +SnapshotApi.prototype.cleanupRepository = function snapshotCleanupRepositoryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['repository'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: repository') + return handleError(err, callback) + } + + var { method, body, repository, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + '_cleanup' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SnapshotApi.prototype.create = function snapshotCreateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['repository'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: repository') + return handleError(err, callback) + } + if (params['snapshot'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: snapshot') + return handleError(err, callback) + } + + // check required url components + if (params['snapshot'] != null && (params['repository'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: repository') + return handleError(err, callback) + } + + var { method, body, repository, snapshot, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SnapshotApi.prototype.createRepository = function snapshotCreateRepositoryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['repository'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: repository') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, repository, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SnapshotApi.prototype.delete = function snapshotDeleteApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['repository'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: repository') + return handleError(err, callback) + } + if (params['snapshot'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: snapshot') + return handleError(err, callback) + } + + // check required url components + if (params['snapshot'] != null && (params['repository'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: repository') + return handleError(err, callback) + } + + var { method, body, repository, snapshot, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SnapshotApi.prototype.deleteRepository = function snapshotDeleteRepositoryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['repository'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: repository') + return handleError(err, callback) + } + + var { method, body, repository, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SnapshotApi.prototype.get = function snapshotGetApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['repository'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: repository') + return handleError(err, callback) + } + if (params['snapshot'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: snapshot') + return handleError(err, callback) + } + + // check required url components + if (params['snapshot'] != null && (params['repository'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: repository') + return handleError(err, callback) + } + + var { method, body, repository, snapshot, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SnapshotApi.prototype.getRepository = function snapshotGetRepositoryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, repository, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((repository) != null) { + if (method == null) method = 'GET' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + } else { + if (method == null) method = 'GET' + path = '/' + '_snapshot' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SnapshotApi.prototype.restore = function snapshotRestoreApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['repository'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: repository') + return handleError(err, callback) + } + if (params['snapshot'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: snapshot') + return handleError(err, callback) + } + + // check required url components + if (params['snapshot'] != null && (params['repository'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: repository') + return handleError(err, callback) + } + + var { method, body, repository, snapshot, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) + '/' + '_restore' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SnapshotApi.prototype.status = function snapshotStatusApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required url components + if (params['snapshot'] != null && (params['repository'] == null)) { + const err = new this[kConfigurationError]('Missing required parameter of the url: repository') + return handleError(err, callback) + } + + var { method, body, repository, snapshot, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((repository) != null && (snapshot) != null) { + if (method == null) method = 'GET' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) + '/' + '_status' + } else if ((repository) != null) { + if (method == null) method = 'GET' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + '_status' + } else { + if (method == null) method = 'GET' + path = '/' + '_snapshot' + '/' + '_status' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +SnapshotApi.prototype.verifyRepository = function snapshotVerifyRepositoryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['repository'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: repository') + return handleError(err, callback) + } + + var { method, body, repository, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + '_verify' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(SnapshotApi.prototype, { + cleanup_repository: { get () { return this.cleanupRepository } }, + create_repository: { get () { return this.createRepository } }, + delete_repository: { get () { return this.deleteRepository } }, + get_repository: { get () { return this.getRepository } }, + verify_repository: { get () { return this.verifyRepository } } +}) + +module.exports = SnapshotApi diff --git a/api/api/snapshot.restore.js b/api/api/snapshot.restore.js deleted file mode 100644 index 422f0a67d..000000000 --- a/api/api/snapshot.restore.js +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSnapshotRestore (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'master_timeout', - 'wait_for_completion', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - waitForCompletion: 'wait_for_completion', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a snapshot.restore request - * Restores a snapshot. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html - */ - return function snapshotRestore (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['repository'] == null) { - const err = new ConfigurationError('Missing required parameter: repository') - return handleError(err, callback) - } - if (params['snapshot'] == null) { - const err = new ConfigurationError('Missing required parameter: snapshot') - return handleError(err, callback) - } - - // check required url components - if (params['snapshot'] != null && (params['repository'] == null)) { - 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') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, repository, snapshot, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) + '/' + '_restore' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSnapshotRestore diff --git a/api/api/snapshot.status.js b/api/api/snapshot.status.js deleted file mode 100644 index a74953ef7..000000000 --- a/api/api/snapshot.status.js +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSnapshotStatus (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'master_timeout', - 'ignore_unavailable', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - ignoreUnavailable: 'ignore_unavailable', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a snapshot.status request - * Returns information about the status of a snapshot. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html - */ - return function snapshotStatus (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required url components - if (params['snapshot'] != null && (params['repository'] == null)) { - 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') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, repository, snapshot, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((repository) != null && (snapshot) != null) { - if (method == null) method = 'GET' - path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + encodeURIComponent(snapshot) + '/' + '_status' - } else if ((repository) != null) { - if (method == null) method = 'GET' - path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + '_status' - } else { - if (method == null) method = 'GET' - path = '/' + '_snapshot' + '/' + '_status' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSnapshotStatus diff --git a/api/api/snapshot.verify_repository.js b/api/api/snapshot.verify_repository.js deleted file mode 100644 index e2f01a810..000000000 --- a/api/api/snapshot.verify_repository.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSnapshotVerifyRepository (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'master_timeout', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - masterTimeout: 'master_timeout', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a snapshot.verify_repository request - * Verifies a repository. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-snapshots.html - */ - return function snapshotVerifyRepository (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['repository'] == null) { - const err = new ConfigurationError('Missing required parameter: repository') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, repository, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_snapshot' + '/' + encodeURIComponent(repository) + '/' + '_verify' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSnapshotVerifyRepository diff --git a/api/api/sql.clear_cursor.js b/api/api/sql.clear_cursor.js deleted file mode 100644 index 2613ee18f..000000000 --- a/api/api/sql.clear_cursor.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSqlClearCursor (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a sql.clear_cursor request - * Clears the SQL cursor - * https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-pagination.html - */ - return function sqlClearCursor (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_sql' + '/' + 'close' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSqlClearCursor diff --git a/api/api/sql.js b/api/api/sql.js new file mode 100644 index 000000000..db4c2d08f --- /dev/null +++ b/api/api/sql.js @@ -0,0 +1,119 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path', 'format'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } + +function SqlApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +SqlApi.prototype.clearCursor = function sqlClearCursorApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_sql' + '/' + 'close' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SqlApi.prototype.query = function sqlQueryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_sql' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +SqlApi.prototype.translate = function sqlTranslateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + '_sql' + '/' + 'translate' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(SqlApi.prototype, { + clear_cursor: { get () { return this.clearCursor } } +}) + +module.exports = SqlApi diff --git a/api/api/sql.query.js b/api/api/sql.query.js deleted file mode 100644 index d5bc8116c..000000000 --- a/api/api/sql.query.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSqlQuery (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'format' - ] - - const snakeCase = { - - } - - /** - * Perform a sql.query request - * Executes a SQL request - * https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-rest-overview.html - */ - return function sqlQuery (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_sql' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSqlQuery diff --git a/api/api/sql.translate.js b/api/api/sql.translate.js deleted file mode 100644 index 38552262a..000000000 --- a/api/api/sql.translate.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSqlTranslate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a sql.translate request - * Translates SQL into Elasticsearch queries - * https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-translate.html - */ - return function sqlTranslate (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_sql' + '/' + 'translate' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSqlTranslate diff --git a/api/api/ssl.certificates.js b/api/api/ssl.certificates.js deleted file mode 100644 index 9c19f2ef7..000000000 --- a/api/api/ssl.certificates.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildSslCertificates (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a ssl.certificates request - * Retrieves information about the X.509 certificates used to encrypt communications in the cluster. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-ssl.html - */ - return function sslCertificates (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_ssl' + '/' + 'certificates' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildSslCertificates diff --git a/api/api/ssl.js b/api/api/ssl.js new file mode 100644 index 000000000..76f02913e --- /dev/null +++ b/api/api/ssl.js @@ -0,0 +1,55 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path' } + +function SslApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +SslApi.prototype.certificates = function sslCertificatesApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_ssl' + '/' + 'certificates' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +module.exports = SslApi diff --git a/api/api/tasks.cancel.js b/api/api/tasks.cancel.js deleted file mode 100644 index 42f2d0222..000000000 --- a/api/api/tasks.cancel.js +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildTasksCancel (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'nodes', - 'actions', - 'parent_task_id', - 'wait_for_completion', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - parentTaskId: 'parent_task_id', - waitForCompletion: 'wait_for_completion', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a tasks.cancel request - * Cancels a task, if it can be cancelled through an API. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html - */ - return function tasksCancel (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, taskId, task_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((task_id || taskId) != null) { - if (method == null) method = 'POST' - path = '/' + '_tasks' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_cancel' - } else { - if (method == null) method = 'POST' - path = '/' + '_tasks' + '/' + '_cancel' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildTasksCancel diff --git a/api/api/tasks.get.js b/api/api/tasks.get.js deleted file mode 100644 index d864c9bff..000000000 --- a/api/api/tasks.get.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildTasksGet (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'wait_for_completion', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - waitForCompletion: 'wait_for_completion', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a tasks.get request - * Returns information about a task. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html - */ - return function tasksGet (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['task_id'] == null && params['taskId'] == null) { - const err = new ConfigurationError('Missing required parameter: task_id or taskId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, taskId, task_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_tasks' + '/' + encodeURIComponent(task_id || taskId) - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildTasksGet diff --git a/api/api/tasks.js b/api/api/tasks.js new file mode 100644 index 000000000..576c36110 --- /dev/null +++ b/api/api/tasks.js @@ -0,0 +1,108 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['nodes', 'actions', 'parent_task_id', 'wait_for_completion', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'timeout', 'detailed', 'group_by'] +const snakeCase = { parentTaskId: 'parent_task_id', waitForCompletion: 'wait_for_completion', errorTrace: 'error_trace', filterPath: 'filter_path', groupBy: 'group_by' } + +function TasksApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +TasksApi.prototype.cancel = function tasksCancelApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, taskId, task_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((task_id || taskId) != null) { + if (method == null) method = 'POST' + path = '/' + '_tasks' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_cancel' + } else { + if (method == null) method = 'POST' + path = '/' + '_tasks' + '/' + '_cancel' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +TasksApi.prototype.get = function tasksGetApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['task_id'] == null && params['taskId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: task_id or taskId') + return handleError(err, callback) + } + + var { method, body, taskId, task_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_tasks' + '/' + encodeURIComponent(task_id || taskId) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +TasksApi.prototype.list = function tasksListApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_tasks' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +module.exports = TasksApi diff --git a/api/api/tasks.list.js b/api/api/tasks.list.js deleted file mode 100644 index 59eba845b..000000000 --- a/api/api/tasks.list.js +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildTasksList (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'nodes', - 'actions', - 'detailed', - 'parent_task_id', - 'wait_for_completion', - 'group_by', - 'timeout', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] - - const snakeCase = { - parentTaskId: 'parent_task_id', - waitForCompletion: 'wait_for_completion', - groupBy: 'group_by', - errorTrace: 'error_trace', - filterPath: 'filter_path' - } - - /** - * Perform a tasks.list request - * Returns a list of tasks. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html - */ - return function tasksList (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_tasks' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildTasksList diff --git a/api/api/termvectors.js b/api/api/termvectors.js index 8542f082a..ba50668b3 100644 --- a/api/api/termvectors.js +++ b/api/api/termvectors.js @@ -22,54 +22,23 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildTermvectors (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['term_statistics', 'field_statistics', 'fields', 'offsets', 'positions', 'payloads', 'preference', 'routing', 'realtime', 'version', 'version_type', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { termStatistics: 'term_statistics', fieldStatistics: 'field_statistics', versionType: 'version_type', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'term_statistics', - 'field_statistics', - 'fields', - 'offsets', - 'positions', - 'payloads', - 'preference', - 'routing', - 'realtime', - 'version', - 'version_type', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function termvectorsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - termStatistics: 'term_statistics', - fieldStatistics: 'field_statistics', - versionType: 'version_type', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) } - /** - * Perform a termvectors request - * Returns information and statistics about terms in the fields of a particular document. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-termvectors.html - */ - return function termvectors (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, index, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) +<<<<<<< HEAD // check required parameters if (params['index'] == null) { const err = new ConfigurationError('Missing required parameter: index') @@ -114,10 +83,26 @@ function buildTermvectors (opts) { body: body || '', querystring } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) +======= + var path = '' + if ((index) != null && (id) != null) { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_termvectors' + '/' + encodeURIComponent(id) + } else { + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_termvectors' } +>>>>>>> a064f0f3... Improve child performances (#1314) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildTermvectors +module.exports = termvectorsApi diff --git a/api/api/transform.delete_transform.js b/api/api/transform.delete_transform.js deleted file mode 100644 index 7c2a5cc19..000000000 --- a/api/api/transform.delete_transform.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildTransformDeleteTransform (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'force' - ] - - const snakeCase = { - - } - - /** - * Perform a transform.delete_transform request - * Deletes an existing transform. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-transform.html - */ - return function transformDeleteTransform (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['transform_id'] == null && params['transformId'] == null) { - const err = new ConfigurationError('Missing required parameter: transform_id or transformId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, transformId, transform_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildTransformDeleteTransform diff --git a/api/api/transform.get_transform.js b/api/api/transform.get_transform.js deleted file mode 100644 index 49164a95f..000000000 --- a/api/api/transform.get_transform.js +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildTransformGetTransform (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'from', - 'size', - 'allow_no_match' - ] - - const snakeCase = { - allowNoMatch: 'allow_no_match' - } - - /** - * Perform a transform.get_transform request - * Retrieves configuration information for transforms. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform.html - */ - return function transformGetTransform (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, transformId, transform_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((transform_id || transformId) != null) { - if (method == null) method = 'GET' - path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) - } else { - if (method == null) method = 'GET' - path = '/' + '_transform' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildTransformGetTransform diff --git a/api/api/transform.get_transform_stats.js b/api/api/transform.get_transform_stats.js deleted file mode 100644 index 78c2621ed..000000000 --- a/api/api/transform.get_transform_stats.js +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildTransformGetTransformStats (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'from', - 'size', - 'allow_no_match' - ] - - const snakeCase = { - allowNoMatch: 'allow_no_match' - } - - /** - * Perform a transform.get_transform_stats request - * Retrieves usage information for transforms. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/get-transform-stats.html - */ - return function transformGetTransformStats (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['transform_id'] == null && params['transformId'] == null) { - const err = new ConfigurationError('Missing required parameter: transform_id or transformId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, transformId, transform_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_stats' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildTransformGetTransformStats diff --git a/api/api/transform.js b/api/api/transform.js new file mode 100644 index 000000000..e52130b2e --- /dev/null +++ b/api/api/transform.js @@ -0,0 +1,268 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['force', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'from', 'size', 'allow_no_match', 'defer_validation', 'timeout', 'wait_for_completion', 'wait_for_checkpoint'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path', allowNoMatch: 'allow_no_match', deferValidation: 'defer_validation', waitForCompletion: 'wait_for_completion', waitForCheckpoint: 'wait_for_checkpoint' } + +function TransformApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +TransformApi.prototype.deleteTransform = function transformDeleteTransformApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['transform_id'] == null && params['transformId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: transform_id or transformId') + return handleError(err, callback) + } + + var { method, body, transformId, transform_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +TransformApi.prototype.getTransform = function transformGetTransformApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, transformId, transform_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((transform_id || transformId) != null) { + if (method == null) method = 'GET' + path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + } else { + if (method == null) method = 'GET' + path = '/' + '_transform' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +TransformApi.prototype.getTransformStats = function transformGetTransformStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['transform_id'] == null && params['transformId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: transform_id or transformId') + return handleError(err, callback) + } + + var { method, body, transformId, transform_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_stats' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +TransformApi.prototype.previewTransform = function transformPreviewTransformApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_transform' + '/' + '_preview' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +TransformApi.prototype.putTransform = function transformPutTransformApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['transform_id'] == null && params['transformId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: transform_id or transformId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, transformId, transform_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +TransformApi.prototype.startTransform = function transformStartTransformApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['transform_id'] == null && params['transformId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: transform_id or transformId') + return handleError(err, callback) + } + + var { method, body, transformId, transform_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_start' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +TransformApi.prototype.stopTransform = function transformStopTransformApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['transform_id'] == null && params['transformId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: transform_id or transformId') + return handleError(err, callback) + } + + var { method, body, transformId, transform_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_stop' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +TransformApi.prototype.updateTransform = function transformUpdateTransformApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['transform_id'] == null && params['transformId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: transform_id or transformId') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) + } + + var { method, body, transformId, transform_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_update' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(TransformApi.prototype, { + delete_transform: { get () { return this.deleteTransform } }, + get_transform: { get () { return this.getTransform } }, + get_transform_stats: { get () { return this.getTransformStats } }, + preview_transform: { get () { return this.previewTransform } }, + put_transform: { get () { return this.putTransform } }, + start_transform: { get () { return this.startTransform } }, + stop_transform: { get () { return this.stopTransform } }, + update_transform: { get () { return this.updateTransform } } +}) + +module.exports = TransformApi diff --git a/api/api/transform.preview_transform.js b/api/api/transform.preview_transform.js deleted file mode 100644 index 49f314f3d..000000000 --- a/api/api/transform.preview_transform.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildTransformPreviewTransform (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a transform.preview_transform request - * Previews a transform. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/preview-transform.html - */ - return function transformPreviewTransform (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_transform' + '/' + '_preview' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildTransformPreviewTransform diff --git a/api/api/transform.put_transform.js b/api/api/transform.put_transform.js deleted file mode 100644 index 6694c6d29..000000000 --- a/api/api/transform.put_transform.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildTransformPutTransform (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'defer_validation' - ] - - const snakeCase = { - deferValidation: 'defer_validation' - } - - /** - * Perform a transform.put_transform request - * Instantiates a transform. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/put-transform.html - */ - return function transformPutTransform (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['transform_id'] == null && params['transformId'] == null) { - const err = new ConfigurationError('Missing required parameter: transform_id or transformId') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, transformId, transform_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildTransformPutTransform diff --git a/api/api/transform.start_transform.js b/api/api/transform.start_transform.js deleted file mode 100644 index 65300821b..000000000 --- a/api/api/transform.start_transform.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildTransformStartTransform (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'timeout' - ] - - const snakeCase = { - - } - - /** - * Perform a transform.start_transform request - * Starts one or more transforms. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/start-transform.html - */ - return function transformStartTransform (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['transform_id'] == null && params['transformId'] == null) { - const err = new ConfigurationError('Missing required parameter: transform_id or transformId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, transformId, transform_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_start' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildTransformStartTransform diff --git a/api/api/transform.stop_transform.js b/api/api/transform.stop_transform.js deleted file mode 100644 index 6ff716fd7..000000000 --- a/api/api/transform.stop_transform.js +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildTransformStopTransform (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'force', - 'wait_for_completion', - 'timeout', - 'allow_no_match', - 'wait_for_checkpoint' - ] - - const snakeCase = { - waitForCompletion: 'wait_for_completion', - allowNoMatch: 'allow_no_match', - waitForCheckpoint: 'wait_for_checkpoint' - } - - /** - * Perform a transform.stop_transform request - * Stops one or more transforms. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/stop-transform.html - */ - return function transformStopTransform (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['transform_id'] == null && params['transformId'] == null) { - const err = new ConfigurationError('Missing required parameter: transform_id or transformId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, transformId, transform_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_stop' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildTransformStopTransform diff --git a/api/api/transform.update_transform.js b/api/api/transform.update_transform.js deleted file mode 100644 index bc8a2d9e9..000000000 --- a/api/api/transform.update_transform.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildTransformUpdateTransform (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'defer_validation' - ] - - const snakeCase = { - deferValidation: 'defer_validation' - } - - /** - * Perform a transform.update_transform request - * Updates certain properties of a transform. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/update-transform.html - */ - return function transformUpdateTransform (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['transform_id'] == null && params['transformId'] == null) { - const err = new ConfigurationError('Missing required parameter: transform_id or transformId') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, transformId, transform_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_transform' + '/' + encodeURIComponent(transform_id || transformId) + '/' + '_update' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildTransformUpdateTransform diff --git a/api/api/update.js b/api/api/update.js index cd013fcfc..cbc827f27 100644 --- a/api/api/update.js +++ b/api/api/update.js @@ -22,10 +22,11 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildUpdate (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['wait_for_active_shards', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'lang', 'refresh', 'retry_on_conflict', 'routing', 'timeout', 'if_seq_no', 'if_primary_term', 'require_alias', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { waitForActiveShards: 'wait_for_active_shards', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', retryOnConflict: 'retry_on_conflict', ifSeqNo: 'if_seq_no', ifPrimaryTerm: 'if_primary_term', requireAlias: 'require_alias', errorTrace: 'error_trace', filterPath: 'filter_path' } +<<<<<<< HEAD const acceptedQuerystring = [ 'wait_for_active_shards', '_source', @@ -56,75 +57,46 @@ function buildUpdate (opts) { requireAlias: 'require_alias', errorTrace: 'error_trace', filterPath: 'filter_path' +======= +function updateApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: body') + return handleError(err, callback) +>>>>>>> a064f0f3... Improve child performances (#1314) } - /** - * Perform a update request - * Updates a document with a script or partial document. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update.html - */ - return function update (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, id, index, type, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } - if (params['body'] == null) { - const err = new ConfigurationError('Missing required parameter: body') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, index, type, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((index) != null && (type) != null && (id) != null) { - if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_update' - } else { - if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_update' + '/' + encodeURIComponent(id) - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + var path = '' + if ((index) != null && (type) != null && (id) != null) { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + encodeURIComponent(type) + '/' + encodeURIComponent(id) + '/' + '_update' + } else { + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_update' + '/' + encodeURIComponent(id) } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) } -module.exports = buildUpdate +module.exports = updateApi diff --git a/api/api/update_by_query.js b/api/api/update_by_query.js index 745e55661..36caddf2d 100644 --- a/api/api/update_by_query.js +++ b/api/api/update_by_query.js @@ -22,10 +22,11 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildUpdateByQuery (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['analyzer', 'analyze_wildcard', 'default_operator', 'df', 'from', 'ignore_unavailable', 'allow_no_indices', 'conflicts', 'expand_wildcards', 'lenient', 'pipeline', 'preference', 'q', 'routing', 'scroll', 'search_type', 'search_timeout', 'max_docs', 'sort', '_source', '_source_excludes', '_source_exclude', '_source_includes', '_source_include', 'terminate_after', 'stats', 'version', 'version_type', 'request_cache', 'refresh', 'timeout', 'wait_for_active_shards', 'scroll_size', 'wait_for_completion', 'requests_per_second', 'slices', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { analyzeWildcard: 'analyze_wildcard', defaultOperator: 'default_operator', ignoreUnavailable: 'ignore_unavailable', allowNoIndices: 'allow_no_indices', expandWildcards: 'expand_wildcards', searchType: 'search_type', searchTimeout: 'search_timeout', maxDocs: 'max_docs', _sourceExcludes: '_source_excludes', _sourceExclude: '_source_exclude', _sourceIncludes: '_source_includes', _sourceInclude: '_source_include', terminateAfter: 'terminate_after', versionType: 'version_type', requestCache: 'request_cache', waitForActiveShards: 'wait_for_active_shards', scrollSize: 'scroll_size', waitForCompletion: 'wait_for_completion', requestsPerSecond: 'requests_per_second', errorTrace: 'error_trace', filterPath: 'filter_path' } +<<<<<<< HEAD const acceptedQuerystring = [ 'analyzer', 'analyze_wildcard', @@ -89,32 +90,25 @@ function buildUpdateByQuery (opts) { requestsPerSecond: 'requests_per_second', errorTrace: 'error_trace', filterPath: 'filter_path' +======= +function updateByQueryApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['index'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: index') + return handleError(err, callback) +>>>>>>> a064f0f3... Improve child performances (#1314) } - /** - * Perform a update_by_query request - * Performs an update on every document in the index without changing the source, -for example to pick up a mapping change. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-update-by-query.html - */ - return function updateByQuery (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, index, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - // check required parameters - if (params['index'] == null) { - const err = new ConfigurationError('Missing required parameter: index') - return handleError(err, callback) - } + var path = '' + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_update_by_query' +<<<<<<< HEAD // check required url components if (params['type'] != null && (params['index'] == null)) { const err = new ConfigurationError('Missing required parameter of the url: index') @@ -156,7 +150,17 @@ for example to pick up a mapping change. options.warnings = warnings.length === 0 ? null : warnings return makeRequest(request, options, callback) +======= + // build request object + const request = { + method, + path, + body: body || '', + querystring +>>>>>>> a064f0f3... Improve child performances (#1314) } + + return this.transport.request(request, options, callback) } -module.exports = buildUpdateByQuery +module.exports = updateByQueryApi diff --git a/api/api/update_by_query_rethrottle.js b/api/api/update_by_query_rethrottle.js index 6a278def8..a5c8145af 100644 --- a/api/api/update_by_query_rethrottle.js +++ b/api/api/update_by_query_rethrottle.js @@ -22,83 +22,39 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildUpdateByQueryRethrottle (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['requests_per_second', 'pretty', 'human', 'error_trace', 'source', 'filter_path'] +const snakeCase = { requestsPerSecond: 'requests_per_second', errorTrace: 'error_trace', filterPath: 'filter_path' } - const acceptedQuerystring = [ - 'requests_per_second', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' - ] +function updateByQueryRethrottleApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) - const snakeCase = { - requestsPerSecond: 'requests_per_second', - errorTrace: 'error_trace', - filterPath: 'filter_path' + // check required parameters + if (params['task_id'] == null && params['taskId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: task_id or taskId') + return handleError(err, callback) + } + if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: requests_per_second or requestsPerSecond') + return handleError(err, callback) } - /** - * Perform a update_by_query_rethrottle request - * Changes the number of requests per second for a particular Update By Query operation. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html - */ - return function updateByQueryRethrottle (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + var { method, body, taskId, task_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) - // check required parameters - if (params['task_id'] == null && params['taskId'] == null) { - const err = new ConfigurationError('Missing required parameter: task_id or taskId') - return handleError(err, callback) - } - if (params['requests_per_second'] == null && params['requestsPerSecond'] == null) { - const err = new ConfigurationError('Missing required parameter: requests_per_second or requestsPerSecond') - return handleError(err, callback) - } + var path = '' + if (method == null) method = 'POST' + path = '/' + '_update_by_query' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_rethrottle' - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, taskId, task_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_update_by_query' + '/' + encodeURIComponent(task_id || taskId) + '/' + '_rethrottle' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + // build request object + const request = { + method, + path, + body: body || '', + querystring } + + return this.transport.request(request, options, callback) } -module.exports = buildUpdateByQueryRethrottle +module.exports = updateByQueryRethrottleApi diff --git a/api/api/watcher.ack_watch.js b/api/api/watcher.ack_watch.js deleted file mode 100644 index 00d14e39f..000000000 --- a/api/api/watcher.ack_watch.js +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildWatcherAckWatch (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a watcher.ack_watch request - * Acknowledges a watch, manually throttling the execution of the watch's actions. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-ack-watch.html - */ - return function watcherAckWatch (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['watch_id'] == null && params['watchId'] == null) { - const err = new ConfigurationError('Missing required parameter: watch_id or watchId') - return handleError(err, callback) - } - - // check required url components - if ((params['action_id'] != null || params['actionId'] != null) && ((params['watch_id'] == null && params['watchId'] == null))) { - const err = new ConfigurationError('Missing required parameter of the url: watch_id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, watchId, watch_id, actionId, action_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((watch_id || watchId) != null && (action_id || actionId) != null) { - if (method == null) method = 'PUT' - path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(watch_id || watchId) + '/' + '_ack' + '/' + encodeURIComponent(action_id || actionId) - } else { - if (method == null) method = 'PUT' - path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(watch_id || watchId) + '/' + '_ack' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildWatcherAckWatch diff --git a/api/api/watcher.activate_watch.js b/api/api/watcher.activate_watch.js deleted file mode 100644 index 3160e544f..000000000 --- a/api/api/watcher.activate_watch.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildWatcherActivateWatch (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a watcher.activate_watch request - * Activates a currently inactive watch. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-activate-watch.html - */ - return function watcherActivateWatch (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['watch_id'] == null && params['watchId'] == null) { - const err = new ConfigurationError('Missing required parameter: watch_id or watchId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, watchId, watch_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(watch_id || watchId) + '/' + '_activate' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildWatcherActivateWatch diff --git a/api/api/watcher.deactivate_watch.js b/api/api/watcher.deactivate_watch.js deleted file mode 100644 index c1a1d4130..000000000 --- a/api/api/watcher.deactivate_watch.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildWatcherDeactivateWatch (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a watcher.deactivate_watch request - * Deactivates a currently active watch. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-deactivate-watch.html - */ - return function watcherDeactivateWatch (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['watch_id'] == null && params['watchId'] == null) { - const err = new ConfigurationError('Missing required parameter: watch_id or watchId') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, watchId, watch_id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(watch_id || watchId) + '/' + '_deactivate' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildWatcherDeactivateWatch diff --git a/api/api/watcher.delete_watch.js b/api/api/watcher.delete_watch.js deleted file mode 100644 index 0945d8534..000000000 --- a/api/api/watcher.delete_watch.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildWatcherDeleteWatch (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a watcher.delete_watch request - * Removes a watch from Watcher. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-delete-watch.html - */ - return function watcherDeleteWatch (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'DELETE' - path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(id) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildWatcherDeleteWatch diff --git a/api/api/watcher.execute_watch.js b/api/api/watcher.execute_watch.js deleted file mode 100644 index 5ee4068f0..000000000 --- a/api/api/watcher.execute_watch.js +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildWatcherExecuteWatch (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'debug' - ] - - const snakeCase = { - - } - - /** - * Perform a watcher.execute_watch request - * Forces the execution of a stored watch. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-execute-watch.html - */ - return function watcherExecuteWatch (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((id) != null) { - if (method == null) method = 'PUT' - path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(id) + '/' + '_execute' - } else { - if (method == null) method = 'PUT' - path = '/' + '_watcher' + '/' + 'watch' + '/' + '_execute' - } - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildWatcherExecuteWatch diff --git a/api/api/watcher.get_watch.js b/api/api/watcher.get_watch.js deleted file mode 100644 index 664c5a5b6..000000000 --- a/api/api/watcher.get_watch.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildWatcherGetWatch (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a watcher.get_watch request - * Retrieves a watch by its ID. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-get-watch.html - */ - return function watcherGetWatch (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(id) - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildWatcherGetWatch diff --git a/api/api/watcher.js b/api/api/watcher.js new file mode 100644 index 000000000..ba1236e00 --- /dev/null +++ b/api/api/watcher.js @@ -0,0 +1,311 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['pretty', 'human', 'error_trace', 'source', 'filter_path', 'debug', 'active', 'version', 'if_seq_no', 'if_primary_term', 'metric', 'emit_stacktraces'] +const snakeCase = { errorTrace: 'error_trace', filterPath: 'filter_path', ifSeqNo: 'if_seq_no', ifPrimaryTerm: 'if_primary_term', emitStacktraces: 'emit_stacktraces' } + +function WatcherApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +WatcherApi.prototype.ackWatch = function watcherAckWatchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['watch_id'] == null && params['watchId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: watch_id or watchId') + return handleError(err, callback) + } + + // check required url components + if ((params['action_id'] != null || params['actionId'] != null) && ((params['watch_id'] == null && params['watchId'] == null))) { + const err = new this[kConfigurationError]('Missing required parameter of the url: watch_id') + return handleError(err, callback) + } + + var { method, body, watchId, watch_id, actionId, action_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((watch_id || watchId) != null && (action_id || actionId) != null) { + if (method == null) method = 'PUT' + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(watch_id || watchId) + '/' + '_ack' + '/' + encodeURIComponent(action_id || actionId) + } else { + if (method == null) method = 'PUT' + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(watch_id || watchId) + '/' + '_ack' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +WatcherApi.prototype.activateWatch = function watcherActivateWatchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['watch_id'] == null && params['watchId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: watch_id or watchId') + return handleError(err, callback) + } + + var { method, body, watchId, watch_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(watch_id || watchId) + '/' + '_activate' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +WatcherApi.prototype.deactivateWatch = function watcherDeactivateWatchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['watch_id'] == null && params['watchId'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: watch_id or watchId') + return handleError(err, callback) + } + + var { method, body, watchId, watch_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(watch_id || watchId) + '/' + '_deactivate' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +WatcherApi.prototype.deleteWatch = function watcherDeleteWatchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'DELETE' + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +WatcherApi.prototype.executeWatch = function watcherExecuteWatchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((id) != null) { + if (method == null) method = 'PUT' + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(id) + '/' + '_execute' + } else { + if (method == null) method = 'PUT' + path = '/' + '_watcher' + '/' + 'watch' + '/' + '_execute' + } + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +WatcherApi.prototype.getWatch = function watcherGetWatchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +WatcherApi.prototype.putWatch = function watcherPutWatchApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + // check required parameters + if (params['id'] == null) { + const err = new this[kConfigurationError]('Missing required parameter: id') + return handleError(err, callback) + } + + var { method, body, id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'PUT' + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(id) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +WatcherApi.prototype.start = function watcherStartApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_watcher' + '/' + '_start' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +WatcherApi.prototype.stats = function watcherStatsApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, metric, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if ((metric) != null) { + if (method == null) method = 'GET' + path = '/' + '_watcher' + '/' + 'stats' + '/' + encodeURIComponent(metric) + } else { + if (method == null) method = 'GET' + path = '/' + '_watcher' + '/' + 'stats' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +WatcherApi.prototype.stop = function watcherStopApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'POST' + path = '/' + '_watcher' + '/' + '_stop' + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + return this.transport.request(request, options, callback) +} + +Object.defineProperties(WatcherApi.prototype, { + ack_watch: { get () { return this.ackWatch } }, + activate_watch: { get () { return this.activateWatch } }, + deactivate_watch: { get () { return this.deactivateWatch } }, + delete_watch: { get () { return this.deleteWatch } }, + execute_watch: { get () { return this.executeWatch } }, + get_watch: { get () { return this.getWatch } }, + put_watch: { get () { return this.putWatch } } +}) + +module.exports = WatcherApi diff --git a/api/api/watcher.put_watch.js b/api/api/watcher.put_watch.js deleted file mode 100644 index 9be705e96..000000000 --- a/api/api/watcher.put_watch.js +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildWatcherPutWatch (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'active', - 'version', - 'if_seq_no', - 'if_primary_term' - ] - - const snakeCase = { - ifSeqNo: 'if_seq_no', - ifPrimaryTerm: 'if_primary_term' - } - - /** - * Perform a watcher.put_watch request - * Creates a new watch, or updates an existing one. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html - */ - return function watcherPutWatch (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // check required parameters - if (params['id'] == null) { - const err = new ConfigurationError('Missing required parameter: id') - return handleError(err, callback) - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, id, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'PUT' - path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(id) - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildWatcherPutWatch diff --git a/api/api/watcher.start.js b/api/api/watcher.start.js deleted file mode 100644 index 60b371b71..000000000 --- a/api/api/watcher.start.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildWatcherStart (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a watcher.start request - * Starts Watcher if it is not already running. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-start.html - */ - return function watcherStart (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_watcher' + '/' + '_start' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildWatcherStart diff --git a/api/api/watcher.stats.js b/api/api/watcher.stats.js deleted file mode 100644 index 58f54d872..000000000 --- a/api/api/watcher.stats.js +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildWatcherStats (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'metric', - 'emit_stacktraces' - ] - - const snakeCase = { - emitStacktraces: 'emit_stacktraces' - } - - /** - * Perform a watcher.stats request - * Retrieves the current Watcher metrics. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stats.html - */ - return function watcherStats (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, metric, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if ((metric) != null) { - if (method == null) method = 'GET' - path = '/' + '_watcher' + '/' + 'stats' + '/' + encodeURIComponent(metric) - } else { - if (method == null) method = 'GET' - path = '/' + '_watcher' + '/' + 'stats' - } - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildWatcherStats diff --git a/api/api/watcher.stop.js b/api/api/watcher.stop.js deleted file mode 100644 index 1f4385247..000000000 --- a/api/api/watcher.stop.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildWatcherStop (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - - ] - - const snakeCase = { - - } - - /** - * Perform a watcher.stop request - * Stops Watcher if it is running. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-stop.html - */ - return function watcherStop (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'POST' - path = '/' + '_watcher' + '/' + '_stop' - - // build request object - const request = { - method, - path, - body: body || '', - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildWatcherStop diff --git a/api/api/xpack.info.js b/api/api/xpack.info.js deleted file mode 100644 index 12cb4f496..000000000 --- a/api/api/xpack.info.js +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildXpackInfo (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'categories', - 'accept_enterprise' - ] - - const snakeCase = { - acceptEnterprise: 'accept_enterprise' - } - - /** - * Perform a xpack.info request - * Retrieves information about the installed X-Pack features. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/info-api.html - */ - return function xpackInfo (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_xpack' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildXpackInfo diff --git a/api/api/xpack.js b/api/api/xpack.js new file mode 100644 index 000000000..47c619fa7 --- /dev/null +++ b/api/api/xpack.js @@ -0,0 +1,76 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +const acceptedQuerystring = ['categories', 'accept_enterprise', 'pretty', 'human', 'error_trace', 'source', 'filter_path', 'master_timeout'] +const snakeCase = { acceptEnterprise: 'accept_enterprise', errorTrace: 'error_trace', filterPath: 'filter_path', masterTimeout: 'master_timeout' } + +function XpackApi (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError +} + +XpackApi.prototype.info = function xpackInfoApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_xpack' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +XpackApi.prototype.usage = function xpackUsageApi (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) + + var { method, body, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) + + var path = '' + if (method == null) method = 'GET' + path = '/' + '_xpack' + '/' + 'usage' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + return this.transport.request(request, options, callback) +} + +module.exports = XpackApi diff --git a/api/api/xpack.usage.js b/api/api/xpack.usage.js deleted file mode 100644 index efef3d792..000000000 --- a/api/api/xpack.usage.js +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -'use strict' - -/* eslint camelcase: 0 */ -/* eslint no-unused-vars: 0 */ - -function buildXpackUsage (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - 'master_timeout' - ] - - const snakeCase = { - masterTimeout: 'master_timeout' - } - - /** - * Perform a xpack.usage request - * Retrieves usage information about the installed X-Pack features. - * https://www.elastic.co/guide/en/elasticsearch/reference/current/usage-api.html - */ - return function xpackUsage (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) - return handleError(err, callback) - } - - var warnings = [] - var { method, body, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - - var path = '' - - if (method == null) method = 'GET' - path = '/' + '_xpack' + '/' + 'usage' - - // build request object - const request = { - method, - path, - body: null, - querystring - } - - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) - } -} - -module.exports = buildXpackUsage diff --git a/api/index.js b/api/index.js index cd61c6fa6..0ed832562 100644 --- a/api/index.js +++ b/api/index.js @@ -19,17 +19,179 @@ 'use strict' -const assert = require('assert') +const bulkApi = require('./api/bulk') +const CatApi = require('./api/cat') +const clearScrollApi = require('./api/clear_scroll') +const ClusterApi = require('./api/cluster') +const countApi = require('./api/count') +const createApi = require('./api/create') +const DanglingIndicesApi = require('./api/dangling_indices') +const deleteApi = require('./api/delete') +const deleteByQueryApi = require('./api/delete_by_query') +const deleteByQueryRethrottleApi = require('./api/delete_by_query_rethrottle') +const deleteScriptApi = require('./api/delete_script') +const existsApi = require('./api/exists') +const existsSourceApi = require('./api/exists_source') +const explainApi = require('./api/explain') +const fieldCapsApi = require('./api/field_caps') +const getApi = require('./api/get') +const getScriptApi = require('./api/get_script') +const getScriptContextApi = require('./api/get_script_context') +const getScriptLanguagesApi = require('./api/get_script_languages') +const getSourceApi = require('./api/get_source') +const indexApi = require('./api/index') +const IndicesApi = require('./api/indices') +const infoApi = require('./api/info') +const IngestApi = require('./api/ingest') +const mgetApi = require('./api/mget') +const msearchApi = require('./api/msearch') +const msearchTemplateApi = require('./api/msearch_template') +const mtermvectorsApi = require('./api/mtermvectors') +const NodesApi = require('./api/nodes') +const pingApi = require('./api/ping') +const putScriptApi = require('./api/put_script') +const rankEvalApi = require('./api/rank_eval') +const reindexApi = require('./api/reindex') +const reindexRethrottleApi = require('./api/reindex_rethrottle') +const renderSearchTemplateApi = require('./api/render_search_template') +const scriptsPainlessExecuteApi = require('./api/scripts_painless_execute') +const scrollApi = require('./api/scroll') +const searchApi = require('./api/search') +const searchShardsApi = require('./api/search_shards') +const searchTemplateApi = require('./api/search_template') +const SnapshotApi = require('./api/snapshot') +const TasksApi = require('./api/tasks') +const termvectorsApi = require('./api/termvectors') +const updateApi = require('./api/update') +const updateByQueryApi = require('./api/update_by_query') +const updateByQueryRethrottleApi = require('./api/update_by_query_rethrottle') +const AsyncSearchApi = require('./api/async_search') +const AutoscalingApi = require('./api/autoscaling') +const CcrApi = require('./api/ccr') +const closePointInTimeApi = require('./api/close_point_in_time') +const EnrichApi = require('./api/enrich') +const EqlApi = require('./api/eql') +const GraphApi = require('./api/graph') +const IlmApi = require('./api/ilm') +const LicenseApi = require('./api/license') +const MigrationApi = require('./api/migration') +const MlApi = require('./api/ml') +const MonitoringApi = require('./api/monitoring') +const openPointInTimeApi = require('./api/open_point_in_time') +const RollupApi = require('./api/rollup') +const SearchableSnapshotsApi = require('./api/searchable_snapshots') +const SecurityApi = require('./api/security') +const SlmApi = require('./api/slm') +const SqlApi = require('./api/sql') +const SslApi = require('./api/ssl') +const TransformApi = require('./api/transform') +const WatcherApi = require('./api/watcher') +const XpackApi = require('./api/xpack') + +const { kConfigurationError } = require('./utils') +const kCat = Symbol('Cat') +const kCluster = Symbol('Cluster') +const kDanglingIndices = Symbol('DanglingIndices') +const kIndices = Symbol('Indices') +const kIngest = Symbol('Ingest') +const kNodes = Symbol('Nodes') +const kSnapshot = Symbol('Snapshot') +const kTasks = Symbol('Tasks') +const kAsyncSearch = Symbol('AsyncSearch') +const kAutoscaling = Symbol('Autoscaling') +const kCcr = Symbol('Ccr') +const kEnrich = Symbol('Enrich') +const kEql = Symbol('Eql') +const kGraph = Symbol('Graph') +const kIlm = Symbol('Ilm') +const kLicense = Symbol('License') +const kMigration = Symbol('Migration') +const kMl = Symbol('Ml') +const kMonitoring = Symbol('Monitoring') +const kRollup = Symbol('Rollup') +const kSearchableSnapshots = Symbol('SearchableSnapshots') +const kSecurity = Symbol('Security') +const kSlm = Symbol('Slm') +const kSql = Symbol('Sql') +const kSsl = Symbol('Ssl') +const kTransform = Symbol('Transform') +const kWatcher = Symbol('Watcher') +const kXpack = Symbol('Xpack') function ESAPI (opts) { - assert(opts.makeRequest, 'Missing makeRequest function') - assert(opts.ConfigurationError, 'Missing ConfigurationError class') - assert(opts.result, 'Missing default result object') + this[kConfigurationError] = opts.ConfigurationError + this[kCat] = null + this[kCluster] = null + this[kDanglingIndices] = null + this[kIndices] = null + this[kIngest] = null + this[kNodes] = null + this[kSnapshot] = null + this[kTasks] = null + this[kAsyncSearch] = null + this[kAutoscaling] = null + this[kCcr] = null + this[kEnrich] = null + this[kEql] = null + this[kGraph] = null + this[kIlm] = null + this[kLicense] = null + this[kMigration] = null + this[kMl] = null + this[kMonitoring] = null + this[kRollup] = null + this[kSearchableSnapshots] = null + this[kSecurity] = null + this[kSlm] = null + this[kSql] = null + this[kSsl] = null + this[kTransform] = null + this[kWatcher] = null + this[kXpack] = null +} - const { result } = opts - opts.handleError = handleError - opts.snakeCaseKeys = snakeCaseKeys +ESAPI.prototype.bulk = bulkApi +ESAPI.prototype.clearScroll = clearScrollApi +ESAPI.prototype.count = countApi +ESAPI.prototype.create = createApi +ESAPI.prototype.delete = deleteApi +ESAPI.prototype.deleteByQuery = deleteByQueryApi +ESAPI.prototype.deleteByQueryRethrottle = deleteByQueryRethrottleApi +ESAPI.prototype.deleteScript = deleteScriptApi +ESAPI.prototype.exists = existsApi +ESAPI.prototype.existsSource = existsSourceApi +ESAPI.prototype.explain = explainApi +ESAPI.prototype.fieldCaps = fieldCapsApi +ESAPI.prototype.get = getApi +ESAPI.prototype.getScript = getScriptApi +ESAPI.prototype.getScriptContext = getScriptContextApi +ESAPI.prototype.getScriptLanguages = getScriptLanguagesApi +ESAPI.prototype.getSource = getSourceApi +ESAPI.prototype.index = indexApi +ESAPI.prototype.info = infoApi +ESAPI.prototype.mget = mgetApi +ESAPI.prototype.msearch = msearchApi +ESAPI.prototype.msearchTemplate = msearchTemplateApi +ESAPI.prototype.mtermvectors = mtermvectorsApi +ESAPI.prototype.ping = pingApi +ESAPI.prototype.putScript = putScriptApi +ESAPI.prototype.rankEval = rankEvalApi +ESAPI.prototype.reindex = reindexApi +ESAPI.prototype.reindexRethrottle = reindexRethrottleApi +ESAPI.prototype.renderSearchTemplate = renderSearchTemplateApi +ESAPI.prototype.scriptsPainlessExecute = scriptsPainlessExecuteApi +ESAPI.prototype.scroll = scrollApi +ESAPI.prototype.search = searchApi +ESAPI.prototype.searchShards = searchShardsApi +ESAPI.prototype.searchTemplate = searchTemplateApi +ESAPI.prototype.termvectors = termvectorsApi +ESAPI.prototype.update = updateApi +ESAPI.prototype.updateByQuery = updateByQueryApi +ESAPI.prototype.updateByQueryRethrottle = updateByQueryRethrottleApi +ESAPI.prototype.closePointInTime = closePointInTimeApi +ESAPI.prototype.openPointInTime = openPointInTimeApi +<<<<<<< HEAD const apis = { async_search: { delete: lazyLoad('async_search.delete', opts), @@ -677,50 +839,258 @@ function ESAPI (opts) { xpack: { info: lazyLoad('xpack.info', opts), usage: lazyLoad('xpack.usage', opts) - } - } - - return apis - - function handleError (err, callback) { - if (callback) { - process.nextTick(callback, err, result) - return { then: noop, catch: noop, abort: noop } - } - return Promise.reject(err) - } - - function snakeCaseKeys (acceptedQuerystring, snakeCase, querystring, warnings) { - var target = {} - var keys = Object.keys(querystring) - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - target[snakeCase[key] || key] = querystring[key] - if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { - warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') +======= +Object.defineProperties(ESAPI.prototype, { + cat: { + get () { + if (this[kCat] === null) { + this[kCat] = new CatApi(this.transport, this[kConfigurationError]) } + return this[kCat] +>>>>>>> a064f0f3... Improve child performances (#1314) } - return target - } -} - -// It's unlikely that a user needs all of our APIs, -// and since require is a sync operation that takes time -// (given the amount of APIs we have), let's lazy load them, -// so a given API file will be required only -// if the user actually needs that API. -// The following implementation takes advantage -// of js closures to have a simple cache with the least overhead. -function lazyLoad (file, opts) { - var fn = null - return function _lazyLoad (params, options, callback) { - if (fn === null) { - fn = require(`./api/${file}.js`)(opts) + }, + clear_scroll: { get () { return this.clearScroll } }, + cluster: { + get () { + if (this[kCluster] === null) { + this[kCluster] = new ClusterApi(this.transport, this[kConfigurationError]) + } + return this[kCluster] + } + }, + danglingIndices: { + get () { + if (this[kDanglingIndices] === null) { + this[kDanglingIndices] = new DanglingIndicesApi(this.transport, this[kConfigurationError]) + } + return this[kDanglingIndices] + } + }, + dangling_indices: { get () { return this.danglingIndices } }, + delete_by_query: { get () { return this.deleteByQuery } }, + delete_by_query_rethrottle: { get () { return this.deleteByQueryRethrottle } }, + delete_script: { get () { return this.deleteScript } }, + exists_source: { get () { return this.existsSource } }, + field_caps: { get () { return this.fieldCaps } }, + get_script: { get () { return this.getScript } }, + get_script_context: { get () { return this.getScriptContext } }, + get_script_languages: { get () { return this.getScriptLanguages } }, + get_source: { get () { return this.getSource } }, + indices: { + get () { + if (this[kIndices] === null) { + this[kIndices] = new IndicesApi(this.transport, this[kConfigurationError]) + } + return this[kIndices] + } + }, + ingest: { + get () { + if (this[kIngest] === null) { + this[kIngest] = new IngestApi(this.transport, this[kConfigurationError]) + } + return this[kIngest] + } + }, + msearch_template: { get () { return this.msearchTemplate } }, + nodes: { + get () { + if (this[kNodes] === null) { + this[kNodes] = new NodesApi(this.transport, this[kConfigurationError]) + } + return this[kNodes] + } + }, + put_script: { get () { return this.putScript } }, + rank_eval: { get () { return this.rankEval } }, + reindex_rethrottle: { get () { return this.reindexRethrottle } }, + render_search_template: { get () { return this.renderSearchTemplate } }, + scripts_painless_execute: { get () { return this.scriptsPainlessExecute } }, + search_shards: { get () { return this.searchShards } }, + search_template: { get () { return this.searchTemplate } }, + snapshot: { + get () { + if (this[kSnapshot] === null) { + this[kSnapshot] = new SnapshotApi(this.transport, this[kConfigurationError]) + } + return this[kSnapshot] + } + }, + tasks: { + get () { + if (this[kTasks] === null) { + this[kTasks] = new TasksApi(this.transport, this[kConfigurationError]) + } + return this[kTasks] + } + }, + update_by_query: { get () { return this.updateByQuery } }, + update_by_query_rethrottle: { get () { return this.updateByQueryRethrottle } }, + asyncSearch: { + get () { + if (this[kAsyncSearch] === null) { + this[kAsyncSearch] = new AsyncSearchApi(this.transport, this[kConfigurationError]) + } + return this[kAsyncSearch] + } + }, + async_search: { get () { return this.asyncSearch } }, + autoscaling: { + get () { + if (this[kAutoscaling] === null) { + this[kAutoscaling] = new AutoscalingApi(this.transport, this[kConfigurationError]) + } + return this[kAutoscaling] + } + }, + ccr: { + get () { + if (this[kCcr] === null) { + this[kCcr] = new CcrApi(this.transport, this[kConfigurationError]) + } + return this[kCcr] + } + }, + close_point_in_time: { get () { return this.closePointInTime } }, + enrich: { + get () { + if (this[kEnrich] === null) { + this[kEnrich] = new EnrichApi(this.transport, this[kConfigurationError]) + } + return this[kEnrich] + } + }, + eql: { + get () { + if (this[kEql] === null) { + this[kEql] = new EqlApi(this.transport, this[kConfigurationError]) + } + return this[kEql] + } + }, + graph: { + get () { + if (this[kGraph] === null) { + this[kGraph] = new GraphApi(this.transport, this[kConfigurationError]) + } + return this[kGraph] + } + }, + ilm: { + get () { + if (this[kIlm] === null) { + this[kIlm] = new IlmApi(this.transport, this[kConfigurationError]) + } + return this[kIlm] + } + }, + license: { + get () { + if (this[kLicense] === null) { + this[kLicense] = new LicenseApi(this.transport, this[kConfigurationError]) + } + return this[kLicense] + } + }, + migration: { + get () { + if (this[kMigration] === null) { + this[kMigration] = new MigrationApi(this.transport, this[kConfigurationError]) + } + return this[kMigration] + } + }, + ml: { + get () { + if (this[kMl] === null) { + this[kMl] = new MlApi(this.transport, this[kConfigurationError]) + } + return this[kMl] + } + }, + monitoring: { + get () { + if (this[kMonitoring] === null) { + this[kMonitoring] = new MonitoringApi(this.transport, this[kConfigurationError]) + } + return this[kMonitoring] + } + }, + open_point_in_time: { get () { return this.openPointInTime } }, + rollup: { + get () { + if (this[kRollup] === null) { + this[kRollup] = new RollupApi(this.transport, this[kConfigurationError]) + } + return this[kRollup] + } + }, + searchableSnapshots: { + get () { + if (this[kSearchableSnapshots] === null) { + this[kSearchableSnapshots] = new SearchableSnapshotsApi(this.transport, this[kConfigurationError]) + } + return this[kSearchableSnapshots] + } + }, + searchable_snapshots: { get () { return this.searchableSnapshots } }, + security: { + get () { + if (this[kSecurity] === null) { + this[kSecurity] = new SecurityApi(this.transport, this[kConfigurationError]) + } + return this[kSecurity] + } + }, + slm: { + get () { + if (this[kSlm] === null) { + this[kSlm] = new SlmApi(this.transport, this[kConfigurationError]) + } + return this[kSlm] + } + }, + sql: { + get () { + if (this[kSql] === null) { + this[kSql] = new SqlApi(this.transport, this[kConfigurationError]) + } + return this[kSql] + } + }, + ssl: { + get () { + if (this[kSsl] === null) { + this[kSsl] = new SslApi(this.transport, this[kConfigurationError]) + } + return this[kSsl] + } + }, + transform: { + get () { + if (this[kTransform] === null) { + this[kTransform] = new TransformApi(this.transport, this[kConfigurationError]) + } + return this[kTransform] + } + }, + watcher: { + get () { + if (this[kWatcher] === null) { + this[kWatcher] = new WatcherApi(this.transport, this[kConfigurationError]) + } + return this[kWatcher] + } + }, + xpack: { + get () { + if (this[kXpack] === null) { + this[kXpack] = new XpackApi(this.transport, this[kConfigurationError]) + } + return this[kXpack] } - return fn(params, options, callback) } -} - -function noop () {} +}) module.exports = ESAPI diff --git a/api/requestParams.d.ts b/api/requestParams.d.ts index c4316cbdb..a6aea51cd 100644 --- a/api/requestParams.d.ts +++ b/api/requestParams.d.ts @@ -28,6 +28,81 @@ export interface Generic { source?: string; } +export interface AsyncSearchDelete extends Generic { + id: string; +} + +export interface AsyncSearchGet extends Generic { + id: string; + wait_for_completion_timeout?: string; + keep_alive?: string; + typed_keys?: boolean; +} + +export interface AsyncSearchSubmit extends Generic { + index?: string | string[]; + _source_exclude?: string | string[]; + _source_include?: string | string[]; + wait_for_completion_timeout?: string; + keep_on_completion?: boolean; + keep_alive?: string; + batched_reduce_size?: number; + request_cache?: boolean; + analyzer?: string; + analyze_wildcard?: boolean; + default_operator?: 'AND' | 'OR'; + df?: string; + explain?: boolean; + stored_fields?: string | string[]; + docvalue_fields?: string | string[]; + from?: number; + ignore_unavailable?: boolean; + ignore_throttled?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; + lenient?: boolean; + preference?: string; + q?: string; + routing?: string | string[]; + search_type?: 'query_then_fetch' | 'dfs_query_then_fetch'; + size?: number; + sort?: string | string[]; + _source?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; + terminate_after?: number; + stats?: string | string[]; + suggest_field?: string; + suggest_mode?: 'missing' | 'popular' | 'always'; + suggest_size?: number; + suggest_text?: string; + timeout?: string; + track_scores?: boolean; + track_total_hits?: boolean | number; + allow_partial_search_results?: boolean; + typed_keys?: boolean; + version?: boolean; + seq_no_primary_term?: boolean; + max_concurrent_shard_requests?: number; + body?: T; +} + +export interface AutoscalingDeleteAutoscalingPolicy extends Generic { + name: string; +} + +export interface AutoscalingGetAutoscalingDecision extends Generic { +} + +export interface AutoscalingGetAutoscalingPolicy extends Generic { + name: string; +} + +export interface AutoscalingPutAutoscalingPolicy extends Generic { + name: string; + body: T; +} + export interface Bulk extends Generic { index?: string; type?: string; @@ -127,6 +202,57 @@ export interface CatMaster extends Generic { v?: boolean; } +export interface CatMlDataFrameAnalytics extends Generic { + id?: string; + allow_no_match?: boolean; + bytes?: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb'; + format?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + time?: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos'; + v?: boolean; +} + +export interface CatMlDatafeeds extends Generic { + datafeed_id?: string; + allow_no_match?: boolean; + allow_no_datafeeds?: boolean; + format?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + time?: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos'; + v?: boolean; +} + +export interface CatMlJobs extends Generic { + job_id?: string; + allow_no_match?: boolean; + allow_no_jobs?: boolean; + bytes?: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb'; + format?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + time?: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos'; + v?: boolean; +} + +export interface CatMlTrainedModels extends Generic { + model_id?: string; + allow_no_match?: boolean; + from?: number; + size?: number; + bytes?: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb'; + format?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + time?: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos'; + v?: boolean; +} + export interface CatNodeattrs extends Generic { format?: string; local?: boolean; @@ -265,11 +391,84 @@ export interface CatThreadPool extends Generic { v?: boolean; } +export interface CatTransforms extends Generic { + transform_id?: string; + from?: number; + size?: number; + allow_no_match?: boolean; + format?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + time?: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos'; + v?: boolean; +} + +export interface CcrDeleteAutoFollowPattern extends Generic { + name: string; +} + +export interface CcrFollow extends Generic { + index: string; + wait_for_active_shards?: string; + body: T; +} + +export interface CcrFollowInfo extends Generic { + index: string | string[]; +} + +export interface CcrFollowStats extends Generic { + index: string | string[]; +} + +export interface CcrForgetFollower extends Generic { + index: string; + body: T; +} + +export interface CcrGetAutoFollowPattern extends Generic { + name?: string; +} + +export interface CcrPauseAutoFollowPattern extends Generic { + name: string; +} + +export interface CcrPauseFollow extends Generic { + index: string; +} + +export interface CcrPutAutoFollowPattern extends Generic { + name: string; + body: T; +} + +export interface CcrResumeAutoFollowPattern extends Generic { + name: string; +} + +export interface CcrResumeFollow extends Generic { + index: string; + body?: T; +} + +export interface CcrStats extends Generic { +} + +export interface CcrUnfollow extends Generic { + index: string; +} + export interface ClearScroll extends Generic { scroll_id?: string | string[]; body?: T; } +export interface ClosePointInTime extends Generic { + body?: T; +} + export interface ClusterAllocationExplain extends Generic { include_yes_decisions?: boolean; include_disk_info?: boolean; @@ -360,8 +559,8 @@ export interface ClusterReroute extends Generic { } export interface ClusterState extends Generic { - index?: string | string[]; metric?: string | string[]; + index?: string | string[]; local?: boolean; master_timeout?: string; flat_settings?: boolean; @@ -493,6 +692,45 @@ export interface DeleteScript extends Generic { master_timeout?: string; } +export interface EnrichDeletePolicy extends Generic { + name: string; +} + +export interface EnrichExecutePolicy extends Generic { + name: string; + wait_for_completion?: boolean; +} + +export interface EnrichGetPolicy extends Generic { + name?: string | string[]; +} + +export interface EnrichPutPolicy extends Generic { + name: string; + body: T; +} + +export interface EnrichStats extends Generic { +} + +export interface EqlDelete extends Generic { + id: string; +} + +export interface EqlGet extends Generic { + id: string; + wait_for_completion_timeout?: string; + keep_alive?: string; +} + +export interface EqlSearch extends Generic { + index: string; + wait_for_completion_timeout?: string; + keep_on_completion?: boolean; + keep_alive?: string; + body: T; +} + export interface Exists extends Generic { id: string; index: string; @@ -595,6 +833,7 @@ export interface GetSource extends Generic { version_type?: 'internal' | 'external' | 'external_gte' | 'force'; } +<<<<<<< HEAD export interface Index extends Generic { id?: string; index: string; @@ -602,6 +841,62 @@ export interface Index extends Generic { wait_for_active_shards?: string; op_type?: 'index' | 'create'; refresh?: 'wait_for' | boolean; +======= +export interface GraphExplore extends Generic { + index: string | string[]; +>>>>>>> a064f0f3... Improve child performances (#1314) + routing?: string; + timeout?: string; + body?: T; +} + +export interface IlmDeleteLifecycle extends Generic { + policy: string; +} + +export interface IlmExplainLifecycle extends Generic { + index: string; + only_managed?: boolean; + only_errors?: boolean; +} + +export interface IlmGetLifecycle extends Generic { + policy?: string; +} + +export interface IlmGetStatus extends Generic { +} + +export interface IlmMoveToStep extends Generic { + index: string; + body?: T; +} + +export interface IlmPutLifecycle extends Generic { + policy: string; + body?: T; +} + +export interface IlmRemovePolicy extends Generic { + index: string; +} + +export interface IlmRetry extends Generic { + index: string; +} + +export interface IlmStart extends Generic { +} + +export interface IlmStop extends Generic { +} + +export interface Index extends Generic { + id?: string; + index: string; + wait_for_active_shards?: string; + op_type?: 'index' | 'create'; + refresh?: 'wait_for' | boolean; routing?: string; timeout?: string; version?: number; @@ -667,6 +962,14 @@ export interface IndicesCreate extends Generic { body?: T; } +export interface IndicesCreateDataStream extends Generic { + name: string; +} + +export interface IndicesDataStreamsStats extends Generic { + name?: string | string[]; +} + export interface IndicesDelete extends Generic { index: string | string[]; timeout?: string; @@ -683,6 +986,10 @@ export interface IndicesDeleteAlias extends Generic { master_timeout?: string; } +export interface IndicesDeleteDataStream extends Generic { + name: string | string[]; +} + export interface IndicesDeleteIndexTemplate extends Generic { name: string; timeout?: string; @@ -763,6 +1070,16 @@ export interface IndicesForcemerge extends Generic { only_expunge_deletes?: boolean; } +export interface IndicesFreeze extends Generic { + index: string; + timeout?: string; + master_timeout?: string; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; + wait_for_active_shards?: string; +} + export interface IndicesGet extends Generic { index: string | string[]; include_type_name?: boolean; @@ -784,6 +1101,10 @@ export interface IndicesGetAlias extends Generic { local?: boolean; } +export interface IndicesGetDataStream extends Generic { + name?: string | string[]; +} + export interface IndicesGetFieldMapping extends Generic { fields: string | string[]; index?: string | string[]; @@ -914,6 +1235,13 @@ export interface IndicesRefresh extends Generic { expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; } +export interface IndicesReloadSearchAnalyzers extends Generic { + index: string | string[]; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; +} + export interface IndicesResolveIndex extends Generic { name: string | string[]; expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; @@ -997,6 +1325,16 @@ export interface IndicesStats extends Generic { forbid_closed_indices?: boolean; } +export interface IndicesUnfreeze extends Generic { + index: string; + timeout?: string; + master_timeout?: string; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; + wait_for_active_shards?: string; +} + export interface IndicesUpdateAliases extends Generic { timeout?: string; master_timeout?: string; @@ -1060,6 +1398,34 @@ export interface IngestSimulate extends Generic { body: T; } +export interface LicenseDelete extends Generic { +} + +export interface LicenseGet extends Generic { + local?: boolean; + accept_enterprise?: boolean; +} + +export interface LicenseGetBasicStatus extends Generic { +} + +export interface LicenseGetTrialStatus extends Generic { +} + +export interface LicensePost extends Generic { + acknowledge?: boolean; + body?: T; +} + +export interface LicensePostStartBasic extends Generic { + acknowledge?: boolean; +} + +export interface LicensePostStartTrial extends Generic { + type?: string; + acknowledge?: boolean; +} + export interface Mget extends Generic { index?: string; type?: string; @@ -1074,6 +1440,7 @@ export interface Mget extends Generic { body: T; } +<<<<<<< HEAD export interface Msearch extends Generic { index?: string | string[]; type?: string | string[]; @@ -1114,62 +1481,84 @@ export interface Mtermvectors extends Generic { version?: number; version_type?: 'internal' | 'external' | 'external_gte' | 'force'; body?: T; +======= +export interface MigrationDeprecations extends Generic { + index?: string; } -export interface NodesHotThreads extends Generic { - node_id?: string | string[]; - interval?: string; - snapshots?: number; - threads?: number; - ignore_idle_threads?: boolean; - type?: 'cpu' | 'wait' | 'block'; - timeout?: string; -} - -export interface NodesInfo extends Generic { - node_id?: string | string[]; - metric?: string | string[]; - flat_settings?: boolean; - timeout?: string; -} - -export interface NodesReloadSecureSettings extends Generic { - node_id?: string | string[]; +export interface MlCloseJob extends Generic { + job_id: string; + allow_no_match?: boolean; + allow_no_jobs?: boolean; + force?: boolean; timeout?: string; body?: T; } -export interface NodesStats extends Generic { - node_id?: string | string[]; - metric?: string | string[]; - index_metric?: string | string[]; - completion_fields?: string | string[]; - fielddata_fields?: string | string[]; - fields?: string | string[]; - groups?: boolean; - level?: 'indices' | 'node' | 'shards'; - types?: string | string[]; - timeout?: string; - include_segment_file_sizes?: boolean; +export interface MlDeleteCalendar extends Generic { + calendar_id: string; +>>>>>>> a064f0f3... Improve child performances (#1314) } -export interface NodesUsage extends Generic { - node_id?: string | string[]; - metric?: string | string[]; - timeout?: string; +export interface MlDeleteCalendarEvent extends Generic { + calendar_id: string; + event_id: string; } -export interface Ping extends Generic { +export interface MlDeleteCalendarJob extends Generic { + calendar_id: string; + job_id: string; } -export interface PutScript extends Generic { +export interface MlDeleteDataFrameAnalytics extends Generic { id: string; - context?: string; + force?: boolean; timeout?: string; - master_timeout?: string; +} + +export interface MlDeleteDatafeed extends Generic { + datafeed_id: string; + force?: boolean; +} + +export interface MlDeleteExpiredData extends Generic { + job_id?: string; + requests_per_second?: number; + timeout?: string; + body?: T; +} + +export interface MlDeleteFilter extends Generic { + filter_id: string; +} + +export interface MlDeleteForecast extends Generic { + job_id: string; + forecast_id?: string; + allow_no_forecasts?: boolean; + timeout?: string; +} + +export interface MlDeleteJob extends Generic { + job_id: string; + force?: boolean; + wait_for_completion?: boolean; +} + +export interface MlDeleteModelSnapshot extends Generic { + job_id: string; + snapshot_id: string; +} + +export interface MlDeleteTrainedModel extends Generic { + model_id: string; +} + +export interface MlEstimateModelMemory extends Generic { body: T; } +<<<<<<< HEAD export interface RankEval extends Generic { index?: string | string[]; ignore_unavailable?: boolean; @@ -1896,6 +2285,8 @@ export interface MlEstimateModelMemory extends Generic { body: T; } +======= +>>>>>>> a064f0f3... Improve child performances (#1314) export interface MlEvaluateDataFrame extends Generic { body: T; } @@ -2079,7 +2470,7 @@ export interface MlGetRecords extends Generic { export interface MlGetTrainedModels extends Generic { model_id?: string; allow_no_match?: boolean; - include_model_definition?: boolean; + include?: string; decompress_definition?: boolean; from?: number; size?: number; @@ -2245,6 +2636,88 @@ export interface MonitoringBulk extends Generic { body: T; } +export interface Msearch extends Generic { + index?: string | string[]; + search_type?: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch'; + max_concurrent_searches?: number; + typed_keys?: boolean; + pre_filter_shard_size?: number; + max_concurrent_shard_requests?: number; + rest_total_hits_as_int?: boolean; + ccs_minimize_roundtrips?: boolean; + body: T; +} + +export interface MsearchTemplate extends Generic { + index?: string | string[]; + search_type?: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch'; + typed_keys?: boolean; + max_concurrent_searches?: number; + rest_total_hits_as_int?: boolean; + ccs_minimize_roundtrips?: boolean; + body: T; +} + +export interface Mtermvectors extends Generic { + index?: string; + ids?: string | string[]; + term_statistics?: boolean; + field_statistics?: boolean; + fields?: string | string[]; + offsets?: boolean; + positions?: boolean; + payloads?: boolean; + preference?: string; + routing?: string; + realtime?: boolean; + version?: number; + version_type?: 'internal' | 'external' | 'external_gte'; + body?: T; +} + +export interface NodesHotThreads extends Generic { + node_id?: string | string[]; + interval?: string; + snapshots?: number; + threads?: number; + ignore_idle_threads?: boolean; + type?: 'cpu' | 'wait' | 'block'; + timeout?: string; +} + +export interface NodesInfo extends Generic { + node_id?: string | string[]; + metric?: string | string[]; + flat_settings?: boolean; + timeout?: string; +} + +export interface NodesReloadSecureSettings extends Generic { + node_id?: string | string[]; + timeout?: string; + body?: T; +} + +export interface NodesStats extends Generic { + node_id?: string | string[]; + metric?: string | string[]; + index_metric?: string | string[]; + completion_fields?: string | string[]; + fielddata_fields?: string | string[]; + fields?: string | string[]; + groups?: boolean; + level?: 'indices' | 'node' | 'shards'; + types?: string | string[]; + timeout?: string; + include_segment_file_sizes?: boolean; +} + +export interface NodesUsage extends Generic { + node_id?: string | string[]; + metric?: string | string[]; + timeout?: string; +} + export interface OpenPointInTime extends Generic { index?: string | string[]; preference?: string; @@ -2254,6 +2727,48 @@ export interface OpenPointInTime extends Generic { keep_alive?: string; } +export interface Ping extends Generic { +} + +export interface PutScript extends Generic { + id: string; + context?: string; + timeout?: string; + master_timeout?: string; + body: T; +} + +export interface RankEval extends Generic { + index?: string | string[]; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; + search_type?: 'query_then_fetch' | 'dfs_query_then_fetch'; + body: T; +} + +export interface Reindex extends Generic { + refresh?: boolean; + timeout?: string; + wait_for_active_shards?: string; + wait_for_completion?: boolean; + requests_per_second?: number; + scroll?: string; + slices?: number|string; + max_docs?: number; + body: T; +} + +export interface ReindexRethrottle extends Generic { + task_id: string; + requests_per_second: number; +} + +export interface RenderSearchTemplate extends Generic { + id?: string; + body?: T; +} + export interface RollupDeleteJob extends Generic { id: string; } @@ -2293,6 +2808,94 @@ export interface RollupStopJob extends Generic { timeout?: string; } +export interface ScriptsPainlessExecute extends Generic { + body?: T; +} + +export interface Scroll extends Generic { + scroll_id?: string; + scroll?: string; + rest_total_hits_as_int?: boolean; + body?: T; +} + +export interface Search extends Generic { + index?: string | string[]; + _source_exclude?: string | string[]; + _source_include?: string | string[]; + analyzer?: string; + analyze_wildcard?: boolean; + ccs_minimize_roundtrips?: boolean; + default_operator?: 'AND' | 'OR'; + df?: string; + explain?: boolean; + stored_fields?: string | string[]; + docvalue_fields?: string | string[]; + from?: number; + ignore_unavailable?: boolean; + ignore_throttled?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; + lenient?: boolean; + preference?: string; + q?: string; + routing?: string | string[]; + scroll?: string; + search_type?: 'query_then_fetch' | 'dfs_query_then_fetch'; + size?: number; + sort?: string | string[]; + _source?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; + terminate_after?: number; + stats?: string | string[]; + suggest_field?: string; + suggest_mode?: 'missing' | 'popular' | 'always'; + suggest_size?: number; + suggest_text?: string; + timeout?: string; + track_scores?: boolean; + track_total_hits?: boolean | number; + allow_partial_search_results?: boolean; + typed_keys?: boolean; + version?: boolean; + seq_no_primary_term?: boolean; + request_cache?: boolean; + batched_reduce_size?: number; + max_concurrent_shard_requests?: number; + pre_filter_shard_size?: number; + rest_total_hits_as_int?: boolean; + body?: T; +} + +export interface SearchShards extends Generic { + index?: string | string[]; + preference?: string; + routing?: string; + local?: boolean; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; +} + +export interface SearchTemplate extends Generic { + index?: string | string[]; + ignore_unavailable?: boolean; + ignore_throttled?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; + preference?: string; + routing?: string | string[]; + scroll?: string; + search_type?: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch'; + explain?: boolean; + profile?: boolean; + typed_keys?: boolean; + rest_total_hits_as_int?: boolean; + ccs_minimize_roundtrips?: boolean; + body: T; +} + export interface SearchableSnapshotsClearCache extends Generic { index?: string | string[]; ignore_unavailable?: boolean; @@ -2477,6 +3080,75 @@ export interface SlmStart extends Generic { export interface SlmStop extends Generic { } +export interface SnapshotCleanupRepository extends Generic { + repository: string; + master_timeout?: string; + timeout?: string; +} + +export interface SnapshotCreate extends Generic { + repository: string; + snapshot: string; + master_timeout?: string; + wait_for_completion?: boolean; + body?: T; +} + +export interface SnapshotCreateRepository extends Generic { + repository: string; + master_timeout?: string; + timeout?: string; + verify?: boolean; + body: T; +} + +export interface SnapshotDelete extends Generic { + repository: string; + snapshot: string | string[]; + master_timeout?: string; +} + +export interface SnapshotDeleteRepository extends Generic { + repository: string | string[]; + master_timeout?: string; + timeout?: string; +} + +export interface SnapshotGet extends Generic { + repository: string; + snapshot: string | string[]; + master_timeout?: string; + ignore_unavailable?: boolean; + verbose?: boolean; +} + +export interface SnapshotGetRepository extends Generic { + repository?: string | string[]; + master_timeout?: string; + local?: boolean; +} + +export interface SnapshotRestore extends Generic { + repository: string; + snapshot: string; + master_timeout?: string; + wait_for_completion?: boolean; + body?: T; +} + +export interface SnapshotStatus extends Generic { + repository?: string; + snapshot?: string | string[]; + master_timeout?: string; + ignore_unavailable?: boolean; +} + +export interface SnapshotVerifyRepository extends Generic { + repository: string; + master_timeout?: string; + timeout?: string; +} + export interface SqlClearCursor extends Generic { body: T; } @@ -2493,6 +3165,47 @@ export interface SqlTranslate extends Generic { export interface SslCertificates extends Generic { } +export interface TasksCancel extends Generic { + task_id?: string; + nodes?: string | string[]; + actions?: string | string[]; + parent_task_id?: string; + wait_for_completion?: boolean; +} + +export interface TasksGet extends Generic { + task_id: string; + wait_for_completion?: boolean; + timeout?: string; +} + +export interface TasksList extends Generic { + nodes?: string | string[]; + actions?: string | string[]; + detailed?: boolean; + parent_task_id?: string; + wait_for_completion?: boolean; + group_by?: 'nodes' | 'parents' | 'none'; + timeout?: string; +} + +export interface Termvectors extends Generic { + index: string; + id?: string; + term_statistics?: boolean; + field_statistics?: boolean; + fields?: string | string[]; + offsets?: boolean; + positions?: boolean; + payloads?: boolean; + preference?: string; + routing?: string; + realtime?: boolean; + version?: number; + version_type?: 'internal' | 'external' | 'external_gte'; + body?: T; +} + export interface TransformDeleteTransform extends Generic { transform_id: string; force?: boolean; @@ -2542,6 +3255,73 @@ export interface TransformUpdateTransform extends Generic { body: T; } +export interface Update extends Generic { + id: string; + index: string; + type?: string; + _source_exclude?: string | string[]; + _source_include?: string | string[]; + wait_for_active_shards?: string; + _source?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; + lang?: string; + refresh?: 'wait_for' | boolean; + retry_on_conflict?: number; + routing?: string; + timeout?: string; + if_seq_no?: number; + if_primary_term?: number; + require_alias?: boolean; + body: T; +} + +export interface UpdateByQuery extends Generic { + index: string | string[]; + _source_exclude?: string | string[]; + _source_include?: string | string[]; + analyzer?: string; + analyze_wildcard?: boolean; + default_operator?: 'AND' | 'OR'; + df?: string; + from?: number; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + conflicts?: 'abort' | 'proceed'; + expand_wildcards?: 'open' | 'closed' | 'hidden' | 'none' | 'all'; + lenient?: boolean; + pipeline?: string; + preference?: string; + q?: string; + routing?: string | string[]; + scroll?: string; + search_type?: 'query_then_fetch' | 'dfs_query_then_fetch'; + search_timeout?: string; + max_docs?: number; + sort?: string | string[]; + _source?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; + terminate_after?: number; + stats?: string | string[]; + version?: boolean; + version_type?: boolean; + request_cache?: boolean; + refresh?: boolean; + timeout?: string; + wait_for_active_shards?: string; + scroll_size?: number; + wait_for_completion?: boolean; + requests_per_second?: number; + slices?: number|string; + body?: T; +} + +export interface UpdateByQueryRethrottle extends Generic { + task_id: string; + requests_per_second: number; +} + export interface WatcherAckWatch extends Generic { watch_id: string; action_id?: string | string[]; diff --git a/api/utils.js b/api/utils.js new file mode 100644 index 000000000..1982d68da --- /dev/null +++ b/api/utils.js @@ -0,0 +1,58 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +'use strict' + +const result = { body: null, statusCode: null, headers: null, warnings: null } +const kConfigurationError = Symbol('configuration error') + +function handleError (err, callback) { + if (callback) { + process.nextTick(callback, err, result) + return { then: noop, catch: noop, abort: noop } + } + return Promise.reject(err) +} + +function snakeCaseKeys (acceptedQuerystring, snakeCase, querystring) { + var target = {} + var keys = Object.keys(querystring) + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + target[snakeCase[key] || key] = querystring[key] + } + return target +} + +function normalizeArguments (params, options, callback) { + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + return [params, options, callback] +} + +function noop () {} + +module.exports = { handleError, snakeCaseKeys, normalizeArguments, noop, kConfigurationError } diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc index e283885fd..d6822f695 100644 --- a/docs/reference.asciidoc +++ b/docs/reference.asciidoc @@ -95,6 +95,7 @@ link:{ref}/common-options.html[Documentation] |`list` - A comma-separated list of filters used to reduce the response. |=== +<<<<<<< HEAD === bulk [source,ts] @@ -765,6 +766,1325 @@ link:{ref}/cat-repositories.html[Documentation] + |=== +=== cat.segments +======= +=== asyncSearch.delete +>>>>>>> a064f0f3... Improve child performances (#1314) + +[source,ts] +---- +client.asyncSearch.delete({ + id: string +}) +---- +link:{ref}/async-search.html[Documentation] + +[cols=2*] +|=== +|`id` +|`string` - The async search ID + +|=== + +=== asyncSearch.get + +[source,ts] +---- +client.asyncSearch.get({ + id: string, + wait_for_completion_timeout: string, + keep_alive: string, + typed_keys: boolean +}) +---- +link:{ref}/async-search.html[Documentation] + +[cols=2*] +|=== +|`id` +|`string` - The async search ID + +|`wait_for_completion_timeout` or `waitForCompletionTimeout` +|`string` - Specify the time that the request should block waiting for the final response + +|`keep_alive` or `keepAlive` +|`string` - Specify the time interval in which the results (partial or final) for this search will be available + +|`typed_keys` or `typedKeys` +|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + +|=== + +=== asyncSearch.submit + +[source,ts] +---- +client.asyncSearch.submit({ + index: string | string[], + wait_for_completion_timeout: string, + keep_on_completion: boolean, + keep_alive: string, + batched_reduce_size: number, + request_cache: boolean, + analyzer: string, + analyze_wildcard: boolean, + default_operator: 'AND' | 'OR', + df: string, + explain: boolean, + stored_fields: string | string[], + docvalue_fields: string | string[], + from: number, + ignore_unavailable: boolean, + ignore_throttled: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + lenient: boolean, + preference: string, + q: string, + routing: string | string[], + search_type: 'query_then_fetch' | 'dfs_query_then_fetch', + size: number, + sort: string | string[], + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + terminate_after: number, + stats: string | string[], + suggest_field: string, + suggest_mode: 'missing' | 'popular' | 'always', + suggest_size: number, + suggest_text: string, + timeout: string, + track_scores: boolean, + track_total_hits: boolean|long, + allow_partial_search_results: boolean, + typed_keys: boolean, + version: boolean, + seq_no_primary_term: boolean, + max_concurrent_shard_requests: number, + body: object +}) +---- +link:{ref}/async-search.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`wait_for_completion_timeout` or `waitForCompletionTimeout` +|`string` - Specify the time that the request should block waiting for the final response + +_Default:_ `1s` + +|`keep_on_completion` or `keepOnCompletion` +|`boolean` - Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false) + +|`keep_alive` or `keepAlive` +|`string` - Update the time interval in which the results (partial or final) for this search will be available + +_Default:_ `5d` + +|`batched_reduce_size` or `batchedReduceSize` +|`number` - The number of shard results that should be reduced at once on the coordinating node. This value should be used as the granularity at which progress results will be made available. + +_Default:_ `5` + +|`request_cache` or `requestCache` +|`boolean` - Specify if request cache should be used for this request or not, defaults to true + +|`analyzer` +|`string` - The analyzer to use for the query string + +|`analyze_wildcard` or `analyzeWildcard` +|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) + +|`default_operator` or `defaultOperator` +|`'AND' \| 'OR'` - The default operator for query string query (AND or OR) + +_Default:_ `OR` + +|`df` +|`string` - The field to use as default where no field prefix is given in the query string + +|`explain` +|`boolean` - Specify whether to return detailed information about score computation as part of a hit + +|`stored_fields` or `storedFields` +|`string \| string[]` - A comma-separated list of stored fields to return as part of a hit + +|`docvalue_fields` or `docvalueFields` +|`string \| string[]` - A comma-separated list of fields to return as the docvalue representation of a field for each hit + +|`from` +|`number` - Starting offset (default: 0) + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`ignore_throttled` or `ignoreThrottled` +|`boolean` - Whether specified concrete, expanded or aliased indices should be ignored when throttled + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `open` + +|`lenient` +|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`q` +|`string` - Query in the Lucene query string syntax + +|`routing` +|`string \| string[]` - A comma-separated list of specific routing values + +|`search_type` or `searchType` +|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type + +|`size` +|`number` - Number of hits to return (default: 10) + +|`sort` +|`string \| string[]` - A comma-separated list of : pairs + +|`_source` +|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return + +|`_source_excludes` or `_sourceExcludes` +|`string \| string[]` - A list of fields to exclude from the returned _source field + +|`_source_includes` or `_sourceIncludes` +|`string \| string[]` - A list of fields to extract and return from the _source field + +|`terminate_after` or `terminateAfter` +|`number` - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + +|`stats` +|`string \| string[]` - Specific 'tag' of the request for logging and statistical purposes + +|`suggest_field` or `suggestField` +|`string` - Specify which field to use for suggestions + +|`suggest_mode` or `suggestMode` +|`'missing' \| 'popular' \| 'always'` - Specify suggest mode + +_Default:_ `missing` + +|`suggest_size` or `suggestSize` +|`number` - How many suggestions to return in response + +|`suggest_text` or `suggestText` +|`string` - The source text for which the suggestions should be returned + +<<<<<<< HEAD +[source,ts] +---- +client.cat.threadPool({ + thread_pool_patterns: string | string[], + format: string, + size: '' | 'k' | 'm' | 'g' | 't' | 'p', + local: boolean, + master_timeout: string, + h: string | string[], + help: boolean, + s: string | string[], + v: boolean +}) +---- +link:{ref}/cat-thread-pool.html[Documentation] + +[cols=2*] +|=== +|`thread_pool_patterns` or `threadPoolPatterns` +|`string \| string[]` - A comma-separated list of regular-expressions to filter the thread pools in the output +======= +|`timeout` +|`string` - Explicit operation timeout +>>>>>>> a064f0f3... Improve child performances (#1314) + +|`track_scores` or `trackScores` +|`boolean` - Whether to calculate and return scores even if they are not used for sorting + +<<<<<<< HEAD +|`size` +|`'' \| 'k' \| 'm' \| 'g' \| 't' \| 'p'` - The multiplier in which to display values + + +WARNING: This parameter has been deprecated. +======= +|`track_total_hits` or `trackTotalHits` +|`boolean\|long` - Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number. +>>>>>>> a064f0f3... Improve child performances (#1314) + +|`allow_partial_search_results` or `allowPartialSearchResults` +|`boolean` - Indicate if an error should be returned if there is a partial search failure or timeout + +_Default:_ `true` + +|`typed_keys` or `typedKeys` +|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + +|`version` +|`boolean` - Specify whether to return document version as part of a hit + +|`seq_no_primary_term` or `seqNoPrimaryTerm` +|`boolean` - Specify whether to return sequence number and primary term of the last modification of each hit + +|`max_concurrent_shard_requests` or `maxConcurrentShardRequests` +|`number` - The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + +_Default:_ `5` + +|`body` +|`object` - The search definition using the Query DSL + +|=== + +=== autoscaling.deleteAutoscalingPolicy +*Stability:* experimental +[source,ts] +---- +client.autoscaling.deleteAutoscalingPolicy({ + name: string +}) +---- +link:{ref}/autoscaling-delete-autoscaling-policy.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - the name of the autoscaling policy + +|=== + +=== autoscaling.getAutoscalingDecision +*Stability:* experimental +[source,ts] +---- +client.autoscaling.getAutoscalingDecision() +---- +link:{ref}/autoscaling-get-autoscaling-decision.html[Documentation] + + + +=== autoscaling.getAutoscalingPolicy +*Stability:* experimental +[source,ts] +---- +client.autoscaling.getAutoscalingPolicy({ + name: string +}) +---- +link:{ref}/autoscaling-get-autoscaling-policy.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - the name of the autoscaling policy + +|=== + +=== autoscaling.putAutoscalingPolicy +*Stability:* experimental +[source,ts] +---- +client.autoscaling.putAutoscalingPolicy({ + name: string, + body: object +}) +---- +link:{ref}/autoscaling-put-autoscaling-policy.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - the name of the autoscaling policy + +|`body` +|`object` - the specification of the autoscaling policy + +|=== + +=== bulk + +[source,ts] +---- +client.bulk({ + index: string, + type: string, + wait_for_active_shards: string, + refresh: 'true' | 'false' | 'wait_for', + routing: string, + timeout: string, + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + pipeline: string, + require_alias: boolean, + body: object +}) +---- +link:{ref}/docs-bulk.html[Documentation] + +{jsclient}/bulk_examples.html[Code Example] + +[cols=2*] +|=== +|`index` +|`string` - Default index for items which don't provide one + +|`type` +|`string` - Default document type for items which don't provide one + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + +|`refresh` +|`'true' \| 'false' \| 'wait_for'` - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + +|`routing` +|`string` - Specific routing value + +|`timeout` +|`string` - Explicit operation timeout + +|`_source` +|`string \| string[]` - True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request + +|`_source_excludes` or `_sourceExcludes` +|`string \| string[]` - Default list of fields to exclude from the returned _source field, can be overridden on each sub-request + +|`_source_includes` or `_sourceIncludes` +|`string \| string[]` - Default list of fields to extract and return from the _source field, can be overridden on each sub-request + +|`pipeline` +|`string` - The pipeline id to preprocess incoming documents with + +|`require_alias` or `requireAlias` +|`boolean` - Sets require_alias for all incoming documents. Defaults to unset (false) + +|`body` +|`object` - The operation definition and data (action-data pairs), separated by newlines + +|=== + +=== cat.aliases + +[source,ts] +---- +client.cat.aliases({ + name: string | string[], + format: string, + local: boolean, + h: string | string[], + help: boolean, + s: string | string[], + v: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' +}) +---- +link:{ref}/cat-alias.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string \| string[]` - A comma-separated list of alias names to return + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `all` + +|=== + +=== cat.allocation + +[source,ts] +---- +client.cat.allocation({ + node_id: string | string[], + format: string, + bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', + local: boolean, + master_timeout: string, + h: string | string[], + help: boolean, + s: string | string[], + v: boolean +}) +---- +link:{ref}/cat-allocation.html[Documentation] + +[cols=2*] +|=== +|`node_id` or `nodeId` +|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`bytes` +|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.count + +[source,ts] +---- +client.cat.count({ + index: string | string[], + format: string, + h: string | string[], + help: boolean, + s: string | string[], + v: boolean +}) +---- +link:{ref}/cat-count.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to limit the returned information + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.fielddata + +[source,ts] +---- +client.cat.fielddata({ + fields: string | string[], + format: string, + bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', + h: string | string[], + help: boolean, + s: string | string[], + v: boolean +}) +---- +link:{ref}/cat-fielddata.html[Documentation] + +[cols=2*] +|=== +|`fields` +|`string \| string[]` - A comma-separated list of fields to return the fielddata size + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`bytes` +|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.health + +[source,ts] +---- +client.cat.health({ + format: string, + h: string | string[], + help: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + ts: boolean, + v: boolean +}) +---- +link:{ref}/cat-health.html[Documentation] + +[cols=2*] +|=== +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values + +|`ts` +|`boolean` - Set to false to disable timestamping + +_Default:_ `true` + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.help + +[source,ts] +---- +client.cat.help({ + help: boolean, + s: string | string[] +}) +---- +link:{ref}/cat.html[Documentation] + +[cols=2*] +|=== +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|=== + +=== cat.indices + +[source,ts] +---- +client.cat.indices({ + index: string | string[], + format: string, + bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', + local: boolean, + master_timeout: string, + h: string | string[], + health: 'green' | 'yellow' | 'red', + help: boolean, + pri: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + v: boolean, + include_unloaded_segments: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' +}) +---- +link:{ref}/cat-indices.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to limit the returned information + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`bytes` +|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`health` +|`'green' \| 'yellow' \| 'red'` - A health status ("green", "yellow", or "red" to filter only indices matching the specified health status + +|`help` +|`boolean` - Return help information + +|`pri` +|`boolean` - Set to true to return stats only for primary shards + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values + +|`v` +|`boolean` - Verbose mode. Display column headers + +|`include_unloaded_segments` or `includeUnloadedSegments` +|`boolean` - If set to true segment stats will include stats for segments that are not currently loaded into memory + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `all` + +|=== + +=== cat.master + +[source,ts] +---- +client.cat.master({ + format: string, + local: boolean, + master_timeout: string, + h: string | string[], + help: boolean, + s: string | string[], + v: boolean +}) +---- +link:{ref}/cat-master.html[Documentation] + +[cols=2*] +|=== +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.mlDataFrameAnalytics + +[source,ts] +---- +client.cat.mlDataFrameAnalytics({ + id: string, + allow_no_match: boolean, + bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', + format: string, + h: string | string[], + help: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + v: boolean +}) +---- +link:{ref}/cat-dfanalytics.html[Documentation] + +[cols=2*] +|=== +|`id` +|`string` - The ID of the data frame analytics to fetch + +|`allow_no_match` or `allowNoMatch` +|`boolean` - Whether to ignore if a wildcard expression matches no configs. (This includes `_all` string or when no configs have been specified) + +|`bytes` +|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.mlDatafeeds + +[source,ts] +---- +client.cat.mlDatafeeds({ + datafeed_id: string, + allow_no_match: boolean, + allow_no_datafeeds: boolean, + format: string, + h: string | string[], + help: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + v: boolean +}) +---- +link:{ref}/cat-datafeeds.html[Documentation] + +[cols=2*] +|=== +|`datafeed_id` or `datafeedId` +|`string` - The ID of the datafeeds stats to fetch + +|`allow_no_match` or `allowNoMatch` +|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + +|`allow_no_datafeeds` or `allowNoDatafeeds` +|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + + +WARNING: This parameter has been deprecated. + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.mlJobs + +[source,ts] +---- +client.cat.mlJobs({ + job_id: string, + allow_no_match: boolean, + allow_no_jobs: boolean, + bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', + format: string, + h: string | string[], + help: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + v: boolean +}) +---- +link:{ref}/cat-anomaly-detectors.html[Documentation] + +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - The ID of the jobs stats to fetch + +|`allow_no_match` or `allowNoMatch` +|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + +|`allow_no_jobs` or `allowNoJobs` +|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + + +WARNING: This parameter has been deprecated. + +|`bytes` +|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.mlTrainedModels + +[source,ts] +---- +<<<<<<< HEAD +client.count({ + index: string | string[], + type: string | string[], + ignore_unavailable: boolean, + ignore_throttled: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + min_score: number, + preference: string, + routing: string | string[], + q: string, + analyzer: string, + analyze_wildcard: boolean, + default_operator: 'AND' | 'OR', + df: string, + lenient: boolean, + terminate_after: number, + body: object +======= +client.cat.mlTrainedModels({ + model_id: string, + allow_no_match: boolean, + from: number, + size: number, + bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', + format: string, + h: string | string[], + help: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + v: boolean +>>>>>>> a064f0f3... Improve child performances (#1314) +}) +---- +link:{ref}/cat-trained-model.html[Documentation] + +[cols=2*] +|=== +|`model_id` or `modelId` +|`string` - The ID of the trained models stats to fetch + +<<<<<<< HEAD +|`type` +|`string \| string[]` - A comma-separated list of types to restrict the results + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) +======= +|`allow_no_match` or `allowNoMatch` +|`boolean` - Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified) + +_Default:_ `true` +>>>>>>> a064f0f3... Improve child performances (#1314) + +|`from` +|`number` - skips a number of trained models + +|`size` +|`number` - specifies a max number of trained models to get + +_Default:_ `100` + +|`bytes` +|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.nodeattrs + +[source,ts] +---- +client.cat.nodeattrs({ + format: string, + local: boolean, + master_timeout: string, + h: string | string[], + help: boolean, + s: string | string[], + v: boolean +}) +---- +link:{ref}/cat-nodeattrs.html[Documentation] + +[cols=2*] +|=== +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.nodes + +[source,ts] +---- +client.cat.nodes({ + bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', + format: string, + full_id: boolean, + master_timeout: string, + h: string | string[], + help: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + v: boolean +}) +---- +link:{ref}/cat-nodes.html[Documentation] + +[cols=2*] +|=== +|`bytes` +|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`full_id` or `fullId` +|`boolean` - Return the full node ID instead of the shortened version (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.pendingTasks + +[source,ts] +---- +client.cat.pendingTasks({ + format: string, + local: boolean, + master_timeout: string, + h: string | string[], + help: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + v: boolean +}) +---- +link:{ref}/cat-pending-tasks.html[Documentation] + +[cols=2*] +|=== +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.plugins + +[source,ts] +---- +client.cat.plugins({ + format: string, + local: boolean, + master_timeout: string, + h: string | string[], + help: boolean, + s: string | string[], + v: boolean +}) +---- +link:{ref}/cat-plugins.html[Documentation] + +[cols=2*] +|=== +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== cat.recovery + +[source,ts] +---- +<<<<<<< HEAD +client.delete({ + id: string, + index: string, + type: string, + wait_for_active_shards: string, + refresh: 'true' | 'false' | 'wait_for', + routing: string, + timeout: string, + if_seq_no: number, + if_primary_term: number, + version: number, + version_type: 'internal' | 'external' | 'external_gte' | 'force' +======= +client.cat.recovery({ + index: string | string[], + format: string, + active_only: boolean, + bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', + detailed: boolean, + h: string | string[], + help: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + v: boolean +>>>>>>> a064f0f3... Improve child performances (#1314) +}) +---- +link:{ref}/cat-recovery.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - Comma-separated list or wildcard expression of index names to limit the returned information + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`active_only` or `activeOnly` +|`boolean` - If `true`, the response only includes ongoing shard recoveries + +|`bytes` +|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values + +|`detailed` +|`boolean` - If `true`, the response includes detailed information about shard recoveries + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values + +<<<<<<< HEAD +|`version_type` or `versionType` +|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type +======= +|`v` +|`boolean` - Verbose mode. Display column headers +>>>>>>> a064f0f3... Improve child performances (#1314) + +|=== + +=== cat.repositories + +[source,ts] +---- +<<<<<<< HEAD +client.deleteByQuery({ + index: string | string[], + type: string | string[], + analyzer: string, + analyze_wildcard: boolean, + default_operator: 'AND' | 'OR', + df: string, + from: number, + ignore_unavailable: boolean, + allow_no_indices: boolean, + conflicts: 'abort' | 'proceed', + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + lenient: boolean, + preference: string, + q: string, + routing: string | string[], + scroll: string, + search_type: 'query_then_fetch' | 'dfs_query_then_fetch', + search_timeout: string, + size: number, + max_docs: number, + sort: string | string[], + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + terminate_after: number, + stats: string | string[], + version: boolean, + request_cache: boolean, + refresh: boolean, + timeout: string, + wait_for_active_shards: string, + scroll_size: number, + wait_for_completion: boolean, + requests_per_second: number, + slices: number|string, + body: object +======= +client.cat.repositories({ + format: string, + local: boolean, + master_timeout: string, + h: string | string[], + help: boolean, + s: string | string[], + v: boolean +>>>>>>> a064f0f3... Improve child performances (#1314) +}) +---- +link:{ref}/cat-repositories.html[Documentation] + +[cols=2*] +|=== +<<<<<<< HEAD +|`index` +|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`type` +|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types + +|`analyzer` +|`string` - The analyzer to use for the query string + +|`analyze_wildcard` or `analyzeWildcard` +|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) + +|`default_operator` or `defaultOperator` +|`'AND' \| 'OR'` - The default operator for query string query (AND or OR) + +_Default:_ `OR` + +|`df` +|`string` - The field to use as default where no field prefix is given in the query string + +|`from` +|`number` - Starting offset (default: 0) + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) +======= +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml +>>>>>>> a064f0f3... Improve child performances (#1314) + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + === cat.segments [source,ts] @@ -788,8 +2108,16 @@ link:{ref}/cat-segments.html[Documentation] + |`format` |`string` - a short version of the Accept header, e.g. json, yaml +<<<<<<< HEAD +|`size` +|`number` - Deprecated, please use `max_docs` instead + +|`max_docs` or `maxDocs` +|`number` - Maximum number of documents to process (default: all documents) +======= |`bytes` |`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values +>>>>>>> a064f0f3... Improve child performances (#1314) |`h` |`string \| string[]` - Comma-separated list of column names to display @@ -831,8 +2159,13 @@ link:{ref}/cat-shards.html[Documentation] + |`format` |`string` - a short version of the Accept header, e.g. json, yaml +<<<<<<< HEAD +|`refresh` +|`boolean` - Should the effected indexes be refreshed? +======= |`bytes` |`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values +>>>>>>> a064f0f3... Improve child performances (#1314) |`local` |`boolean` - Return local information, do not retrieve the state from master node (default: false) @@ -961,6 +2294,22 @@ link:{ref}/tasks.html[Documentation] + [source,ts] ---- +<<<<<<< HEAD +client.exists({ + id: string, + index: string, + type: string, + stored_fields: string | string[], + preference: string, + realtime: boolean, + refresh: boolean, + routing: string, + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + version: number, + version_type: 'internal' | 'external' | 'external_gte' | 'force' +======= client.cat.templates({ name: string, format: string, @@ -970,13 +2319,36 @@ client.cat.templates({ help: boolean, s: string | string[], v: boolean +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/cat-templates.html[Documentation] + [cols=2*] |=== +<<<<<<< HEAD +|`id` +|`string` - The document ID + +|`index` +|`string` - The name of the index + +|`type` +|`string` - The type of the document (use `_all` to fetch the first document matching the ID across all types) + + +WARNING: This parameter has been deprecated. + +|`stored_fields` or `storedFields` +|`string \| string[]` - A comma-separated list of stored fields to return in the response + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`realtime` +|`boolean` - Specify whether to perform the operation in realtime or search mode +======= |`name` |`string` - A pattern that returned template names must match +>>>>>>> a064f0f3... Improve child performances (#1314) |`format` |`string` - a short version of the Accept header, e.g. json, yaml @@ -996,8 +2368,13 @@ link:{ref}/cat-templates.html[Documentation] + |`s` |`string \| string[]` - Comma-separated list of column names or column aliases to sort by +<<<<<<< HEAD +|`version_type` or `versionType` +|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type +======= |`v` |`boolean` - Verbose mode. Display column headers +>>>>>>> a064f0f3... Improve child performances (#1314) |=== @@ -1005,16 +2382,32 @@ link:{ref}/cat-templates.html[Documentation] + [source,ts] ---- +<<<<<<< HEAD +client.existsSource({ + id: string, + index: string, + type: string, + preference: string, + realtime: boolean, + refresh: boolean, + routing: string, + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + version: number, + version_type: 'internal' | 'external' | 'external_gte' | 'force' +======= client.cat.threadPool({ thread_pool_patterns: string | string[], format: string, - size: '' | 'k' | 'm' | 'g' | 't' | 'p', + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', local: boolean, master_timeout: string, h: string | string[], help: boolean, s: string | string[], v: boolean +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/cat-thread-pool.html[Documentation] + @@ -1026,10 +2419,8 @@ link:{ref}/cat-thread-pool.html[Documentation] + |`format` |`string` - a short version of the Accept header, e.g. json, yaml -|`size` -|`'' \| 'k' \| 'm' \| 'g' \| 't' \| 'p'` - The multiplier in which to display values + - -WARNING: This parameter has been deprecated. +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values |`local` |`boolean` - Return local information, do not retrieve the state from master node (default: false) @@ -1046,8 +2437,388 @@ WARNING: This parameter has been deprecated. |`s` |`string \| string[]` - Comma-separated list of column names or column aliases to sort by +<<<<<<< HEAD +|`version_type` or `versionType` +|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type +======= |`v` |`boolean` - Verbose mode. Display column headers +>>>>>>> a064f0f3... Improve child performances (#1314) + +|=== + +=== cat.transforms + +[source,ts] +---- +<<<<<<< HEAD +client.explain({ + id: string, + index: string, + type: string, + analyze_wildcard: boolean, + analyzer: string, + default_operator: 'AND' | 'OR', + df: string, + stored_fields: string | string[], + lenient: boolean, + preference: string, + q: string, + routing: string, + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + body: object +======= +client.cat.transforms({ + transform_id: string, + from: number, + size: number, + allow_no_match: boolean, + format: string, + h: string | string[], + help: boolean, + s: string | string[], + time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', + v: boolean +>>>>>>> a064f0f3... Improve child performances (#1314) +}) +---- +link:{ref}/cat-transforms.html[Documentation] + +[cols=2*] +|=== +<<<<<<< HEAD +|`id` +|`string` - The document ID + +|`index` +|`string` - The name of the index + +|`type` +|`string` - The type of the document + + +WARNING: This parameter has been deprecated. + +|`analyze_wildcard` or `analyzeWildcard` +|`boolean` - Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false) +======= +|`transform_id` or `transformId` +|`string` - The id of the transform for which to get stats. '_all' or '*' implies all transforms +>>>>>>> a064f0f3... Improve child performances (#1314) + +|`from` +|`number` - skips a number of transform configs, defaults to 0 + +|`size` +|`number` - specifies a max number of transforms to get, defaults to 100 + +|`allow_no_match` or `allowNoMatch` +|`boolean` - Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`time` +|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + +=== ccr.deleteAutoFollowPattern + +[source,ts] +---- +client.ccr.deleteAutoFollowPattern({ + name: string +}) +---- +link:{ref}/ccr-delete-auto-follow-pattern.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - The name of the auto follow pattern. + +|=== + +=== ccr.follow + +[source,ts] +---- +client.ccr.follow({ + index: string, + wait_for_active_shards: string, + body: object +}) +---- +link:{ref}/ccr-put-follow.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the follower index + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of shard copies that must be active before returning. Defaults to 0. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + +_Default:_ `0` + +|`body` +|`object` - The name of the leader index and other optional ccr related parameters + +|=== + +=== ccr.followInfo + +[source,ts] +---- +client.ccr.followInfo({ + index: string | string[] +}) +---- +link:{ref}/ccr-get-follow-info.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index patterns; use `_all` to perform the operation on all indices + +|=== + +=== ccr.followStats + +[source,ts] +---- +<<<<<<< HEAD +client.get({ + id: string, + index: string, + type: string, + stored_fields: string | string[], + preference: string, + realtime: boolean, + refresh: boolean, + routing: string, + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + version: number, + version_type: 'internal' | 'external' | 'external_gte' | 'force' +======= +client.ccr.followStats({ + index: string | string[] +>>>>>>> a064f0f3... Improve child performances (#1314) +}) +---- +link:{ref}/ccr-get-follow-stats.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index patterns; use `_all` to perform the operation on all indices + +<<<<<<< HEAD +|`type` +|`string` - The type of the document (use `_all` to fetch the first document matching the ID across all types) + + +WARNING: This parameter has been deprecated. + +|`stored_fields` or `storedFields` +|`string \| string[]` - A comma-separated list of stored fields to return in the response +======= +|=== +>>>>>>> a064f0f3... Improve child performances (#1314) + +=== ccr.forgetFollower + +[source,ts] +---- +client.ccr.forgetFollower({ + index: string, + body: object +}) +---- +link:{ref}/ccr-post-forget-follower.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - the name of the leader index for which specified follower retention leases should be removed + +|`body` +|`object` - the name and UUID of the follower index, the name of the cluster containing the follower index, and the alias from the perspective of that cluster for the remote cluster containing the leader index + +|=== + +=== ccr.getAutoFollowPattern + +[source,ts] +---- +client.ccr.getAutoFollowPattern({ + name: string +}) +---- +link:{ref}/ccr-get-auto-follow-pattern.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - The name of the auto follow pattern. + +|=== + +=== ccr.pauseAutoFollowPattern + +<<<<<<< HEAD +|`version_type` or `versionType` +|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type +======= +[source,ts] +---- +client.ccr.pauseAutoFollowPattern({ + name: string +}) +---- +link:{ref}/ccr-pause-auto-follow-pattern.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - The name of the auto follow pattern that should pause discovering new indices to follow. +>>>>>>> a064f0f3... Improve child performances (#1314) + +|=== + +=== ccr.pauseFollow + +[source,ts] +---- +client.ccr.pauseFollow({ + index: string +}) +---- +link:{ref}/ccr-post-pause-follow.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the follower index that should pause following its leader index. + +|=== + +=== ccr.putAutoFollowPattern + +[source,ts] +---- +client.ccr.putAutoFollowPattern({ + name: string, + body: object +}) +---- +link:{ref}/ccr-put-auto-follow-pattern.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - The name of the auto follow pattern. + +|`body` +|`object` - The specification of the auto follow pattern + +|=== + +=== ccr.resumeAutoFollowPattern + +[source,ts] +---- +client.ccr.resumeAutoFollowPattern({ + name: string +}) +---- +link:{ref}/ccr-resume-auto-follow-pattern.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - The name of the auto follow pattern to resume discovering new indices to follow. + +|=== + +=== ccr.resumeFollow + +[source,ts] +---- +client.ccr.resumeFollow({ + index: string, +<<<<<<< HEAD + type: string, + preference: string, + realtime: boolean, + refresh: boolean, + routing: string, + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + version: number, + version_type: 'internal' | 'external' | 'external_gte' | 'force' +======= + body: object +>>>>>>> a064f0f3... Improve child performances (#1314) +}) +---- +link:{ref}/ccr-post-resume-follow.html[Documentation] + +[cols=2*] +|=== +|`index` +<<<<<<< HEAD +|`string` - The name of the index + +|`type` +|`string` - The type of the document; deprecated and optional starting with 7.0 + + +WARNING: This parameter has been deprecated. + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`realtime` +|`boolean` - Specify whether to perform the operation in realtime or search mode +======= +|`string` - The name of the follow index to resume following. +>>>>>>> a064f0f3... Improve child performances (#1314) + +|`body` +|`object` - The name of the leader index and other optional ccr related parameters + +|=== + +=== ccr.stats + +[source,ts] +---- +client.ccr.stats() +---- +link:{ref}/ccr-get-stats.html[Documentation] + + + +=== ccr.unfollow + +<<<<<<< HEAD +|`version_type` or `versionType` +|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type +======= +[source,ts] +---- +client.ccr.unfollow({ + index: string +}) +---- +link:{ref}/ccr-post-unfollow.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the follower index that should be turned into a regular index. +>>>>>>> a064f0f3... Improve child performances (#1314) |=== @@ -1055,16 +2826,53 @@ WARNING: This parameter has been deprecated. [source,ts] ---- +<<<<<<< HEAD +client.index({ + id: string, + index: string, + type: string, + wait_for_active_shards: string, + op_type: 'index' | 'create', + refresh: 'true' | 'false' | 'wait_for', + routing: string, + timeout: string, + version: number, + version_type: 'internal' | 'external' | 'external_gte', + if_seq_no: number, + if_primary_term: number, + pipeline: string, + require_alias: boolean, +======= client.clearScroll({ scroll_id: string | string[], +>>>>>>> a064f0f3... Improve child performances (#1314) body: object }) ---- link:{ref}/clear-scroll-api.html[Documentation] + [cols=2*] |=== +<<<<<<< HEAD +|`id` +|`string` - Document ID + +|`index` +|`string` - The name of the index + +|`type` +|`string` - The type of the document + + +WARNING: This parameter has been deprecated. + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + +|`op_type` or `opType` +|`'index' \| 'create'` - Explicit operation type. Defaults to `index` for requests with an explicit document ID, and to `create`for requests without an explicit document ID +======= |`scroll_id` or `scrollId` |`string \| string[]` - A comma-separated list of scroll IDs to clear + +>>>>>>> a064f0f3... Improve child performances (#1314) WARNING: This parameter has been deprecated. @@ -1073,6 +2881,22 @@ WARNING: This parameter has been deprecated. |=== +=== closePointInTime + +[source,ts] +---- +client.closePointInTime({ + body: object +}) +---- +link:{ref}/point-in-time-api.html[Documentation] + +[cols=2*] +|=== +|`body` +|`object` - a point-in-time id to close + +|=== + === cluster.allocationExplain [source,ts] @@ -1280,16 +3104,40 @@ _Default:_ `cluster` [source,ts] ---- +<<<<<<< HEAD +client.indices.create({ + index: string, + include_type_name: boolean, + wait_for_active_shards: string, + timeout: string, + master_timeout: string, + body: object +======= client.cluster.pendingTasks({ local: boolean, master_timeout: string +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/cluster-pending.html[Documentation] + [cols=2*] |=== +<<<<<<< HEAD +|`index` +|`string` - The name of the index + +|`include_type_name` or `includeTypeName` +|`boolean` - Whether a type should be expected in the body of the mappings. + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Set the number of active shards to wait for before the operation returns. + +|`timeout` +|`string` - Explicit operation timeout +======= |`local` |`boolean` - Return local information, do not retrieve the state from master node (default: false) +>>>>>>> a064f0f3... Improve child performances (#1314) |`master_timeout` or `masterTimeout` |`string` - Specify timeout for connection to master @@ -1435,8 +3283,8 @@ link:{ref}/cluster-reroute.html[Documentation] + [source,ts] ---- client.cluster.state({ - index: string | string[], metric: string | string[], + index: string | string[], local: boolean, master_timeout: string, flat_settings: boolean, @@ -1450,12 +3298,12 @@ client.cluster.state({ link:{ref}/cluster-state.html[Documentation] + [cols=2*] |=== -|`index` -|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices - |`metric` |`string \| string[]` - Limit the information returned to the specified metrics +|`index` +|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices + |`local` |`boolean` - Return local information, do not retrieve the state from master node (default: false) @@ -1513,7 +3361,6 @@ link:{ref}/cluster-stats.html[Documentation] + ---- client.count({ index: string | string[], - type: string | string[], ignore_unavailable: boolean, ignore_throttled: boolean, allow_no_indices: boolean, @@ -1537,9 +3384,6 @@ link:{ref}/search-count.html[Documentation] + |`index` |`string \| string[]` - A comma-separated list of indices to restrict the results -|`type` -|`string \| string[]` - A comma-separated list of types to restrict the results - |`ignore_unavailable` or `ignoreUnavailable` |`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -1589,7 +3433,40 @@ _Default:_ `OR` |=== +<<<<<<< HEAD +=== indices.flushSynced + +[source,ts] +---- +client.indices.flushSynced({ + index: string | string[], + ignore_unavailable: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'none' | 'all' +}) +---- +link:{ref}/indices-synced-flush-api.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string for all indices + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `open` + +|=== + +=== indices.forcemerge +======= === create +>>>>>>> a064f0f3... Improve child performances (#1314) [source,ts] ---- @@ -1651,18 +3528,51 @@ WARNING: This parameter has been deprecated. [source,ts] ---- +<<<<<<< HEAD +client.indices.get({ + index: string | string[], + include_type_name: boolean, + local: boolean, + ignore_unavailable: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + flat_settings: boolean, + include_defaults: boolean, +======= client.danglingIndices.deleteDanglingIndex({ index_uuid: string, accept_data_loss: boolean, timeout: string, +>>>>>>> a064f0f3... Improve child performances (#1314) master_timeout: string }) ---- link:{ref}/modules-gateway-dangling-indices.html[Documentation] + [cols=2*] |=== +<<<<<<< HEAD +|`index` +|`string \| string[]` - A comma-separated list of index names + +|`include_type_name` or `includeTypeName` +|`boolean` - Whether to add the type name to the response (default: false) + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Ignore unavailable indexes (default: false) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Ignore if a wildcard expression resolves to no concrete indices (default: false) + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether wildcard expressions should get expanded to open or closed indices (default: open) + +_Default:_ `open` +======= |`index_uuid` or `indexUuid` |`string` - The UUID of the dangling index +>>>>>>> a064f0f3... Improve child performances (#1314) |`accept_data_loss` or `acceptDataLoss` |`boolean` - Must be set to true in order to delete the dangling index @@ -1716,6 +3626,18 @@ link:{ref}/modules-gateway-dangling-indices.html[Documentation] + [source,ts] ---- +<<<<<<< HEAD +client.indices.getFieldMapping({ + fields: string | string[], + index: string | string[], + type: string | string[], + include_type_name: boolean, + include_defaults: boolean, + ignore_unavailable: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + local: boolean +======= client.delete({ id: string, index: string, @@ -1727,7 +3649,8 @@ client.delete({ if_seq_no: number, if_primary_term: number, version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force' + version_type: 'internal' | 'external' | 'external_gte' +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/docs-delete.html[Documentation] + @@ -1740,7 +3663,19 @@ link:{ref}/docs-delete.html[Documentation] + |`string` - The name of the index |`type` +<<<<<<< HEAD +|`string \| string[]` - A comma-separated list of document types + + +WARNING: This parameter has been deprecated. + +|`include_type_name` or `includeTypeName` +|`boolean` - Whether a type should be returned in the body of the mappings. + +|`include_defaults` or `includeDefaults` +|`boolean` - Whether the default mapping values should be returned as well +======= |`string` - The type of the document + +>>>>>>> a064f0f3... Improve child performances (#1314) WARNING: This parameter has been deprecated. @@ -1766,7 +3701,7 @@ WARNING: This parameter has been deprecated. |`number` - Explicit version number for concurrency control |`version_type` or `versionType` -|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type +|`'internal' \| 'external' \| 'external_gte'` - Specific version type |=== @@ -1776,7 +3711,6 @@ WARNING: This parameter has been deprecated. ---- client.deleteByQuery({ index: string | string[], - type: string | string[], analyzer: string, analyze_wildcard: boolean, default_operator: 'AND' | 'OR', @@ -1793,7 +3727,6 @@ client.deleteByQuery({ scroll: string, search_type: 'query_then_fetch' | 'dfs_query_then_fetch', search_timeout: string, - size: number, max_docs: number, sort: string | string[], _source: string | string[], @@ -1819,9 +3752,6 @@ link:{ref}/docs-delete-by-query.html[Documentation] + |`index` |`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices -|`type` -|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types - |`analyzer` |`string` - The analyzer to use for the query string @@ -1835,8 +3765,37 @@ _Default:_ `OR` |`df` |`string` - The field to use as default where no field prefix is given in the query string +<<<<<<< HEAD +[source,ts] +---- +client.indices.getMapping({ + index: string | string[], + type: string | string[], + include_type_name: boolean, + ignore_unavailable: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + master_timeout: string, + local: boolean +}) +---- +link:{ref}/indices-get-mapping.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names +======= |`from` |`number` - Starting offset (default: 0) +>>>>>>> a064f0f3... Improve child performances (#1314) + +|`type` +|`string \| string[]` - A comma-separated list of document types + + +WARNING: This parameter has been deprecated. + +|`include_type_name` or `includeTypeName` +|`boolean` - Whether to add the type name to the response (default: false) |`ignore_unavailable` or `ignoreUnavailable` |`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -1873,9 +3832,6 @@ _Default:_ `open` |`search_timeout` or `searchTimeout` |`string` - Explicit timeout for each search request. Defaults to no timeout. -|`size` -|`number` - Deprecated, please use `max_docs` instead - |`max_docs` or `maxDocs` |`number` - Maximum number of documents to process (default: all documents) @@ -1903,12 +3859,36 @@ _Default:_ `open` |`request_cache` or `requestCache` |`boolean` - Specify if request cache should be used for this request or not, defaults to index level setting +<<<<<<< HEAD +[source,ts] +---- +client.indices.getTemplate({ + name: string | string[], + include_type_name: boolean, + flat_settings: boolean, + master_timeout: string, + local: boolean +}) +---- +link:{ref}/indices-templates.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string \| string[]` - The comma separated names of the index templates + +|`include_type_name` or `includeTypeName` +|`boolean` - Whether a type should be returned in the body of the mappings. + +|`flat_settings` or `flatSettings` +|`boolean` - Return settings in flat format (default: false) +======= |`refresh` -|`boolean` - Should the effected indexes be refreshed? +|`boolean` - Should the affected indexes be refreshed? |`timeout` |`string` - Time each individual bulk request should wait for shards that are unavailable. + _Default:_ `1m` +>>>>>>> a064f0f3... Improve child performances (#1314) |`wait_for_active_shards` or `waitForActiveShards` |`string` - Sets the number of shard copies that must be active before proceeding with the delete by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) @@ -1977,6 +3957,211 @@ link:{ref}/modules-scripting.html[Documentation] + |=== +=== enrich.deletePolicy + +[source,ts] +---- +client.enrich.deletePolicy({ + name: string +}) +---- +link:{ref}/delete-enrich-policy-api.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - The name of the enrich policy + +|=== + +=== enrich.executePolicy + +[source,ts] +---- +client.enrich.executePolicy({ + name: string, + wait_for_completion: boolean +}) +---- +link:{ref}/execute-enrich-policy-api.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - The name of the enrich policy + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Should the request should block until the execution is complete. + +_Default:_ `true` + +|=== + +=== enrich.getPolicy + +[source,ts] +---- +client.enrich.getPolicy({ + name: string | string[] +}) +---- +link:{ref}/get-enrich-policy-api.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string \| string[]` - A comma-separated list of enrich policy names + +|=== + +=== enrich.putPolicy + +[source,ts] +---- +<<<<<<< HEAD +client.indices.putMapping({ + index: string | string[], + type: string, + include_type_name: boolean, + timeout: string, + master_timeout: string, + ignore_unavailable: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + write_index_only: boolean, +======= +client.enrich.putPolicy({ + name: string, +>>>>>>> a064f0f3... Improve child performances (#1314) + body: object +}) +---- +link:{ref}/put-enrich-policy-api.html[Documentation] + +[cols=2*] +|=== +<<<<<<< HEAD +|`index` +|`string \| string[]` - A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. + +|`type` +|`string` - The name of the document type + + +WARNING: This parameter has been deprecated. + +|`include_type_name` or `includeTypeName` +|`boolean` - Whether a type should be expected in the body of the mappings. + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master +======= +|`name` +|`string` - The name of the enrich policy +>>>>>>> a064f0f3... Improve child performances (#1314) + +|`body` +|`object` - The enrich policy to register + +|=== + +=== enrich.stats + +[source,ts] +---- +client.enrich.stats() +---- +link:{ref}/enrich-stats-api.html[Documentation] + + + +=== eql.delete +*Stability:* beta +[source,ts] +---- +client.eql.delete({ + id: string +}) +---- +link:{ref}/eql-search-api.html[Documentation] + +[cols=2*] +|=== +|`id` +|`string` - The async search ID + +|=== + +=== eql.get +*Stability:* beta +[source,ts] +---- +client.eql.get({ + id: string, + wait_for_completion_timeout: string, + keep_alive: string +}) +---- +link:{ref}/eql-search-api.html[Documentation] + +[cols=2*] +|=== +|`id` +|`string` - The async search ID + +|`wait_for_completion_timeout` or `waitForCompletionTimeout` +|`string` - Specify the time that the request should block waiting for the final response + +|`keep_alive` or `keepAlive` +|`string` - Update the time interval in which the results (partial or final) for this search will be available + +_Default:_ `5d` + +|=== + +=== eql.search +*Stability:* beta +[source,ts] +---- +<<<<<<< HEAD +client.indices.putTemplate({ + name: string, + include_type_name: boolean, + order: number, + create: boolean, + master_timeout: string, +======= +client.eql.search({ + index: string, + wait_for_completion_timeout: string, + keep_on_completion: boolean, + keep_alive: string, +>>>>>>> a064f0f3... Improve child performances (#1314) + body: object +}) +---- +link:{ref}/eql-search-api.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the index to scope the operation + +<<<<<<< HEAD +|`include_type_name` or `includeTypeName` +|`boolean` - Whether a type should be returned in the body of the mappings. + +|`order` +|`number` - The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers) +======= +|`wait_for_completion_timeout` or `waitForCompletionTimeout` +|`string` - Specify the time that the request should block waiting for the final response +>>>>>>> a064f0f3... Improve child performances (#1314) + +|`keep_on_completion` or `keepOnCompletion` +|`boolean` - Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false) + +|`keep_alive` or `keepAlive` +|`string` - Update the time interval in which the results (partial or final) for this search will be available + +_Default:_ `5d` + +|`body` +|`object` - Eql request body. Use the `query` to limit the query scope. + +|=== + === exists [source,ts] @@ -1984,7 +4169,6 @@ link:{ref}/modules-scripting.html[Documentation] + client.exists({ id: string, index: string, - type: string, stored_fields: string | string[], preference: string, realtime: boolean, @@ -1994,7 +4178,7 @@ client.exists({ _source_excludes: string | string[], _source_includes: string | string[], version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force' + version_type: 'internal' | 'external' | 'external_gte' }) ---- link:{ref}/docs-get.html[Documentation] + @@ -2007,11 +4191,6 @@ link:{ref}/docs-get.html[Documentation] + |`index` |`string` - The name of the index -|`type` -|`string` - The type of the document (use `_all` to fetch the first document matching the ID across all types) + - -WARNING: This parameter has been deprecated. - |`stored_fields` or `storedFields` |`string \| string[]` - A comma-separated list of stored fields to return in the response @@ -2040,7 +4219,7 @@ WARNING: This parameter has been deprecated. |`number` - Explicit version number for concurrency control |`version_type` or `versionType` -|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type +|`'internal' \| 'external' \| 'external_gte'` - Specific version type |=== @@ -2060,7 +4239,7 @@ client.existsSource({ _source_excludes: string | string[], _source_includes: string | string[], version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force' + version_type: 'internal' | 'external' | 'external_gte' }) ---- link:{ref}/docs-get.html[Documentation] + @@ -2102,7 +4281,7 @@ WARNING: This parameter has been deprecated. |`number` - Explicit version number for concurrency control |`version_type` or `versionType` -|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type +|`'internal' \| 'external' \| 'external_gte'` - Specific version type |=== @@ -2110,10 +4289,19 @@ WARNING: This parameter has been deprecated. [source,ts] ---- +<<<<<<< HEAD +client.indices.rollover({ + alias: string, + new_index: string, + include_type_name: boolean, + timeout: string, + dry_run: boolean, + master_timeout: string, + wait_for_active_shards: string, +======= client.explain({ id: string, index: string, - type: string, analyze_wildcard: boolean, analyzer: string, default_operator: 'AND' | 'OR', @@ -2126,6 +4314,7 @@ client.explain({ _source: string | string[], _source_excludes: string | string[], _source_includes: string | string[], +>>>>>>> a064f0f3... Improve child performances (#1314) body: object }) ---- @@ -2138,13 +4327,16 @@ link:{ref}/search-explain.html[Documentation] + |`index` |`string` - The name of the index -|`type` -|`string` - The type of the document + - -WARNING: This parameter has been deprecated. +<<<<<<< HEAD +|`include_type_name` or `includeTypeName` +|`boolean` - Whether a type should be included in the body of the mappings. +|`timeout` +|`string` - Explicit operation timeout +======= |`analyze_wildcard` or `analyzeWildcard` |`boolean` - Specify whether wildcards and prefix queries in the query string query should be analyzed (default: false) +>>>>>>> a064f0f3... Improve child performances (#1314) |`analyzer` |`string` - The analyzer for the query string query @@ -2233,7 +4425,14 @@ _Default:_ `open` client.get({ id: string, index: string, - type: string, +<<<<<<< HEAD + target: string, + copy_settings: boolean, + timeout: string, + master_timeout: string, + wait_for_active_shards: string, + body: object +======= stored_fields: string | string[], preference: string, realtime: boolean, @@ -2243,7 +4442,8 @@ client.get({ _source_excludes: string | string[], _source_includes: string | string[], version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force' + version_type: 'internal' | 'external' | 'external_gte' +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/docs-get.html[Documentation] + @@ -2253,13 +4453,16 @@ link:{ref}/docs-get.html[Documentation] + |`id` |`string` - The document ID +<<<<<<< HEAD +|`copy_settings` or `copySettings` +|`boolean` - whether or not to copy settings from the source index (defaults to false) + +|`timeout` +|`string` - Explicit operation timeout +======= |`index` |`string` - The name of the index - -|`type` -|`string` - The type of the document (use `_all` to fetch the first document matching the ID across all types) + - -WARNING: This parameter has been deprecated. +>>>>>>> a064f0f3... Improve child performances (#1314) |`stored_fields` or `storedFields` |`string \| string[]` - A comma-separated list of stored fields to return in the response @@ -2289,7 +4492,7 @@ WARNING: This parameter has been deprecated. |`number` - Explicit version number for concurrency control |`version_type` or `versionType` -|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type +|`'internal' \| 'external' \| 'external_gte'` - Specific version type |=== @@ -2317,9 +4520,39 @@ link:{ref}/modules-scripting.html[Documentation] + *Stability:* experimental [source,ts] ---- +<<<<<<< HEAD +client.indices.split({ + index: string, + target: string, + copy_settings: boolean, + timeout: string, + master_timeout: string, + wait_for_active_shards: string, + body: object +}) +---- +link:{ref}/indices-split-index.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the source index to split + +|`target` +|`string` - The name of the target index to split into + +|`copy_settings` or `copySettings` +|`boolean` - whether or not to copy settings from the source index (defaults to false) + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master +======= client.getScriptContext() ---- link:https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-contexts.html[Documentation] + +>>>>>>> a064f0f3... Improve child performances (#1314) === getScriptLanguages @@ -2338,7 +4571,6 @@ link:{ref}/modules-scripting.html[Documentation] + client.getSource({ id: string, index: string, - type: string, preference: string, realtime: boolean, refresh: boolean, @@ -2347,7 +4579,7 @@ client.getSource({ _source_excludes: string | string[], _source_includes: string | string[], version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force' + version_type: 'internal' | 'external' | 'external_gte' }) ---- link:{ref}/docs-get.html[Documentation] + @@ -2359,11 +4591,6 @@ link:{ref}/docs-get.html[Documentation] + |`index` |`string` - The name of the index -|`type` -|`string` - The type of the document; deprecated and optional starting with 7.0 + - -WARNING: This parameter has been deprecated. - |`preference` |`string` - Specify the node or shard the operation should be performed on (default: random) @@ -2389,10 +4616,193 @@ WARNING: This parameter has been deprecated. |`number` - Explicit version number for concurrency control |`version_type` or `versionType` -|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type +|`'internal' \| 'external' \| 'external_gte'` - Specific version type |=== +=== graph.explore + +[source,ts] +---- +client.graph.explore({ + index: string | string[], + routing: string, + timeout: string, + body: object +}) +---- +link:{ref}/graph-explore-api.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`routing` +|`string` - Specific routing value + +|`timeout` +|`string` - Explicit operation timeout + +|`body` +|`object` - Graph Query DSL + +|=== + +=== ilm.deleteLifecycle + +[source,ts] +---- +client.ilm.deleteLifecycle({ + policy: string +}) +---- +link:{ref}/ilm-delete-lifecycle.html[Documentation] + +[cols=2*] +|=== +|`policy` +|`string` - The name of the index lifecycle policy + +|=== + +=== ilm.explainLifecycle + +[source,ts] +---- +client.ilm.explainLifecycle({ + index: string, + only_managed: boolean, + only_errors: boolean +}) +---- +link:{ref}/ilm-explain-lifecycle.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the index to explain + +|`only_managed` or `onlyManaged` +|`boolean` - filters the indices included in the response to ones managed by ILM + +|`only_errors` or `onlyErrors` +|`boolean` - filters the indices included in the response to ones in an ILM error state, implies only_managed + +|=== + +=== ilm.getLifecycle + +[source,ts] +---- +client.ilm.getLifecycle({ + policy: string +}) +---- +link:{ref}/ilm-get-lifecycle.html[Documentation] + +[cols=2*] +|=== +|`policy` +|`string` - The name of the index lifecycle policy + +|=== + +=== ilm.getStatus + +[source,ts] +---- +client.ilm.getStatus() +---- +link:{ref}/ilm-get-status.html[Documentation] + + + +=== ilm.moveToStep + +[source,ts] +---- +client.ilm.moveToStep({ + index: string, + body: object +}) +---- +link:{ref}/ilm-move-to-step.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the index whose lifecycle step is to change + +|`body` +|`object` - The new lifecycle step to move to + +|=== + +=== ilm.putLifecycle + +[source,ts] +---- +client.ilm.putLifecycle({ + policy: string, + body: object +}) +---- +link:{ref}/ilm-put-lifecycle.html[Documentation] + +[cols=2*] +|=== +|`policy` +|`string` - The name of the index lifecycle policy + +|`body` +|`object` - The lifecycle policy definition to register + +|=== + +=== ilm.removePolicy + +[source,ts] +---- +client.ilm.removePolicy({ + index: string +}) +---- +link:{ref}/ilm-remove-policy.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the index to remove policy on + +|=== + +=== ilm.retry + +[source,ts] +---- +client.ilm.retry({ + index: string +}) +---- +link:{ref}/ilm-retry-policy.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the indices (comma-separated) whose failed lifecycle step is to be retry + +|=== + +=== ilm.start + +[source,ts] +---- +client.ilm.start() +---- +link:{ref}/ilm-start.html[Documentation] + + + +=== ilm.stop + +[source,ts] +---- +client.ilm.stop() +---- +link:{ref}/ilm-stop.html[Documentation] + + + === index [source,ts] @@ -2400,7 +4810,6 @@ WARNING: This parameter has been deprecated. client.index({ id: string, index: string, - type: string, wait_for_active_shards: string, op_type: 'index' | 'create', refresh: 'true' | 'false' | 'wait_for', @@ -2424,11 +4833,6 @@ link:{ref}/docs-index_.html[Documentation] + |`index` |`string` - The name of the index -|`type` -|`string` - The type of the document + - -WARNING: This parameter has been deprecated. - |`wait_for_active_shards` or `waitForActiveShards` |`string` - Sets the number of shard copies that must be active before proceeding with the index operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) @@ -2471,6 +4875,20 @@ WARNING: This parameter has been deprecated. [source,ts] ---- +<<<<<<< HEAD +client.mget({ + index: string, + type: string, + stored_fields: string | string[], + preference: string, + realtime: boolean, + refresh: boolean, + routing: string, + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + body: object +======= client.indices.addBlock({ index: string | string[], block: string, @@ -2479,6 +4897,7 @@ client.indices.addBlock({ ignore_unavailable: boolean, allow_no_indices: boolean, expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/index-modules-blocks.html[Documentation] + @@ -2487,8 +4906,18 @@ link:{ref}/index-modules-blocks.html[Documentation] + |`index` |`string \| string[]` - A comma separated list of indices to add a block to +<<<<<<< HEAD +|`type` +|`string` - The type of the document + + +WARNING: This parameter has been deprecated. + +|`stored_fields` or `storedFields` +|`string \| string[]` - A comma-separated list of stored fields to return in the response +======= |`block` |`string` - The block to add (one of read, write, read_only or metadata) +>>>>>>> a064f0f3... Improve child performances (#1314) |`timeout` |`string` - Explicit operation timeout @@ -2524,7 +4953,11 @@ link:{ref}/indices-analyze.html[Documentation] + |`string` - The name of the index to scope the operation |`body` +<<<<<<< HEAD +|`object` - Document identifiers; can be either `docs` (containing full document information) or `ids` (when index and type is provided in the URL. +======= |`object` - Define analyzer/tokenizer parameters and the text on which the analysis should be performed +>>>>>>> a064f0f3... Improve child performances (#1314) |=== @@ -2534,6 +4967,17 @@ link:{ref}/indices-analyze.html[Documentation] + ---- client.indices.clearCache({ index: string | string[], +<<<<<<< HEAD + type: string | string[], + search_type: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch', + max_concurrent_searches: number, + typed_keys: boolean, + pre_filter_shard_size: number, + max_concurrent_shard_requests: number, + rest_total_hits_as_int: boolean, + ccs_minimize_roundtrips: boolean, + body: object +======= fielddata: boolean, fields: string | string[], query: boolean, @@ -2541,13 +4985,24 @@ client.indices.clearCache({ allow_no_indices: boolean, expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', request: boolean +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/indices-clearcache.html[Documentation] + [cols=2*] |=== |`index` +<<<<<<< HEAD +|`string \| string[]` - A comma-separated list of index names to use as default + +|`type` +|`string \| string[]` - A comma-separated list of document types to use as default + +|`search_type` or `searchType` +|`'query_then_fetch' \| 'query_and_fetch' \| 'dfs_query_then_fetch' \| 'dfs_query_and_fetch'` - Search operation type +======= |`string \| string[]` - A comma-separated list of index name to limit the operation +>>>>>>> a064f0f3... Improve child performances (#1314) |`fielddata` |`boolean` - Clear field data @@ -2577,12 +5032,23 @@ _Default:_ `open` [source,ts] ---- +<<<<<<< HEAD +client.msearchTemplate({ + index: string | string[], + type: string | string[], + search_type: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch', + typed_keys: boolean, + max_concurrent_searches: number, + rest_total_hits_as_int: boolean, + ccs_minimize_roundtrips: boolean, +======= client.indices.clone({ index: string, target: string, timeout: string, master_timeout: string, wait_for_active_shards: string, +>>>>>>> a064f0f3... Improve child performances (#1314) body: object }) ---- @@ -2590,7 +5056,17 @@ link:{ref}/indices-clone-index.html[Documentation] + [cols=2*] |=== |`index` +<<<<<<< HEAD +|`string \| string[]` - A comma-separated list of index names to use as default + +|`type` +|`string \| string[]` - A comma-separated list of document types to use as default + +|`search_type` or `searchType` +|`'query_then_fetch' \| 'query_and_fetch' \| 'dfs_query_then_fetch' \| 'dfs_query_and_fetch'` - Search operation type +======= |`string` - The name of the source index to clone +>>>>>>> a064f0f3... Improve child performances (#1314) |`target` |`string` - The name of the target index to clone into @@ -2613,6 +5089,24 @@ link:{ref}/indices-clone-index.html[Documentation] + [source,ts] ---- +<<<<<<< HEAD +client.mtermvectors({ + index: string, + type: string, + ids: string | string[], + term_statistics: boolean, + field_statistics: boolean, + fields: string | string[], + offsets: boolean, + positions: boolean, + payloads: boolean, + preference: string, + routing: string, + realtime: boolean, + version: number, + version_type: 'internal' | 'external' | 'external_gte' | 'force', + body: object +======= client.indices.close({ index: string | string[], timeout: string, @@ -2621,13 +5115,46 @@ client.indices.close({ allow_no_indices: boolean, expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', wait_for_active_shards: string +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/indices-open-close.html[Documentation] + [cols=2*] |=== |`index` +<<<<<<< HEAD +|`string` - The index in which the document resides. + +|`type` +|`string` - The type of the document. + +|`ids` +|`string \| string[]` - A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body + +|`term_statistics` or `termStatistics` +|`boolean` - Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +|`field_statistics` or `fieldStatistics` +|`boolean` - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +_Default:_ `true` + +|`fields` +|`string \| string[]` - A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +|`offsets` +|`boolean` - Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +_Default:_ `true` + +|`positions` +|`boolean` - Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +_Default:_ `true` + +|`payloads` +|`boolean` - Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +_Default:_ `true` +======= |`string \| string[]` - A comma separated list of indices to close +>>>>>>> a064f0f3... Improve child performances (#1314) |`timeout` |`string` - Explicit operation timeout @@ -2641,9 +5168,14 @@ link:{ref}/indices-open-close.html[Documentation] + |`allow_no_indices` or `allowNoIndices` |`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) +<<<<<<< HEAD +|`version_type` or `versionType` +|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type +======= |`expand_wildcards` or `expandWildcards` |`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + _Default:_ `open` +>>>>>>> a064f0f3... Improve child performances (#1314) |`wait_for_active_shards` or `waitForActiveShards` |`string` - Sets the number of active shards to wait for before the operation returns. @@ -2656,7 +5188,6 @@ _Default:_ `open` ---- client.indices.create({ index: string, - include_type_name: boolean, wait_for_active_shards: string, timeout: string, master_timeout: string, @@ -2669,9 +5200,6 @@ link:{ref}/indices-create-index.html[Documentation] + |`index` |`string` - The name of the index -|`include_type_name` or `includeTypeName` -|`boolean` - Whether a type should be expected in the body of the mappings. - |`wait_for_active_shards` or `waitForActiveShards` |`string` - Set the number of active shards to wait for before the operation returns. @@ -2686,6 +5214,38 @@ link:{ref}/indices-create-index.html[Documentation] + |=== +=== indices.createDataStream + +[source,ts] +---- +client.indices.createDataStream({ + name: string +}) +---- +link:{ref}/data-streams.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - The name of the data stream + +|=== + +=== indices.dataStreamsStats + +[source,ts] +---- +client.indices.dataStreamsStats({ + name: string | string[] +}) +---- +link:{ref}/data-streams.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string \| string[]` - A comma-separated list of data stream names; use `_all` or empty string to perform the operation on all data streams + +|=== + === indices.delete [source,ts] @@ -2751,6 +5311,22 @@ link:{ref}/indices-aliases.html[Documentation] + |=== +=== indices.deleteDataStream + +[source,ts] +---- +client.indices.deleteDataStream({ + name: string | string[] +}) +---- +link:{ref}/data-streams.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string \| string[]` - A comma-separated list of data streams to delete; use `*` to delete all data streams + +|=== + === indices.deleteIndexTemplate *Stability:* experimental [source,ts] @@ -2976,11 +5552,58 @@ _Default:_ `open` ---- client.indices.flush({ index: string | string[], +<<<<<<< HEAD + type: string | string[], + analyzer: string, + analyze_wildcard: boolean, + ccs_minimize_roundtrips: boolean, + default_operator: 'AND' | 'OR', + df: string, + explain: boolean, + stored_fields: string | string[], + docvalue_fields: string | string[], + from: number, +======= force: boolean, wait_if_ongoing: boolean, +>>>>>>> a064f0f3... Improve child performances (#1314) ignore_unavailable: boolean, allow_no_indices: boolean, +<<<<<<< HEAD + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + lenient: boolean, + preference: string, + q: string, + routing: string | string[], + scroll: string, + search_type: 'query_then_fetch' | 'dfs_query_then_fetch', + size: number, + sort: string | string[], + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + terminate_after: number, + stats: string | string[], + suggest_field: string, + suggest_mode: 'missing' | 'popular' | 'always', + suggest_size: number, + suggest_text: string, + timeout: string, + track_scores: boolean, + track_total_hits: boolean, + allow_partial_search_results: boolean, + typed_keys: boolean, + version: boolean, + seq_no_primary_term: boolean, + request_cache: boolean, + batched_reduce_size: number, + max_concurrent_shard_requests: number, + pre_filter_shard_size: number, + rest_total_hits_as_int: boolean, + body: object +======= expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/indices-flush.html[Documentation] + @@ -2989,8 +5612,16 @@ link:{ref}/indices-flush.html[Documentation] + |`index` |`string \| string[]` - A comma-separated list of index names; use `_all` or empty string for all indices +<<<<<<< HEAD +|`type` +|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types + +|`analyzer` +|`string` - The analyzer to use for the query string +======= |`force` |`boolean` - Whether a flush should be forced even if it is not necessarily needed ie. if no changes will be committed to the index. This is useful if transaction log IDs should be incremented even if no uncommitted changes are present. (This setting can be considered as internal) +>>>>>>> a064f0f3... Improve child performances (#1314) |`wait_if_ongoing` or `waitIfOngoing` |`boolean` - If set to true the flush operation will block until the flush can be executed if another flush operation is already executing. The default is true. If set to false the flush will be skipped iff if another flush operation is already running. @@ -3007,35 +5638,6 @@ _Default:_ `open` |=== -=== indices.flushSynced - -[source,ts] ----- -client.indices.flushSynced({ - index: string | string[], - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'none' | 'all' -}) ----- -link:{ref}/indices-synced-flush-api.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names; use `_all` or empty string for all indices - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|=== - === indices.forcemerge [source,ts] @@ -3077,13 +5679,53 @@ _Default:_ `open` |=== +=== indices.freeze + +[source,ts] +---- +client.indices.freeze({ + index: string, + timeout: string, + master_timeout: string, + ignore_unavailable: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + wait_for_active_shards: string +}) +---- +link:{ref}/freeze-index-api.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the index to freeze + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `closed` + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of active shards to wait for before the operation returns. + +|=== + === indices.get [source,ts] ---- client.indices.get({ index: string | string[], - include_type_name: boolean, local: boolean, ignore_unavailable: boolean, allow_no_indices: boolean, @@ -3099,9 +5741,6 @@ link:{ref}/indices-get-index.html[Documentation] + |`index` |`string \| string[]` - A comma-separated list of index names -|`include_type_name` or `includeTypeName` -|`boolean` - Whether to add the type name to the response (default: false) - |`local` |`boolean` - Return local information, do not retrieve the state from master node (default: false) @@ -3124,7 +5763,12 @@ _Default:_ `open` |`master_timeout` or `masterTimeout` |`string` - Specify timeout for connection to master +<<<<<<< HEAD +|`track_total_hits` or `trackTotalHits` +|`boolean` - Indicate if the number of documents that match the query should be tracked +======= |=== +>>>>>>> a064f0f3... Improve child performances (#1314) === indices.getAlias @@ -3163,6 +5807,22 @@ _Default:_ `all` |=== +=== indices.getDataStream + +[source,ts] +---- +client.indices.getDataStream({ + name: string | string[] +}) +---- +link:{ref}/data-streams.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string \| string[]` - A comma-separated list of data streams to get; use `*` to get all data streams + +|=== + === indices.getFieldMapping [source,ts] @@ -3170,8 +5830,6 @@ _Default:_ `all` client.indices.getFieldMapping({ fields: string | string[], index: string | string[], - type: string | string[], - include_type_name: boolean, include_defaults: boolean, ignore_unavailable: boolean, allow_no_indices: boolean, @@ -3188,14 +5846,6 @@ link:{ref}/indices-get-field-mapping.html[Documentation] + |`index` |`string \| string[]` - A comma-separated list of index names -|`type` -|`string \| string[]` - A comma-separated list of document types + - -WARNING: This parameter has been deprecated. - -|`include_type_name` or `includeTypeName` -|`boolean` - Whether a type should be returned in the body of the mappings. - |`include_defaults` or `includeDefaults` |`boolean` - Whether the default mapping values should be returned as well @@ -3249,7 +5899,6 @@ link:{ref}/indices-templates.html[Documentation] + client.indices.getMapping({ index: string | string[], type: string | string[], - include_type_name: boolean, ignore_unavailable: boolean, allow_no_indices: boolean, expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', @@ -3264,12 +5913,7 @@ link:{ref}/indices-get-mapping.html[Documentation] + |`string \| string[]` - A comma-separated list of index names |`type` -|`string \| string[]` - A comma-separated list of document types + - -WARNING: This parameter has been deprecated. - -|`include_type_name` or `includeTypeName` -|`boolean` - Whether to add the type name to the response (default: false) +|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types |`ignore_unavailable` or `ignoreUnavailable` |`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -3346,7 +5990,6 @@ _Default:_ `all` ---- client.indices.getTemplate({ name: string | string[], - include_type_name: boolean, flat_settings: boolean, master_timeout: string, local: boolean @@ -3358,9 +6001,6 @@ link:{ref}/indices-templates.html[Documentation] + |`name` |`string \| string[]` - The comma separated names of the index templates -|`include_type_name` or `includeTypeName` -|`boolean` - Whether a type should be returned in the body of the mappings. - |`flat_settings` or `flatSettings` |`boolean` - Return settings in flat format (default: false) @@ -3446,12 +6086,19 @@ _Default:_ `closed` [source,ts] ---- +<<<<<<< HEAD +client.snapshot.delete({ + repository: string, + snapshot: string, + master_timeout: string +======= client.indices.putAlias({ index: string | string[], name: string, timeout: string, master_timeout: string, body: object +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/indices-aliases.html[Documentation] + @@ -3460,11 +6107,16 @@ link:{ref}/indices-aliases.html[Documentation] + |`index` |`string \| string[]` - A comma-separated list of index names the alias should point to (supports wildcards); use `_all` to perform the operation on all indices. +<<<<<<< HEAD +|`snapshot` +|`string` - A snapshot name +======= |`name` |`string` - The name of the alias to be created or updated |`timeout` |`string` - Explicit timestamp for the document +>>>>>>> a064f0f3... Improve child performances (#1314) |`master_timeout` or `masterTimeout` |`string` - Specify timeout for connection to master @@ -3512,8 +6164,6 @@ link:{ref}/indices-templates.html[Documentation] + ---- client.indices.putMapping({ index: string | string[], - type: string, - include_type_name: boolean, timeout: string, master_timeout: string, ignore_unavailable: boolean, @@ -3529,14 +6179,6 @@ link:{ref}/indices-put-mapping.html[Documentation] + |`index` |`string \| string[]` - A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. -|`type` -|`string` - The name of the document type + - -WARNING: This parameter has been deprecated. - -|`include_type_name` or `includeTypeName` -|`boolean` - Whether a type should be expected in the body of the mappings. - |`timeout` |`string` - Explicit operation timeout @@ -3616,7 +6258,6 @@ _Default:_ `open` ---- client.indices.putTemplate({ name: string, - include_type_name: boolean, order: number, create: boolean, master_timeout: string, @@ -3629,9 +6270,6 @@ link:{ref}/indices-templates.html[Documentation] + |`name` |`string` - The name of the template -|`include_type_name` or `includeTypeName` -|`boolean` - Whether a type should be returned in the body of the mappings. - |`order` |`number` - The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers) @@ -3699,6 +6337,35 @@ _Default:_ `open` |=== +=== indices.reloadSearchAnalyzers + +[source,ts] +---- +client.indices.reloadSearchAnalyzers({ + index: string | string[], + ignore_unavailable: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' +}) +---- +link:{ref}/indices-reload-analyzers.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to reload analyzers for + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `open` + +|=== + === indices.resolveIndex *Stability:* experimental [source,ts] @@ -3727,7 +6394,6 @@ _Default:_ `open` client.indices.rollover({ alias: string, new_index: string, - include_type_name: boolean, timeout: string, dry_run: boolean, master_timeout: string, @@ -3744,9 +6410,6 @@ link:{ref}/indices-rollover-index.html[Documentation] + |`new_index` or `newIndex` |`string` - The name of the rollover index -|`include_type_name` or `includeTypeName` -|`boolean` - Whether a type should be included in the body of the mappings. - |`timeout` |`string` - Explicit operation timeout @@ -3768,19 +6431,55 @@ link:{ref}/indices-rollover-index.html[Documentation] + [source,ts] ---- +<<<<<<< HEAD +client.termvectors({ + index: string, + id: string, + type: string, + term_statistics: boolean, + field_statistics: boolean, + fields: string | string[], + offsets: boolean, + positions: boolean, + payloads: boolean, + preference: string, + routing: string, + realtime: boolean, + version: number, + version_type: 'internal' | 'external' | 'external_gte' | 'force', + body: object +======= client.indices.segments({ index: string | string[], ignore_unavailable: boolean, allow_no_indices: boolean, expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', verbose: boolean +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/indices-segments.html[Documentation] + [cols=2*] |=== |`index` +<<<<<<< HEAD +|`string` - The index in which the document resides. + +|`id` +|`string` - The id of the document, when not specified a doc param should be supplied. + +|`type` +|`string` - The type of the document. + +|`term_statistics` or `termStatistics` +|`boolean` - Specifies if total term frequency and document frequency should be returned. + +|`field_statistics` or `fieldStatistics` +|`boolean` - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. + +_Default:_ `true` +======= |`string \| string[]` - A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices +>>>>>>> a064f0f3... Improve child performances (#1314) |`ignore_unavailable` or `ignoreUnavailable` |`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) @@ -3818,8 +6517,13 @@ link:{ref}/indices-shards-stores.html[Documentation] + |`status` |`string \| string[]` - A comma-separated list of statuses used to filter on shards to get store information for +<<<<<<< HEAD +|`version_type` or `versionType` +|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type +======= |`ignore_unavailable` or `ignoreUnavailable` |`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) +>>>>>>> a064f0f3... Improve child performances (#1314) |`allow_no_indices` or `allowNoIndices` |`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) @@ -3837,7 +6541,6 @@ _Default:_ `open` client.indices.shrink({ index: string, target: string, - copy_settings: boolean, timeout: string, master_timeout: string, wait_for_active_shards: string, @@ -3853,9 +6556,6 @@ link:{ref}/indices-shrink-index.html[Documentation] + |`target` |`string` - The name of the target index to shrink into -|`copy_settings` or `copySettings` -|`boolean` - whether or not to copy settings from the source index (defaults to false) - |`timeout` |`string` - Explicit operation timeout @@ -3874,11 +6574,52 @@ link:{ref}/indices-shrink-index.html[Documentation] + *Stability:* experimental [source,ts] ---- +<<<<<<< HEAD +client.updateByQuery({ + index: string | string[], + type: string | string[], + analyzer: string, + analyze_wildcard: boolean, + default_operator: 'AND' | 'OR', + df: string, + from: number, + ignore_unavailable: boolean, + allow_no_indices: boolean, + conflicts: 'abort' | 'proceed', + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + lenient: boolean, + pipeline: string, + preference: string, + q: string, + routing: string | string[], + scroll: string, + search_type: 'query_then_fetch' | 'dfs_query_then_fetch', + search_timeout: string, + size: number, + max_docs: number, + sort: string | string[], + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + terminate_after: number, + stats: string | string[], + version: boolean, + version_type: boolean, + request_cache: boolean, + refresh: boolean, + timeout: string, + wait_for_active_shards: string, + scroll_size: number, + wait_for_completion: boolean, + requests_per_second: number, + slices: number|string, +======= client.indices.simulateIndexTemplate({ name: string, create: boolean, cause: string, master_timeout: string, +>>>>>>> a064f0f3... Improve child performances (#1314) body: object }) ---- @@ -3888,8 +6629,16 @@ link:{ref}/indices-templates.html[Documentation] + |`name` |`string` - The name of the index (it must be a concrete index name) +<<<<<<< HEAD +|`type` +|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types + +|`analyzer` +|`string` - The analyzer to use for the query string +======= |`create` |`boolean` - Whether the index template we optionally defined in the body should only be dry-run added if new or can also replace an existing one +>>>>>>> a064f0f3... Improve child performances (#1314) |`cause` |`string` - User defined reason for dry-run creating the new template for simulation purposes @@ -3941,7 +6690,6 @@ link:{ref}/indices-templates.html[Documentation] + client.indices.split({ index: string, target: string, - copy_settings: boolean, timeout: string, master_timeout: string, wait_for_active_shards: string, @@ -3957,9 +6705,6 @@ link:{ref}/indices-split-index.html[Documentation] + |`target` |`string` - The name of the target index to split into -|`copy_settings` or `copySettings` -|`boolean` - whether or not to copy settings from the source index (defaults to false) - |`timeout` |`string` - Explicit operation timeout @@ -3969,8 +6714,16 @@ link:{ref}/indices-split-index.html[Documentation] + |`wait_for_active_shards` or `waitForActiveShards` |`string` - Set the number of active shards to wait for on the shrunken index before the operation returns. +<<<<<<< HEAD +|`size` +|`number` - Deprecated, please use `max_docs` instead + +|`max_docs` or `maxDocs` +|`number` - Maximum number of documents to process (default: all documents) +======= |`body` |`object` - The configuration for the target index (`settings` and `aliases`) +>>>>>>> a064f0f3... Improve child performances (#1314) |=== @@ -4037,6 +6790,47 @@ _Default:_ `true` |=== +=== indices.unfreeze + +[source,ts] +---- +client.indices.unfreeze({ + index: string, + timeout: string, + master_timeout: string, + ignore_unavailable: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + wait_for_active_shards: string +}) +---- +link:{ref}/unfreeze-index-api.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the index to unfreeze + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `closed` + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of active shards to wait for before the operation returns. + +|=== + === indices.updateAliases [source,ts] @@ -4110,6 +6904,29 @@ client.indices.validateQuery({ allow_no_indices: boolean, expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', q: string, +<<<<<<< HEAD + routing: string | string[], + search_type: 'query_then_fetch' | 'dfs_query_then_fetch', + size: number, + sort: string | string[], + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + terminate_after: number, + stats: string | string[], + suggest_field: string, + suggest_mode: 'missing' | 'popular' | 'always', + suggest_size: number, + suggest_text: string, + timeout: string, + track_scores: boolean, + track_total_hits: boolean, + allow_partial_search_results: boolean, + typed_keys: boolean, + version: boolean, + seq_no_primary_term: boolean, + max_concurrent_shard_requests: number, +======= analyzer: string, analyze_wildcard: boolean, default_operator: 'AND' | 'OR', @@ -4117,6 +6934,7 @@ client.indices.validateQuery({ lenient: boolean, rewrite: boolean, all_shards: boolean, +>>>>>>> a064f0f3... Improve child performances (#1314) body: object }) ---- @@ -4205,6 +7023,35 @@ link:{ref}/delete-pipeline-api.html[Documentation] + |`timeout` |`string` - Explicit operation timeout +<<<<<<< HEAD +|`track_scores` or `trackScores` +|`boolean` - Whether to calculate and return scores even if they are not used for sorting + +|`track_total_hits` or `trackTotalHits` +|`boolean` - Indicate if the number of documents that match the query should be tracked + +|`allow_partial_search_results` or `allowPartialSearchResults` +|`boolean` - Indicate if an error should be returned if there is a partial search failure or timeout + +_Default:_ `true` + +|`typed_keys` or `typedKeys` +|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + +|`version` +|`boolean` - Specify whether to return document version as part of a hit + +|`seq_no_primary_term` or `seqNoPrimaryTerm` +|`boolean` - Specify whether to return sequence number and primary term of the last modification of each hit + +|`max_concurrent_shard_requests` or `maxConcurrentShardRequests` +|`number` - The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + +_Default:_ `5` + +|`body` +|`object` - The search definition using the Query DSL + +======= +>>>>>>> a064f0f3... Improve child performances (#1314) |=== === ingest.getPipeline @@ -4288,2987 +7135,6 @@ link:{ref}/simulate-pipeline-api.html[Documentation] + |=== -=== mget - -[source,ts] ----- -client.mget({ - index: string, - type: string, - stored_fields: string | string[], - preference: string, - realtime: boolean, - refresh: boolean, - routing: string, - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - body: object -}) ----- -link:{ref}/docs-multi-get.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index - -|`type` -|`string` - The type of the document + - -WARNING: This parameter has been deprecated. - -|`stored_fields` or `storedFields` -|`string \| string[]` - A comma-separated list of stored fields to return in the response - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`realtime` -|`boolean` - Specify whether to perform the operation in realtime or search mode - -|`refresh` -|`boolean` - Refresh the shard containing the document before performing the operation - -|`routing` -|`string` - Specific routing value - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - A list of fields to exclude from the returned _source field - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - A list of fields to extract and return from the _source field - -|`body` -|`object` - Document identifiers; can be either `docs` (containing full document information) or `ids` (when index and type is provided in the URL. - -|=== - -=== msearch - -[source,ts] ----- -client.msearch({ - index: string | string[], - type: string | string[], - search_type: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch', - max_concurrent_searches: number, - typed_keys: boolean, - pre_filter_shard_size: number, - max_concurrent_shard_requests: number, - rest_total_hits_as_int: boolean, - ccs_minimize_roundtrips: boolean, - body: object -}) ----- -link:{ref}/search-multi-search.html[Documentation] + -{jsclient}/msearch_examples.html[Code Example] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to use as default - -|`type` -|`string \| string[]` - A comma-separated list of document types to use as default - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'query_and_fetch' \| 'dfs_query_then_fetch' \| 'dfs_query_and_fetch'` - Search operation type - -|`max_concurrent_searches` or `maxConcurrentSearches` -|`number` - Controls the maximum number of concurrent searches the multi search api will execute - -|`typed_keys` or `typedKeys` -|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response - -|`pre_filter_shard_size` or `preFilterShardSize` -|`number` - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. - -|`max_concurrent_shard_requests` or `maxConcurrentShardRequests` -|`number` - The number of concurrent shard requests each sub search executes concurrently per node. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + -_Default:_ `5` - -|`rest_total_hits_as_int` or `restTotalHitsAsInt` -|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response - -|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` -|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + -_Default:_ `true` - -|`body` -|`object` - The request definitions (metadata-search request definition pairs), separated by newlines - -|=== - -=== msearchTemplate - -[source,ts] ----- -client.msearchTemplate({ - index: string | string[], - type: string | string[], - search_type: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch', - typed_keys: boolean, - max_concurrent_searches: number, - rest_total_hits_as_int: boolean, - ccs_minimize_roundtrips: boolean, - body: object -}) ----- -link:{ref}/search-multi-search.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to use as default - -|`type` -|`string \| string[]` - A comma-separated list of document types to use as default - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'query_and_fetch' \| 'dfs_query_then_fetch' \| 'dfs_query_and_fetch'` - Search operation type - -|`typed_keys` or `typedKeys` -|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response - -|`max_concurrent_searches` or `maxConcurrentSearches` -|`number` - Controls the maximum number of concurrent searches the multi search api will execute - -|`rest_total_hits_as_int` or `restTotalHitsAsInt` -|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response - -|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` -|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + -_Default:_ `true` - -|`body` -|`object` - The request definitions (metadata-search request definition pairs), separated by newlines - -|=== - -=== mtermvectors - -[source,ts] ----- -client.mtermvectors({ - index: string, - type: string, - ids: string | string[], - term_statistics: boolean, - field_statistics: boolean, - fields: string | string[], - offsets: boolean, - positions: boolean, - payloads: boolean, - preference: string, - routing: string, - realtime: boolean, - version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force', - body: object -}) ----- -link:{ref}/docs-multi-termvectors.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The index in which the document resides. - -|`type` -|`string` - The type of the document. - -|`ids` -|`string \| string[]` - A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body - -|`term_statistics` or `termStatistics` -|`boolean` - Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". - -|`field_statistics` or `fieldStatistics` -|`boolean` - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + -_Default:_ `true` - -|`fields` -|`string \| string[]` - A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs". - -|`offsets` -|`boolean` - Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + -_Default:_ `true` - -|`positions` -|`boolean` - Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + -_Default:_ `true` - -|`payloads` -|`boolean` - Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + -_Default:_ `true` - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body "params" or "docs". - -|`routing` -|`string` - Specific routing value. Applies to all returned documents unless otherwise specified in body "params" or "docs". - -|`realtime` -|`boolean` - Specifies if requests are real-time as opposed to near-real-time (default: true). - -|`version` -|`number` - Explicit version number for concurrency control - -|`version_type` or `versionType` -|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type - -|`body` -|`object` - Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation. - -|=== - -=== nodes.hotThreads - -[source,ts] ----- -client.nodes.hotThreads({ - node_id: string | string[], - interval: string, - snapshots: number, - threads: number, - ignore_idle_threads: boolean, - type: 'cpu' | 'wait' | 'block', - timeout: string -}) ----- -link:{ref}/cluster-nodes-hot-threads.html[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - -|`interval` -|`string` - The interval for the second sampling of threads - -|`snapshots` -|`number` - Number of samples of thread stacktrace (default: 10) - -|`threads` -|`number` - Specify the number of threads to provide information for (default: 3) - -|`ignore_idle_threads` or `ignoreIdleThreads` -|`boolean` - Don't show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue (default: true) - -|`type` -|`'cpu' \| 'wait' \| 'block'` - The type to sample (default: cpu) - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -=== nodes.info - -[source,ts] ----- -client.nodes.info({ - node_id: string | string[], - metric: string | string[], - flat_settings: boolean, - timeout: string -}) ----- -link:{ref}/cluster-nodes-info.html[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - -|`metric` -|`string \| string[]` - A comma-separated list of metrics you wish returned. Leave empty to return all. - -|`flat_settings` or `flatSettings` -|`boolean` - Return settings in flat format (default: false) - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -=== nodes.reloadSecureSettings - -[source,ts] ----- -client.nodes.reloadSecureSettings({ - node_id: string | string[], - timeout: string, - body: object -}) ----- -link:{ref}/secure-settings.html#reloadable-secure-settings[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string \| string[]` - A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes. - -|`timeout` -|`string` - Explicit operation timeout - -|`body` -|`object` - An object containing the password for the elasticsearch keystore - -|=== - -=== nodes.stats - -[source,ts] ----- -client.nodes.stats({ - node_id: string | string[], - metric: string | string[], - index_metric: string | string[], - completion_fields: string | string[], - fielddata_fields: string | string[], - fields: string | string[], - groups: boolean, - level: 'indices' | 'node' | 'shards', - types: string | string[], - timeout: string, - include_segment_file_sizes: boolean -}) ----- -link:{ref}/cluster-nodes-stats.html[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - -|`metric` -|`string \| string[]` - Limit the information returned to the specified metrics - -|`index_metric` or `indexMetric` -|`string \| string[]` - Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified. - -|`completion_fields` or `completionFields` -|`string \| string[]` - A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) - -|`fielddata_fields` or `fielddataFields` -|`string \| string[]` - A comma-separated list of fields for `fielddata` index metric (supports wildcards) - -|`fields` -|`string \| string[]` - A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) - -|`groups` -|`boolean` - A comma-separated list of search groups for `search` index metric - -|`level` -|`'indices' \| 'node' \| 'shards'` - Return indices stats aggregated at index, node or shard level + -_Default:_ `node` - -|`types` -|`string \| string[]` - A comma-separated list of document types for the `indexing` index metric - -|`timeout` -|`string` - Explicit operation timeout - -|`include_segment_file_sizes` or `includeSegmentFileSizes` -|`boolean` - Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) - -|=== - -=== nodes.usage - -[source,ts] ----- -client.nodes.usage({ - node_id: string | string[], - metric: string | string[], - timeout: string -}) ----- -link:{ref}/cluster-nodes-usage.html[Documentation] + -[cols=2*] -|=== -|`node_id` or `nodeId` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - -|`metric` -|`string \| string[]` - Limit the information returned to the specified metrics - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -=== ping - -[source,ts] ----- -client.ping() ----- -link:{ref}/index.html[Documentation] + - - -=== putScript - -[source,ts] ----- -client.putScript({ - id: string, - context: string, - timeout: string, - master_timeout: string, - body: object -}) ----- -link:{ref}/modules-scripting.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - Script ID - -|`context` -|`string` - Script context - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`body` -|`object` - The document - -|=== - -=== rankEval -*Stability:* experimental -[source,ts] ----- -client.rankEval({ - index: string | string[], - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - search_type: 'query_then_fetch' | 'dfs_query_then_fetch', - body: object -}) ----- -link:{ref}/search-rank-eval.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type - -|`body` -|`object` - The ranking evaluation search definition, including search requests, document ratings and ranking metric definition. - -|=== - -=== reindex - -[source,ts] ----- -client.reindex({ - refresh: boolean, - timeout: string, - wait_for_active_shards: string, - wait_for_completion: boolean, - requests_per_second: number, - scroll: string, - slices: number|string, - max_docs: number, - body: object -}) ----- -link:{ref}/docs-reindex.html[Documentation] + -{jsclient}/reindex_examples.html[Code Example] + -[cols=2*] -|=== -|`refresh` -|`boolean` - Should the affected indexes be refreshed? - -|`timeout` -|`string` - Time each individual bulk request should wait for shards that are unavailable. + -_Default:_ `1m` - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should the request should block until the reindex is complete. + -_Default:_ `true` - -|`requests_per_second` or `requestsPerSecond` -|`number` - The throttle to set on this request in sub-requests per second. -1 means no throttle. - -|`scroll` -|`string` - Control how long to keep the search context alive + -_Default:_ `5m` - -|`slices` -|`number\|string` - The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. + -_Default:_ `1` - -|`max_docs` or `maxDocs` -|`number` - Maximum number of documents to process (default: all documents) - -|`body` -|`object` - The search definition using the Query DSL and the prototype for the index request. - -|=== - -=== reindexRethrottle - -[source,ts] ----- -client.reindexRethrottle({ - task_id: string, - requests_per_second: number -}) ----- -link:{ref}/docs-reindex.html[Documentation] + -[cols=2*] -|=== -|`task_id` or `taskId` -|`string` - The task id to rethrottle - -|`requests_per_second` or `requestsPerSecond` -|`number` - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. - -|=== - -=== renderSearchTemplate - -[source,ts] ----- -client.renderSearchTemplate({ - id: string, - body: object -}) ----- -link:{ref}/search-template.html#_validating_templates[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The id of the stored search template - -|`body` -|`object` - The search definition template and its params - -|=== - -=== scriptsPainlessExecute -*Stability:* experimental -[source,ts] ----- -client.scriptsPainlessExecute({ - body: object -}) ----- -link:https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html[Documentation] + -[cols=2*] -|=== -|`body` -|`object` - The script to execute - -|=== - -=== scroll - -[source,ts] ----- -client.scroll({ - scroll_id: string, - scroll: string, - rest_total_hits_as_int: boolean, - body: object -}) ----- -link:{ref}/search-request-body.html#request-body-search-scroll[Documentation] + -{jsclient}/scroll_examples.html[Code Example] + -[cols=2*] -|=== -|`scroll_id` or `scrollId` -|`string` - The scroll ID + - -WARNING: This parameter has been deprecated. - -|`scroll` -|`string` - Specify how long a consistent view of the index should be maintained for scrolled search - -|`rest_total_hits_as_int` or `restTotalHitsAsInt` -|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response - -|`body` -|`object` - The scroll ID if not passed by URL or query parameter. - -|=== - -=== search - -[source,ts] ----- -client.search({ - index: string | string[], - type: string | string[], - analyzer: string, - analyze_wildcard: boolean, - ccs_minimize_roundtrips: boolean, - default_operator: 'AND' | 'OR', - df: string, - explain: boolean, - stored_fields: string | string[], - docvalue_fields: string | string[], - from: number, - ignore_unavailable: boolean, - ignore_throttled: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - lenient: boolean, - preference: string, - q: string, - routing: string | string[], - scroll: string, - search_type: 'query_then_fetch' | 'dfs_query_then_fetch', - size: number, - sort: string | string[], - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - terminate_after: number, - stats: string | string[], - suggest_field: string, - suggest_mode: 'missing' | 'popular' | 'always', - suggest_size: number, - suggest_text: string, - timeout: string, - track_scores: boolean, - track_total_hits: boolean, - allow_partial_search_results: boolean, - typed_keys: boolean, - version: boolean, - seq_no_primary_term: boolean, - request_cache: boolean, - batched_reduce_size: number, - max_concurrent_shard_requests: number, - pre_filter_shard_size: number, - rest_total_hits_as_int: boolean, - body: object -}) ----- -link:{ref}/search-search.html[Documentation] + -{jsclient}/search_examples.html[Code Example] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`type` -|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types - -|`analyzer` -|`string` - The analyzer to use for the query string - -|`analyze_wildcard` or `analyzeWildcard` -|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) - -|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` -|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + -_Default:_ `true` - -|`default_operator` or `defaultOperator` -|`'AND' \| 'OR'` - The default operator for query string query (AND or OR) + -_Default:_ `OR` - -|`df` -|`string` - The field to use as default where no field prefix is given in the query string - -|`explain` -|`boolean` - Specify whether to return detailed information about score computation as part of a hit - -|`stored_fields` or `storedFields` -|`string \| string[]` - A comma-separated list of stored fields to return as part of a hit - -|`docvalue_fields` or `docvalueFields` -|`string \| string[]` - A comma-separated list of fields to return as the docvalue representation of a field for each hit - -|`from` -|`number` - Starting offset (default: 0) - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`ignore_throttled` or `ignoreThrottled` -|`boolean` - Whether specified concrete, expanded or aliased indices should be ignored when throttled - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`lenient` -|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`q` -|`string` - Query in the Lucene query string syntax - -|`routing` -|`string \| string[]` - A comma-separated list of specific routing values - -|`scroll` -|`string` - Specify how long a consistent view of the index should be maintained for scrolled search - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type - -|`size` -|`number` - Number of hits to return (default: 10) - -|`sort` -|`string \| string[]` - A comma-separated list of : pairs - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - A list of fields to exclude from the returned _source field - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - A list of fields to extract and return from the _source field - -|`terminate_after` or `terminateAfter` -|`number` - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. - -|`stats` -|`string \| string[]` - Specific 'tag' of the request for logging and statistical purposes - -|`suggest_field` or `suggestField` -|`string` - Specify which field to use for suggestions - -|`suggest_mode` or `suggestMode` -|`'missing' \| 'popular' \| 'always'` - Specify suggest mode + -_Default:_ `missing` - -|`suggest_size` or `suggestSize` -|`number` - How many suggestions to return in response - -|`suggest_text` or `suggestText` -|`string` - The source text for which the suggestions should be returned - -|`timeout` -|`string` - Explicit operation timeout - -|`track_scores` or `trackScores` -|`boolean` - Whether to calculate and return scores even if they are not used for sorting - -|`track_total_hits` or `trackTotalHits` -|`boolean` - Indicate if the number of documents that match the query should be tracked - -|`allow_partial_search_results` or `allowPartialSearchResults` -|`boolean` - Indicate if an error should be returned if there is a partial search failure or timeout + -_Default:_ `true` - -|`typed_keys` or `typedKeys` -|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response - -|`version` -|`boolean` - Specify whether to return document version as part of a hit - -|`seq_no_primary_term` or `seqNoPrimaryTerm` -|`boolean` - Specify whether to return sequence number and primary term of the last modification of each hit - -|`request_cache` or `requestCache` -|`boolean` - Specify if request cache should be used for this request or not, defaults to index level setting - -|`batched_reduce_size` or `batchedReduceSize` -|`number` - The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. + -_Default:_ `512` - -|`max_concurrent_shard_requests` or `maxConcurrentShardRequests` -|`number` - The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + -_Default:_ `5` - -|`pre_filter_shard_size` or `preFilterShardSize` -|`number` - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. - -|`rest_total_hits_as_int` or `restTotalHitsAsInt` -|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response - -|`body` -|`object` - The search definition using the Query DSL - -|=== - -=== searchShards - -[source,ts] ----- -client.searchShards({ - index: string | string[], - preference: string, - routing: string, - local: boolean, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' -}) ----- -link:{ref}/search-shards.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`routing` -|`string` - Specific routing value - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|=== - -=== searchTemplate - -[source,ts] ----- -client.searchTemplate({ - index: string | string[], - type: string | string[], - ignore_unavailable: boolean, - ignore_throttled: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - preference: string, - routing: string | string[], - scroll: string, - search_type: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch', - explain: boolean, - profile: boolean, - typed_keys: boolean, - rest_total_hits_as_int: boolean, - ccs_minimize_roundtrips: boolean, - body: object -}) ----- -link:{ref}/search-template.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`type` -|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`ignore_throttled` or `ignoreThrottled` -|`boolean` - Whether specified concrete, expanded or aliased indices should be ignored when throttled - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`routing` -|`string \| string[]` - A comma-separated list of specific routing values - -|`scroll` -|`string` - Specify how long a consistent view of the index should be maintained for scrolled search - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'query_and_fetch' \| 'dfs_query_then_fetch' \| 'dfs_query_and_fetch'` - Search operation type - -|`explain` -|`boolean` - Specify whether to return detailed information about score computation as part of a hit - -|`profile` -|`boolean` - Specify whether to profile the query execution - -|`typed_keys` or `typedKeys` -|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response - -|`rest_total_hits_as_int` or `restTotalHitsAsInt` -|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response - -|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` -|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + -_Default:_ `true` - -|`body` -|`object` - The search definition template and its params - -|=== - -=== snapshot.cleanupRepository - -[source,ts] ----- -client.snapshot.cleanupRepository({ - repository: string, - master_timeout: string, - timeout: string -}) ----- -link:{ref}/clean-up-snapshot-repo-api.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -=== snapshot.create - -[source,ts] ----- -client.snapshot.create({ - repository: string, - snapshot: string, - master_timeout: string, - wait_for_completion: boolean, - body: object -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`snapshot` -|`string` - A snapshot name - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should this request wait until the operation has completed before returning - -|`body` -|`object` - The snapshot definition - -|=== - -=== snapshot.createRepository - -[source,ts] ----- -client.snapshot.createRepository({ - repository: string, - master_timeout: string, - timeout: string, - verify: boolean, - body: object -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`timeout` -|`string` - Explicit operation timeout - -|`verify` -|`boolean` - Whether to verify the repository after creation - -|`body` -|`object` - The repository definition - -|=== - -=== snapshot.delete - -[source,ts] ----- -client.snapshot.delete({ - repository: string, - snapshot: string, - master_timeout: string -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`snapshot` -|`string` - A snapshot name - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|=== - -=== snapshot.deleteRepository - -[source,ts] ----- -client.snapshot.deleteRepository({ - repository: string | string[], - master_timeout: string, - timeout: string -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string \| string[]` - Name of the snapshot repository to unregister. Wildcard (`*`) patterns are supported. - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -=== snapshot.get - -[source,ts] ----- -client.snapshot.get({ - repository: string, - snapshot: string | string[], - master_timeout: string, - ignore_unavailable: boolean, - verbose: boolean -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`snapshot` -|`string \| string[]` - A comma-separated list of snapshot names - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown - -|`verbose` -|`boolean` - Whether to show verbose snapshot info or only show the basic info found in the repository index blob - -|=== - -=== snapshot.getRepository - -[source,ts] ----- -client.snapshot.getRepository({ - repository: string | string[], - master_timeout: string, - local: boolean -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string \| string[]` - A comma-separated list of repository names - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`local` -|`boolean` - Return local information, do not retrieve the state from master node (default: false) - -|=== - -=== snapshot.restore - -[source,ts] ----- -client.snapshot.restore({ - repository: string, - snapshot: string, - master_timeout: string, - wait_for_completion: boolean, - body: object -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`snapshot` -|`string` - A snapshot name - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should this request wait until the operation has completed before returning - -|`body` -|`object` - Details of what to restore - -|=== - -=== snapshot.status - -[source,ts] ----- -client.snapshot.status({ - repository: string, - snapshot: string | string[], - master_timeout: string, - ignore_unavailable: boolean -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`snapshot` -|`string \| string[]` - A comma-separated list of snapshot names - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown - -|=== - -=== snapshot.verifyRepository - -[source,ts] ----- -client.snapshot.verifyRepository({ - repository: string, - master_timeout: string, - timeout: string -}) ----- -link:{ref}/modules-snapshots.html[Documentation] + -[cols=2*] -|=== -|`repository` -|`string` - A repository name - -|`master_timeout` or `masterTimeout` -|`string` - Explicit operation timeout for connection to master node - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -=== tasks.cancel - -[source,ts] ----- -client.tasks.cancel({ - task_id: string, - nodes: string | string[], - actions: string | string[], - parent_task_id: string, - wait_for_completion: boolean -}) ----- -link:{ref}/tasks.html[Documentation] + -[cols=2*] -|=== -|`task_id` or `taskId` -|`string` - Cancel the task with specified task id (node_id:task_number) - -|`nodes` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - -|`actions` -|`string \| string[]` - A comma-separated list of actions that should be cancelled. Leave empty to cancel all. - -|`parent_task_id` or `parentTaskId` -|`string` - Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all. - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should the request block until the cancellation of the task and its descendant tasks is completed. Defaults to false - -|=== - -=== tasks.get - -[source,ts] ----- -client.tasks.get({ - task_id: string, - wait_for_completion: boolean, - timeout: string -}) ----- -link:{ref}/tasks.html[Documentation] + -[cols=2*] -|=== -|`task_id` or `taskId` -|`string` - Return the task with specified id (node_id:task_number) - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Wait for the matching tasks to complete (default: false) - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -=== tasks.list - -[source,ts] ----- -client.tasks.list({ - nodes: string | string[], - actions: string | string[], - detailed: boolean, - parent_task_id: string, - wait_for_completion: boolean, - group_by: 'nodes' | 'parents' | 'none', - timeout: string -}) ----- -link:{ref}/tasks.html[Documentation] + -[cols=2*] -|=== -|`nodes` -|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes - -|`actions` -|`string \| string[]` - A comma-separated list of actions that should be returned. Leave empty to return all. - -|`detailed` -|`boolean` - Return detailed task information (default: false) - -|`parent_task_id` or `parentTaskId` -|`string` - Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all. - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Wait for the matching tasks to complete (default: false) - -|`group_by` or `groupBy` -|`'nodes' \| 'parents' \| 'none'` - Group tasks by nodes or parent/child relationships + -_Default:_ `nodes` - -|`timeout` -|`string` - Explicit operation timeout - -|=== - -=== termvectors - -[source,ts] ----- -client.termvectors({ - index: string, - id: string, - type: string, - term_statistics: boolean, - field_statistics: boolean, - fields: string | string[], - offsets: boolean, - positions: boolean, - payloads: boolean, - preference: string, - routing: string, - realtime: boolean, - version: number, - version_type: 'internal' | 'external' | 'external_gte' | 'force', - body: object -}) ----- -link:{ref}/docs-termvectors.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The index in which the document resides. - -|`id` -|`string` - The id of the document, when not specified a doc param should be supplied. - -|`type` -|`string` - The type of the document. - -|`term_statistics` or `termStatistics` -|`boolean` - Specifies if total term frequency and document frequency should be returned. - -|`field_statistics` or `fieldStatistics` -|`boolean` - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. + -_Default:_ `true` - -|`fields` -|`string \| string[]` - A comma-separated list of fields to return. - -|`offsets` -|`boolean` - Specifies if term offsets should be returned. + -_Default:_ `true` - -|`positions` -|`boolean` - Specifies if term positions should be returned. + -_Default:_ `true` - -|`payloads` -|`boolean` - Specifies if term payloads should be returned. + -_Default:_ `true` - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random). - -|`routing` -|`string` - Specific routing value. - -|`realtime` -|`boolean` - Specifies if request is real-time as opposed to near-real-time (default: true). - -|`version` -|`number` - Explicit version number for concurrency control - -|`version_type` or `versionType` -|`'internal' \| 'external' \| 'external_gte' \| 'force'` - Specific version type - -|`body` -|`object` - Define parameters and or supply a document to get termvectors for. See documentation. - -|=== - -=== update - -[source,ts] ----- -client.update({ - id: string, - index: string, - type: string, - wait_for_active_shards: string, - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - lang: string, - refresh: 'true' | 'false' | 'wait_for', - retry_on_conflict: number, - routing: string, - timeout: string, - if_seq_no: number, - if_primary_term: number, - require_alias: boolean, - body: object -}) ----- -link:{ref}/docs-update.html[Documentation] + -{jsclient}/update_examples.html[Code Example] + -[cols=2*] -|=== -|`id` -|`string` - Document ID - -|`index` -|`string` - The name of the index - -|`type` -|`string` - The type of the document + - -WARNING: This parameter has been deprecated. - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - A list of fields to exclude from the returned _source field - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - A list of fields to extract and return from the _source field - -|`lang` -|`string` - The script language (default: painless) - -|`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. - -|`retry_on_conflict` or `retryOnConflict` -|`number` - Specify how many times should the operation be retried when a conflict occurs (default: 0) - -|`routing` -|`string` - Specific routing value - -|`timeout` -|`string` - Explicit operation timeout - -|`if_seq_no` or `ifSeqNo` -|`number` - only perform the update operation if the last operation that has changed the document has the specified sequence number - -|`if_primary_term` or `ifPrimaryTerm` -|`number` - only perform the update operation if the last operation that has changed the document has the specified primary term - -|`require_alias` or `requireAlias` -|`boolean` - When true, requires destination is an alias. Default is false - -|`body` -|`object` - The request definition requires either `script` or partial `doc` - -|=== - -=== updateByQuery - -[source,ts] ----- -client.updateByQuery({ - index: string | string[], - type: string | string[], - analyzer: string, - analyze_wildcard: boolean, - default_operator: 'AND' | 'OR', - df: string, - from: number, - ignore_unavailable: boolean, - allow_no_indices: boolean, - conflicts: 'abort' | 'proceed', - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - lenient: boolean, - pipeline: string, - preference: string, - q: string, - routing: string | string[], - scroll: string, - search_type: 'query_then_fetch' | 'dfs_query_then_fetch', - search_timeout: string, - size: number, - max_docs: number, - sort: string | string[], - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - terminate_after: number, - stats: string | string[], - version: boolean, - version_type: boolean, - request_cache: boolean, - refresh: boolean, - timeout: string, - wait_for_active_shards: string, - scroll_size: number, - wait_for_completion: boolean, - requests_per_second: number, - slices: number|string, - body: object -}) ----- -link:{ref}/docs-update-by-query.html[Documentation] + -{jsclient}/update_by_query_examples.html[Code Example] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`type` -|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types - -|`analyzer` -|`string` - The analyzer to use for the query string - -|`analyze_wildcard` or `analyzeWildcard` -|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) - -|`default_operator` or `defaultOperator` -|`'AND' \| 'OR'` - The default operator for query string query (AND or OR) + -_Default:_ `OR` - -|`df` -|`string` - The field to use as default where no field prefix is given in the query string - -|`from` -|`number` - Starting offset (default: 0) - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`conflicts` -|`'abort' \| 'proceed'` - What to do when the update by query hits version conflicts? + -_Default:_ `abort` - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`lenient` -|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - -|`pipeline` -|`string` - Ingest pipeline to set on index requests made by this action. (default: none) - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`q` -|`string` - Query in the Lucene query string syntax - -|`routing` -|`string \| string[]` - A comma-separated list of specific routing values - -|`scroll` -|`string` - Specify how long a consistent view of the index should be maintained for scrolled search - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type - -|`search_timeout` or `searchTimeout` -|`string` - Explicit timeout for each search request. Defaults to no timeout. - -|`size` -|`number` - Deprecated, please use `max_docs` instead - -|`max_docs` or `maxDocs` -|`number` - Maximum number of documents to process (default: all documents) - -|`sort` -|`string \| string[]` - A comma-separated list of : pairs - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - A list of fields to exclude from the returned _source field - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - A list of fields to extract and return from the _source field - -|`terminate_after` or `terminateAfter` -|`number` - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. - -|`stats` -|`string \| string[]` - Specific 'tag' of the request for logging and statistical purposes - -|`version` -|`boolean` - Specify whether to return document version as part of a hit - -|`version_type` or `versionType` -|`boolean` - Should the document increment the version number (internal) on hit or not (reindex) - -|`request_cache` or `requestCache` -|`boolean` - Specify if request cache should be used for this request or not, defaults to index level setting - -|`refresh` -|`boolean` - Should the affected indexes be refreshed? - -|`timeout` -|`string` - Time each individual bulk request should wait for shards that are unavailable. + -_Default:_ `1m` - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - -|`scroll_size` or `scrollSize` -|`number` - Size on the scroll request powering the update by query + -_Default:_ `100` - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should the request should block until the update by query operation is complete. + -_Default:_ `true` - -|`requests_per_second` or `requestsPerSecond` -|`number` - The throttle to set on this request in sub-requests per second. -1 means no throttle. - -|`slices` -|`number\|string` - The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. + -_Default:_ `1` - -|`body` -|`object` - The search definition using the Query DSL - -|=== - -=== updateByQueryRethrottle - -[source,ts] ----- -client.updateByQueryRethrottle({ - task_id: string, - requests_per_second: number -}) ----- -link:{ref}/docs-update-by-query.html[Documentation] + -[cols=2*] -|=== -|`task_id` or `taskId` -|`string` - The task id to rethrottle - -|`requests_per_second` or `requestsPerSecond` -|`number` - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. - -|=== - -=== asyncSearch.delete - -[source,ts] ----- -client.asyncSearch.delete({ - id: string -}) ----- -link:{ref}/async-search.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The async search ID - -|=== - -=== asyncSearch.get - -[source,ts] ----- -client.asyncSearch.get({ - id: string, - wait_for_completion_timeout: string, - keep_alive: string, - typed_keys: boolean -}) ----- -link:{ref}/async-search.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The async search ID - -|`wait_for_completion_timeout` or `waitForCompletionTimeout` -|`string` - Specify the time that the request should block waiting for the final response - -|`keep_alive` or `keepAlive` -|`string` - Specify the time interval in which the results (partial or final) for this search will be available - -|`typed_keys` or `typedKeys` -|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response - -|=== - -=== asyncSearch.submit - -[source,ts] ----- -client.asyncSearch.submit({ - index: string | string[], - wait_for_completion_timeout: string, - keep_on_completion: boolean, - keep_alive: string, - batched_reduce_size: number, - request_cache: boolean, - analyzer: string, - analyze_wildcard: boolean, - default_operator: 'AND' | 'OR', - df: string, - explain: boolean, - stored_fields: string | string[], - docvalue_fields: string | string[], - from: number, - ignore_unavailable: boolean, - ignore_throttled: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - lenient: boolean, - preference: string, - q: string, - routing: string | string[], - search_type: 'query_then_fetch' | 'dfs_query_then_fetch', - size: number, - sort: string | string[], - _source: string | string[], - _source_excludes: string | string[], - _source_includes: string | string[], - terminate_after: number, - stats: string | string[], - suggest_field: string, - suggest_mode: 'missing' | 'popular' | 'always', - suggest_size: number, - suggest_text: string, - timeout: string, - track_scores: boolean, - track_total_hits: boolean, - allow_partial_search_results: boolean, - typed_keys: boolean, - version: boolean, - seq_no_primary_term: boolean, - max_concurrent_shard_requests: number, - body: object -}) ----- -link:{ref}/async-search.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`wait_for_completion_timeout` or `waitForCompletionTimeout` -|`string` - Specify the time that the request should block waiting for the final response + -_Default:_ `1s` - -|`keep_on_completion` or `keepOnCompletion` -|`boolean` - Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false) - -|`keep_alive` or `keepAlive` -|`string` - Update the time interval in which the results (partial or final) for this search will be available + -_Default:_ `5d` - -|`batched_reduce_size` or `batchedReduceSize` -|`number` - The number of shard results that should be reduced at once on the coordinating node. This value should be used as the granularity at which progress results will be made available. + -_Default:_ `5` - -|`request_cache` or `requestCache` -|`boolean` - Specify if request cache should be used for this request or not, defaults to true - -|`analyzer` -|`string` - The analyzer to use for the query string - -|`analyze_wildcard` or `analyzeWildcard` -|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) - -|`default_operator` or `defaultOperator` -|`'AND' \| 'OR'` - The default operator for query string query (AND or OR) + -_Default:_ `OR` - -|`df` -|`string` - The field to use as default where no field prefix is given in the query string - -|`explain` -|`boolean` - Specify whether to return detailed information about score computation as part of a hit - -|`stored_fields` or `storedFields` -|`string \| string[]` - A comma-separated list of stored fields to return as part of a hit - -|`docvalue_fields` or `docvalueFields` -|`string \| string[]` - A comma-separated list of fields to return as the docvalue representation of a field for each hit - -|`from` -|`number` - Starting offset (default: 0) - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`ignore_throttled` or `ignoreThrottled` -|`boolean` - Whether specified concrete, expanded or aliased indices should be ignored when throttled - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|`lenient` -|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored - -|`preference` -|`string` - Specify the node or shard the operation should be performed on (default: random) - -|`q` -|`string` - Query in the Lucene query string syntax - -|`routing` -|`string \| string[]` - A comma-separated list of specific routing values - -|`search_type` or `searchType` -|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type - -|`size` -|`number` - Number of hits to return (default: 10) - -|`sort` -|`string \| string[]` - A comma-separated list of : pairs - -|`_source` -|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return - -|`_source_excludes` or `_sourceExcludes` -|`string \| string[]` - A list of fields to exclude from the returned _source field - -|`_source_includes` or `_sourceIncludes` -|`string \| string[]` - A list of fields to extract and return from the _source field - -|`terminate_after` or `terminateAfter` -|`number` - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. - -|`stats` -|`string \| string[]` - Specific 'tag' of the request for logging and statistical purposes - -|`suggest_field` or `suggestField` -|`string` - Specify which field to use for suggestions - -|`suggest_mode` or `suggestMode` -|`'missing' \| 'popular' \| 'always'` - Specify suggest mode + -_Default:_ `missing` - -|`suggest_size` or `suggestSize` -|`number` - How many suggestions to return in response - -|`suggest_text` or `suggestText` -|`string` - The source text for which the suggestions should be returned - -|`timeout` -|`string` - Explicit operation timeout - -|`track_scores` or `trackScores` -|`boolean` - Whether to calculate and return scores even if they are not used for sorting - -|`track_total_hits` or `trackTotalHits` -|`boolean` - Indicate if the number of documents that match the query should be tracked - -|`allow_partial_search_results` or `allowPartialSearchResults` -|`boolean` - Indicate if an error should be returned if there is a partial search failure or timeout + -_Default:_ `true` - -|`typed_keys` or `typedKeys` -|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response - -|`version` -|`boolean` - Specify whether to return document version as part of a hit - -|`seq_no_primary_term` or `seqNoPrimaryTerm` -|`boolean` - Specify whether to return sequence number and primary term of the last modification of each hit - -|`max_concurrent_shard_requests` or `maxConcurrentShardRequests` -|`number` - The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + -_Default:_ `5` - -|`body` -|`object` - The search definition using the Query DSL - -|=== - -=== autoscaling.deleteAutoscalingPolicy -*Stability:* experimental -[source,ts] ----- -client.autoscaling.deleteAutoscalingPolicy({ - name: string -}) ----- -link:{ref}/autoscaling-delete-autoscaling-policy.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - the name of the autoscaling policy - -|=== - -=== autoscaling.getAutoscalingDecision -*Stability:* experimental -[source,ts] ----- -client.autoscaling.getAutoscalingDecision() ----- -link:{ref}/autoscaling-get-autoscaling-decision.html[Documentation] + - - -=== autoscaling.getAutoscalingPolicy -*Stability:* experimental -[source,ts] ----- -client.autoscaling.getAutoscalingPolicy({ - name: string -}) ----- -link:{ref}/autoscaling-get-autoscaling-policy.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - the name of the autoscaling policy - -|=== - -=== autoscaling.putAutoscalingPolicy -*Stability:* experimental -[source,ts] ----- -client.autoscaling.putAutoscalingPolicy({ - name: string, - body: object -}) ----- -link:{ref}/autoscaling-put-autoscaling-policy.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - the name of the autoscaling policy - -|`body` -|`object` - the specification of the autoscaling policy - -|=== - -=== cat.mlDataFrameAnalytics - -[source,ts] ----- -client.cat.mlDataFrameAnalytics({ - id: string, - allow_no_match: boolean, - bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', - format: string, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean -}) ----- -link:{ref}/cat-dfanalytics.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The ID of the data frame analytics to fetch - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no configs. (This includes `_all` string or when no configs have been specified) - -|`bytes` -|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -=== cat.mlDatafeeds - -[source,ts] ----- -client.cat.mlDatafeeds({ - datafeed_id: string, - allow_no_match: boolean, - allow_no_datafeeds: boolean, - format: string, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean -}) ----- -link:{ref}/cat-datafeeds.html[Documentation] + -[cols=2*] -|=== -|`datafeed_id` or `datafeedId` -|`string` - The ID of the datafeeds stats to fetch - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) - -|`allow_no_datafeeds` or `allowNoDatafeeds` -|`boolean` - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) + - -WARNING: This parameter has been deprecated. - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -=== cat.mlJobs - -[source,ts] ----- -client.cat.mlJobs({ - job_id: string, - allow_no_match: boolean, - allow_no_jobs: boolean, - bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', - format: string, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean -}) ----- -link:{ref}/cat-anomaly-detectors.html[Documentation] + -[cols=2*] -|=== -|`job_id` or `jobId` -|`string` - The ID of the jobs stats to fetch - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) - -|`allow_no_jobs` or `allowNoJobs` -|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + - -WARNING: This parameter has been deprecated. - -|`bytes` -|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -=== cat.mlTrainedModels - -[source,ts] ----- -client.cat.mlTrainedModels({ - model_id: string, - allow_no_match: boolean, - from: number, - size: number, - bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', - format: string, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean -}) ----- -link:{ref}/cat-trained-model.html[Documentation] + -[cols=2*] -|=== -|`model_id` or `modelId` -|`string` - The ID of the trained models stats to fetch - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified) + -_Default:_ `true` - -|`from` -|`number` - skips a number of trained models - -|`size` -|`number` - specifies a max number of trained models to get + -_Default:_ `100` - -|`bytes` -|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -=== cat.transforms - -[source,ts] ----- -client.cat.transforms({ - transform_id: string, - from: number, - size: number, - allow_no_match: boolean, - format: string, - h: string | string[], - help: boolean, - s: string | string[], - time: 'd' | 'h' | 'm' | 's' | 'ms' | 'micros' | 'nanos', - v: boolean -}) ----- -link:{ref}/cat-transforms.html[Documentation] + -[cols=2*] -|=== -|`transform_id` or `transformId` -|`string` - The id of the transform for which to get stats. '_all' or '*' implies all transforms - -|`from` -|`number` - skips a number of transform configs, defaults to 0 - -|`size` -|`number` - specifies a max number of transforms to get, defaults to 100 - -|`allow_no_match` or `allowNoMatch` -|`boolean` - Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified) - -|`format` -|`string` - a short version of the Accept header, e.g. json, yaml - -|`h` -|`string \| string[]` - Comma-separated list of column names to display - -|`help` -|`boolean` - Return help information - -|`s` -|`string \| string[]` - Comma-separated list of column names or column aliases to sort by - -|`time` -|`'d' \| 'h' \| 'm' \| 's' \| 'ms' \| 'micros' \| 'nanos'` - The unit in which to display time values - -|`v` -|`boolean` - Verbose mode. Display column headers - -|=== - -=== ccr.deleteAutoFollowPattern - -[source,ts] ----- -client.ccr.deleteAutoFollowPattern({ - name: string -}) ----- -link:{ref}/ccr-delete-auto-follow-pattern.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the auto follow pattern. - -|=== - -=== ccr.follow - -[source,ts] ----- -client.ccr.follow({ - index: string, - wait_for_active_shards: string, - body: object -}) ----- -link:{ref}/ccr-put-follow.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the follower index - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of shard copies that must be active before returning. Defaults to 0. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + -_Default:_ `0` - -|`body` -|`object` - The name of the leader index and other optional ccr related parameters - -|=== - -=== ccr.followInfo - -[source,ts] ----- -client.ccr.followInfo({ - index: string | string[] -}) ----- -link:{ref}/ccr-get-follow-info.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index patterns; use `_all` to perform the operation on all indices - -|=== - -=== ccr.followStats - -[source,ts] ----- -client.ccr.followStats({ - index: string | string[] -}) ----- -link:{ref}/ccr-get-follow-stats.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index patterns; use `_all` to perform the operation on all indices - -|=== - -=== ccr.forgetFollower - -[source,ts] ----- -client.ccr.forgetFollower({ - index: string, - body: object -}) ----- -link:{ref}/ccr-post-forget-follower.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - the name of the leader index for which specified follower retention leases should be removed - -|`body` -|`object` - the name and UUID of the follower index, the name of the cluster containing the follower index, and the alias from the perspective of that cluster for the remote cluster containing the leader index - -|=== - -=== ccr.getAutoFollowPattern - -[source,ts] ----- -client.ccr.getAutoFollowPattern({ - name: string -}) ----- -link:{ref}/ccr-get-auto-follow-pattern.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the auto follow pattern. - -|=== - -=== ccr.pauseAutoFollowPattern - -[source,ts] ----- -client.ccr.pauseAutoFollowPattern({ - name: string -}) ----- -link:{ref}/ccr-pause-auto-follow-pattern.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the auto follow pattern that should pause discovering new indices to follow. - -|=== - -=== ccr.pauseFollow - -[source,ts] ----- -client.ccr.pauseFollow({ - index: string -}) ----- -link:{ref}/ccr-post-pause-follow.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the follower index that should pause following its leader index. - -|=== - -=== ccr.putAutoFollowPattern - -[source,ts] ----- -client.ccr.putAutoFollowPattern({ - name: string, - body: object -}) ----- -link:{ref}/ccr-put-auto-follow-pattern.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the auto follow pattern. - -|`body` -|`object` - The specification of the auto follow pattern - -|=== - -=== ccr.resumeAutoFollowPattern - -[source,ts] ----- -client.ccr.resumeAutoFollowPattern({ - name: string -}) ----- -link:{ref}/ccr-resume-auto-follow-pattern.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the auto follow pattern to resume discovering new indices to follow. - -|=== - -=== ccr.resumeFollow - -[source,ts] ----- -client.ccr.resumeFollow({ - index: string, - body: object -}) ----- -link:{ref}/ccr-post-resume-follow.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the follow index to resume following. - -|`body` -|`object` - The name of the leader index and other optional ccr related parameters - -|=== - -=== ccr.stats - -[source,ts] ----- -client.ccr.stats() ----- -link:{ref}/ccr-get-stats.html[Documentation] + - - -=== ccr.unfollow - -[source,ts] ----- -client.ccr.unfollow({ - index: string -}) ----- -link:{ref}/ccr-post-unfollow.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the follower index that should be turned into a regular index. - -|=== - -=== closePointInTime - -[source,ts] ----- -client.closePointInTime({ - body: object -}) ----- -link:{ref}/point-in-time-api.html[Documentation] + -[cols=2*] -|=== -|`body` -|`object` - a point-in-time id to close - -|=== - -=== enrich.deletePolicy - -[source,ts] ----- -client.enrich.deletePolicy({ - name: string -}) ----- -link:{ref}/delete-enrich-policy-api.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the enrich policy - -|=== - -=== enrich.executePolicy - -[source,ts] ----- -client.enrich.executePolicy({ - name: string, - wait_for_completion: boolean -}) ----- -link:{ref}/execute-enrich-policy-api.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the enrich policy - -|`wait_for_completion` or `waitForCompletion` -|`boolean` - Should the request should block until the execution is complete. + -_Default:_ `true` - -|=== - -=== enrich.getPolicy - -[source,ts] ----- -client.enrich.getPolicy({ - name: string | string[] -}) ----- -link:{ref}/get-enrich-policy-api.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - A comma-separated list of enrich policy names - -|=== - -=== enrich.putPolicy - -[source,ts] ----- -client.enrich.putPolicy({ - name: string, - body: object -}) ----- -link:{ref}/put-enrich-policy-api.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the enrich policy - -|`body` -|`object` - The enrich policy to register - -|=== - -=== enrich.stats - -[source,ts] ----- -client.enrich.stats() ----- -link:{ref}/enrich-stats-api.html[Documentation] + - - -=== eql.delete -*Stability:* beta -[source,ts] ----- -client.eql.delete({ - id: string -}) ----- -link:{ref}/eql-search-api.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The async search ID - -|=== - -=== eql.get -*Stability:* beta -[source,ts] ----- -client.eql.get({ - id: string, - wait_for_completion_timeout: string, - keep_alive: string -}) ----- -link:{ref}/eql-search-api.html[Documentation] + -[cols=2*] -|=== -|`id` -|`string` - The async search ID - -|`wait_for_completion_timeout` or `waitForCompletionTimeout` -|`string` - Specify the time that the request should block waiting for the final response - -|`keep_alive` or `keepAlive` -|`string` - Update the time interval in which the results (partial or final) for this search will be available + -_Default:_ `5d` - -|=== - -=== eql.search -*Stability:* beta -[source,ts] ----- -client.eql.search({ - index: string, - wait_for_completion_timeout: string, - keep_on_completion: boolean, - keep_alive: string, - body: object -}) ----- -link:{ref}/eql-search-api.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index to scope the operation - -|`wait_for_completion_timeout` or `waitForCompletionTimeout` -|`string` - Specify the time that the request should block waiting for the final response - -|`keep_on_completion` or `keepOnCompletion` -|`boolean` - Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false) - -|`keep_alive` or `keepAlive` -|`string` - Update the time interval in which the results (partial or final) for this search will be available + -_Default:_ `5d` - -|`body` -|`object` - Eql request body. Use the `query` to limit the query scope. - -|=== - -=== graph.explore - -[source,ts] ----- -client.graph.explore({ - index: string | string[], - type: string | string[], - routing: string, - timeout: string, - body: object -}) ----- -link:{ref}/graph-explore-api.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices - -|`type` -|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types + - -WARNING: This parameter has been deprecated. - -|`routing` -|`string` - Specific routing value - -|`timeout` -|`string` - Explicit operation timeout - -|`body` -|`object` - Graph Query DSL - -|=== - -=== ilm.deleteLifecycle - -[source,ts] ----- -client.ilm.deleteLifecycle({ - policy: string -}) ----- -link:{ref}/ilm-delete-lifecycle.html[Documentation] + -[cols=2*] -|=== -|`policy` -|`string` - The name of the index lifecycle policy - -|=== - -=== ilm.explainLifecycle - -[source,ts] ----- -client.ilm.explainLifecycle({ - index: string, - only_managed: boolean, - only_errors: boolean -}) ----- -link:{ref}/ilm-explain-lifecycle.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index to explain - -|`only_managed` or `onlyManaged` -|`boolean` - filters the indices included in the response to ones managed by ILM - -|`only_errors` or `onlyErrors` -|`boolean` - filters the indices included in the response to ones in an ILM error state, implies only_managed - -|=== - -=== ilm.getLifecycle - -[source,ts] ----- -client.ilm.getLifecycle({ - policy: string -}) ----- -link:{ref}/ilm-get-lifecycle.html[Documentation] + -[cols=2*] -|=== -|`policy` -|`string` - The name of the index lifecycle policy - -|=== - -=== ilm.getStatus - -[source,ts] ----- -client.ilm.getStatus() ----- -link:{ref}/ilm-get-status.html[Documentation] + - - -=== ilm.moveToStep - -[source,ts] ----- -client.ilm.moveToStep({ - index: string, - body: object -}) ----- -link:{ref}/ilm-move-to-step.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index whose lifecycle step is to change - -|`body` -|`object` - The new lifecycle step to move to - -|=== - -=== ilm.putLifecycle - -[source,ts] ----- -client.ilm.putLifecycle({ - policy: string, - body: object -}) ----- -link:{ref}/ilm-put-lifecycle.html[Documentation] + -[cols=2*] -|=== -|`policy` -|`string` - The name of the index lifecycle policy - -|`body` -|`object` - The lifecycle policy definition to register - -|=== - -=== ilm.removePolicy - -[source,ts] ----- -client.ilm.removePolicy({ - index: string -}) ----- -link:{ref}/ilm-remove-policy.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index to remove policy on - -|=== - -=== ilm.retry - -[source,ts] ----- -client.ilm.retry({ - index: string -}) ----- -link:{ref}/ilm-retry-policy.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the indices (comma-separated) whose failed lifecycle step is to be retry - -|=== - -=== ilm.start - -[source,ts] ----- -client.ilm.start() ----- -link:{ref}/ilm-start.html[Documentation] + - - -=== ilm.stop - -[source,ts] ----- -client.ilm.stop() ----- -link:{ref}/ilm-stop.html[Documentation] + - - -=== indices.createDataStream - -[source,ts] ----- -client.indices.createDataStream({ - name: string -}) ----- -link:{ref}/data-streams.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string` - The name of the data stream - -|=== - -=== indices.dataStreamsStats - -[source,ts] ----- -client.indices.dataStreamsStats({ - name: string | string[] -}) ----- -link:{ref}/data-streams.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - A comma-separated list of data stream names; use `_all` or empty string to perform the operation on all data streams - -|=== - -=== indices.deleteDataStream - -[source,ts] ----- -client.indices.deleteDataStream({ - name: string | string[] -}) ----- -link:{ref}/data-streams.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - A comma-separated list of data streams to delete; use `*` to delete all data streams - -|=== - -=== indices.freeze - -[source,ts] ----- -client.indices.freeze({ - index: string, - timeout: string, - master_timeout: string, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - wait_for_active_shards: string -}) ----- -link:{ref}/freeze-index-api.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index to freeze - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `closed` - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of active shards to wait for before the operation returns. - -|=== - -=== indices.getDataStream - -[source,ts] ----- -client.indices.getDataStream({ - name: string | string[] -}) ----- -link:{ref}/data-streams.html[Documentation] + -[cols=2*] -|=== -|`name` -|`string \| string[]` - A comma-separated list of data streams to get; use `*` to get all data streams - -|=== - -=== indices.reloadSearchAnalyzers - -[source,ts] ----- -client.indices.reloadSearchAnalyzers({ - index: string | string[], - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' -}) ----- -link:{ref}/indices-reload-analyzers.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string \| string[]` - A comma-separated list of index names to reload analyzers for - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `open` - -|=== - -=== indices.unfreeze - -[source,ts] ----- -client.indices.unfreeze({ - index: string, - timeout: string, - master_timeout: string, - ignore_unavailable: boolean, - allow_no_indices: boolean, - expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', - wait_for_active_shards: string -}) ----- -link:{ref}/unfreeze-index-api.html[Documentation] + -[cols=2*] -|=== -|`index` -|`string` - The name of the index to unfreeze - -|`timeout` -|`string` - Explicit operation timeout - -|`master_timeout` or `masterTimeout` -|`string` - Specify timeout for connection to master - -|`ignore_unavailable` or `ignoreUnavailable` -|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) - -|`allow_no_indices` or `allowNoIndices` -|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) - -|`expand_wildcards` or `expandWildcards` -|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + -_Default:_ `closed` - -|`wait_for_active_shards` or `waitForActiveShards` -|`string` - Sets the number of active shards to wait for before the operation returns. - -|=== - === license.delete [source,ts] @@ -7294,7 +7160,9 @@ link:{ref}/get-license.html[Documentation] + |`boolean` - Return local information, do not retrieve the state from master node (default: false) |`accept_enterprise` or `acceptEnterprise` -|`boolean` - If the active license is an enterprise license, return type as 'enterprise' (default: false) +|`boolean` - Supported for backwards compatibility with 7.x. If this param is used it must be set to true + + +WARNING: This parameter has been deprecated. |=== @@ -7372,6 +7240,58 @@ link:{ref}/start-trial.html[Documentation] + |=== +=== mget + +[source,ts] +---- +client.mget({ + index: string, + stored_fields: string | string[], + preference: string, + realtime: boolean, + refresh: boolean, + routing: string, + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + body: object +}) +---- +link:{ref}/docs-multi-get.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The name of the index + +|`stored_fields` or `storedFields` +|`string \| string[]` - A comma-separated list of stored fields to return in the response + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`realtime` +|`boolean` - Specify whether to perform the operation in realtime or search mode + +|`refresh` +|`boolean` - Refresh the shard containing the document before performing the operation + +|`routing` +|`string` - Specific routing value + +|`_source` +|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return + +|`_source_excludes` or `_sourceExcludes` +|`string \| string[]` - A list of fields to exclude from the returned _source field + +|`_source_includes` or `_sourceIncludes` +|`string \| string[]` - A list of fields to extract and return from the _source field + +|`body` +|`object` - Document identifiers; can be either `docs` (containing full document information) or `ids` (when index is provided in the URL. + +|=== + === migration.deprecations [source,ts] @@ -7691,6 +7611,10 @@ link:{ref}/evaluate-dfanalytics.html[Documentation] + |=== +<<<<<<< HEAD +=== enrich.deletePolicy + +======= === ml.explainDataFrameAnalytics *Stability:* experimental [source,ts] @@ -8016,6 +7940,7 @@ link:{ref}/ml-get-category.html[Documentation] + === ml.getDataFrameAnalytics *Stability:* experimental +>>>>>>> a064f0f3... Improve child performances (#1314) [source,ts] ---- client.ml.getDataFrameAnalytics({ @@ -8210,10 +8135,19 @@ link:{ref}/ml-get-influencer.html[Documentation] + [source,ts] ---- +<<<<<<< HEAD +client.graph.explore({ + index: string | string[], + type: string | string[], + routing: string, + timeout: string, + body: object +======= client.ml.getJobStats({ job_id: string, allow_no_match: boolean, allow_no_jobs: boolean +>>>>>>> a064f0f3... Improve child performances (#1314) }) ---- link:{ref}/ml-get-job-stats.html[Documentation] + @@ -8222,8 +8156,18 @@ link:{ref}/ml-get-job-stats.html[Documentation] + |`job_id` or `jobId` |`string` - The ID of the jobs stats to fetch +<<<<<<< HEAD +|`type` +|`string \| string[]` - A comma-separated list of document types to search; leave empty to perform the operation on all types + + +WARNING: This parameter has been deprecated. + +|`routing` +|`string` - Specific routing value +======= |`allow_no_match` or `allowNoMatch` |`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) +>>>>>>> a064f0f3... Improve child performances (#1314) |`allow_no_jobs` or `allowNoJobs` |`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + @@ -8419,7 +8363,7 @@ link:{ref}/ml-get-record.html[Documentation] + client.ml.getTrainedModels({ model_id: string, allow_no_match: boolean, - include_model_definition: boolean, + include: string, decompress_definition: boolean, from: number, size: number, @@ -8437,8 +8381,8 @@ link:{ref}/get-inference.html[Documentation] + |`boolean` - Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified) + _Default:_ `true` -|`include_model_definition` or `includeModelDefinition` -|`boolean` - Should the full model definition be included in the results. These definitions can be large. So be cautious when including them. Defaults to false. +|`include` +|`string` - A comma-separate list of fields to optionally include. Valid options are 'definition' and 'total_feature_importance'. Default is none. |`decompress_definition` or `decompressDefinition` |`boolean` - Should the model definition be decompressed into valid JSON or returned in a custom compressed format. Defaults to true. + @@ -8630,8 +8574,35 @@ client.ml.putDataFrameAnalytics({ link:{ref}/put-dfanalytics.html[Documentation] + [cols=2*] |=== +<<<<<<< HEAD +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`accept_enterprise` or `acceptEnterprise` +|`boolean` - If the active license is an enterprise license, return type as 'enterprise' (default: false) + +|=== + +=== license.getBasicStatus + +[source,ts] +---- +client.license.getBasicStatus() +---- +link:{ref}/get-basic-status.html[Documentation] + + + +=== license.getTrialStatus + +[source,ts] +---- +client.license.getTrialStatus() +---- +link:{ref}/get-trial-status.html[Documentation] + +======= |`id` |`string` - The ID of the data frame analytics to create +>>>>>>> a064f0f3... Improve child performances (#1314) |`body` |`object` - The data frame analytics configuration @@ -9094,6 +9065,343 @@ WARNING: This parameter has been deprecated. |=== +=== msearch + +[source,ts] +---- +client.msearch({ + index: string | string[], + search_type: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch', + max_concurrent_searches: number, + typed_keys: boolean, + pre_filter_shard_size: number, + max_concurrent_shard_requests: number, + rest_total_hits_as_int: boolean, + ccs_minimize_roundtrips: boolean, + body: object +}) +---- +link:{ref}/search-multi-search.html[Documentation] + +{jsclient}/msearch_examples.html[Code Example] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to use as default + +|`search_type` or `searchType` +|`'query_then_fetch' \| 'query_and_fetch' \| 'dfs_query_then_fetch' \| 'dfs_query_and_fetch'` - Search operation type + +|`max_concurrent_searches` or `maxConcurrentSearches` +|`number` - Controls the maximum number of concurrent searches the multi search api will execute + +|`typed_keys` or `typedKeys` +|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + +|`pre_filter_shard_size` or `preFilterShardSize` +|`number` - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. + +|`max_concurrent_shard_requests` or `maxConcurrentShardRequests` +|`number` - The number of concurrent shard requests each sub search executes concurrently per node. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + +_Default:_ `5` + +|`rest_total_hits_as_int` or `restTotalHitsAsInt` +|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response + +|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` +|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + +_Default:_ `true` + +|`body` +|`object` - The request definitions (metadata-search request definition pairs), separated by newlines + +|=== + +=== msearchTemplate + +[source,ts] +---- +client.msearchTemplate({ + index: string | string[], + search_type: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch', + typed_keys: boolean, + max_concurrent_searches: number, + rest_total_hits_as_int: boolean, + ccs_minimize_roundtrips: boolean, + body: object +}) +---- +link:{ref}/search-multi-search.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to use as default + +|`search_type` or `searchType` +|`'query_then_fetch' \| 'query_and_fetch' \| 'dfs_query_then_fetch' \| 'dfs_query_and_fetch'` - Search operation type + +|`typed_keys` or `typedKeys` +|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + +|`max_concurrent_searches` or `maxConcurrentSearches` +|`number` - Controls the maximum number of concurrent searches the multi search api will execute + +|`rest_total_hits_as_int` or `restTotalHitsAsInt` +|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response + +|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` +|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + +_Default:_ `true` + +|`body` +|`object` - The request definitions (metadata-search request definition pairs), separated by newlines + +|=== + +=== mtermvectors + +[source,ts] +---- +client.mtermvectors({ + index: string, + ids: string | string[], + term_statistics: boolean, + field_statistics: boolean, + fields: string | string[], + offsets: boolean, + positions: boolean, + payloads: boolean, + preference: string, + routing: string, + realtime: boolean, + version: number, + version_type: 'internal' | 'external' | 'external_gte', + body: object +}) +---- +link:{ref}/docs-multi-termvectors.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The index in which the document resides. + +|`ids` +|`string \| string[]` - A comma-separated list of documents ids. You must define ids as parameter or set "ids" or "docs" in the request body + +|`term_statistics` or `termStatistics` +|`boolean` - Specifies if total term frequency and document frequency should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +|`field_statistics` or `fieldStatistics` +|`boolean` - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +_Default:_ `true` + +|`fields` +|`string \| string[]` - A comma-separated list of fields to return. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +|`offsets` +|`boolean` - Specifies if term offsets should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +_Default:_ `true` + +|`positions` +|`boolean` - Specifies if term positions should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +_Default:_ `true` + +|`payloads` +|`boolean` - Specifies if term payloads should be returned. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +_Default:_ `true` + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) .Applies to all returned documents unless otherwise specified in body "params" or "docs". + +|`routing` +|`string` - Specific routing value. Applies to all returned documents unless otherwise specified in body "params" or "docs". + +|`realtime` +|`boolean` - Specifies if requests are real-time as opposed to near-real-time (default: true). + +|`version` +|`number` - Explicit version number for concurrency control + +|`version_type` or `versionType` +|`'internal' \| 'external' \| 'external_gte'` - Specific version type + +|`body` +|`object` - Define ids, documents, parameters or a list of parameters per document here. You must at least provide a list of document ids. See documentation. + +|=== + +=== nodes.hotThreads + +[source,ts] +---- +client.nodes.hotThreads({ + node_id: string | string[], + interval: string, + snapshots: number, + threads: number, + ignore_idle_threads: boolean, + type: 'cpu' | 'wait' | 'block', + timeout: string +}) +---- +link:{ref}/cluster-nodes-hot-threads.html[Documentation] + +[cols=2*] +|=== +|`node_id` or `nodeId` +|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +|`interval` +|`string` - The interval for the second sampling of threads + +|`snapshots` +|`number` - Number of samples of thread stacktrace (default: 10) + +|`threads` +|`number` - Specify the number of threads to provide information for (default: 3) + +|`ignore_idle_threads` or `ignoreIdleThreads` +|`boolean` - Don't show threads that are in known-idle places, such as waiting on a socket select or pulling from an empty task queue (default: true) + +|`type` +|`'cpu' \| 'wait' \| 'block'` - The type to sample (default: cpu) + +|`timeout` +|`string` - Explicit operation timeout + +|=== + +=== nodes.info + +[source,ts] +---- +client.nodes.info({ + node_id: string | string[], + metric: string | string[], + flat_settings: boolean, + timeout: string +}) +---- +link:{ref}/cluster-nodes-info.html[Documentation] + +[cols=2*] +|=== +|`node_id` or `nodeId` +|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +|`metric` +|`string \| string[]` - A comma-separated list of metrics you wish returned. Leave empty to return all. + +|`flat_settings` or `flatSettings` +|`boolean` - Return settings in flat format (default: false) + +|`timeout` +|`string` - Explicit operation timeout + +|=== + +=== nodes.reloadSecureSettings + +[source,ts] +---- +client.nodes.reloadSecureSettings({ + node_id: string | string[], + timeout: string, + body: object +}) +---- +link:{ref}/secure-settings.html#reloadable-secure-settings[Documentation] + +[cols=2*] +|=== +|`node_id` or `nodeId` +|`string \| string[]` - A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes. + +|`timeout` +|`string` - Explicit operation timeout + +|`body` +|`object` - An object containing the password for the elasticsearch keystore + +|=== + +=== nodes.stats + +[source,ts] +---- +client.nodes.stats({ + node_id: string | string[], + metric: string | string[], + index_metric: string | string[], + completion_fields: string | string[], + fielddata_fields: string | string[], + fields: string | string[], + groups: boolean, + level: 'indices' | 'node' | 'shards', + types: string | string[], + timeout: string, + include_segment_file_sizes: boolean +}) +---- +link:{ref}/cluster-nodes-stats.html[Documentation] + +[cols=2*] +|=== +|`node_id` or `nodeId` +|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +|`metric` +|`string \| string[]` - Limit the information returned to the specified metrics + +|`index_metric` or `indexMetric` +|`string \| string[]` - Limit the information returned for `indices` metric to the specific index metrics. Isn't used if `indices` (or `all`) metric isn't specified. + +|`completion_fields` or `completionFields` +|`string \| string[]` - A comma-separated list of fields for `fielddata` and `suggest` index metric (supports wildcards) + +|`fielddata_fields` or `fielddataFields` +|`string \| string[]` - A comma-separated list of fields for `fielddata` index metric (supports wildcards) + +|`fields` +|`string \| string[]` - A comma-separated list of fields for `fielddata` and `completion` index metric (supports wildcards) + +|`groups` +|`boolean` - A comma-separated list of search groups for `search` index metric + +|`level` +|`'indices' \| 'node' \| 'shards'` - Return indices stats aggregated at index, node or shard level + +_Default:_ `node` + +|`types` +|`string \| string[]` - A comma-separated list of document types for the `indexing` index metric + +|`timeout` +|`string` - Explicit operation timeout + +|`include_segment_file_sizes` or `includeSegmentFileSizes` +|`boolean` - Whether to report the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested) + +|=== + +=== nodes.usage + +[source,ts] +---- +client.nodes.usage({ + node_id: string | string[], + metric: string | string[], + timeout: string +}) +---- +link:{ref}/cluster-nodes-usage.html[Documentation] + +[cols=2*] +|=== +|`node_id` or `nodeId` +|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +|`metric` +|`string \| string[]` - Limit the information returned to the specified metrics + +|`timeout` +|`string` - Explicit operation timeout + +|=== + === openPointInTime [source,ts] @@ -9131,6 +9439,177 @@ _Default:_ `open` |=== +=== ping + +[source,ts] +---- +client.ping() +---- +link:{ref}/index.html[Documentation] + + + +=== putScript + +[source,ts] +---- +client.putScript({ + id: string, + context: string, + timeout: string, + master_timeout: string, + body: object +}) +---- +link:{ref}/modules-scripting.html[Documentation] + +[cols=2*] +|=== +|`id` +|`string` - Script ID + +|`context` +|`string` - Script context + +|`timeout` +|`string` - Explicit operation timeout + +|`master_timeout` or `masterTimeout` +|`string` - Specify timeout for connection to master + +|`body` +|`object` - The document + +|=== + +=== rankEval +*Stability:* experimental +[source,ts] +---- +client.rankEval({ + index: string | string[], + ignore_unavailable: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + search_type: 'query_then_fetch' | 'dfs_query_then_fetch', + body: object +}) +---- +link:{ref}/search-rank-eval.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `open` + +|`search_type` or `searchType` +|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type + +|`body` +|`object` - The ranking evaluation search definition, including search requests, document ratings and ranking metric definition. + +|=== + +=== reindex + +[source,ts] +---- +client.reindex({ + refresh: boolean, + timeout: string, + wait_for_active_shards: string, + wait_for_completion: boolean, + requests_per_second: number, + scroll: string, + slices: number|string, + max_docs: number, + body: object +}) +---- +link:{ref}/docs-reindex.html[Documentation] + +{jsclient}/reindex_examples.html[Code Example] + +[cols=2*] +|=== +|`refresh` +|`boolean` - Should the affected indexes be refreshed? + +|`timeout` +|`string` - Time each individual bulk request should wait for shards that are unavailable. + +_Default:_ `1m` + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Should the request should block until the reindex is complete. + +_Default:_ `true` + +|`requests_per_second` or `requestsPerSecond` +|`number` - The throttle to set on this request in sub-requests per second. -1 means no throttle. + +|`scroll` +|`string` - Control how long to keep the search context alive + +_Default:_ `5m` + +|`slices` +|`number\|string` - The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. + +_Default:_ `1` + +|`max_docs` or `maxDocs` +|`number` - Maximum number of documents to process (default: all documents) + +|`body` +|`object` - The search definition using the Query DSL and the prototype for the index request. + +|=== + +=== reindexRethrottle + +[source,ts] +---- +client.reindexRethrottle({ + task_id: string, + requests_per_second: number +}) +---- +link:{ref}/docs-reindex.html[Documentation] + +[cols=2*] +|=== +|`task_id` or `taskId` +|`string` - The task id to rethrottle + +|`requests_per_second` or `requestsPerSecond` +|`number` - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. + +|=== + +=== renderSearchTemplate + +[source,ts] +---- +client.renderSearchTemplate({ + id: string, + body: object +}) +---- +link:{ref}/search-template.html#_validating_templates[Documentation] + +[cols=2*] +|=== +|`id` +|`string` - The id of the stored search template + +|`body` +|`object` - The search definition template and its params + +|=== + === rollup.deleteJob *Stability:* experimental [source,ts] @@ -9289,6 +9768,364 @@ link:{ref}/rollup-stop-job.html[Documentation] + |=== +=== scriptsPainlessExecute +*Stability:* experimental +[source,ts] +---- +client.scriptsPainlessExecute({ + body: object +}) +---- +link:https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html[Documentation] + +[cols=2*] +|=== +|`body` +|`object` - The script to execute + +|=== + +=== scroll + +[source,ts] +---- +client.scroll({ + scroll_id: string, + scroll: string, + rest_total_hits_as_int: boolean, + body: object +}) +---- +link:{ref}/search-request-body.html#request-body-search-scroll[Documentation] + +{jsclient}/scroll_examples.html[Code Example] + +[cols=2*] +|=== +|`scroll_id` or `scrollId` +|`string` - The scroll ID + + +WARNING: This parameter has been deprecated. + +|`scroll` +|`string` - Specify how long a consistent view of the index should be maintained for scrolled search + +|`rest_total_hits_as_int` or `restTotalHitsAsInt` +|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response + +|`body` +|`object` - The scroll ID if not passed by URL or query parameter. + +|=== + +=== search + +[source,ts] +---- +client.search({ + index: string | string[], + analyzer: string, + analyze_wildcard: boolean, + ccs_minimize_roundtrips: boolean, + default_operator: 'AND' | 'OR', + df: string, + explain: boolean, + stored_fields: string | string[], + docvalue_fields: string | string[], + from: number, + ignore_unavailable: boolean, + ignore_throttled: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + lenient: boolean, + preference: string, + q: string, + routing: string | string[], + scroll: string, + search_type: 'query_then_fetch' | 'dfs_query_then_fetch', + size: number, + sort: string | string[], + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + terminate_after: number, + stats: string | string[], + suggest_field: string, + suggest_mode: 'missing' | 'popular' | 'always', + suggest_size: number, + suggest_text: string, + timeout: string, + track_scores: boolean, + track_total_hits: boolean|long, + allow_partial_search_results: boolean, + typed_keys: boolean, + version: boolean, + seq_no_primary_term: boolean, + request_cache: boolean, + batched_reduce_size: number, + max_concurrent_shard_requests: number, + pre_filter_shard_size: number, + rest_total_hits_as_int: boolean, + body: object +}) +---- +link:{ref}/search-search.html[Documentation] + +{jsclient}/search_examples.html[Code Example] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`analyzer` +|`string` - The analyzer to use for the query string + +|`analyze_wildcard` or `analyzeWildcard` +|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) + +|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` +|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + +_Default:_ `true` + +|`default_operator` or `defaultOperator` +|`'AND' \| 'OR'` - The default operator for query string query (AND or OR) + +_Default:_ `OR` + +|`df` +|`string` - The field to use as default where no field prefix is given in the query string + +|`explain` +|`boolean` - Specify whether to return detailed information about score computation as part of a hit + +|`stored_fields` or `storedFields` +|`string \| string[]` - A comma-separated list of stored fields to return as part of a hit + +|`docvalue_fields` or `docvalueFields` +|`string \| string[]` - A comma-separated list of fields to return as the docvalue representation of a field for each hit + +|`from` +|`number` - Starting offset (default: 0) + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`ignore_throttled` or `ignoreThrottled` +|`boolean` - Whether specified concrete, expanded or aliased indices should be ignored when throttled + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `open` + +|`lenient` +|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`q` +|`string` - Query in the Lucene query string syntax + +|`routing` +|`string \| string[]` - A comma-separated list of specific routing values + +|`scroll` +|`string` - Specify how long a consistent view of the index should be maintained for scrolled search + +|`search_type` or `searchType` +|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type + +|`size` +|`number` - Number of hits to return (default: 10) + +|`sort` +|`string \| string[]` - A comma-separated list of : pairs + +|`_source` +|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return + +|`_source_excludes` or `_sourceExcludes` +|`string \| string[]` - A list of fields to exclude from the returned _source field + +|`_source_includes` or `_sourceIncludes` +|`string \| string[]` - A list of fields to extract and return from the _source field + +|`terminate_after` or `terminateAfter` +|`number` - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + +|`stats` +|`string \| string[]` - Specific 'tag' of the request for logging and statistical purposes + +|`suggest_field` or `suggestField` +|`string` - Specify which field to use for suggestions + +|`suggest_mode` or `suggestMode` +|`'missing' \| 'popular' \| 'always'` - Specify suggest mode + +_Default:_ `missing` + +|`suggest_size` or `suggestSize` +|`number` - How many suggestions to return in response + +|`suggest_text` or `suggestText` +|`string` - The source text for which the suggestions should be returned + +|`timeout` +|`string` - Explicit operation timeout + +|`track_scores` or `trackScores` +|`boolean` - Whether to calculate and return scores even if they are not used for sorting + +|`track_total_hits` or `trackTotalHits` +|`boolean\|long` - Indicate if the number of documents that match the query should be tracked. A number can also be specified, to accurately track the total hit count up to the number. + +|`allow_partial_search_results` or `allowPartialSearchResults` +|`boolean` - Indicate if an error should be returned if there is a partial search failure or timeout + +_Default:_ `true` + +|`typed_keys` or `typedKeys` +|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + +|`version` +|`boolean` - Specify whether to return document version as part of a hit + +|`seq_no_primary_term` or `seqNoPrimaryTerm` +|`boolean` - Specify whether to return sequence number and primary term of the last modification of each hit + +|`request_cache` or `requestCache` +|`boolean` - Specify if request cache should be used for this request or not, defaults to index level setting + +|`batched_reduce_size` or `batchedReduceSize` +|`number` - The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. + +_Default:_ `512` + +|`max_concurrent_shard_requests` or `maxConcurrentShardRequests` +|`number` - The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + +_Default:_ `5` + +|`pre_filter_shard_size` or `preFilterShardSize` +|`number` - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. + +|`rest_total_hits_as_int` or `restTotalHitsAsInt` +|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response + +|`body` +|`object` - The search definition using the Query DSL + +|=== + +=== searchShards + +[source,ts] +---- +client.searchShards({ + index: string | string[], + preference: string, + routing: string, + local: boolean, + ignore_unavailable: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all' +}) +---- +link:{ref}/search-shards.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`routing` +|`string` - Specific routing value + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `open` + +|=== + +=== searchTemplate + +[source,ts] +---- +client.searchTemplate({ + index: string | string[], + ignore_unavailable: boolean, + ignore_throttled: boolean, + allow_no_indices: boolean, + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + preference: string, + routing: string | string[], + scroll: string, + search_type: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch', + explain: boolean, + profile: boolean, + typed_keys: boolean, + rest_total_hits_as_int: boolean, + ccs_minimize_roundtrips: boolean, + body: object +}) +---- +link:{ref}/search-template.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`ignore_throttled` or `ignoreThrottled` +|`boolean` - Whether specified concrete, expanded or aliased indices should be ignored when throttled + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `open` + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`routing` +|`string \| string[]` - A comma-separated list of specific routing values + +|`scroll` +|`string` - Specify how long a consistent view of the index should be maintained for scrolled search + +|`search_type` or `searchType` +|`'query_then_fetch' \| 'query_and_fetch' \| 'dfs_query_then_fetch' \| 'dfs_query_and_fetch'` - Search operation type + +|`explain` +|`boolean` - Specify whether to return detailed information about score computation as part of a hit + +|`profile` +|`boolean` - Specify whether to profile the query execution + +|`typed_keys` or `typedKeys` +|`boolean` - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + +|`rest_total_hits_as_int` or `restTotalHitsAsInt` +|`boolean` - Indicates whether hits.total should be rendered as an integer or an object in the rest search response + +|`ccs_minimize_roundtrips` or `ccsMinimizeRoundtrips` +|`boolean` - Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution + +_Default:_ `true` + +|`body` +|`object` - The search definition template and its params + +|=== + === searchableSnapshots.clearCache *Stability:* experimental [source,ts] @@ -9677,14 +10514,14 @@ link:{ref}/security-api-get-privileges.html[Documentation] + [source,ts] ---- client.security.getRole({ - name: string + name: string | string[] }) ---- link:{ref}/security-api-get-role.html[Documentation] + [cols=2*] |=== |`name` -|`string` - Role name +|`string \| string[]` - A comma-separated list of role names |=== @@ -9693,14 +10530,14 @@ link:{ref}/security-api-get-role.html[Documentation] + [source,ts] ---- client.security.getRoleMapping({ - name: string + name: string | string[] }) ---- link:{ref}/security-api-get-role-mapping.html[Documentation] + [cols=2*] |=== |`name` -|`string` - Role-Mapping name +|`string \| string[]` - A comma-separated list of role-mapping names |=== @@ -10002,6 +10839,302 @@ client.slm.stop() link:{ref}/slm-api-stop.html[Documentation] + +=== snapshot.cleanupRepository + +[source,ts] +---- +client.snapshot.cleanupRepository({ + repository: string, + master_timeout: string, + timeout: string +}) +---- +link:{ref}/clean-up-snapshot-repo-api.html[Documentation] + +[cols=2*] +|=== +|`repository` +|`string` - A repository name + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`timeout` +|`string` - Explicit operation timeout + +|=== + +=== snapshot.create + +[source,ts] +---- +client.snapshot.create({ + repository: string, + snapshot: string, + master_timeout: string, + wait_for_completion: boolean, + body: object +}) +---- +link:{ref}/modules-snapshots.html[Documentation] + +[cols=2*] +|=== +|`repository` +|`string` - A repository name + +|`snapshot` +|`string` - A snapshot name + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Should this request wait until the operation has completed before returning + +|`body` +|`object` - The snapshot definition + +|=== + +=== snapshot.createRepository + +[source,ts] +---- +client.snapshot.createRepository({ + repository: string, + master_timeout: string, + timeout: string, + verify: boolean, + body: object +}) +---- +link:{ref}/modules-snapshots.html[Documentation] + +[cols=2*] +|=== +|`repository` +|`string` - A repository name + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`timeout` +|`string` - Explicit operation timeout + +|`verify` +|`boolean` - Whether to verify the repository after creation + +|`body` +|`object` - The repository definition + +|=== + +=== snapshot.delete + +[source,ts] +---- +client.snapshot.delete({ + repository: string, + snapshot: string | string[], + master_timeout: string +}) +---- +link:{ref}/modules-snapshots.html[Documentation] + +[cols=2*] +|=== +|`repository` +|`string` - A repository name + +|`snapshot` +|`string \| string[]` - A comma-separated list of snapshot names + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|=== + +=== snapshot.deleteRepository + +[source,ts] +---- +client.snapshot.deleteRepository({ + repository: string | string[], + master_timeout: string, + timeout: string +}) +---- +link:{ref}/modules-snapshots.html[Documentation] + +[cols=2*] +|=== +|`repository` +|`string \| string[]` - Name of the snapshot repository to unregister. Wildcard (`*`) patterns are supported. + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`timeout` +|`string` - Explicit operation timeout + +|=== + +=== snapshot.get + +[source,ts] +---- +client.snapshot.get({ + repository: string, + snapshot: string | string[], + master_timeout: string, + ignore_unavailable: boolean, + verbose: boolean +}) +---- +link:{ref}/modules-snapshots.html[Documentation] + +[cols=2*] +|=== +|`repository` +|`string` - A repository name + +|`snapshot` +|`string \| string[]` - A comma-separated list of snapshot names + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown + +|`verbose` +|`boolean` - Whether to show verbose snapshot info or only show the basic info found in the repository index blob + +|=== + +=== snapshot.getRepository + +[source,ts] +---- +client.snapshot.getRepository({ + repository: string | string[], + master_timeout: string, + local: boolean +}) +---- +link:{ref}/modules-snapshots.html[Documentation] + +[cols=2*] +|=== +|`repository` +|`string \| string[]` - A comma-separated list of repository names + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`local` +|`boolean` - Return local information, do not retrieve the state from master node (default: false) + +|=== + +=== snapshot.restore + +[source,ts] +---- +<<<<<<< HEAD +client.security.getRole({ + name: string +======= +client.snapshot.restore({ + repository: string, + snapshot: string, + master_timeout: string, + wait_for_completion: boolean, + body: object +>>>>>>> a064f0f3... Improve child performances (#1314) +}) +---- +link:{ref}/modules-snapshots.html[Documentation] + +[cols=2*] +|=== +<<<<<<< HEAD +|`name` +|`string` - Role name +======= +|`repository` +|`string` - A repository name + +|`snapshot` +|`string` - A snapshot name + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Should this request wait until the operation has completed before returning + +|`body` +|`object` - Details of what to restore +>>>>>>> a064f0f3... Improve child performances (#1314) + +|=== + +=== snapshot.status + +[source,ts] +---- +<<<<<<< HEAD +client.security.getRoleMapping({ + name: string +======= +client.snapshot.status({ + repository: string, + snapshot: string | string[], + master_timeout: string, + ignore_unavailable: boolean +>>>>>>> a064f0f3... Improve child performances (#1314) +}) +---- +link:{ref}/modules-snapshots.html[Documentation] + +[cols=2*] +|=== +<<<<<<< HEAD +|`name` +|`string` - Role-Mapping name +======= +|`repository` +|`string` - A repository name + +|`snapshot` +|`string \| string[]` - A comma-separated list of snapshot names + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether to ignore unavailable snapshots, defaults to false which means a SnapshotMissingException is thrown +>>>>>>> a064f0f3... Improve child performances (#1314) + +|=== + +=== snapshot.verifyRepository + +[source,ts] +---- +client.snapshot.verifyRepository({ + repository: string, + master_timeout: string, + timeout: string +}) +---- +link:{ref}/modules-snapshots.html[Documentation] + +[cols=2*] +|=== +|`repository` +|`string` - A repository name + +|`master_timeout` or `masterTimeout` +|`string` - Explicit operation timeout for connection to master node + +|`timeout` +|`string` - Explicit operation timeout + +|=== + === sql.clearCursor [source,ts] @@ -10064,6 +11197,175 @@ client.ssl.certificates() link:{ref}/security-api-ssl.html[Documentation] + +=== tasks.cancel + +[source,ts] +---- +client.tasks.cancel({ + task_id: string, + nodes: string | string[], + actions: string | string[], + parent_task_id: string, + wait_for_completion: boolean +}) +---- +link:{ref}/tasks.html[Documentation] + +[cols=2*] +|=== +|`task_id` or `taskId` +|`string` - Cancel the task with specified task id (node_id:task_number) + +|`nodes` +|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +|`actions` +|`string \| string[]` - A comma-separated list of actions that should be cancelled. Leave empty to cancel all. + +|`parent_task_id` or `parentTaskId` +|`string` - Cancel tasks with specified parent task id (node_id:task_number). Set to -1 to cancel all. + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Should the request block until the cancellation of the task and its descendant tasks is completed. Defaults to false + +|=== + +=== tasks.get + +[source,ts] +---- +client.tasks.get({ + task_id: string, + wait_for_completion: boolean, + timeout: string +}) +---- +link:{ref}/tasks.html[Documentation] + +[cols=2*] +|=== +|`task_id` or `taskId` +|`string` - Return the task with specified id (node_id:task_number) + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Wait for the matching tasks to complete (default: false) + +|`timeout` +|`string` - Explicit operation timeout + +|=== + +=== tasks.list + +[source,ts] +---- +client.tasks.list({ + nodes: string | string[], + actions: string | string[], + detailed: boolean, + parent_task_id: string, + wait_for_completion: boolean, + group_by: 'nodes' | 'parents' | 'none', + timeout: string +}) +---- +link:{ref}/tasks.html[Documentation] + +[cols=2*] +|=== +|`nodes` +|`string \| string[]` - A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes + +|`actions` +|`string \| string[]` - A comma-separated list of actions that should be returned. Leave empty to return all. + +|`detailed` +|`boolean` - Return detailed task information (default: false) + +|`parent_task_id` or `parentTaskId` +|`string` - Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all. + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Wait for the matching tasks to complete (default: false) + +|`group_by` or `groupBy` +|`'nodes' \| 'parents' \| 'none'` - Group tasks by nodes or parent/child relationships + +_Default:_ `nodes` + +|`timeout` +|`string` - Explicit operation timeout + +|=== + +=== termvectors + +[source,ts] +---- +client.termvectors({ + index: string, + id: string, + term_statistics: boolean, + field_statistics: boolean, + fields: string | string[], + offsets: boolean, + positions: boolean, + payloads: boolean, + preference: string, + routing: string, + realtime: boolean, + version: number, + version_type: 'internal' | 'external' | 'external_gte', + body: object +}) +---- +link:{ref}/docs-termvectors.html[Documentation] + +[cols=2*] +|=== +|`index` +|`string` - The index in which the document resides. + +|`id` +|`string` - The id of the document, when not specified a doc param should be supplied. + +|`term_statistics` or `termStatistics` +|`boolean` - Specifies if total term frequency and document frequency should be returned. + +|`field_statistics` or `fieldStatistics` +|`boolean` - Specifies if document count, sum of document frequencies and sum of total term frequencies should be returned. + +_Default:_ `true` + +|`fields` +|`string \| string[]` - A comma-separated list of fields to return. + +|`offsets` +|`boolean` - Specifies if term offsets should be returned. + +_Default:_ `true` + +|`positions` +|`boolean` - Specifies if term positions should be returned. + +_Default:_ `true` + +|`payloads` +|`boolean` - Specifies if term payloads should be returned. + +_Default:_ `true` + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random). + +|`routing` +|`string` - Specific routing value. + +|`realtime` +|`boolean` - Specifies if request is real-time as opposed to near-real-time (default: true). + +|`version` +|`number` - Explicit version number for concurrency control + +|`version_type` or `versionType` +|`'internal' \| 'external' \| 'external_gte'` - Specific version type + +|`body` +|`object` - Define parameters and or supply a document to get termvectors for. See documentation. + +|=== + === transform.deleteTransform [source,ts] @@ -10260,6 +11562,269 @@ link:{ref}/update-transform.html[Documentation] + |=== +=== update + +[source,ts] +---- +client.update({ + id: string, + index: string, + type: string, + wait_for_active_shards: string, + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + lang: string, + refresh: 'true' | 'false' | 'wait_for', + retry_on_conflict: number, + routing: string, + timeout: string, + if_seq_no: number, + if_primary_term: number, + require_alias: boolean, + body: object +}) +---- +link:{ref}/docs-update.html[Documentation] + +{jsclient}/update_examples.html[Code Example] + +[cols=2*] +|=== +|`id` +|`string` - Document ID + +|`index` +|`string` - The name of the index + +|`type` +|`string` - The type of the document + + +WARNING: This parameter has been deprecated. + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + +|`_source` +|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return + +|`_source_excludes` or `_sourceExcludes` +|`string \| string[]` - A list of fields to exclude from the returned _source field + +|`_source_includes` or `_sourceIncludes` +|`string \| string[]` - A list of fields to extract and return from the _source field + +|`lang` +|`string` - The script language (default: painless) + +|`refresh` +|`'true' \| 'false' \| 'wait_for'` - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. + +|`retry_on_conflict` or `retryOnConflict` +|`number` - Specify how many times should the operation be retried when a conflict occurs (default: 0) + +|`routing` +|`string` - Specific routing value + +|`timeout` +|`string` - Explicit operation timeout + +|`if_seq_no` or `ifSeqNo` +|`number` - only perform the update operation if the last operation that has changed the document has the specified sequence number + +|`if_primary_term` or `ifPrimaryTerm` +|`number` - only perform the update operation if the last operation that has changed the document has the specified primary term + +|`require_alias` or `requireAlias` +|`boolean` - When true, requires destination is an alias. Default is false + +|`body` +|`object` - The request definition requires either `script` or partial `doc` + +|=== + +=== updateByQuery + +[source,ts] +---- +client.updateByQuery({ + index: string | string[], + analyzer: string, + analyze_wildcard: boolean, + default_operator: 'AND' | 'OR', + df: string, + from: number, + ignore_unavailable: boolean, + allow_no_indices: boolean, + conflicts: 'abort' | 'proceed', + expand_wildcards: 'open' | 'closed' | 'hidden' | 'none' | 'all', + lenient: boolean, + pipeline: string, + preference: string, + q: string, + routing: string | string[], + scroll: string, + search_type: 'query_then_fetch' | 'dfs_query_then_fetch', + search_timeout: string, + max_docs: number, + sort: string | string[], + _source: string | string[], + _source_excludes: string | string[], + _source_includes: string | string[], + terminate_after: number, + stats: string | string[], + version: boolean, + version_type: boolean, + request_cache: boolean, + refresh: boolean, + timeout: string, + wait_for_active_shards: string, + scroll_size: number, + wait_for_completion: boolean, + requests_per_second: number, + slices: number|string, + body: object +}) +---- +link:{ref}/docs-update-by-query.html[Documentation] + +{jsclient}/update_by_query_examples.html[Code Example] + +[cols=2*] +|=== +|`index` +|`string \| string[]` - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices + +|`analyzer` +|`string` - The analyzer to use for the query string + +|`analyze_wildcard` or `analyzeWildcard` +|`boolean` - Specify whether wildcard and prefix queries should be analyzed (default: false) + +|`default_operator` or `defaultOperator` +|`'AND' \| 'OR'` - The default operator for query string query (AND or OR) + +_Default:_ `OR` + +|`df` +|`string` - The field to use as default where no field prefix is given in the query string + +|`from` +|`number` - Starting offset (default: 0) + +|`ignore_unavailable` or `ignoreUnavailable` +|`boolean` - Whether specified concrete indices should be ignored when unavailable (missing or closed) + +|`allow_no_indices` or `allowNoIndices` +|`boolean` - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + +|`conflicts` +|`'abort' \| 'proceed'` - What to do when the update by query hits version conflicts? + +_Default:_ `abort` + +|`expand_wildcards` or `expandWildcards` +|`'open' \| 'closed' \| 'hidden' \| 'none' \| 'all'` - Whether to expand wildcard expression to concrete indices that are open, closed or both. + +_Default:_ `open` + +|`lenient` +|`boolean` - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored + +|`pipeline` +|`string` - Ingest pipeline to set on index requests made by this action. (default: none) + +|`preference` +|`string` - Specify the node or shard the operation should be performed on (default: random) + +|`q` +|`string` - Query in the Lucene query string syntax + +|`routing` +|`string \| string[]` - A comma-separated list of specific routing values + +|`scroll` +|`string` - Specify how long a consistent view of the index should be maintained for scrolled search + +|`search_type` or `searchType` +|`'query_then_fetch' \| 'dfs_query_then_fetch'` - Search operation type + +|`search_timeout` or `searchTimeout` +|`string` - Explicit timeout for each search request. Defaults to no timeout. + +|`max_docs` or `maxDocs` +|`number` - Maximum number of documents to process (default: all documents) + +|`sort` +|`string \| string[]` - A comma-separated list of : pairs + +|`_source` +|`string \| string[]` - True or false to return the _source field or not, or a list of fields to return + +|`_source_excludes` or `_sourceExcludes` +|`string \| string[]` - A list of fields to exclude from the returned _source field + +|`_source_includes` or `_sourceIncludes` +|`string \| string[]` - A list of fields to extract and return from the _source field + +|`terminate_after` or `terminateAfter` +|`number` - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. + +|`stats` +|`string \| string[]` - Specific 'tag' of the request for logging and statistical purposes + +|`version` +|`boolean` - Specify whether to return document version as part of a hit + +|`version_type` or `versionType` +|`boolean` - Should the document increment the version number (internal) on hit or not (reindex) + +|`request_cache` or `requestCache` +|`boolean` - Specify if request cache should be used for this request or not, defaults to index level setting + +|`refresh` +|`boolean` - Should the affected indexes be refreshed? + +|`timeout` +|`string` - Time each individual bulk request should wait for shards that are unavailable. + +_Default:_ `1m` + +|`wait_for_active_shards` or `waitForActiveShards` +|`string` - Sets the number of shard copies that must be active before proceeding with the update by query operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) + +|`scroll_size` or `scrollSize` +|`number` - Size on the scroll request powering the update by query + +_Default:_ `100` + +|`wait_for_completion` or `waitForCompletion` +|`boolean` - Should the request should block until the update by query operation is complete. + +_Default:_ `true` + +|`requests_per_second` or `requestsPerSecond` +|`number` - The throttle to set on this request in sub-requests per second. -1 means no throttle. + +|`slices` +|`number\|string` - The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`. + +_Default:_ `1` + +|`body` +|`object` - The search definition using the Query DSL + +|=== + +=== updateByQueryRethrottle + +[source,ts] +---- +client.updateByQueryRethrottle({ + task_id: string, + requests_per_second: number +}) +---- +link:{ref}/docs-update-by-query.html[Documentation] + +[cols=2*] +|=== +|`task_id` or `taskId` +|`string` - The task id to rethrottle + +|`requests_per_second` or `requestsPerSecond` +|`number` - The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. + +|=== + === watcher.ackWatch [source,ts] diff --git a/index.js b/index.js index 466a51988..d575bc2d8 100644 --- a/index.js +++ b/index.js @@ -32,17 +32,19 @@ const Helpers = nodeMajor < 10 ? /* istanbul ignore next */ null : require('./li const Serializer = require('./lib/Serializer') const errors = require('./lib/errors') const { ConfigurationError } = errors +const { prepareHeaders } = Connection.internals const kInitialOptions = Symbol('elasticsearchjs-initial-options') const kChild = Symbol('elasticsearchjs-child') const kExtensions = Symbol('elasticsearchjs-extensions') const kEventEmitter = Symbol('elasticsearchjs-event-emitter') -const buildApi = require('./api') +const ESAPI = require('./api') -class Client { +class Client extends ESAPI { constructor (opts = {}) { - if (opts.cloud) { + super({ ConfigurationError }) + if (opts.cloud && opts[kChild] === undefined) { const { id, username, password } = opts.cloud // the cloud id is `cluster-name:base64encodedurl` // the url is a string divided by two '$', the first is the cloud url @@ -71,38 +73,42 @@ class Client { throw new ConfigurationError('Missing node(s) option') } - const checkAuth = getAuth(opts.node || opts.nodes) - if (checkAuth && checkAuth.username && checkAuth.password) { - opts.auth = Object.assign({}, opts.auth, { username: checkAuth.username, password: checkAuth.password }) + if (opts[kChild] === undefined) { + const checkAuth = getAuth(opts.node || opts.nodes) + if (checkAuth && checkAuth.username && checkAuth.password) { + opts.auth = Object.assign({}, opts.auth, { username: checkAuth.username, password: checkAuth.password }) + } } - const options = Object.assign({}, { - Connection, - Transport, - Serializer, - ConnectionPool: opts.cloud ? CloudConnectionPool : ConnectionPool, - maxRetries: 3, - requestTimeout: 30000, - pingTimeout: 3000, - sniffInterval: false, - sniffOnStart: false, - sniffEndpoint: '_nodes/_all/http', - sniffOnConnectionFault: false, - resurrectStrategy: 'ping', - suggestCompression: false, - compression: false, - ssl: null, - agent: null, - headers: {}, - nodeFilter: null, - nodeSelector: 'round-robin', - generateRequestId: null, - name: 'elasticsearch-js', - auth: null, - opaqueIdPrefix: null, - context: null, - proxy: null - }, opts) + const options = opts[kChild] !== undefined + ? opts[kChild].initialOptions + : Object.assign({}, { + Connection, + Transport, + Serializer, + ConnectionPool: opts.cloud ? CloudConnectionPool : ConnectionPool, + maxRetries: 3, + requestTimeout: 30000, + pingTimeout: 3000, + sniffInterval: false, + sniffOnStart: false, + sniffEndpoint: '_nodes/_all/http', + sniffOnConnectionFault: false, + resurrectStrategy: 'ping', + suggestCompression: false, + compression: false, + ssl: null, + agent: null, + headers: {}, + nodeFilter: null, + nodeSelector: 'round-robin', + generateRequestId: null, + name: 'elasticsearch-js', + auth: null, + opaqueIdPrefix: null, + context: null, + proxy: null + }, opts) this[kInitialOptions] = options this[kExtensions] = [] @@ -157,17 +163,6 @@ class Client { if (Helpers !== null) { this.helpers = new Helpers({ client: this, maxRetries: options.maxRetries }) } - - const apis = buildApi({ - makeRequest: this.transport.request.bind(this.transport), - result: { body: null, statusCode: null, headers: null, warnings: null }, - ConfigurationError - }) - - const apiNames = Object.keys(apis) - for (var i = 0, len = apiNames.length; i < len; i++) { - this[apiNames[i]] = apis[apiNames[i]] - } } get emit () { @@ -203,7 +198,7 @@ class Client { throw new Error(`The method "${method}" already exists on namespace "${namespace}"`) } - this[namespace] = this[namespace] || {} + if (this[namespace] == null) this[namespace] = {} this[namespace][method] = fn({ makeRequest: this.transport.request.bind(this.transport), result: { body: null, statusCode: null, headers: null, warnings: null }, @@ -226,15 +221,21 @@ class Client { child (opts) { // Merge the new options with the initial ones - const initialOptions = Object.assign({}, this[kInitialOptions], opts) + const options = Object.assign({}, this[kInitialOptions], opts) // Pass to the child client the parent instances that cannot be overriden - initialOptions[kChild] = { + options[kChild] = { connectionPool: this.connectionPool, serializer: this.serializer, - eventEmitter: this[kEventEmitter] + eventEmitter: this[kEventEmitter], + initialOptions: options } - const client = new Client(initialOptions) + /* istanbul ignore else */ + if (options.auth !== undefined) { + options.headers = prepareHeaders(options.headers, options.auth) + } + + const client = new Client(options) // Add parent extensions if (this[kExtensions].length > 0) { this[kExtensions].forEach(({ name, opts, fn }) => { diff --git a/lib/Connection.js b/lib/Connection.js index 3eebea6b7..e1945b131 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -347,3 +347,4 @@ function prepareHeaders (headers = {}, auth) { } module.exports = Connection +module.exports.internals = { prepareHeaders } diff --git a/lib/Transport.js b/lib/Transport.js index d86092fc3..791f1018c 100644 --- a/lib/Transport.js +++ b/lib/Transport.js @@ -127,10 +127,17 @@ class Transport { body: null, statusCode: null, headers: null, - warnings: options.warnings || null, meta } + Object.defineProperty(result, 'warnings', { + get () { + return this.headers && this.headers.warning + ? this.headers.warning.split(/(?!\B"[^"]*),(?![^"]*"\B)/) + : null + } + }) + // We should not retry if we are sending a stream body, because we should store in memory // a copy of the stream to be able to send it again, but since we don't know in advance // the size of the stream, we risk to take too much memory. @@ -198,11 +205,6 @@ class Transport { const { statusCode, headers } = response result.statusCode = statusCode result.headers = headers - if (headers.warning !== undefined) { - result.warnings = result.warnings || [] - // split the string over the commas not inside quotes - result.warnings.push.apply(result.warnings, headers.warning.split(/(?!\B"[^"]*),(?![^"]*"\B)/)) - } if (options.asStream === true) { result.body = response diff --git a/scripts/generate.js b/scripts/generate.js index 732af2ff0..9c292ad43 100644 --- a/scripts/generate.js +++ b/scripts/generate.js @@ -51,7 +51,6 @@ function start (opts) { const kibanaTypeDefFile = join(packageFolder, 'kibana.d.ts') const docOutputFile = join(__dirname, '..', 'docs', 'reference.asciidoc') const requestParamsOutputFile = join(packageFolder, 'requestParams.d.ts') - const allSpec = [] log.text = 'Cleaning API folder...' rimraf.sync(join(apiOutputFolder, '*.js')) @@ -66,8 +65,25 @@ function start (opts) { const xPackFolderContents = readdirSync(xPackFolder) .filter(file => !file.startsWith('data_frame_transform_deprecated')) - apiFolderContents.forEach(generateApiFile(apiFolder, log)) - xPackFolderContents.forEach(generateApiFile(xPackFolder, log)) + const allSpec = apiFolderContents.concat(xPackFolderContents) + .filter(file => file !== '_common.json') + .filter(file => !file.includes('deprecated')) + .sort() + .map(file => { + try { + return JSON.parse(readFileSync(join(apiFolder, file), 'utf8')) + } catch (err) { + return JSON.parse(readFileSync(join(xPackFolder, file), 'utf8')) + } + }) + + const namespaces = namespacify(apiFolderContents.concat(xPackFolderContents)) + for (const namespace in namespaces) { + if (namespace === '_common') continue + const code = generate(namespace, namespaces[namespace], { apiFolder, xPackFolder }, opts.branch || opts.tag) + const filePath = join(apiOutputFolder, `${namespace}.js`) + writeFileSync(filePath, code, { encoding: 'utf8' }) + } writeFileSync( requestParamsOutputFile, @@ -75,7 +91,7 @@ function start (opts) { { encoding: 'utf8' } ) - const { fn: factory, types, kibanaTypes } = genFactory(apiOutputFolder, [apiFolder, xPackFolder]) + const { fn: factory, types, kibanaTypes } = genFactory(apiOutputFolder, [apiFolder, xPackFolder], namespaces) writeFileSync( mainOutputFile, factory, @@ -104,9 +120,6 @@ function start (opts) { lintFiles(log, () => { log.text = 'Generating documentation' - const allSpec = apiFolderContents.filter(f => f !== '_common.json') - .map(f => require(join(apiFolder, f))) - .concat(xPackFolderContents.map(f => require(join(xPackFolder, f)))) writeFileSync( docOutputFile, generateDocs(require(join(apiFolder, '_common.json')), allSpec), @@ -117,27 +130,6 @@ function start (opts) { }) }) - function generateApiFile (apiFolder, log) { - var common = null - try { - common = require(join(apiFolder, '_common.json')) - } catch (e) {} - - return function _generateApiFile (file) { - if (file === '_common.json') return - log.text = `Processing ${file}` - - const spec = require(join(apiFolder, file)) - // const { stability } = spec[Object.keys(spec)[0]] - // if (stability !== 'stable') return - allSpec.push(spec) - const code = generate(opts.branch || opts.tag, spec, common) - const filePath = join(apiOutputFolder, `${file.slice(0, file.lastIndexOf('.'))}.js`) - - writeFileSync(filePath, code, { encoding: 'utf8' }) - } - } - function lintFiles (log, cb) { log.text = 'Linting...' const files = [join(packageFolder, '*.js'), join(apiOutputFolder, '*.js')] @@ -148,4 +140,21 @@ function start (opts) { cb() }) } + + function namespacify (apis) { + return apis + .map(api => api.slice(0, -5)) + .filter(api => api !== '_common') + .filter(api => !api.includes('deprecated')) + .reduce((acc, val) => { + if (val.includes('.')) { + val = val.split('.') + acc[val[0]] = acc[val[0]] || [] + acc[val[0]].push(val[1]) + } else { + acc[val] = [] + } + return acc + }, {}) + } } diff --git a/scripts/utils/generateApis.js b/scripts/utils/generateApis.js index 4eacdcb06..52b665fb9 100644 --- a/scripts/utils/generateApis.js +++ b/scripts/utils/generateApis.js @@ -23,6 +23,7 @@ 'use strict' +const { join } = require('path') const dedent = require('dedent') const semver = require('semver') const allowedMethods = { @@ -70,7 +71,115 @@ const ndjsonApi = [ 'xpack.monitoring.bulk' ] -function generate (version, spec, common) { +function generateNamespace (namespace, nested, folders, version) { + const common = require(join(folders.apiFolder, '_common.json')) + let code = dedent` + /* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + 'use strict' + + /* eslint camelcase: 0 */ + /* eslint no-unused-vars: 0 */ + + const { handleError, snakeCaseKeys, normalizeArguments, kConfigurationError } = require('../utils') +` + if (nested.length > 0) { + let getters = '' + for (const n of nested) { + if (n.includes('_')) { + const nameSnaked = n + .replace(/\.([a-z])/g, k => k[1].toUpperCase()) + .replace(/_([a-z])/g, k => k[1].toUpperCase()) + getters += `${n}: { get () { return this.${nameSnaked} } },\n` + } + } + const api = generateMultiApi(version, namespace, nested, common, folders) + if (getters.length > 0) { + getters = `Object.defineProperties(${api.namespace}Api.prototype, {\n${getters}})` + } + + code += ` + const acceptedQuerystring = ${JSON.stringify(api.acceptedQuerystring)} + const snakeCase = ${JSON.stringify(api.snakeCase)} + + function ${api.namespace}Api (transport, ConfigurationError) { + this.transport = transport + this[kConfigurationError] = ConfigurationError + } + + ${api.code} + + ${getters} + + module.exports = ${api.namespace}Api + ` + } else { + let spec = null + try { + spec = require(join(folders.apiFolder, `${namespace}.json`)) + } catch (err) { + spec = require(join(folders.xPackFolder, `${namespace}.json`)) + } + const api = generateSingleApi(version, spec, common) + code += ` + const acceptedQuerystring = ${JSON.stringify(api.acceptedQuerystring)} + const snakeCase = ${JSON.stringify(api.snakeCase)} + + ${api.code} + + module.exports = ${api.name}Api + ` + } + return code +} + +function generateMultiApi (version, namespace, nested, common, folders) { + const namespaceSnaked = namespace + .replace(/\.([a-z])/g, k => k[1].toUpperCase()) + .replace(/_([a-z])/g, k => k[1].toUpperCase()) + let code = '' + const snakeCase = {} + const acceptedQuerystring = [] + for (const n of nested) { + let spec = null + const nameSnaked = n + .replace(/\.([a-z])/g, k => k[1].toUpperCase()) + .replace(/_([a-z])/g, k => k[1].toUpperCase()) + try { + spec = require(join(folders.apiFolder, `${namespace}.${n}.json`)) + } catch (err) { + spec = require(join(folders.xPackFolder, `${namespace}.${n}.json`)) + } + const api = generateSingleApi(version, spec, common) + code += `${Uppercase(namespaceSnaked)}Api.prototype.${nameSnaked} = ${api.code}\n\n` + Object.assign(snakeCase, api.snakeCase) + for (const q of api.acceptedQuerystring) { + if (!acceptedQuerystring.includes(q)) { + acceptedQuerystring.push(q) + } + } + } + return { code, snakeCase, acceptedQuerystring, namespace: Uppercase(namespaceSnaked) } +} + +function generateSingleApi (version, spec, common) { const release = semver.valid(version) ? semver.major(version) : version const api = Object.keys(spec)[0] const name = api @@ -136,37 +245,15 @@ function generate (version, spec, common) { } const code = ` - function ${safeWords(name)} (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } + function ${name}Api (params, options, callback) { + ;[params, options, callback] = normalizeArguments(params, options, callback) ${genRequiredChecks()} ${genUrlValidation(paths, api)} - // validate headers object - if (options.headers != null && typeof options.headers !== 'object') { - const err = new ConfigurationError(\`Headers should be an object, instead got: \${typeof options.headers}\`) - return handleError(err, callback) - } - - var warnings = [] var { ${genQueryBlacklist(false)}, ...querystring } = params - querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) - - var ignore = options.ignore - if (typeof ignore === 'number') { - options.ignore = [ignore] - } - + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring) var path = '' ${buildPath(api)} @@ -179,58 +266,18 @@ function generate (version, spec, common) { querystring } - options.warnings = warnings.length === 0 ? null : warnings - return makeRequest(request, options, callback) + return this.transport.request(request, options, callback) } `.trim() // always call trim to avoid newlines - const fn = dedent` - /* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - 'use strict' - - /* eslint camelcase: 0 */ - /* eslint no-unused-vars: 0 */ - - function build${name[0].toUpperCase() + name.slice(1)} (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts - - const acceptedQuerystring = [ - ${acceptedQuerystring.map(q => `'${q}'`).join(',\n')} - ] - - const snakeCase = { - ${genSnakeCaseMap()} - } - - ${generateDocumentation(spec[api], api)} - return ${code} + return { + name, + code, + acceptedQuerystring: acceptedQuerystring, + snakeCase: genSnakeCaseMap(), + documentation: generateDocumentation(spec[api], api) } - module.exports = build${name[0].toUpperCase() + name.slice(1)} -` - - // new line at the end of file - return fn + '\n' - function genRequiredChecks (param) { const code = required .map(_genRequiredCheck) @@ -251,7 +298,7 @@ function generate (version, spec, common) { if (param === camelCased) { const check = ` if (params['${param}'] == null) { - const err = new ConfigurationError('Missing required parameter: ${param}') + const err = new this[kConfigurationError]('Missing required parameter: ${param}') return handleError(err, callback) } ` @@ -259,7 +306,7 @@ function generate (version, spec, common) { } else { const check = ` if (params['${param}'] == null && params['${camelCased}'] == null) { - const err = new ConfigurationError('Missing required parameter: ${param} or ${camelCased}') + const err = new this[kConfigurationError]('Missing required parameter: ${param} or ${camelCased}') return handleError(err, callback) } ` @@ -270,7 +317,7 @@ function generate (version, spec, common) { function _noBody () { const check = ` if (params.body != null) { - const err = new ConfigurationError('This API does not require a body') + const err = new this[kConfigurationError]('This API does not require a body') return handleError(err, callback) } ` @@ -287,13 +334,10 @@ function generate (version, spec, common) { return acceptedQuerystring.reduce((acc, val, index) => { if (toCamelCase(val) !== val) { - acc += `${toCamelCase(val)}: '${val}'` - if (index !== acceptedQuerystring.length - 1) { - acc += ',\n' - } + acc[toCamelCase(val)] = val } return acc - }, '') + }, {}) } function genQueryBlacklist (addQuotes = true) { @@ -363,13 +407,11 @@ function generate (version, spec, common) { for (var i = 0; i < sortedPaths.length; i++) { const { path, methods } = sortedPaths[i] if (sortedPaths.length === 1) { - code += ` - if (method == null) method = ${generatePickMethod(methods)} + code += `if (method == null) method = ${generatePickMethod(methods)} path = ${genPath(path)} ` } else if (i === 0) { - code += ` - if (${genCheck(path)}) { + code += `if (${genCheck(path)}) { if (method == null) method = ${generatePickMethod(methods)} path = ${genPath(path)} } @@ -389,60 +431,10 @@ function generate (version, spec, common) { } } - // var hasStaticPath = false - // var singlePathComponent = false - // paths - // .filter(path => { - // if (path.indexOf('{') > -1) return true - // if (hasStaticPath === false) { - // hasStaticPath = true - // return true - // } - // return false - // }) - // .sort((a, b) => (b.split('{').length + b.split('/').length) - (a.split('{').length + a.split('/').length)) - // .forEach((path, index, arr) => { - // if (arr.length === 1) { - // singlePathComponent = true - // code += ` - // path = ${genPath(path)} - // ` - // } else if (index === 0) { - // code += ` - // if (${genCheck(path)}) { - // path = ${genPath(path)} - // ` - // } else if (index === arr.length - 1) { - // code += ` - // } else { - // path = ${genPath(path)} - // ` - // } else { - // code += ` - // } else if (${genCheck(path)}) { - // path = ${genPath(path)} - // ` - // } - // }) - - // code += singlePathComponent ? '' : '}' return code } } -function safeWords (str) { - switch (str) { - // delete is a reserved word - case 'delete': - return '_delete' - // index is also a parameter - case 'index': - return '_index' - default: - return str - } -} - function generatePickMethod (methods) { if (methods.length === 1) { return `'${methods[0]}'` @@ -529,7 +521,7 @@ function genUrlValidation (paths, api) { } } code += `)) { - const err = new ConfigurationError('Missing required parameter of the url: ${params.join(', ')}') + const err = new this[kConfigurationError]('Missing required parameter of the url: ${params.join(', ')}') return handleError(err, callback) ` }) @@ -574,5 +566,9 @@ function intersect (first, ...rest) { }, first) } -module.exports = generate +function Uppercase (str) { + return str[0].toUpperCase() + str.slice(1) +} + +module.exports = generateNamespace module.exports.ndjsonApi = ndjsonApi diff --git a/scripts/utils/generateMain.js b/scripts/utils/generateMain.js index 8ee0431a7..cfdd2fe3a 100644 --- a/scripts/utils/generateMain.js +++ b/scripts/utils/generateMain.js @@ -35,24 +35,29 @@ const ndjsonApiKey = ndjsonApi }) .map(toPascalCase) -function genFactory (folder, paths) { +function genFactory (folder, paths, namespaces) { // get all the API files - const apiFiles = readdirSync(folder) + // const apiFiles = readdirSync(folder) + const apiFiles = readdirSync(paths[0]) + .concat(readdirSync(paths[1])) + .filter(file => file !== '_common.json') + .filter(file => !file.includes('deprecated')) + .sort() const types = apiFiles .map(file => { const name = file - .slice(0, -3) + .slice(0, -5) .replace(/\.([a-z])/g, k => k[1].toUpperCase()) .replace(/_([a-z])/g, k => k[1].toUpperCase()) return file - .slice(0, -3) // remove `.js` extension + .slice(0, -5) // remove `.json` extension .split('.') .reverse() .reduce((acc, val) => { - const spec = readSpec(paths, file.slice(0, -3)) - const isHead = isHeadMethod(spec, file.slice(0, -3)) - const body = hasBody(spec, file.slice(0, -3)) + const spec = readSpec(paths, file.slice(0, -5)) + const isHead = isHeadMethod(spec, file.slice(0, -5)) + const body = hasBody(spec, file.slice(0, -5)) const methods = acc === null ? buildMethodDefinition({ kibana: false }, val, name, body, isHead) : null const obj = {} if (methods) { @@ -73,18 +78,18 @@ function genFactory (folder, paths) { const kibanaTypes = apiFiles .map(file => { const name = file - .slice(0, -3) + .slice(0, -5) .replace(/\.([a-z])/g, k => k[1].toUpperCase()) .replace(/_([a-z])/g, k => k[1].toUpperCase()) return file - .slice(0, -3) // remove `.js` extension + .slice(0, -5) // remove `.json` extension .split('.') .reverse() .reduce((acc, val) => { - const spec = readSpec(paths, file.slice(0, -3)) - const isHead = isHeadMethod(spec, file.slice(0, -3)) - const body = hasBody(spec, file.slice(0, -3)) + const spec = readSpec(paths, file.slice(0, -5)) + const isHead = isHeadMethod(spec, file.slice(0, -5)) + const body = hasBody(spec, file.slice(0, -5)) const methods = acc === null ? buildMethodDefinition({ kibana: true }, val, name, body, isHead) : null const obj = {} if (methods) { @@ -99,37 +104,6 @@ function genFactory (folder, paths) { }) .reduce((acc, val) => deepmerge(acc, val), {}) - const apis = apiFiles - .map(file => { - // const name = format(file.slice(0, -3)) - return file - .slice(0, -3) // remove `.js` extension - .split('.') - .reverse() - .reduce((acc, val) => { - const obj = { - [val]: acc === null - ? `lazyLoad('${file.slice(0, -3)}', opts)` // `${name}(opts)` - : acc - } - if (isSnakeCased(val)) { - obj[camelify(val)] = acc === null - ? `lazyLoad('${file.slice(0, -3)}', opts)` // `${name}(opts)` - : acc - } - return obj - }, null) - }) - .reduce((acc, val) => deepmerge(acc, val), {}) - - // serialize the API object - const apisStr = JSON.stringify(apis, null, 2) - // split & join to fix the indentation - .split('\n') - .join('\n ') - // remove useless quotes - .replace(/"/g, '') - // serialize the type object const typesStr = Object.keys(types) .map(key => { @@ -156,6 +130,48 @@ function genFactory (folder, paths) { .replace(/"/g, '') .replace(/,$/gm, '') + let apisStr = '' + const getters = [] + for (const namespace in namespaces) { + if (namespaces[namespace].length > 0) { + getters.push(`${camelify(namespace)}: { + get () { + if (this[k${toPascalCase(camelify(namespace))}] === null) { + this[k${toPascalCase(camelify(namespace))}] = new ${toPascalCase(camelify(namespace))}Api(this.transport, this[kConfigurationError]) + } + return this[k${toPascalCase(camelify(namespace))}] + } + },\n`) + if (namespace.includes('_')) { + getters.push(`${namespace}: { get () { return this.${camelify(namespace)} } },\n`) + } + } else { + apisStr += `ESAPI.prototype.${camelify(namespace)} = ${camelify(namespace)}Api\n` + if (namespace.includes('_')) { + getters.push(`${namespace}: { get () { return this.${camelify(namespace)} } },\n`) + } + } + } + + apisStr += '\nObject.defineProperties(ESAPI.prototype, {\n' + for (const getter of getters) { + apisStr += getter + } + apisStr += '})' + + let modules = '' + let symbols = '' + let symbolsInstance = '' + for (const namespace in namespaces) { + if (namespaces[namespace].length > 0) { + modules += `const ${toPascalCase(camelify(namespace))}Api = require('./api/${namespace}')\n` + symbols += `const k${toPascalCase(camelify(namespace))} = Symbol('${toPascalCase(camelify(namespace))}')\n` + symbolsInstance += `this[k${toPascalCase(camelify(namespace))}] = null\n` + } else { + modules += `const ${camelify(namespace)}Api = require('./api/${namespace}')\n` + } + } + const fn = dedent` /* * Licensed to Elasticsearch B.V. under one or more contributor @@ -178,62 +194,17 @@ function genFactory (folder, paths) { 'use strict' - const assert = require('assert') + ${modules} + + const { kConfigurationError } = require('./utils') + ${symbols} function ESAPI (opts) { - assert(opts.makeRequest, 'Missing makeRequest function') - assert(opts.ConfigurationError, 'Missing ConfigurationError class') - assert(opts.result, 'Missing default result object') - - const { result } = opts - opts.handleError = handleError - opts.snakeCaseKeys = snakeCaseKeys - - const apis = ${apisStr} - - - return apis - - function handleError (err, callback) { - if (callback) { - process.nextTick(callback, err, result) - return { then: noop, catch: noop, abort: noop } - } - return Promise.reject(err) - } - - function snakeCaseKeys (acceptedQuerystring, snakeCase, querystring, warnings) { - var target = {} - var keys = Object.keys(querystring) - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - target[snakeCase[key] || key] = querystring[key] - if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) { - warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter') - } - } - return target - } + this[kConfigurationError] = opts.ConfigurationError + ${symbolsInstance} } - // It's unlikely that a user needs all of our APIs, - // and since require is a sync operation that takes time - // (given the amount of APIs we have), let's lazy load them, - // so a given API file will be required only - // if the user actually needs that API. - // The following implementation takes advantage - // of js closures to have a simple cache with the least overhead. - function lazyLoad (file, opts) { - var fn = null - return function _lazyLoad (params, options, callback) { - if (fn === null) { - fn = require(${'`./api/${file}.js`'})(opts) - } - return fn(params, options, callback) - } - } - - function noop () {} + ${apisStr} module.exports = ESAPI ` diff --git a/test/bundlers/parcel-test/index.js b/test/bundlers/parcel-test/index.js new file mode 100644 index 000000000..792b4b873 --- /dev/null +++ b/test/bundlers/parcel-test/index.js @@ -0,0 +1,7 @@ +'use strict' + +const { Client } = require('../../../index') +const client = new Client({ node: 'http://localhost:9200' }) +client.info((err, result) => { + process.exit(err ? 1 : 0) +}) diff --git a/test/bundlers/parcel-test/package.json b/test/bundlers/parcel-test/package.json new file mode 100644 index 000000000..3f02de1db --- /dev/null +++ b/test/bundlers/parcel-test/package.json @@ -0,0 +1,16 @@ +{ + "name": "parcel-test", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "start": "node bundle.js", + "build": "parcel build index.js --target node --bundle-node-modules --out-file bundle.js --no-source-maps --out-dir ." + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "parcel-bundler": "^1.12.4" + } +} diff --git a/test/bundlers/rollup-test/index.js b/test/bundlers/rollup-test/index.js new file mode 100644 index 000000000..792b4b873 --- /dev/null +++ b/test/bundlers/rollup-test/index.js @@ -0,0 +1,7 @@ +'use strict' + +const { Client } = require('../../../index') +const client = new Client({ node: 'http://localhost:9200' }) +client.info((err, result) => { + process.exit(err ? 1 : 0) +}) diff --git a/test/bundlers/rollup-test/package.json b/test/bundlers/rollup-test/package.json new file mode 100644 index 000000000..7f74a670d --- /dev/null +++ b/test/bundlers/rollup-test/package.json @@ -0,0 +1,19 @@ +{ + "name": "rollup-test", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "start": "node bundle.js", + "build": "rollup -c" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "@rollup/plugin-commonjs": "^15.1.0", + "@rollup/plugin-json": "^4.1.0", + "@rollup/plugin-node-resolve": "^9.0.0", + "rollup": "^2.28.0" + } +} diff --git a/test/bundlers/rollup-test/rollup.config.js b/test/bundlers/rollup-test/rollup.config.js new file mode 100644 index 000000000..55a936824 --- /dev/null +++ b/test/bundlers/rollup-test/rollup.config.js @@ -0,0 +1,13 @@ +import resolve from '@rollup/plugin-node-resolve' +import commonjs from '@rollup/plugin-commonjs' +import json from '@rollup/plugin-json' + +export default { + input: 'index.js', + output: { + file: 'bundle.js', + format: 'iife', + name: 'MyModule' + }, + plugins: [resolve(), commonjs({ include: ['../../../node_modules/**'] }), json()] +} diff --git a/test/bundlers/webpack-test/index.js b/test/bundlers/webpack-test/index.js new file mode 100644 index 000000000..792b4b873 --- /dev/null +++ b/test/bundlers/webpack-test/index.js @@ -0,0 +1,7 @@ +'use strict' + +const { Client } = require('../../../index') +const client = new Client({ node: 'http://localhost:9200' }) +client.info((err, result) => { + process.exit(err ? 1 : 0) +}) diff --git a/test/bundlers/webpack-test/package.json b/test/bundlers/webpack-test/package.json new file mode 100644 index 000000000..12e6b80f6 --- /dev/null +++ b/test/bundlers/webpack-test/package.json @@ -0,0 +1,17 @@ +{ + "name": "webpack-test", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "start": "node bundle.js", + "build": "webpack" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "webpack": "^4.44.2", + "webpack-cli": "^3.3.12" + } +} diff --git a/test/bundlers/webpack-test/webpack.config.js b/test/bundlers/webpack-test/webpack.config.js new file mode 100644 index 000000000..d4da84724 --- /dev/null +++ b/test/bundlers/webpack-test/webpack.config.js @@ -0,0 +1,12 @@ +'use strict' + +const path = require('path') + +module.exports = { + entry: './index.js', + target: 'node', + output: { + filename: 'bundle.js', + path: path.resolve(__dirname) + } +} diff --git a/test/integration/test-runner.js b/test/integration/test-runner.js index 6a7ebcaeb..4ba69b653 100644 --- a/test/integration/test-runner.js +++ b/test/integration/test-runner.js @@ -57,13 +57,19 @@ function build (opts = {}) { stash.clear() try { - await client.indices.deleteAlias({ index: '_all', name: '_all' }, { ignore: 404 }) + await client.indices.deleteAlias({ + index: '_all', + name: '_all' + }, { ignore: [404] }) } catch (err) { assert.ifError(err, 'should not error: indices.deleteAlias') } try { - await client.indices.delete({ index: '_all', expandWildcards: 'all' }, { ignore: 404 }) + await client.indices.delete({ + index: '_all', + expand_wildcards: 'open,closed,hidden' + }, { ignore: [404] }) } catch (err) { assert.ifError(err, 'should not error: indices.delete') } @@ -386,6 +392,7 @@ function build (opts = {}) { } const options = { ignore: cmd.params.ignore, headers: action.headers } + if (!Array.isArray(options.ignore)) options.ignore = [options.ignore] if (cmd.params.ignore) delete cmd.params.ignore const [err, result] = await to(api(cmd.params, options)) diff --git a/test/unit/api.test.js b/test/unit/api.test.js index e75431ad6..f08422221 100644 --- a/test/unit/api.test.js +++ b/test/unit/api.test.js @@ -233,33 +233,6 @@ test('Basic (options and promises)', t => { }) }) -test('Pass unknown parameters as query parameters (and get a warning)', t => { - t.plan(4) - - function handler (req, res) { - t.strictEqual(req.url, '/test/_search?q=foo%3Abar&winter=is%20coming') - res.setHeader('Content-Type', 'application/json;utf=8') - res.end(JSON.stringify({ hello: 'world' })) - } - - buildServer(handler, ({ port }, server) => { - const client = new Client({ - node: `http://localhost:${port}` - }) - - client.search({ - index: 'test', - q: 'foo:bar', - winter: 'is coming' - }, (err, { body, warnings }) => { - t.error(err) - t.deepEqual(body, { hello: 'world' }) - t.deepEqual(warnings, ['Client - Unknown parameter: "winter", sending it as query parameter']) - server.stop() - }) - }) -}) - test('If the API uses the same key for both url and query parameter, the url should win', t => { t.plan(2) diff --git a/test/unit/child.test.js b/test/unit/child.test.js index 110a7e866..2f42131f4 100644 --- a/test/unit/child.test.js +++ b/test/unit/child.test.js @@ -280,3 +280,41 @@ test('Should create a child client (name check)', t => { child.info(t.error) }) }) + +test('Should create a child client (auth check)', t => { + t.plan(4) + + var count = 0 + function handler (req, res) { + if (count++ === 0) { + t.match(req.headers, { authorization: 'Basic Zm9vOmJhcg==' }) + } else { + t.match(req.headers, { authorization: 'ApiKey foobar' }) + } + 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}`, + auth: { + username: 'foo', + password: 'bar' + } + }) + const child = client.child({ + auth: { + apiKey: 'foobar' + } + }) + + client.info((err, res) => { + t.error(err) + child.info((err, res) => { + t.error(err) + server.stop() + }) + }) + }) +}) diff --git a/test/unit/transport.test.js b/test/unit/transport.test.js index 830e45a4a..a46faf572 100644 --- a/test/unit/transport.test.js +++ b/test/unit/transport.test.js @@ -1806,45 +1806,6 @@ test('Warning header', t => { }) }) - t.test('Multiple warnings and external warning', t => { - t.plan(5) - - const warn1 = '112 - "cache down" "Wed, 21 Oct 2015 07:28:00 GMT"' - const warn2 = '199 agent "Error message" "2015-01-01"' - function handler (req, res) { - res.setHeader('Content-Type', 'application/json;utf=8') - res.setHeader('Warning', warn1 + ',' + warn2) - res.end(JSON.stringify({ hello: 'world' })) - } - - buildServer(handler, ({ port }, server) => { - const pool = new ConnectionPool({ Connection }) - pool.addConnection(`http://localhost:${port}`) - - const transport = new Transport({ - emit: () => {}, - connectionPool: pool, - serializer: new Serializer(), - maxRetries: 3, - requestTimeout: 30000, - sniffInterval: false, - sniffOnStart: false - }) - - transport.request({ - method: 'GET', - path: '/hello' - }, { - warnings: ['winter is coming'] - }, (err, { warnings }) => { - t.error(err) - t.deepEqual(warnings, ['winter is coming', warn1, warn2]) - warnings.forEach(w => t.type(w, 'string')) - server.stop() - }) - }) - }) - t.end() })