From 7acd2e3b07285fa8b74672de0a0c0c5fb518aa71 Mon Sep 17 00:00:00 2001 From: Tomas Della Vedova Date: Tue, 29 Jan 2019 12:10:20 +0100 Subject: [PATCH] =?UTF-8?q?Elasticsearch=207=20support=20=F0=9F=9A=80=20(#?= =?UTF-8?q?760)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * API generation * Updated typings * Updated code generation * Updated test * Updated ci configuration * Fixed test --- .ci/docker-compose.yml | 5 +- .ci/test-matrix.yml | 2 +- .travis.yml | 2 +- api/api/bulk.js | 28 +- api/api/cat.aliases.js | 11 +- api/api/cat.allocation.js | 11 +- api/api/cat.count.js | 11 +- api/api/cat.fielddata.js | 11 +- api/api/cat.health.js | 7 +- api/api/cat.help.js | 7 +- api/api/cat.indices.js | 11 +- api/api/cat.master.js | 7 +- api/api/cat.nodeattrs.js | 7 +- api/api/cat.nodes.js | 7 +- api/api/cat.pending_tasks.js | 7 +- api/api/cat.plugins.js | 7 +- api/api/cat.recovery.js | 11 +- api/api/cat.repositories.js | 7 +- api/api/cat.segments.js | 11 +- api/api/cat.shards.js | 11 +- api/api/cat.snapshots.js | 11 +- api/api/cat.tasks.js | 7 +- api/api/cat.templates.js | 11 +- api/api/cat.thread_pool.js | 11 +- api/api/ccr.delete_auto_follow_pattern.js | 7 +- api/api/ccr.follow.js | 7 +- api/api/ccr.follow_stats.js | 7 +- api/api/ccr.get_auto_follow_pattern.js | 11 +- api/api/ccr.pause_follow.js | 7 +- api/api/ccr.put_auto_follow_pattern.js | 7 +- api/api/ccr.resume_follow.js | 7 +- api/api/ccr.stats.js | 7 +- api/api/ccr.unfollow.js | 7 +- api/api/clear_scroll.js | 11 +- api/api/cluster.allocation_explain.js | 7 +- api/api/cluster.get_settings.js | 7 +- api/api/cluster.health.js | 11 +- api/api/cluster.pending_tasks.js | 7 +- api/api/cluster.put_settings.js | 7 +- api/api/cluster.remote_info.js | 7 +- api/api/cluster.reroute.js | 7 +- api/api/cluster.state.js | 19 +- api/api/cluster.stats.js | 13 +- api/api/count.js | 16 +- api/api/create.js | 7 +- api/api/delete.js | 24 +- api/api/delete_by_query.js | 23 +- api/api/delete_by_query_rethrottle.js | 7 +- api/api/delete_script.js | 7 +- api/api/exists.js | 42 +- api/api/exists_source.js | 19 +- api/api/explain.js | 42 +- api/api/field_caps.js | 22 +- api/api/get.js | 36 +- api/api/get_script.js | 7 +- api/api/get_source.js | 19 +- api/api/ilm.delete_lifecycle.js | 104 ++ api/api/ilm.explain_lifecycle.js | 105 ++ api/api/ilm.get_lifecycle.js | 108 ++ api/api/ilm.get_status.js | 103 ++ api/api/ilm.move_to_step.js | 97 ++ api/api/ilm.put_lifecycle.js | 97 ++ api/api/ilm.remove_policy.js | 104 ++ api/api/ilm.retry.js | 104 ++ ...{xpack.watcher.restart.js => ilm.start.js} | 17 +- api/api/ilm.stop.js | 103 ++ api/api/index.js | 28 +- api/api/indices.analyze.js | 11 +- api/api/indices.clear_cache.js | 19 +- api/api/indices.close.js | 7 +- api/api/indices.create.js | 13 +- api/api/indices.delete.js | 7 +- api/api/indices.delete_alias.js | 13 +- api/api/indices.delete_template.js | 7 +- api/api/indices.exists.js | 7 +- api/api/indices.exists_alias.js | 11 +- api/api/indices.exists_template.js | 7 +- api/api/indices.exists_type.js | 7 +- api/api/indices.flush.js | 11 +- api/api/indices.flush_synced.js | 11 +- api/api/indices.forcemerge.js | 11 +- api/api/indices.freeze.js | 126 +++ api/api/indices.get.js | 7 +- api/api/indices.get_alias.js | 15 +- api/api/indices.get_field_mapping.js | 15 +- api/api/indices.get_mapping.js | 18 +- api/api/indices.get_settings.js | 15 +- api/api/indices.get_template.js | 11 +- api/api/indices.get_upgrade.js | 11 +- api/api/indices.open.js | 7 +- api/api/indices.put_alias.js | 13 +- api/api/indices.put_mapping.js | 35 +- api/api/indices.put_settings.js | 11 +- api/api/indices.put_template.js | 7 +- api/api/indices.recovery.js | 11 +- api/api/indices.refresh.js | 11 +- api/api/indices.rollover.js | 11 +- api/api/indices.segments.js | 11 +- api/api/indices.shard_stores.js | 11 +- api/api/indices.shrink.js | 7 +- api/api/indices.split.js | 7 +- api/api/indices.stats.js | 15 +- api/api/indices.unfreeze.js | 126 +++ api/api/indices.update_aliases.js | 7 +- api/api/indices.upgrade.js | 11 +- api/api/indices.validate_query.js | 13 +- api/api/info.js | 7 +- api/api/ingest.delete_pipeline.js | 7 +- api/api/ingest.get_pipeline.js | 11 +- api/api/ingest.processor_grok.js | 7 +- api/api/ingest.put_pipeline.js | 7 +- api/api/ingest.simulate.js | 11 +- api/api/mget.js | 25 +- ...{xpack.ml.close_job.js => ml.close_job.js} | 17 +- ...lete_calendar.js => ml.delete_calendar.js} | 17 +- ...r_event.js => ml.delete_calendar_event.js} | 17 +- ...endar_job.js => ml.delete_calendar_job.js} | 17 +- ...lete_datafeed.js => ml.delete_datafeed.js} | 17 +- ...ired_data.js => ml.delete_expired_data.js} | 17 +- ...l.delete_filter.js => ml.delete_filter.js} | 17 +- ...lete_forecast.js => ml.delete_forecast.js} | 21 +- ...pack.ml.delete_job.js => ml.delete_job.js} | 17 +- ...napshot.js => ml.delete_model_snapshot.js} | 17 +- ...structure.js => ml.find_file_structure.js} | 17 +- ...{xpack.ml.flush_job.js => ml.flush_job.js} | 17 +- .../{xpack.ml.forecast.js => ml.forecast.js} | 17 +- ...ck.ml.get_buckets.js => ml.get_buckets.js} | 21 +- ...ar_events.js => ml.get_calendar_events.js} | 17 +- ...l.get_calendars.js => ml.get_calendars.js} | 21 +- ...get_categories.js => ml.get_categories.js} | 23 +- ...feed_stats.js => ml.get_datafeed_stats.js} | 21 +- ...l.get_datafeeds.js => ml.get_datafeeds.js} | 21 +- ...ck.ml.get_filters.js => ml.get_filters.js} | 21 +- ...t_influencers.js => ml.get_influencers.js} | 17 +- ...l.get_job_stats.js => ml.get_job_stats.js} | 21 +- .../{xpack.ml.get_jobs.js => ml.get_jobs.js} | 21 +- ...snapshots.js => ml.get_model_snapshots.js} | 21 +- ...l_buckets.js => ml.get_overall_buckets.js} | 17 +- ...ck.ml.get_records.js => ml.get_records.js} | 17 +- api/api/{xpack.ml.info.js => ml.info.js} | 17 +- .../{xpack.ml.open_job.js => ml.open_job.js} | 17 +- ...r_events.js => ml.post_calendar_events.js} | 17 +- ...{xpack.ml.post_data.js => ml.post_data.js} | 17 +- ...iew_datafeed.js => ml.preview_datafeed.js} | 17 +- ....ml.put_calendar.js => ml.put_calendar.js} | 17 +- ...calendar_job.js => ml.put_calendar_job.js} | 17 +- ....ml.put_datafeed.js => ml.put_datafeed.js} | 17 +- ...pack.ml.put_filter.js => ml.put_filter.js} | 17 +- .../{xpack.ml.put_job.js => ml.put_job.js} | 17 +- ...napshot.js => ml.revert_model_snapshot.js} | 17 +- ...start_datafeed.js => ml.start_datafeed.js} | 17 +- ...l.stop_datafeed.js => ml.stop_datafeed.js} | 17 +- ...date_datafeed.js => ml.update_datafeed.js} | 17 +- ...l.update_filter.js => ml.update_filter.js} | 17 +- ...pack.ml.update_job.js => ml.update_job.js} | 17 +- ...napshot.js => ml.update_model_snapshot.js} | 17 +- .../{xpack.ml.validate.js => ml.validate.js} | 17 +- ...te_detector.js => ml.validate_detector.js} | 17 +- ....monitoring.bulk.js => monitoring.bulk.js} | 21 +- api/api/msearch.js | 16 +- api/api/msearch_template.js | 16 +- api/api/mtermvectors.js | 13 +- api/api/nodes.hot_threads.js | 19 +- api/api/nodes.info.js | 15 +- api/api/nodes.reload_secure_settings.js | 13 +- api/api/nodes.stats.js | 19 +- api/api/nodes.usage.js | 15 +- api/api/ping.js | 7 +- api/api/put_script.js | 11 +- api/api/rank_eval.js | 11 +- api/api/reindex.js | 7 +- api/api/reindex_rethrottle.js | 7 +- api/api/render_search_template.js | 11 +- api/api/scripts_painless_execute.js | 7 +- api/api/scroll.js | 14 +- api/api/search.js | 33 +- api/api/search_shards.js | 11 +- api/api/search_template.js | 19 +- ...rtificates.js => security.authenticate.js} | 17 +- ...assword.js => security.change_password.js} | 21 +- ...lms.js => security.clear_cached_realms.js} | 17 +- ...oles.js => security.clear_cached_roles.js} | 17 +- ...leges.js => security.delete_privileges.js} | 17 +- ...delete_role.js => security.delete_role.js} | 17 +- ...ing.js => security.delete_role_mapping.js} | 17 +- ...delete_user.js => security.delete_user.js} | 17 +- ...sable_user.js => security.disable_user.js} | 17 +- ...enable_user.js => security.enable_user.js} | 17 +- ...ivileges.js => security.get_privileges.js} | 17 +- ...urity.get_role.js => security.get_role.js} | 21 +- ...apping.js => security.get_role_mapping.js} | 21 +- ...ity.get_token.js => security.get_token.js} | 17 +- ...urity.get_user.js => security.get_user.js} | 21 +- ...ate.js => security.get_user_privileges.js} | 17 +- ...ivileges.js => security.has_privileges.js} | 21 +- ..._token.js => security.invalidate_token.js} | 17 +- ...ivileges.js => security.put_privileges.js} | 17 +- ...urity.put_role.js => security.put_role.js} | 17 +- ...apping.js => security.put_role_mapping.js} | 17 +- ...urity.put_user.js => security.put_user.js} | 17 +- api/api/snapshot.create.js | 7 +- api/api/snapshot.create_repository.js | 7 +- api/api/snapshot.delete.js | 7 +- api/api/snapshot.delete_repository.js | 7 +- api/api/snapshot.get.js | 7 +- api/api/snapshot.get_repository.js | 11 +- api/api/snapshot.restore.js | 7 +- api/api/snapshot.status.js | 13 +- api/api/snapshot.verify_repository.js | 7 +- api/api/ssl.certificates.js | 103 ++ api/api/tasks.cancel.js | 11 +- api/api/tasks.get.js | 7 +- api/api/tasks.list.js | 7 +- api/api/termvectors.js | 34 +- api/api/update.js | 45 +- api/api/update_by_query.js | 23 +- api/api/update_by_query_rethrottle.js | 7 +- api/api/xpack.graph.explore.js | 11 +- api/api/xpack.info.js | 7 +- api/api/xpack.license.delete.js | 7 +- api/api/xpack.license.get.js | 7 +- api/api/xpack.license.get_basic_status.js | 7 +- api/api/xpack.license.get_trial_status.js | 7 +- api/api/xpack.license.post.js | 7 +- api/api/xpack.license.post_start_basic.js | 7 +- api/api/xpack.license.post_start_trial.js | 7 +- api/api/xpack.migration.deprecations.js | 11 +- api/api/xpack.migration.get_assistance.js | 11 +- api/api/xpack.migration.upgrade.js | 7 +- api/api/xpack.rollup.delete_job.js | 7 +- api/api/xpack.rollup.get_jobs.js | 11 +- api/api/xpack.rollup.get_rollup_caps.js | 11 +- api/api/xpack.rollup.get_rollup_index_caps.js | 7 +- api/api/xpack.rollup.put_job.js | 7 +- api/api/xpack.rollup.rollup_search.js | 21 +- api/api/xpack.rollup.start_job.js | 7 +- api/api/xpack.rollup.stop_job.js | 15 +- api/api/xpack.security.get_user_privileges.js | 100 -- api/api/xpack.sql.clear_cursor.js | 7 +- api/api/xpack.sql.query.js | 7 +- api/api/xpack.sql.translate.js | 7 +- api/api/xpack.usage.js | 7 +- api/api/xpack.watcher.ack_watch.js | 16 +- api/api/xpack.watcher.activate_watch.js | 12 +- api/api/xpack.watcher.deactivate_watch.js | 12 +- api/api/xpack.watcher.delete_watch.js | 12 +- api/api/xpack.watcher.execute_watch.js | 11 +- api/api/xpack.watcher.get_watch.js | 7 +- api/api/xpack.watcher.put_watch.js | 10 +- api/api/xpack.watcher.start.js | 7 +- api/api/xpack.watcher.stats.js | 11 +- api/api/xpack.watcher.stop.js | 7 +- api/index.js | 302 +++--- api/requestParams.d.ts | 982 ++++++++++-------- index.d.ts | 302 +++--- scripts/es-docker.sh | 4 +- scripts/utils/generate.js | 155 ++- test/integration/index.js | 26 +- test/unit/connection.test.js | 2 +- 259 files changed, 4368 insertions(+), 1990 deletions(-) create mode 100644 api/api/ilm.delete_lifecycle.js create mode 100644 api/api/ilm.explain_lifecycle.js create mode 100644 api/api/ilm.get_lifecycle.js create mode 100644 api/api/ilm.get_status.js create mode 100644 api/api/ilm.move_to_step.js create mode 100644 api/api/ilm.put_lifecycle.js create mode 100644 api/api/ilm.remove_policy.js create mode 100644 api/api/ilm.retry.js rename api/api/{xpack.watcher.restart.js => ilm.start.js} (82%) create mode 100644 api/api/ilm.stop.js create mode 100644 api/api/indices.freeze.js create mode 100644 api/api/indices.unfreeze.js rename api/api/{xpack.ml.close_job.js => ml.close_job.js} (84%) rename api/api/{xpack.ml.delete_calendar.js => ml.delete_calendar.js} (84%) rename api/api/{xpack.ml.delete_calendar_event.js => ml.delete_calendar_event.js} (85%) rename api/api/{xpack.ml.delete_calendar_job.js => ml.delete_calendar_job.js} (85%) rename api/api/{xpack.ml.delete_datafeed.js => ml.delete_datafeed.js} (82%) rename api/api/{xpack.ml.delete_expired_data.js => ml.delete_expired_data.js} (83%) rename api/api/{xpack.ml.delete_filter.js => ml.delete_filter.js} (84%) rename api/api/{xpack.ml.delete_forecast.js => ml.delete_forecast.js} (78%) rename api/api/{xpack.ml.delete_job.js => ml.delete_job.js} (84%) rename api/api/{xpack.ml.delete_model_snapshot.js => ml.delete_model_snapshot.js} (82%) rename api/api/{xpack.ml.find_file_structure.js => ml.find_file_structure.js} (89%) rename api/api/{xpack.ml.flush_job.js => ml.flush_job.js} (86%) rename api/api/{xpack.ml.forecast.js => ml.forecast.js} (86%) rename api/api/{xpack.ml.get_buckets.js => ml.get_buckets.js} (81%) rename api/api/{xpack.ml.get_calendar_events.js => ml.get_calendar_events.js} (86%) rename api/api/{xpack.ml.get_calendars.js => ml.get_calendars.js} (82%) rename api/api/{xpack.ml.get_categories.js => ml.get_categories.js} (75%) rename api/api/{xpack.ml.get_datafeed_stats.js => ml.get_datafeed_stats.js} (78%) rename api/api/{xpack.ml.get_datafeeds.js => ml.get_datafeeds.js} (80%) rename api/api/{xpack.ml.get_filters.js => ml.get_filters.js} (82%) rename api/api/{xpack.ml.get_influencers.js => ml.get_influencers.js} (85%) rename api/api/{xpack.ml.get_job_stats.js => ml.get_job_stats.js} (79%) rename api/api/{xpack.ml.get_jobs.js => ml.get_jobs.js} (81%) rename api/api/{xpack.ml.get_model_snapshots.js => ml.get_model_snapshots.js} (79%) rename api/api/{xpack.ml.get_overall_buckets.js => ml.get_overall_buckets.js} (85%) rename api/api/{xpack.ml.get_records.js => ml.get_records.js} (85%) rename api/api/{xpack.ml.info.js => ml.info.js} (85%) rename api/api/{xpack.ml.open_job.js => ml.open_job.js} (84%) rename api/api/{xpack.ml.post_calendar_events.js => ml.post_calendar_events.js} (83%) rename api/api/{xpack.ml.post_data.js => ml.post_data.js} (84%) rename api/api/{xpack.ml.preview_datafeed.js => ml.preview_datafeed.js} (81%) rename api/api/{xpack.ml.put_calendar.js => ml.put_calendar.js} (84%) rename api/api/{xpack.ml.put_calendar_job.js => ml.put_calendar_job.js} (85%) rename api/api/{xpack.ml.put_datafeed.js => ml.put_datafeed.js} (83%) rename api/api/{xpack.ml.put_filter.js => ml.put_filter.js} (85%) rename api/api/{xpack.ml.put_job.js => ml.put_job.js} (83%) rename api/api/{xpack.ml.revert_model_snapshot.js => ml.revert_model_snapshot.js} (83%) rename api/api/{xpack.ml.start_datafeed.js => ml.start_datafeed.js} (83%) rename api/api/{xpack.ml.stop_datafeed.js => ml.stop_datafeed.js} (84%) rename api/api/{xpack.ml.update_datafeed.js => ml.update_datafeed.js} (82%) rename api/api/{xpack.ml.update_filter.js => ml.update_filter.js} (84%) rename api/api/{xpack.ml.update_job.js => ml.update_job.js} (83%) rename api/api/{xpack.ml.update_model_snapshot.js => ml.update_model_snapshot.js} (83%) rename api/api/{xpack.ml.validate.js => ml.validate.js} (85%) rename api/api/{xpack.ml.validate_detector.js => ml.validate_detector.js} (83%) rename api/api/{xpack.monitoring.bulk.js => monitoring.bulk.js} (83%) rename api/api/{xpack.ssl.certificates.js => security.authenticate.js} (82%) rename api/api/{xpack.security.change_password.js => security.change_password.js} (80%) rename api/api/{xpack.security.clear_cached_realms.js => security.clear_cached_realms.js} (81%) rename api/api/{xpack.security.clear_cached_roles.js => security.clear_cached_roles.js} (80%) rename api/api/{xpack.security.delete_privileges.js => security.delete_privileges.js} (86%) rename api/api/{xpack.security.delete_role.js => security.delete_role.js} (83%) rename api/api/{xpack.security.delete_role_mapping.js => security.delete_role_mapping.js} (82%) rename api/api/{xpack.security.delete_user.js => security.delete_user.js} (83%) rename api/api/{xpack.security.disable_user.js => security.disable_user.js} (82%) rename api/api/{xpack.security.enable_user.js => security.enable_user.js} (82%) rename api/api/{xpack.security.get_privileges.js => security.get_privileges.js} (84%) rename api/api/{xpack.security.get_role.js => security.get_role.js} (80%) rename api/api/{xpack.security.get_role_mapping.js => security.get_role_mapping.js} (78%) rename api/api/{xpack.security.get_token.js => security.get_token.js} (81%) rename api/api/{xpack.security.get_user.js => security.get_user.js} (80%) rename api/api/{xpack.security.authenticate.js => security.get_user_privileges.js} (81%) rename api/api/{xpack.security.has_privileges.js => security.has_privileges.js} (78%) rename api/api/{xpack.security.invalidate_token.js => security.invalidate_token.js} (80%) rename api/api/{xpack.security.put_privileges.js => security.put_privileges.js} (85%) rename api/api/{xpack.security.put_role.js => security.put_role.js} (84%) rename api/api/{xpack.security.put_role_mapping.js => security.put_role_mapping.js} (83%) rename api/api/{xpack.security.put_user.js => security.put_user.js} (84%) create mode 100644 api/api/ssl.certificates.js delete mode 100644 api/api/xpack.security.get_user_privileges.js diff --git a/.ci/docker-compose.yml b/.ci/docker-compose.yml index 5176c6440..17b4a4797 100644 --- a/.ci/docker-compose.yml +++ b/.ci/docker-compose.yml @@ -20,7 +20,7 @@ services: depends_on: - elasticsearch elasticsearch: - image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-6.5.0} + image: docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-7.0.0-alpha2} volumes: - esvol:/tmp networks: @@ -30,7 +30,8 @@ services: - "repositories.url.allowed_urls=http://*" - node.attr.testattr=test - bootstrap.memory_lock=false - - "discovery.zen.ping.unicast.hosts=elasticsearch" + # - "discovery.zen.ping.unicast.hosts=elasticsearch" + - "discovery.type=single-node" - "http.max_content_length=5mb" networks: esnet: diff --git a/.ci/test-matrix.yml b/.ci/test-matrix.yml index 6625ffaac..78f9ccd21 100644 --- a/.ci/test-matrix.yml +++ b/.ci/test-matrix.yml @@ -1,6 +1,6 @@ --- ELASTICSEARCH_VERSION: -- 6.5.0 +- 7.0.0-alpha2 NODE_JS_VERSION: - 10 diff --git a/.travis.yml b/.travis.yml index 743820f04..a37514d99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ node_js: env: global: - - ELASTICSEARCH_VERSION=6.5.0 + - ELASTICSEARCH_VERSION=7.0.0-alpha2 - QUIET=true before_install: diff --git a/api/api/bulk.js b/api/api/bulk.js index 45165b1c2..9a310438a 100644 --- a/api/api/bulk.js +++ b/api/api/bulk.js @@ -13,10 +13,9 @@ function buildBulk (opts) { * @param {string} routing - Specific routing value * @param {time} timeout - Explicit operation timeout * @param {string} type - Default document type for items which don't provide one - * @param {list} fields - Default comma-separated list of fields to return in the response for updates, can be overridden on each sub-request * @param {list} _source - True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request - * @param {list} _source_exclude - Default list of fields to exclude from the returned _source field, can be overridden on each sub-request - * @param {list} _source_include - Default list of fields to extract and return from the _source field, can be overridden on each sub-request + * @param {list} _source_excludes - Default list of fields to exclude from the returned _source field, can be overridden on each sub-request + * @param {list} _source_includes - Default list of fields to extract and return from the _source field, can be overridden on each sub-request * @param {string} pipeline - The pipeline id to preprocess incoming documents with * @param {object} body - The operation definition and data (action-data pairs), separated by newlines */ @@ -65,10 +64,9 @@ function buildBulk (opts) { 'routing', 'timeout', 'type', - 'fields', '_source', - '_source_exclude', - '_source_include', + '_source_excludes', + '_source_includes', 'pipeline', 'pretty', 'human', @@ -82,10 +80,9 @@ function buildBulk (opts) { 'routing', 'timeout', 'type', - 'fields', '_source', - '_sourceExclude', - '_sourceInclude', + '_sourceExcludes', + '_sourceIncludes', 'pipeline', 'pretty', 'human', @@ -125,11 +122,20 @@ function buildBulk (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_bulk' + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_bulk' + } else { + path = '/' + '_bulk' + } + // build request object - const parts = [params['index'], params['type'], '_bulk'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, bulkBody: params.body, querystring } diff --git a/api/api/cat.aliases.js b/api/api/cat.aliases.js index 5a55df2a2..44a925878 100644 --- a/api/api/cat.aliases.js +++ b/api/api/cat.aliases.js @@ -106,11 +106,18 @@ function buildCatAliases (opts) { ignore = [ignore] } + var path = '' + + if ((params['name']) != null) { + path = '/' + '_cat' + '/' + 'aliases' + '/' + encodeURIComponent(params['name']) + } else { + path = '/' + '_cat' + '/' + 'aliases' + } + // build request object - const parts = ['_cat', 'aliases', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.allocation.js b/api/api/cat.allocation.js index 71e73aa9c..483da3e42 100644 --- a/api/api/cat.allocation.js +++ b/api/api/cat.allocation.js @@ -109,11 +109,18 @@ function buildCatAllocation (opts) { ignore = [ignore] } + var path = '' + + if ((params['node_id'] || params['nodeId']) != null) { + path = '/' + '_cat' + '/' + 'allocation' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + } else { + path = '/' + '_cat' + '/' + 'allocation' + } + // build request object - const parts = ['_cat', 'allocation', params['node_id'] || params['nodeId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.count.js b/api/api/cat.count.js index 31d497340..351f119d2 100644 --- a/api/api/cat.count.js +++ b/api/api/cat.count.js @@ -106,11 +106,18 @@ function buildCatCount (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + '_cat' + '/' + 'count' + '/' + encodeURIComponent(params['index']) + } else { + path = '/' + '_cat' + '/' + 'count' + } + // build request object - const parts = ['_cat', 'count', params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.fielddata.js b/api/api/cat.fielddata.js index 0a6cc1d59..484467085 100644 --- a/api/api/cat.fielddata.js +++ b/api/api/cat.fielddata.js @@ -112,11 +112,18 @@ function buildCatFielddata (opts) { ignore = [ignore] } + var path = '' + + if ((params['fields']) != null) { + path = '/' + '_cat' + '/' + 'fielddata' + '/' + encodeURIComponent(params['fields']) + } else { + path = '/' + '_cat' + '/' + 'fielddata' + } + // build request object - const parts = ['_cat', 'fielddata', params['fields']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.health.js b/api/api/cat.health.js index fbb4c5946..a22eeef1b 100644 --- a/api/api/cat.health.js +++ b/api/api/cat.health.js @@ -108,11 +108,14 @@ function buildCatHealth (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cat' + '/' + 'health' + // build request object - const parts = ['_cat', 'health'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.help.js b/api/api/cat.help.js index 6b671f2b2..55838067e 100644 --- a/api/api/cat.help.js +++ b/api/api/cat.help.js @@ -90,11 +90,14 @@ function buildCatHelp (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cat' + // build request object - const parts = ['_cat'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.indices.js b/api/api/cat.indices.js index 0b0370fbb..7f4231376 100644 --- a/api/api/cat.indices.js +++ b/api/api/cat.indices.js @@ -115,11 +115,18 @@ function buildCatIndices (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + '_cat' + '/' + 'indices' + '/' + encodeURIComponent(params['index']) + } else { + path = '/' + '_cat' + '/' + 'indices' + } + // build request object - const parts = ['_cat', 'indices', params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.master.js b/api/api/cat.master.js index a313a0c6e..c7474c209 100644 --- a/api/api/cat.master.js +++ b/api/api/cat.master.js @@ -105,11 +105,14 @@ function buildCatMaster (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cat' + '/' + 'master' + // build request object - const parts = ['_cat', 'master'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.nodeattrs.js b/api/api/cat.nodeattrs.js index 31234406e..1b491a9b6 100644 --- a/api/api/cat.nodeattrs.js +++ b/api/api/cat.nodeattrs.js @@ -105,11 +105,14 @@ function buildCatNodeattrs (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cat' + '/' + 'nodeattrs' + // build request object - const parts = ['_cat', 'nodeattrs'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.nodes.js b/api/api/cat.nodes.js index 4785a9e93..8191197c6 100644 --- a/api/api/cat.nodes.js +++ b/api/api/cat.nodes.js @@ -108,11 +108,14 @@ function buildCatNodes (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cat' + '/' + 'nodes' + // build request object - const parts = ['_cat', 'nodes'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.pending_tasks.js b/api/api/cat.pending_tasks.js index bd355ebef..755c78feb 100644 --- a/api/api/cat.pending_tasks.js +++ b/api/api/cat.pending_tasks.js @@ -105,11 +105,14 @@ function buildCatPendingTasks (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cat' + '/' + 'pending_tasks' + // build request object - const parts = ['_cat', 'pending_tasks'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.plugins.js b/api/api/cat.plugins.js index eaf9874a1..2cfd47dd5 100644 --- a/api/api/cat.plugins.js +++ b/api/api/cat.plugins.js @@ -105,11 +105,14 @@ function buildCatPlugins (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cat' + '/' + 'plugins' + // build request object - const parts = ['_cat', 'plugins'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.recovery.js b/api/api/cat.recovery.js index c453e4703..204bffe54 100644 --- a/api/api/cat.recovery.js +++ b/api/api/cat.recovery.js @@ -106,11 +106,18 @@ function buildCatRecovery (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + '_cat' + '/' + 'recovery' + '/' + encodeURIComponent(params['index']) + } else { + path = '/' + '_cat' + '/' + 'recovery' + } + // build request object - const parts = ['_cat', 'recovery', params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.repositories.js b/api/api/cat.repositories.js index f022ca815..6b2f01746 100644 --- a/api/api/cat.repositories.js +++ b/api/api/cat.repositories.js @@ -105,11 +105,14 @@ function buildCatRepositories (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cat' + '/' + 'repositories' + // build request object - const parts = ['_cat', 'repositories'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.segments.js b/api/api/cat.segments.js index 6075d045e..2a502db05 100644 --- a/api/api/cat.segments.js +++ b/api/api/cat.segments.js @@ -103,11 +103,18 @@ function buildCatSegments (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + '_cat' + '/' + 'segments' + '/' + encodeURIComponent(params['index']) + } else { + path = '/' + '_cat' + '/' + 'segments' + } + // build request object - const parts = ['_cat', 'segments', params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.shards.js b/api/api/cat.shards.js index dc2cd6cb8..c9cecbdee 100644 --- a/api/api/cat.shards.js +++ b/api/api/cat.shards.js @@ -109,11 +109,18 @@ function buildCatShards (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + '_cat' + '/' + 'shards' + '/' + encodeURIComponent(params['index']) + } else { + path = '/' + '_cat' + '/' + 'shards' + } + // build request object - const parts = ['_cat', 'shards', params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.snapshots.js b/api/api/cat.snapshots.js index 4d192d79c..1a36c6994 100644 --- a/api/api/cat.snapshots.js +++ b/api/api/cat.snapshots.js @@ -106,11 +106,18 @@ function buildCatSnapshots (opts) { ignore = [ignore] } + var path = '' + + if ((params['repository']) != null) { + path = '/' + '_cat' + '/' + 'snapshots' + '/' + encodeURIComponent(params['repository']) + } else { + path = '/' + '_cat' + '/' + 'snapshots' + } + // build request object - const parts = ['_cat', 'snapshots', params['repository']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.tasks.js b/api/api/cat.tasks.js index 9546b0166..b51c5d0e5 100644 --- a/api/api/cat.tasks.js +++ b/api/api/cat.tasks.js @@ -111,11 +111,14 @@ function buildCatTasks (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cat' + '/' + 'tasks' + // build request object - const parts = ['_cat', 'tasks'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.templates.js b/api/api/cat.templates.js index ce2ffbd18..1fbcf3549 100644 --- a/api/api/cat.templates.js +++ b/api/api/cat.templates.js @@ -106,11 +106,18 @@ function buildCatTemplates (opts) { ignore = [ignore] } + var path = '' + + if ((params['name']) != null) { + path = '/' + '_cat' + '/' + 'templates' + '/' + encodeURIComponent(params['name']) + } else { + path = '/' + '_cat' + '/' + 'templates' + } + // build request object - const parts = ['_cat', 'templates', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cat.thread_pool.js b/api/api/cat.thread_pool.js index edba83157..c32c15d5e 100644 --- a/api/api/cat.thread_pool.js +++ b/api/api/cat.thread_pool.js @@ -109,11 +109,18 @@ function buildCatThreadPool (opts) { ignore = [ignore] } + var path = '' + + if ((params['thread_pool_patterns'] || params['threadPoolPatterns']) != null) { + path = '/' + '_cat' + '/' + 'thread_pool' + '/' + encodeURIComponent(params['thread_pool_patterns'] || params['threadPoolPatterns']) + } else { + path = '/' + '_cat' + '/' + 'thread_pool' + } + // build request object - const parts = ['_cat', 'thread_pool', params['thread_pool_patterns'] || params['threadPoolPatterns']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/ccr.delete_auto_follow_pattern.js b/api/api/ccr.delete_auto_follow_pattern.js index d676aa96a..83f4f279b 100644 --- a/api/api/ccr.delete_auto_follow_pattern.js +++ b/api/api/ccr.delete_auto_follow_pattern.js @@ -77,11 +77,14 @@ function buildCcrDeleteAutoFollowPattern (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_ccr', 'auto_follow', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/ccr.follow.js b/api/api/ccr.follow.js index 344e12a83..2ac210f45 100644 --- a/api/api/ccr.follow.js +++ b/api/api/ccr.follow.js @@ -84,11 +84,14 @@ function buildCcrFollow (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_ccr' + '/' + 'follow' + // build request object - const parts = [params['index'], '_ccr', 'follow'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/ccr.follow_stats.js b/api/api/ccr.follow_stats.js index a073af9fc..f095eb271 100644 --- a/api/api/ccr.follow_stats.js +++ b/api/api/ccr.follow_stats.js @@ -69,11 +69,14 @@ function buildCcrFollowStats (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_ccr' + '/' + 'stats' + // build request object - const parts = [params['index'], '_ccr', 'stats'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/ccr.get_auto_follow_pattern.js b/api/api/ccr.get_auto_follow_pattern.js index e0b15f89e..ee2f82606 100644 --- a/api/api/ccr.get_auto_follow_pattern.js +++ b/api/api/ccr.get_auto_follow_pattern.js @@ -69,11 +69,18 @@ function buildCcrGetAutoFollowPattern (opts) { ignore = [ignore] } + var path = '' + + if ((params['name']) != null) { + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(params['name']) + } else { + path = '/' + '_ccr' + '/' + 'auto_follow' + } + // build request object - const parts = ['_ccr', 'auto_follow', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/ccr.pause_follow.js b/api/api/ccr.pause_follow.js index e0f646809..2b79f162e 100644 --- a/api/api/ccr.pause_follow.js +++ b/api/api/ccr.pause_follow.js @@ -77,11 +77,14 @@ function buildCcrPauseFollow (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_ccr' + '/' + 'pause_follow' + // build request object - const parts = [params['index'], '_ccr', 'pause_follow'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/ccr.put_auto_follow_pattern.js b/api/api/ccr.put_auto_follow_pattern.js index 766a24d9e..49ae7ff06 100644 --- a/api/api/ccr.put_auto_follow_pattern.js +++ b/api/api/ccr.put_auto_follow_pattern.js @@ -84,11 +84,14 @@ function buildCcrPutAutoFollowPattern (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_ccr', 'auto_follow', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/ccr.resume_follow.js b/api/api/ccr.resume_follow.js index 989e04e1a..7ee6ba6c5 100644 --- a/api/api/ccr.resume_follow.js +++ b/api/api/ccr.resume_follow.js @@ -84,11 +84,14 @@ function buildCcrResumeFollow (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_ccr' + '/' + 'resume_follow' + // build request object - const parts = [params['index'], '_ccr', 'resume_follow'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/ccr.stats.js b/api/api/ccr.stats.js index 786a130cb..00e94ea6d 100644 --- a/api/api/ccr.stats.js +++ b/api/api/ccr.stats.js @@ -68,11 +68,14 @@ function buildCcrStats (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ccr' + '/' + 'stats' + // build request object - const parts = ['_ccr', 'stats'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/ccr.unfollow.js b/api/api/ccr.unfollow.js index 92f192de4..bd810eaa9 100644 --- a/api/api/ccr.unfollow.js +++ b/api/api/ccr.unfollow.js @@ -77,11 +77,14 @@ function buildCcrUnfollow (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_ccr' + '/' + 'unfollow' + // build request object - const parts = [params['index'], '_ccr', 'unfollow'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/clear_scroll.js b/api/api/clear_scroll.js index 439a07481..229df18d6 100644 --- a/api/api/clear_scroll.js +++ b/api/api/clear_scroll.js @@ -78,11 +78,18 @@ function buildClearScroll (opts) { ignore = [ignore] } + var path = '' + + if ((params['scroll_id'] || params['scrollId']) != null) { + path = '/' + '_search' + '/' + 'scroll' + '/' + encodeURIComponent(params['scroll_id'] || params['scrollId']) + } else { + path = '/' + '_search' + '/' + 'scroll' + } + // build request object - const parts = ['_search', 'scroll', params['scroll_id'] || params['scrollId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/cluster.allocation_explain.js b/api/api/cluster.allocation_explain.js index 799658e2a..c7cecff23 100644 --- a/api/api/cluster.allocation_explain.js +++ b/api/api/cluster.allocation_explain.js @@ -83,11 +83,14 @@ function buildClusterAllocationExplain (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cluster' + '/' + 'allocation' + '/' + 'explain' + // build request object - const parts = ['_cluster', 'allocation', 'explain'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/cluster.get_settings.js b/api/api/cluster.get_settings.js index 8897c47c7..dd35c7343 100644 --- a/api/api/cluster.get_settings.js +++ b/api/api/cluster.get_settings.js @@ -96,11 +96,14 @@ function buildClusterGetSettings (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cluster' + '/' + 'settings' + // build request object - const parts = ['_cluster', 'settings'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cluster.health.js b/api/api/cluster.health.js index 018a91159..9fce75525 100644 --- a/api/api/cluster.health.js +++ b/api/api/cluster.health.js @@ -115,11 +115,18 @@ function buildClusterHealth (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + '_cluster' + '/' + 'health' + '/' + encodeURIComponent(params['index']) + } else { + path = '/' + '_cluster' + '/' + 'health' + } + // build request object - const parts = ['_cluster', 'health', params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cluster.pending_tasks.js b/api/api/cluster.pending_tasks.js index 2310d4313..afcaafe78 100644 --- a/api/api/cluster.pending_tasks.js +++ b/api/api/cluster.pending_tasks.js @@ -90,11 +90,14 @@ function buildClusterPendingTasks (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cluster' + '/' + 'pending_tasks' + // build request object - const parts = ['_cluster', 'pending_tasks'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cluster.put_settings.js b/api/api/cluster.put_settings.js index a5b5edc1b..74edae830 100644 --- a/api/api/cluster.put_settings.js +++ b/api/api/cluster.put_settings.js @@ -94,11 +94,14 @@ function buildClusterPutSettings (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cluster' + '/' + 'settings' + // build request object - const parts = ['_cluster', 'settings'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/cluster.remote_info.js b/api/api/cluster.remote_info.js index 89eb5a8c2..97ba00e6b 100644 --- a/api/api/cluster.remote_info.js +++ b/api/api/cluster.remote_info.js @@ -84,11 +84,14 @@ function buildClusterRemoteInfo (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_remote' + '/' + 'info' + // build request object - const parts = ['_remote', 'info'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cluster.reroute.js b/api/api/cluster.reroute.js index 3749abcde..f4f114305 100644 --- a/api/api/cluster.reroute.js +++ b/api/api/cluster.reroute.js @@ -95,11 +95,14 @@ function buildClusterReroute (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_cluster' + '/' + 'reroute' + // build request object - const parts = ['_cluster', 'reroute'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/cluster.state.js b/api/api/cluster.state.js index e749f4a17..70e1307ec 100644 --- a/api/api/cluster.state.js +++ b/api/api/cluster.state.js @@ -11,6 +11,8 @@ function buildClusterState (opts) { * @param {boolean} local - Return local information, do not retrieve the state from master node (default: false) * @param {time} master_timeout - Specify timeout for connection to master * @param {boolean} flat_settings - Return settings in flat format (default: false) + * @param {number} wait_for_metadata_version - Wait for the metadata version to be equal or greater than the specified metadata version + * @param {time} wait_for_timeout - The maximum time to wait for wait_for_metadata_version before timing out * @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) * @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. @@ -58,6 +60,8 @@ function buildClusterState (opts) { 'local', 'master_timeout', 'flat_settings', + 'wait_for_metadata_version', + 'wait_for_timeout', 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', @@ -71,6 +75,8 @@ function buildClusterState (opts) { 'local', 'masterTimeout', 'flatSettings', + 'waitForMetadataVersion', + 'waitForTimeout', 'ignoreUnavailable', 'allowNoIndices', 'expandWildcards', @@ -112,11 +118,20 @@ function buildClusterState (opts) { ignore = [ignore] } + var path = '' + + if ((params['metric']) != null && (params['index']) != null) { + path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(params['metric']) + '/' + encodeURIComponent(params['index']) + } else if ((params['metric']) != null) { + path = '/' + '_cluster' + '/' + 'state' + '/' + encodeURIComponent(params['metric']) + } else { + path = '/' + '_cluster' + '/' + 'state' + } + // build request object - const parts = ['_cluster', 'state', params['metric'], params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/cluster.stats.js b/api/api/cluster.stats.js index 8c37aba10..50a797066 100644 --- a/api/api/cluster.stats.js +++ b/api/api/cluster.stats.js @@ -91,13 +91,18 @@ function buildClusterStats (opts) { ignore = [ignore] } + var path = '' + + if ((params['node_id'] || params['nodeId']) != null) { + path = '/' + '_cluster' + '/' + 'stats' + '/' + 'nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + } else { + path = '/' + '_cluster' + '/' + 'stats' + } + // build request object - const parts = ['_cluster', 'stats', 'nodes', params['node_id'] || params['nodeId']] const request = { method, - path: (params['node_id'] || params['nodeId']) != null - ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') - : '/_cluster/stats', + path, body: null, querystring } diff --git a/api/api/count.js b/api/api/count.js index 568a403b6..74e261b14 100644 --- a/api/api/count.js +++ b/api/api/count.js @@ -9,6 +9,7 @@ function buildCount (opts) { * @param {list} index - A comma-separated list of indices to restrict the results * @param {list} type - A comma-separated list of types to restrict the results * @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {boolean} ignore_throttled - Whether specified concrete, expanded or aliased indices should be ignored when throttled * @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {number} min_score - Include only documents with a specific `_score` value in the result @@ -56,6 +57,7 @@ function buildCount (opts) { const keys = Object.keys(params) const acceptedQuerystring = [ 'ignore_unavailable', + 'ignore_throttled', 'allow_no_indices', 'expand_wildcards', 'min_score', @@ -76,6 +78,7 @@ function buildCount (opts) { ] const acceptedQuerystringCamelCased = [ 'ignoreUnavailable', + 'ignoreThrottled', 'allowNoIndices', 'expandWildcards', 'minScore', @@ -126,11 +129,20 @@ function buildCount (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_count' + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_count' + } else { + path = '/' + '_count' + } + // build request object - const parts = [params['index'], params['type'], '_count'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/create.js b/api/api/create.js index 38c40df49..b20a5269a 100644 --- a/api/api/create.js +++ b/api/api/create.js @@ -143,11 +143,14 @@ function buildCreate (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_create' + // build request object - const parts = [params['index'], params['type'], params['id'], '_create'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/delete.js b/api/api/delete.js index a6545c05c..d4b227a4f 100644 --- a/api/api/delete.js +++ b/api/api/delete.js @@ -50,12 +50,6 @@ function buildDelete (opts) { result ) } - if (params['type'] == null) { - return callback( - new ConfigurationError('Missing required parameter: type'), - result - ) - } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), @@ -64,12 +58,7 @@ function buildDelete (opts) { } // check required url components - if (params['id'] != null && (params['type'] == null || params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: type, index'), - result - ) - } else if (params['type'] != null && (params['index'] == null)) { + if (params['id'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), result @@ -139,11 +128,18 @@ function buildDelete (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null && (params['id']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_doc' + '/' + encodeURIComponent(params['id']) + } + // build request object - const parts = [params['index'], params['type'], params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/delete_by_query.js b/api/api/delete_by_query.js index e0b984a53..91302e500 100644 --- a/api/api/delete_by_query.js +++ b/api/api/delete_by_query.js @@ -27,8 +27,8 @@ function buildDeleteByQuery (opts) { * @param {number} size - Number of hits to return (default: 10) * @param {list} sort - A comma-separated list of : pairs * @param {list} _source - True or false to return the _source field or not, or a list of fields to return - * @param {list} _source_exclude - A list of fields to exclude from the returned _source field - * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {list} _source_excludes - A list of fields to exclude from the returned _source field + * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {number} terminate_after - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. * @param {list} stats - Specific 'tag' of the request for logging and statistical purposes * @param {boolean} version - Specify whether to return document version as part of a hit @@ -107,8 +107,8 @@ function buildDeleteByQuery (opts) { 'size', 'sort', '_source', - '_source_exclude', - '_source_include', + '_source_excludes', + '_source_includes', 'terminate_after', 'stats', 'version', @@ -146,8 +146,8 @@ function buildDeleteByQuery (opts) { 'size', 'sort', '_source', - '_sourceExclude', - '_sourceInclude', + '_sourceExcludes', + '_sourceIncludes', 'terminateAfter', 'stats', 'version', @@ -197,11 +197,18 @@ function buildDeleteByQuery (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_delete_by_query' + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_delete_by_query' + } + // build request object - const parts = [params['index'], params['type'], '_delete_by_query'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/delete_by_query_rethrottle.js b/api/api/delete_by_query_rethrottle.js index 423144942..ef307c463 100644 --- a/api/api/delete_by_query_rethrottle.js +++ b/api/api/delete_by_query_rethrottle.js @@ -100,11 +100,14 @@ function buildDeleteByQueryRethrottle (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_delete_by_query' + '/' + encodeURIComponent(params['task_id'] || params['taskId']) + '/' + '_rethrottle' + // build request object - const parts = ['_delete_by_query', params['task_id'] || params['taskId'], '_rethrottle'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/delete_script.js b/api/api/delete_script.js index 0459738b7..280b73d46 100644 --- a/api/api/delete_script.js +++ b/api/api/delete_script.js @@ -97,11 +97,14 @@ function buildDeleteScript (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_scripts' + '/' + encodeURIComponent(params['id']) + // build request object - const parts = ['_scripts', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/exists.js b/api/api/exists.js index b2b27dcb5..d2be719f3 100644 --- a/api/api/exists.js +++ b/api/api/exists.js @@ -16,8 +16,8 @@ function buildExists (opts) { * @param {boolean} refresh - Refresh the shard containing the document before performing the operation * @param {string} routing - Specific routing value * @param {list} _source - True or false to return the _source field or not, or a list of fields to return - * @param {list} _source_exclude - A list of fields to exclude from the returned _source field - * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {list} _source_excludes - A list of fields to exclude from the returned _source field + * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {number} version - Explicit version number for concurrency control * @param {enum} version_type - Specific version type */ @@ -54,12 +54,6 @@ function buildExists (opts) { result ) } - if (params['type'] == null) { - return callback( - new ConfigurationError('Missing required parameter: type'), - result - ) - } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), @@ -67,19 +61,6 @@ function buildExists (opts) { ) } - // check required url components - if (params['id'] != null && (params['type'] == null || params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: type, index'), - result - ) - } else if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) - } - // build querystring object const querystring = {} const keys = Object.keys(params) @@ -91,8 +72,8 @@ function buildExists (opts) { 'refresh', 'routing', '_source', - '_source_exclude', - '_source_include', + '_source_excludes', + '_source_includes', 'version', 'version_type', 'pretty', @@ -109,8 +90,8 @@ function buildExists (opts) { 'refresh', 'routing', '_source', - '_sourceExclude', - '_sourceInclude', + '_sourceExcludes', + '_sourceIncludes', 'version', 'versionType', 'pretty', @@ -151,11 +132,18 @@ function buildExists (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null && (params['id']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_doc' + '/' + encodeURIComponent(params['id']) + } + // build request object - const parts = [params['index'], params['type'], params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/exists_source.js b/api/api/exists_source.js index 188d53ed4..47d5cd451 100644 --- a/api/api/exists_source.js +++ b/api/api/exists_source.js @@ -15,8 +15,8 @@ function buildExistsSource (opts) { * @param {boolean} refresh - Refresh the shard containing the document before performing the operation * @param {string} routing - Specific routing value * @param {list} _source - True or false to return the _source field or not, or a list of fields to return - * @param {list} _source_exclude - A list of fields to exclude from the returned _source field - * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {list} _source_excludes - A list of fields to exclude from the returned _source field + * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {number} version - Explicit version number for concurrency control * @param {enum} version_type - Specific version type */ @@ -89,8 +89,8 @@ function buildExistsSource (opts) { 'refresh', 'routing', '_source', - '_source_exclude', - '_source_include', + '_source_excludes', + '_source_includes', 'version', 'version_type', 'pretty', @@ -106,8 +106,8 @@ function buildExistsSource (opts) { 'refresh', 'routing', '_source', - '_sourceExclude', - '_sourceInclude', + '_sourceExcludes', + '_sourceIncludes', 'version', 'versionType', 'pretty', @@ -148,11 +148,14 @@ function buildExistsSource (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_source' + // build request object - const parts = [params['index'], params['type'], params['id'], '_source'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/explain.js b/api/api/explain.js index a0ffea3e3..aa3c60c12 100644 --- a/api/api/explain.js +++ b/api/api/explain.js @@ -20,8 +20,8 @@ function buildExplain (opts) { * @param {string} q - Query in the Lucene query string syntax * @param {string} routing - Specific routing value * @param {list} _source - True or false to return the _source field or not, or a list of fields to return - * @param {list} _source_exclude - A list of fields to exclude from the returned _source field - * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {list} _source_excludes - A list of fields to exclude from the returned _source field + * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {object} body - The query definition using the Query DSL */ return function explain (params, options, callback) { @@ -57,25 +57,6 @@ function buildExplain (opts) { result ) } - if (params['type'] == null) { - return callback( - new ConfigurationError('Missing required parameter: type'), - result - ) - } - - // check required url components - if (params['id'] != null && (params['type'] == null || params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: type, index'), - result - ) - } else if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) - } // build querystring object const querystring = {} @@ -92,8 +73,8 @@ function buildExplain (opts) { 'q', 'routing', '_source', - '_source_exclude', - '_source_include', + '_source_excludes', + '_source_includes', 'pretty', 'human', 'error_trace', @@ -112,8 +93,8 @@ function buildExplain (opts) { 'q', 'routing', '_source', - '_sourceExclude', - '_sourceInclude', + '_sourceExcludes', + '_sourceIncludes', 'pretty', 'human', 'errorTrace', @@ -152,11 +133,18 @@ function buildExplain (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null && (params['id']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_explain' + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_explain' + '/' + encodeURIComponent(params['id']) + } + // build request object - const parts = [params['index'], params['type'], params['id'], '_explain'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/field_caps.js b/api/api/field_caps.js index b69b053e2..836651834 100644 --- a/api/api/field_caps.js +++ b/api/api/field_caps.js @@ -11,7 +11,6 @@ function buildFieldCaps (opts) { * @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) * @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. - * @param {object} body - Field json objects containing an array of field names */ return function fieldCaps (params, options, callback) { options = options || {} @@ -33,6 +32,14 @@ function buildFieldCaps (opts) { }) } + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + // build querystring object const querystring = {} const keys = Object.keys(params) @@ -90,12 +97,19 @@ function buildFieldCaps (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_field_caps' + } else { + path = '/' + '_field_caps' + } + // build request object - const parts = [params['index'], '_field_caps'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - body: params.body || '', + path, + body: '', querystring } diff --git a/api/api/get.js b/api/api/get.js index da4e07579..861bf49bc 100644 --- a/api/api/get.js +++ b/api/api/get.js @@ -16,6 +16,8 @@ function buildGet (opts) { * @param {boolean} refresh - Refresh the shard containing the document before performing the operation * @param {string} routing - Specific routing value * @param {list} _source - True or false to return the _source field or not, or a list of fields to return + * @param {list} _source_excludes - A list of fields to exclude from the returned _source field + * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {list} _source_exclude - A list of fields to exclude from the returned _source field * @param {list} _source_include - A list of fields to extract and return from the _source field * @param {number} version - Explicit version number for concurrency control @@ -54,12 +56,6 @@ function buildGet (opts) { result ) } - if (params['type'] == null) { - return callback( - new ConfigurationError('Missing required parameter: type'), - result - ) - } if (params.body != null) { return callback( new ConfigurationError('This API does not require a body'), @@ -67,19 +63,6 @@ function buildGet (opts) { ) } - // check required url components - if (params['id'] != null && (params['type'] == null || params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: type, index'), - result - ) - } else if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) - } - // build querystring object const querystring = {} const keys = Object.keys(params) @@ -91,6 +74,8 @@ function buildGet (opts) { 'refresh', 'routing', '_source', + '_source_excludes', + '_source_includes', '_source_exclude', '_source_include', 'version', @@ -109,6 +94,8 @@ function buildGet (opts) { 'refresh', 'routing', '_source', + '_sourceExcludes', + '_sourceIncludes', '_sourceExclude', '_sourceInclude', 'version', @@ -151,11 +138,18 @@ function buildGet (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null && (params['id']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_doc' + '/' + encodeURIComponent(params['id']) + } + // build request object - const parts = [params['index'], params['type'], params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/get_script.js b/api/api/get_script.js index 852df3d5c..37b6c09ca 100644 --- a/api/api/get_script.js +++ b/api/api/get_script.js @@ -94,11 +94,14 @@ function buildGetScript (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_scripts' + '/' + encodeURIComponent(params['id']) + // build request object - const parts = ['_scripts', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/get_source.js b/api/api/get_source.js index 37300e8b5..700b58940 100644 --- a/api/api/get_source.js +++ b/api/api/get_source.js @@ -15,8 +15,8 @@ function buildGetSource (opts) { * @param {boolean} refresh - Refresh the shard containing the document before performing the operation * @param {string} routing - Specific routing value * @param {list} _source - True or false to return the _source field or not, or a list of fields to return - * @param {list} _source_exclude - A list of fields to exclude from the returned _source field - * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {list} _source_excludes - A list of fields to exclude from the returned _source field + * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {number} version - Explicit version number for concurrency control * @param {enum} version_type - Specific version type */ @@ -89,8 +89,8 @@ function buildGetSource (opts) { 'refresh', 'routing', '_source', - '_source_exclude', - '_source_include', + '_source_excludes', + '_source_includes', 'version', 'version_type', 'pretty', @@ -106,8 +106,8 @@ function buildGetSource (opts) { 'refresh', 'routing', '_source', - '_sourceExclude', - '_sourceInclude', + '_sourceExcludes', + '_sourceIncludes', 'version', 'versionType', 'pretty', @@ -148,11 +148,14 @@ function buildGetSource (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_source' + // build request object - const parts = [params['index'], params['type'], params['id'], '_source'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/ilm.delete_lifecycle.js b/api/api/ilm.delete_lifecycle.js new file mode 100644 index 000000000..69968d7d3 --- /dev/null +++ b/api/api/ilm.delete_lifecycle.js @@ -0,0 +1,104 @@ +'use strict' + +function buildIlmDeleteLifecycle (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ilm.delete_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-delete-lifecycle.html) request + * + * @param {string} policy - The name of the index lifecycle policy + */ + return function ilmDeleteLifecycle (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmDeleteLifecycle(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'DELETE' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(params['policy']) + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIlmDeleteLifecycle diff --git a/api/api/ilm.explain_lifecycle.js b/api/api/ilm.explain_lifecycle.js new file mode 100644 index 000000000..56ddafcfd --- /dev/null +++ b/api/api/ilm.explain_lifecycle.js @@ -0,0 +1,105 @@ +'use strict' + +function buildIlmExplainLifecycle (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ilm.explain_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-explain-lifecycle.html) request + * + * @param {string} index - The name of the index to explain + * @param {boolean} human - Return data such as dates in a human readable format + */ + return function ilmExplainLifecycle (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmExplainLifecycle(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'human' + ] + const acceptedQuerystringCamelCased = [ + 'human' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_ilm' + '/' + 'explain' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIlmExplainLifecycle diff --git a/api/api/ilm.get_lifecycle.js b/api/api/ilm.get_lifecycle.js new file mode 100644 index 000000000..93869ca64 --- /dev/null +++ b/api/api/ilm.get_lifecycle.js @@ -0,0 +1,108 @@ +'use strict' + +function buildIlmGetLifecycle (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ilm.get_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-lifecycle.html) request + * + * @param {string} policy - The name of the index lifecycle policy + */ + return function ilmGetLifecycle (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmGetLifecycle(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + if ((params['policy']) != null) { + path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(params['policy']) + } else { + path = '/' + '_ilm' + '/' + 'policy' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIlmGetLifecycle diff --git a/api/api/ilm.get_status.js b/api/api/ilm.get_status.js new file mode 100644 index 000000000..7d4bfaed5 --- /dev/null +++ b/api/api/ilm.get_status.js @@ -0,0 +1,103 @@ +'use strict' + +function buildIlmGetStatus (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ilm.get_status](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-get-status.html) request + * + */ + return function ilmGetStatus (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmGetStatus(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ilm' + '/' + 'status' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIlmGetStatus diff --git a/api/api/ilm.move_to_step.js b/api/api/ilm.move_to_step.js new file mode 100644 index 000000000..e1562289d --- /dev/null +++ b/api/api/ilm.move_to_step.js @@ -0,0 +1,97 @@ +'use strict' + +function buildIlmMoveToStep (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ilm.move_to_step](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-move-to-step.html) request + * + * @param {string} index - The name of the index whose lifecycle step is to change + * @param {object} body - The new lifecycle step to move to + */ + return function ilmMoveToStep (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmMoveToStep(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ilm' + '/' + 'move' + '/' + encodeURIComponent(params['index']) + + // build request object + const request = { + method, + path, + body: params.body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIlmMoveToStep diff --git a/api/api/ilm.put_lifecycle.js b/api/api/ilm.put_lifecycle.js new file mode 100644 index 000000000..7f2c7d447 --- /dev/null +++ b/api/api/ilm.put_lifecycle.js @@ -0,0 +1,97 @@ +'use strict' + +function buildIlmPutLifecycle (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ilm.put_lifecycle](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-put-lifecycle.html) request + * + * @param {string} policy - The name of the index lifecycle policy + * @param {object} body - The lifecycle policy definition to register + */ + return function ilmPutLifecycle (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmPutLifecycle(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'PUT' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ilm' + '/' + 'policy' + '/' + encodeURIComponent(params['policy']) + + // build request object + const request = { + method, + path, + body: params.body || '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIlmPutLifecycle diff --git a/api/api/ilm.remove_policy.js b/api/api/ilm.remove_policy.js new file mode 100644 index 000000000..09e429ebc --- /dev/null +++ b/api/api/ilm.remove_policy.js @@ -0,0 +1,104 @@ +'use strict' + +function buildIlmRemovePolicy (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ilm.remove_policy](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-remove-policy.html) request + * + * @param {string} index - The name of the index to remove policy on + */ + return function ilmRemovePolicy (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmRemovePolicy(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_ilm' + '/' + 'remove' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIlmRemovePolicy diff --git a/api/api/ilm.retry.js b/api/api/ilm.retry.js new file mode 100644 index 000000000..0e3f7dc2c --- /dev/null +++ b/api/api/ilm.retry.js @@ -0,0 +1,104 @@ +'use strict' + +function buildIlmRetry (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ilm.retry](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-retry-policy.html) request + * + * @param {string} index - The name of the indices (comma-separated) whose failed lifecycle step is to be retry + */ + return function ilmRetry (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmRetry(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_ilm' + '/' + 'retry' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIlmRetry diff --git a/api/api/xpack.watcher.restart.js b/api/api/ilm.start.js similarity index 82% rename from api/api/xpack.watcher.restart.js rename to api/api/ilm.start.js index 12c1337a3..f0b9a77ca 100644 --- a/api/api/xpack.watcher.restart.js +++ b/api/api/ilm.start.js @@ -1,13 +1,13 @@ 'use strict' -function buildXpackWatcherRestart (opts) { +function buildIlmStart (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.watcher.restart](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-restart.html) request + * Perform a [ilm.start](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-start.html) request * */ - return function xpackWatcherRestart (params, options, callback) { + return function ilmStart (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -21,7 +21,7 @@ function buildXpackWatcherRestart (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackWatcherRestart(params, options, (err, body) => { + ilmStart(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -76,11 +76,14 @@ function buildXpackWatcherRestart (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ilm' + '/' + 'start' + // build request object - const parts = ['_xpack', 'watcher', '_restart'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -97,4 +100,4 @@ function buildXpackWatcherRestart (opts) { } } -module.exports = buildXpackWatcherRestart +module.exports = buildIlmStart diff --git a/api/api/ilm.stop.js b/api/api/ilm.stop.js new file mode 100644 index 000000000..500e10a3e --- /dev/null +++ b/api/api/ilm.stop.js @@ -0,0 +1,103 @@ +'use strict' + +function buildIlmStop (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ilm.stop](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-stop.html) request + * + */ + return function ilmStop (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + ilmStop(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ilm' + '/' + 'stop' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIlmStop diff --git a/api/api/index.js b/api/api/index.js index ab0c1a920..db8aa2648 100644 --- a/api/api/index.js +++ b/api/api/index.js @@ -47,12 +47,6 @@ function buildIndex (opts) { result ) } - if (params['type'] == null) { - return callback( - new ConfigurationError('Missing required parameter: type'), - result - ) - } if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), @@ -61,12 +55,7 @@ function buildIndex (opts) { } // check required url components - if (params['id'] != null && (params['type'] == null || params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: type, index'), - result - ) - } else if (params['type'] != null && (params['index'] == null)) { + if (params['id'] != null && (params['index'] == null)) { return callback( new ConfigurationError('Missing required parameter of the url: index'), result @@ -140,11 +129,22 @@ function buildIndex (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null && (params['id']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + } else if ((params['index']) != null && (params['id']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_doc' + '/' + encodeURIComponent(params['id']) + } else if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_doc' + } + // build request object - const parts = [params['index'], params['type'], params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/indices.analyze.js b/api/api/indices.analyze.js index 37fd178ce..87ef4e735 100644 --- a/api/api/indices.analyze.js +++ b/api/api/indices.analyze.js @@ -81,11 +81,18 @@ function buildIndicesAnalyze (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_analyze' + } else { + path = '/' + '_analyze' + } + // build request object - const parts = [params['index'], '_analyze'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/indices.clear_cache.js b/api/api/indices.clear_cache.js index 6e0ed7555..8b5b78219 100644 --- a/api/api/indices.clear_cache.js +++ b/api/api/indices.clear_cache.js @@ -7,7 +7,6 @@ function buildIndicesClearCache (opts) { * Perform a [indices.clear_cache](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-clearcache.html) request * * @param {list} index - A comma-separated list of index name to limit the operation - * @param {boolean} field_data - Clear field data. This is deprecated. Prefer `fielddata`. * @param {boolean} fielddata - Clear field data * @param {list} fields - A comma-separated list of fields to clear when using the `fielddata` parameter (default: all) * @param {boolean} query - Clear query caches @@ -15,7 +14,6 @@ function buildIndicesClearCache (opts) { * @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {list} index - A comma-separated list of index name to limit the operation - * @param {boolean} request_cache - Clear request cache * @param {boolean} request - Clear request cache */ return function indicesClearCache (params, options, callback) { @@ -50,7 +48,6 @@ function buildIndicesClearCache (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ - 'field_data', 'fielddata', 'fields', 'query', @@ -58,7 +55,6 @@ function buildIndicesClearCache (opts) { 'allow_no_indices', 'expand_wildcards', 'index', - 'request_cache', 'request', 'pretty', 'human', @@ -67,7 +63,6 @@ function buildIndicesClearCache (opts) { 'filter_path' ] const acceptedQuerystringCamelCased = [ - 'fieldData', 'fielddata', 'fields', 'query', @@ -75,7 +70,6 @@ function buildIndicesClearCache (opts) { 'allowNoIndices', 'expandWildcards', 'index', - 'requestCache', 'request', 'pretty', 'human', @@ -99,7 +93,7 @@ function buildIndicesClearCache (opts) { // configure http method var method = params.method if (method == null) { - method = params.body == null ? 'GET' : 'POST' + method = 'POST' } // validate headers object @@ -115,11 +109,18 @@ function buildIndicesClearCache (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_cache' + '/' + 'clear' + } else { + path = '/' + '_cache' + '/' + 'clear' + } + // build request object - const parts = [params['index'], '_cache', 'clear'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/indices.close.js b/api/api/indices.close.js index 3d8c33f86..22eec8674 100644 --- a/api/api/indices.close.js +++ b/api/api/indices.close.js @@ -106,11 +106,14 @@ function buildIndicesClose (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_close' + // build request object - const parts = [params['index'], '_close'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/indices.create.js b/api/api/indices.create.js index a855bafec..97e913b91 100644 --- a/api/api/indices.create.js +++ b/api/api/indices.create.js @@ -7,10 +7,10 @@ function buildIndicesCreate (opts) { * Perform a [indices.create](http://www.elastic.co/guide/en/elasticsearch/reference/master/indices-create-index.html) request * * @param {string} index - The name of the index + * @param {string} include_type_name - Whether a type should be expected in the body of the mappings. * @param {string} wait_for_active_shards - Set the number of active shards to wait for before the operation returns. * @param {time} timeout - Explicit operation timeout * @param {time} master_timeout - Specify timeout for connection to master - * @param {boolean} update_all_types - Whether to update the mapping for all fields with the same name across all types or not * @param {object} body - The configuration for the index (`settings` and `mappings`) */ return function indicesCreate (params, options, callback) { @@ -45,10 +45,10 @@ function buildIndicesCreate (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ + 'include_type_name', 'wait_for_active_shards', 'timeout', 'master_timeout', - 'update_all_types', 'pretty', 'human', 'error_trace', @@ -56,10 +56,10 @@ function buildIndicesCreate (opts) { 'filter_path' ] const acceptedQuerystringCamelCased = [ + 'includeTypeName', 'waitForActiveShards', 'timeout', 'masterTimeout', - 'updateAllTypes', 'pretty', 'human', 'errorTrace', @@ -98,11 +98,14 @@ function buildIndicesCreate (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + // build request object - const parts = [params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/indices.delete.js b/api/api/indices.delete.js index 06b649926..a0c9c2f70 100644 --- a/api/api/indices.delete.js +++ b/api/api/indices.delete.js @@ -106,11 +106,14 @@ function buildIndicesDelete (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + // build request object - const parts = [params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/indices.delete_alias.js b/api/api/indices.delete_alias.js index 43447d915..d4725eb62 100644 --- a/api/api/indices.delete_alias.js +++ b/api/api/indices.delete_alias.js @@ -112,13 +112,18 @@ function buildIndicesDeleteAlias (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['name']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_alias' + '/' + encodeURIComponent(params['name']) + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_aliases' + '/' + encodeURIComponent(params['name']) + } + // build request object - const parts = [params['index'], '_aliases', params['name']] const request = { method, - path: params['index'] != null && params['name'] != null - ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') - : '/{index}/_alias/{name}', + path, body: '', querystring } diff --git a/api/api/indices.delete_template.js b/api/api/indices.delete_template.js index 3c4dd12ea..9cbd307c8 100644 --- a/api/api/indices.delete_template.js +++ b/api/api/indices.delete_template.js @@ -97,11 +97,14 @@ function buildIndicesDeleteTemplate (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_template' + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_template', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/indices.exists.js b/api/api/indices.exists.js index dc2fe554a..145e754d0 100644 --- a/api/api/indices.exists.js +++ b/api/api/indices.exists.js @@ -109,11 +109,14 @@ function buildIndicesExists (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + // build request object - const parts = [params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.exists_alias.js b/api/api/indices.exists_alias.js index d827db77c..61e218698 100644 --- a/api/api/indices.exists_alias.js +++ b/api/api/indices.exists_alias.js @@ -104,11 +104,18 @@ function buildIndicesExistsAlias (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['name']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_alias' + '/' + encodeURIComponent(params['name']) + } else { + path = '/' + '_alias' + '/' + encodeURIComponent(params['name']) + } + // build request object - const parts = [params['index'], '_alias', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.exists_template.js b/api/api/indices.exists_template.js index 78d5056ba..1902bd5c2 100644 --- a/api/api/indices.exists_template.js +++ b/api/api/indices.exists_template.js @@ -100,11 +100,14 @@ function buildIndicesExistsTemplate (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_template' + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_template', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.exists_type.js b/api/api/indices.exists_type.js index 00c2f3036..4e9305263 100644 --- a/api/api/indices.exists_type.js +++ b/api/api/indices.exists_type.js @@ -118,11 +118,14 @@ function buildIndicesExistsType (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + '/' + encodeURIComponent(params['type']) + // build request object - const parts = [params['index'], '_mapping', params['type']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.flush.js b/api/api/indices.flush.js index df05b411b..87a8d76f9 100644 --- a/api/api/indices.flush.js +++ b/api/api/indices.flush.js @@ -100,11 +100,18 @@ function buildIndicesFlush (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_flush' + } else { + path = '/' + '_flush' + } + // build request object - const parts = [params['index'], '_flush'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/indices.flush_synced.js b/api/api/indices.flush_synced.js index aa5a65bdc..857670661 100644 --- a/api/api/indices.flush_synced.js +++ b/api/api/indices.flush_synced.js @@ -94,11 +94,18 @@ function buildIndicesFlushSynced (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_flush' + '/' + 'synced' + } else { + path = '/' + '_flush' + '/' + 'synced' + } + // build request object - const parts = [params['index'], '_flush', 'synced'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/indices.forcemerge.js b/api/api/indices.forcemerge.js index 3631441d6..ea8633ae8 100644 --- a/api/api/indices.forcemerge.js +++ b/api/api/indices.forcemerge.js @@ -103,11 +103,18 @@ function buildIndicesForcemerge (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_forcemerge' + } else { + path = '/' + '_forcemerge' + } + // build request object - const parts = [params['index'], '_forcemerge'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/indices.freeze.js b/api/api/indices.freeze.js new file mode 100644 index 000000000..5226f6064 --- /dev/null +++ b/api/api/indices.freeze.js @@ -0,0 +1,126 @@ +'use strict' + +function buildIndicesFreeze (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [indices.freeze](https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.html) request + * + * @param {string} index - The name of the index to freeze + * @param {time} timeout - Explicit operation timeout + * @param {time} master_timeout - Specify timeout for connection to master + * @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {string} wait_for_active_shards - Sets the number of active shards to wait for before the operation returns. + */ + return function indicesFreeze (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesFreeze(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'wait_for_active_shards' + ] + const acceptedQuerystringCamelCased = [ + 'timeout', + 'masterTimeout', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'waitForActiveShards' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_freeze' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIndicesFreeze diff --git a/api/api/indices.get.js b/api/api/indices.get.js index 0322a28d7..b0a9b8dad 100644 --- a/api/api/indices.get.js +++ b/api/api/indices.get.js @@ -112,11 +112,14 @@ function buildIndicesGet (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + // build request object - const parts = [params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.get_alias.js b/api/api/indices.get_alias.js index e7904cc2c..b5401a1bd 100644 --- a/api/api/indices.get_alias.js +++ b/api/api/indices.get_alias.js @@ -98,11 +98,22 @@ function buildIndicesGetAlias (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['name']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_alias' + '/' + encodeURIComponent(params['name']) + } else if ((params['name']) != null) { + path = '/' + '_alias' + '/' + encodeURIComponent(params['name']) + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_alias' + } else { + path = '/' + '_alias' + } + // build request object - const parts = [params['index'], '_alias', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.get_field_mapping.js b/api/api/indices.get_field_mapping.js index 003ac8f3c..63fa23006 100644 --- a/api/api/indices.get_field_mapping.js +++ b/api/api/indices.get_field_mapping.js @@ -108,11 +108,22 @@ function buildIndicesGetFieldMapping (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null && (params['fields']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + '/' + encodeURIComponent(params['type']) + '/' + 'field' + '/' + encodeURIComponent(params['fields']) + } else if ((params['index']) != null && (params['fields']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + '/' + 'field' + '/' + encodeURIComponent(params['fields']) + } else if ((params['type']) != null && (params['fields']) != null) { + path = '/' + '_mapping' + '/' + encodeURIComponent(params['type']) + '/' + 'field' + '/' + encodeURIComponent(params['fields']) + } else { + path = '/' + '_mapping' + '/' + 'field' + '/' + encodeURIComponent(params['fields']) + } + // build request object - const parts = [params['index'], '_mapping', params['type'], 'field', params['fields']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.get_mapping.js b/api/api/indices.get_mapping.js index 0a6870540..84c8f249c 100644 --- a/api/api/indices.get_mapping.js +++ b/api/api/indices.get_mapping.js @@ -8,6 +8,7 @@ function buildIndicesGetMapping (opts) { * * @param {list} index - A comma-separated list of index names * @param {list} type - A comma-separated list of document types + * @param {string} include_type_name - Whether to add the type name to the response * @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) * @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. @@ -46,6 +47,7 @@ function buildIndicesGetMapping (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ + 'include_type_name', 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', @@ -58,6 +60,7 @@ function buildIndicesGetMapping (opts) { 'filter_path' ] const acceptedQuerystringCamelCased = [ + 'includeTypeName', 'ignoreUnavailable', 'allowNoIndices', 'expandWildcards', @@ -101,11 +104,22 @@ function buildIndicesGetMapping (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + '/' + encodeURIComponent(params['type']) + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + } else if ((params['type']) != null) { + path = '/' + '_mapping' + '/' + encodeURIComponent(params['type']) + } else { + path = '/' + '_mapping' + } + // build request object - const parts = [params['index'], '_mapping', params['type']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.get_settings.js b/api/api/indices.get_settings.js index 76d8a13a9..22a8639a9 100644 --- a/api/api/indices.get_settings.js +++ b/api/api/indices.get_settings.js @@ -107,11 +107,22 @@ function buildIndicesGetSettings (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['name']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_settings' + '/' + encodeURIComponent(params['name']) + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_settings' + } else if ((params['name']) != null) { + path = '/' + '_settings' + '/' + encodeURIComponent(params['name']) + } else { + path = '/' + '_settings' + } + // build request object - const parts = [params['index'], '_settings', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.get_template.js b/api/api/indices.get_template.js index d392de288..f22726bf2 100644 --- a/api/api/indices.get_template.js +++ b/api/api/indices.get_template.js @@ -94,11 +94,18 @@ function buildIndicesGetTemplate (opts) { ignore = [ignore] } + var path = '' + + if ((params['name']) != null) { + path = '/' + '_template' + '/' + encodeURIComponent(params['name']) + } else { + path = '/' + '_template' + } + // build request object - const parts = ['_template', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.get_upgrade.js b/api/api/indices.get_upgrade.js index 1a8b2a1a5..02e1a01bf 100644 --- a/api/api/indices.get_upgrade.js +++ b/api/api/indices.get_upgrade.js @@ -94,11 +94,18 @@ function buildIndicesGetUpgrade (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_upgrade' + } else { + path = '/' + '_upgrade' + } + // build request object - const parts = [params['index'], '_upgrade'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.open.js b/api/api/indices.open.js index addc18a50..76a014b5d 100644 --- a/api/api/indices.open.js +++ b/api/api/indices.open.js @@ -109,11 +109,14 @@ function buildIndicesOpen (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_open' + // build request object - const parts = [params['index'], '_open'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/indices.put_alias.js b/api/api/indices.put_alias.js index 48cb6d31e..200e833e6 100644 --- a/api/api/indices.put_alias.js +++ b/api/api/indices.put_alias.js @@ -107,13 +107,18 @@ function buildIndicesPutAlias (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['name']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_alias' + '/' + encodeURIComponent(params['name']) + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_aliases' + '/' + encodeURIComponent(params['name']) + } + // build request object - const parts = [params['index'], '_aliases', params['name']] const request = { method, - path: params['index'] != null && params['name'] != null - ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') - : '/{index}/_alias/{name}', + path, body: params.body || '', querystring } diff --git a/api/api/indices.put_mapping.js b/api/api/indices.put_mapping.js index e2c12da00..8a04ed0c9 100644 --- a/api/api/indices.put_mapping.js +++ b/api/api/indices.put_mapping.js @@ -8,12 +8,12 @@ function buildIndicesPutMapping (opts) { * * @param {list} index - A comma-separated list of index names the mapping should be added to (supports wildcards); use `_all` or omit to add the mapping on all indices. * @param {string} type - The name of the document type + * @param {string} include_type_name - Whether a type should be expected in the body of the mappings. * @param {time} timeout - Explicit operation timeout * @param {time} master_timeout - Specify timeout for connection to master * @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) * @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. - * @param {boolean} update_all_types - Whether to update the mapping for all fields with the same name across all types or not * @param {object} body - The mapping definition */ return function indicesPutMapping (params, options, callback) { @@ -37,12 +37,6 @@ function buildIndicesPutMapping (opts) { } // check required parameters - if (params['type'] == null) { - return callback( - new ConfigurationError('Missing required parameter: type'), - result - ) - } if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), @@ -54,12 +48,12 @@ function buildIndicesPutMapping (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ + 'include_type_name', 'timeout', 'master_timeout', 'ignore_unavailable', 'allow_no_indices', 'expand_wildcards', - 'update_all_types', 'pretty', 'human', 'error_trace', @@ -67,12 +61,12 @@ function buildIndicesPutMapping (opts) { 'filter_path' ] const acceptedQuerystringCamelCased = [ + 'includeTypeName', 'timeout', 'masterTimeout', 'ignoreUnavailable', 'allowNoIndices', 'expandWildcards', - 'updateAllTypes', 'pretty', 'human', 'errorTrace', @@ -111,11 +105,30 @@ function buildIndicesPutMapping (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_mapping' + } else if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + '/' + encodeURIComponent(params['type']) + } else if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_mappings' + } else if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_mappings' + '/' + encodeURIComponent(params['type']) + } else if ((params['type']) != null) { + path = '/' + '_mapping' + '/' + encodeURIComponent(params['type']) + } else if ((params['type']) != null) { + path = '/' + '_mappings' + '/' + encodeURIComponent(params['type']) + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_mappings' + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_mapping' + } + // build request object - const parts = [params['index'], '_mappings', params['type']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/indices.put_settings.js b/api/api/indices.put_settings.js index dc4c28656..0c2532df3 100644 --- a/api/api/indices.put_settings.js +++ b/api/api/indices.put_settings.js @@ -107,11 +107,18 @@ function buildIndicesPutSettings (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_settings' + } else { + path = '/' + '_settings' + } + // build request object - const parts = [params['index'], '_settings'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/indices.put_template.js b/api/api/indices.put_template.js index 962c3814a..97b317e0f 100644 --- a/api/api/indices.put_template.js +++ b/api/api/indices.put_template.js @@ -107,11 +107,14 @@ function buildIndicesPutTemplate (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_template' + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_template', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/indices.recovery.js b/api/api/indices.recovery.js index efa854df6..f36f31d01 100644 --- a/api/api/indices.recovery.js +++ b/api/api/indices.recovery.js @@ -91,11 +91,18 @@ function buildIndicesRecovery (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_recovery' + } else { + path = '/' + '_recovery' + } + // build request object - const parts = [params['index'], '_recovery'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.refresh.js b/api/api/indices.refresh.js index 90bb65a31..0e264b781 100644 --- a/api/api/indices.refresh.js +++ b/api/api/indices.refresh.js @@ -94,11 +94,18 @@ function buildIndicesRefresh (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_refresh' + } else { + path = '/' + '_refresh' + } + // build request object - const parts = [params['index'], '_refresh'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/indices.rollover.js b/api/api/indices.rollover.js index 9a50a7543..166c41856 100644 --- a/api/api/indices.rollover.js +++ b/api/api/indices.rollover.js @@ -107,11 +107,18 @@ function buildIndicesRollover (opts) { ignore = [ignore] } + var path = '' + + if ((params['alias']) != null && (params['new_index'] || params['newIndex']) != null) { + path = '/' + encodeURIComponent(params['alias']) + '/' + '_rollover' + '/' + encodeURIComponent(params['new_index'] || params['newIndex']) + } else { + path = '/' + encodeURIComponent(params['alias']) + '/' + '_rollover' + } + // build request object - const parts = [params['alias'], '_rollover', params['new_index'] || params['newIndex']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/indices.segments.js b/api/api/indices.segments.js index 18a80b030..e8f044e1a 100644 --- a/api/api/indices.segments.js +++ b/api/api/indices.segments.js @@ -97,11 +97,18 @@ function buildIndicesSegments (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_segments' + } else { + path = '/' + '_segments' + } + // build request object - const parts = [params['index'], '_segments'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.shard_stores.js b/api/api/indices.shard_stores.js index bfc958c1e..663841e74 100644 --- a/api/api/indices.shard_stores.js +++ b/api/api/indices.shard_stores.js @@ -97,11 +97,18 @@ function buildIndicesShardStores (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_shard_stores' + } else { + path = '/' + '_shard_stores' + } + // build request object - const parts = [params['index'], '_shard_stores'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.shrink.js b/api/api/indices.shrink.js index 670806137..db423b13f 100644 --- a/api/api/indices.shrink.js +++ b/api/api/indices.shrink.js @@ -113,11 +113,14 @@ function buildIndicesShrink (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_shrink' + '/' + encodeURIComponent(params['target']) + // build request object - const parts = [params['index'], '_shrink', params['target']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/indices.split.js b/api/api/indices.split.js index 831d3ed08..b2ce07cf7 100644 --- a/api/api/indices.split.js +++ b/api/api/indices.split.js @@ -113,11 +113,14 @@ function buildIndicesSplit (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_split' + '/' + encodeURIComponent(params['target']) + // build request object - const parts = [params['index'], '_split', params['target']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/indices.stats.js b/api/api/indices.stats.js index d7a4d0f0d..63bb90ab4 100644 --- a/api/api/indices.stats.js +++ b/api/api/indices.stats.js @@ -107,11 +107,22 @@ function buildIndicesStats (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['metric']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_stats' + '/' + encodeURIComponent(params['metric']) + } else if ((params['metric']) != null) { + path = '/' + '_stats' + '/' + encodeURIComponent(params['metric']) + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_stats' + } else { + path = '/' + '_stats' + } + // build request object - const parts = [params['index'], '_stats', params['metric']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/indices.unfreeze.js b/api/api/indices.unfreeze.js new file mode 100644 index 000000000..3f6ade686 --- /dev/null +++ b/api/api/indices.unfreeze.js @@ -0,0 +1,126 @@ +'use strict' + +function buildIndicesUnfreeze (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [indices.unfreeze](https://www.elastic.co/guide/en/elasticsearch/reference/current/frozen.html) request + * + * @param {string} index - The name of the index to unfreeze + * @param {time} timeout - Explicit operation timeout + * @param {time} master_timeout - Specify timeout for connection to master + * @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) + * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. + * @param {string} wait_for_active_shards - Sets the number of active shards to wait for before the operation returns. + */ + return function indicesUnfreeze (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + indicesUnfreeze(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params['index'] == null) { + return callback( + new ConfigurationError('Missing required parameter: index'), + result + ) + } + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + 'timeout', + 'master_timeout', + 'ignore_unavailable', + 'allow_no_indices', + 'expand_wildcards', + 'wait_for_active_shards' + ] + const acceptedQuerystringCamelCased = [ + 'timeout', + 'masterTimeout', + 'ignoreUnavailable', + 'allowNoIndices', + 'expandWildcards', + 'waitForActiveShards' + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'POST' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_unfreeze' + + // build request object + const request = { + method, + path, + body: '', + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildIndicesUnfreeze diff --git a/api/api/indices.update_aliases.js b/api/api/indices.update_aliases.js index f507ae604..cb2b8f91b 100644 --- a/api/api/indices.update_aliases.js +++ b/api/api/indices.update_aliases.js @@ -91,11 +91,14 @@ function buildIndicesUpdateAliases (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_aliases' + // build request object - const parts = ['_aliases'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/indices.upgrade.js b/api/api/indices.upgrade.js index 9741684d5..bfa521d65 100644 --- a/api/api/indices.upgrade.js +++ b/api/api/indices.upgrade.js @@ -100,11 +100,18 @@ function buildIndicesUpgrade (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_upgrade' + } else { + path = '/' + '_upgrade' + } + // build request object - const parts = [params['index'], '_upgrade'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/indices.validate_query.js b/api/api/indices.validate_query.js index cbd783b86..2c3d76aae 100644 --- a/api/api/indices.validate_query.js +++ b/api/api/indices.validate_query.js @@ -123,11 +123,20 @@ function buildIndicesValidateQuery (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_validate' + '/' + 'query' + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_validate' + '/' + 'query' + } else { + path = '/' + '_validate' + '/' + 'query' + } + // build request object - const parts = [params['index'], params['type'], '_validate', 'query'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/info.js b/api/api/info.js index 6e6c58746..280d74b2b 100644 --- a/api/api/info.js +++ b/api/api/info.js @@ -84,11 +84,14 @@ function buildInfo (opts) { ignore = [ignore] } + var path = '' + + path = '/' + // build request object - const parts = [] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/ingest.delete_pipeline.js b/api/api/ingest.delete_pipeline.js index 78b6cbc33..48ed5832a 100644 --- a/api/api/ingest.delete_pipeline.js +++ b/api/api/ingest.delete_pipeline.js @@ -97,11 +97,14 @@ function buildIngestDeletePipeline (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(params['id']) + // build request object - const parts = ['_ingest', 'pipeline', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/ingest.get_pipeline.js b/api/api/ingest.get_pipeline.js index 2f15be8f9..b275e6283 100644 --- a/api/api/ingest.get_pipeline.js +++ b/api/api/ingest.get_pipeline.js @@ -88,11 +88,18 @@ function buildIngestGetPipeline (opts) { ignore = [ignore] } + var path = '' + + if ((params['id']) != null) { + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(params['id']) + } else { + path = '/' + '_ingest' + '/' + 'pipeline' + } + // build request object - const parts = ['_ingest', 'pipeline', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/ingest.processor_grok.js b/api/api/ingest.processor_grok.js index c9c40f32c..c64b7c6b2 100644 --- a/api/api/ingest.processor_grok.js +++ b/api/api/ingest.processor_grok.js @@ -84,11 +84,14 @@ function buildIngestProcessorGrok (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ingest' + '/' + 'processor' + '/' + 'grok' + // build request object - const parts = ['_ingest', 'processor', 'grok'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/ingest.put_pipeline.js b/api/api/ingest.put_pipeline.js index 6a14d4637..2a50f23b2 100644 --- a/api/api/ingest.put_pipeline.js +++ b/api/api/ingest.put_pipeline.js @@ -98,11 +98,14 @@ function buildIngestPutPipeline (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(params['id']) + // build request object - const parts = ['_ingest', 'pipeline', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/ingest.simulate.js b/api/api/ingest.simulate.js index fb0c0a1a6..d5e961359 100644 --- a/api/api/ingest.simulate.js +++ b/api/api/ingest.simulate.js @@ -89,11 +89,18 @@ function buildIngestSimulate (opts) { ignore = [ignore] } + var path = '' + + if ((params['id']) != null) { + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + encodeURIComponent(params['id']) + '/' + '_simulate' + } else { + path = '/' + '_ingest' + '/' + 'pipeline' + '/' + '_simulate' + } + // build request object - const parts = ['_ingest', 'pipeline', params['id'], '_simulate'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/mget.js b/api/api/mget.js index 1327af217..2213dff78 100644 --- a/api/api/mget.js +++ b/api/api/mget.js @@ -14,8 +14,8 @@ function buildMget (opts) { * @param {boolean} refresh - Refresh the shard containing the document before performing the operation * @param {string} routing - Specific routing value * @param {list} _source - True or false to return the _source field or not, or a list of fields to return - * @param {list} _source_exclude - A list of fields to exclude from the returned _source field - * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {list} _source_excludes - A list of fields to exclude from the returned _source field + * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {object} body - Document identifiers; can be either `docs` (containing full document information) or `ids` (when index and type is provided in the URL. */ return function mget (params, options, callback) { @@ -64,8 +64,8 @@ function buildMget (opts) { 'refresh', 'routing', '_source', - '_source_exclude', - '_source_include', + '_source_excludes', + '_source_includes', 'pretty', 'human', 'error_trace', @@ -79,8 +79,8 @@ function buildMget (opts) { 'refresh', 'routing', '_source', - '_sourceExclude', - '_sourceInclude', + '_sourceExcludes', + '_sourceIncludes', 'pretty', 'human', 'errorTrace', @@ -119,11 +119,20 @@ function buildMget (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_mget' + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_mget' + } else { + path = '/' + '_mget' + } + // build request object - const parts = [params['index'], params['type'], '_mget'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.ml.close_job.js b/api/api/ml.close_job.js similarity index 84% rename from api/api/xpack.ml.close_job.js rename to api/api/ml.close_job.js index bee77a2f1..b69411c12 100644 --- a/api/api/xpack.ml.close_job.js +++ b/api/api/ml.close_job.js @@ -1,17 +1,17 @@ 'use strict' -function buildXpackMlCloseJob (opts) { +function buildMlCloseJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.close_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-close-job.html) request + * Perform a [ml.close_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-close-job.html) request * * @param {string} job_id - The name of the job to close * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) * @param {boolean} force - True if the job should be forcefully closed * @param {time} timeout - Controls the time to wait until a job has closed. Default to 30 minutes */ - return function xpackMlCloseJob (params, options, callback) { + return function mlCloseJob (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -25,7 +25,7 @@ function buildXpackMlCloseJob (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlCloseJob(params, options, (err, body) => { + mlCloseJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackMlCloseJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_close' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_close'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -105,4 +108,4 @@ function buildXpackMlCloseJob (opts) { } } -module.exports = buildXpackMlCloseJob +module.exports = buildMlCloseJob diff --git a/api/api/xpack.ml.delete_calendar.js b/api/api/ml.delete_calendar.js similarity index 84% rename from api/api/xpack.ml.delete_calendar.js rename to api/api/ml.delete_calendar.js index 3431be54c..e287d0a81 100644 --- a/api/api/xpack.ml.delete_calendar.js +++ b/api/api/ml.delete_calendar.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackMlDeleteCalendar (opts) { +function buildMlDeleteCalendar (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.delete_calendar](undefined) request + * Perform a [ml.delete_calendar](undefined) request * * @param {string} calendar_id - The ID of the calendar to delete */ - return function xpackMlDeleteCalendar (params, options, callback) { + return function mlDeleteCalendar (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackMlDeleteCalendar (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteCalendar(params, options, (err, body) => { + mlDeleteCalendar(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -83,11 +83,14 @@ function buildXpackMlDeleteCalendar (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + // build request object - const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -104,4 +107,4 @@ function buildXpackMlDeleteCalendar (opts) { } } -module.exports = buildXpackMlDeleteCalendar +module.exports = buildMlDeleteCalendar diff --git a/api/api/xpack.ml.delete_calendar_event.js b/api/api/ml.delete_calendar_event.js similarity index 85% rename from api/api/xpack.ml.delete_calendar_event.js rename to api/api/ml.delete_calendar_event.js index a385fcdf0..9a8e67ed5 100644 --- a/api/api/xpack.ml.delete_calendar_event.js +++ b/api/api/ml.delete_calendar_event.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlDeleteCalendarEvent (opts) { +function buildMlDeleteCalendarEvent (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.delete_calendar_event](undefined) request + * Perform a [ml.delete_calendar_event](undefined) request * * @param {string} calendar_id - The ID of the calendar to modify * @param {string} event_id - The ID of the event to remove from the calendar */ - return function xpackMlDeleteCalendarEvent (params, options, callback) { + return function mlDeleteCalendarEvent (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlDeleteCalendarEvent (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteCalendarEvent(params, options, (err, body) => { + mlDeleteCalendarEvent(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -98,11 +98,14 @@ function buildXpackMlDeleteCalendarEvent (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + '/' + 'events' + '/' + encodeURIComponent(params['event_id'] || params['eventId']) + // build request object - const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId'], 'events', params['event_id'] || params['eventId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -119,4 +122,4 @@ function buildXpackMlDeleteCalendarEvent (opts) { } } -module.exports = buildXpackMlDeleteCalendarEvent +module.exports = buildMlDeleteCalendarEvent diff --git a/api/api/xpack.ml.delete_calendar_job.js b/api/api/ml.delete_calendar_job.js similarity index 85% rename from api/api/xpack.ml.delete_calendar_job.js rename to api/api/ml.delete_calendar_job.js index 33a958c88..17dcac080 100644 --- a/api/api/xpack.ml.delete_calendar_job.js +++ b/api/api/ml.delete_calendar_job.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlDeleteCalendarJob (opts) { +function buildMlDeleteCalendarJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.delete_calendar_job](undefined) request + * Perform a [ml.delete_calendar_job](undefined) request * * @param {string} calendar_id - The ID of the calendar to modify * @param {string} job_id - The ID of the job to remove from the calendar */ - return function xpackMlDeleteCalendarJob (params, options, callback) { + return function mlDeleteCalendarJob (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlDeleteCalendarJob (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteCalendarJob(params, options, (err, body) => { + mlDeleteCalendarJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -98,11 +98,14 @@ function buildXpackMlDeleteCalendarJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + '/' + 'jobs' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + // build request object - const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId'], 'jobs', params['job_id'] || params['jobId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -119,4 +122,4 @@ function buildXpackMlDeleteCalendarJob (opts) { } } -module.exports = buildXpackMlDeleteCalendarJob +module.exports = buildMlDeleteCalendarJob diff --git a/api/api/xpack.ml.delete_datafeed.js b/api/api/ml.delete_datafeed.js similarity index 82% rename from api/api/xpack.ml.delete_datafeed.js rename to api/api/ml.delete_datafeed.js index 766ac2253..ff4b9e3f3 100644 --- a/api/api/xpack.ml.delete_datafeed.js +++ b/api/api/ml.delete_datafeed.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlDeleteDatafeed (opts) { +function buildMlDeleteDatafeed (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.delete_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html) request + * Perform a [ml.delete_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-datafeed.html) request * * @param {string} datafeed_id - The ID of the datafeed to delete * @param {boolean} force - True if the datafeed should be forcefully deleted */ - return function xpackMlDeleteDatafeed (params, options, callback) { + return function mlDeleteDatafeed (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlDeleteDatafeed (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteDatafeed(params, options, (err, body) => { + mlDeleteDatafeed(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackMlDeleteDatafeed (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + // build request object - const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -105,4 +108,4 @@ function buildXpackMlDeleteDatafeed (opts) { } } -module.exports = buildXpackMlDeleteDatafeed +module.exports = buildMlDeleteDatafeed diff --git a/api/api/xpack.ml.delete_expired_data.js b/api/api/ml.delete_expired_data.js similarity index 83% rename from api/api/xpack.ml.delete_expired_data.js rename to api/api/ml.delete_expired_data.js index bcba02e9a..95bd3781c 100644 --- a/api/api/xpack.ml.delete_expired_data.js +++ b/api/api/ml.delete_expired_data.js @@ -1,13 +1,13 @@ 'use strict' -function buildXpackMlDeleteExpiredData (opts) { +function buildMlDeleteExpiredData (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.delete_expired_data](undefined) request + * Perform a [ml.delete_expired_data](undefined) request * */ - return function xpackMlDeleteExpiredData (params, options, callback) { + return function mlDeleteExpiredData (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -21,7 +21,7 @@ function buildXpackMlDeleteExpiredData (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteExpiredData(params, options, (err, body) => { + mlDeleteExpiredData(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -76,11 +76,14 @@ function buildXpackMlDeleteExpiredData (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + '_delete_expired_data' + // build request object - const parts = ['_xpack', 'ml', '_delete_expired_data'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -97,4 +100,4 @@ function buildXpackMlDeleteExpiredData (opts) { } } -module.exports = buildXpackMlDeleteExpiredData +module.exports = buildMlDeleteExpiredData diff --git a/api/api/xpack.ml.delete_filter.js b/api/api/ml.delete_filter.js similarity index 84% rename from api/api/xpack.ml.delete_filter.js rename to api/api/ml.delete_filter.js index c16aa45df..d8306bbda 100644 --- a/api/api/xpack.ml.delete_filter.js +++ b/api/api/ml.delete_filter.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackMlDeleteFilter (opts) { +function buildMlDeleteFilter (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.delete_filter](undefined) request + * Perform a [ml.delete_filter](undefined) request * * @param {string} filter_id - The ID of the filter to delete */ - return function xpackMlDeleteFilter (params, options, callback) { + return function mlDeleteFilter (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackMlDeleteFilter (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteFilter(params, options, (err, body) => { + mlDeleteFilter(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -83,11 +83,14 @@ function buildXpackMlDeleteFilter (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(params['filter_id'] || params['filterId']) + // build request object - const parts = ['_xpack', 'ml', 'filters', params['filter_id'] || params['filterId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -104,4 +107,4 @@ function buildXpackMlDeleteFilter (opts) { } } -module.exports = buildXpackMlDeleteFilter +module.exports = buildMlDeleteFilter diff --git a/api/api/xpack.ml.delete_forecast.js b/api/api/ml.delete_forecast.js similarity index 78% rename from api/api/xpack.ml.delete_forecast.js rename to api/api/ml.delete_forecast.js index 6beb8aac4..e235dcb55 100644 --- a/api/api/xpack.ml.delete_forecast.js +++ b/api/api/ml.delete_forecast.js @@ -1,17 +1,17 @@ 'use strict' -function buildXpackMlDeleteForecast (opts) { +function buildMlDeleteForecast (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.delete_forecast](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html) request + * Perform a [ml.delete_forecast](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-forecast.html) request * * @param {string} job_id - The ID of the job from which to delete forecasts * @param {string} forecast_id - The ID of the forecast to delete, can be comma delimited list. Leaving blank implies `_all` * @param {boolean} allow_no_forecasts - Whether to ignore if `_all` matches no forecasts * @param {time} timeout - Controls the time to wait until the forecast(s) are deleted. Default to 30 seconds */ - return function xpackMlDeleteForecast (params, options, callback) { + return function mlDeleteForecast (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -25,7 +25,7 @@ function buildXpackMlDeleteForecast (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteForecast(params, options, (err, body) => { + mlDeleteForecast(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -96,11 +96,18 @@ function buildXpackMlDeleteForecast (opts) { ignore = [ignore] } + var path = '' + + if ((params['job_id'] || params['jobId']) != null && (params['forecast_id'] || params['forecastId']) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_forecast' + '/' + encodeURIComponent(params['forecast_id'] || params['forecastId']) + } else { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_forecast' + } + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_forecast', params['forecast_id'] || params['forecastId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -117,4 +124,4 @@ function buildXpackMlDeleteForecast (opts) { } } -module.exports = buildXpackMlDeleteForecast +module.exports = buildMlDeleteForecast diff --git a/api/api/xpack.ml.delete_job.js b/api/api/ml.delete_job.js similarity index 84% rename from api/api/xpack.ml.delete_job.js rename to api/api/ml.delete_job.js index 699f8c75c..dfa895748 100644 --- a/api/api/xpack.ml.delete_job.js +++ b/api/api/ml.delete_job.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackMlDeleteJob (opts) { +function buildMlDeleteJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.delete_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html) request + * Perform a [ml.delete_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-job.html) request * * @param {string} job_id - The ID of the job to delete * @param {boolean} force - True if the job should be forcefully deleted * @param {boolean} wait_for_completion - Should this request wait until the operation has completed before returning */ - return function xpackMlDeleteJob (params, options, callback) { + return function mlDeleteJob (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackMlDeleteJob (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteJob(params, options, (err, body) => { + mlDeleteJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -87,11 +87,14 @@ function buildXpackMlDeleteJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -108,4 +111,4 @@ function buildXpackMlDeleteJob (opts) { } } -module.exports = buildXpackMlDeleteJob +module.exports = buildMlDeleteJob diff --git a/api/api/xpack.ml.delete_model_snapshot.js b/api/api/ml.delete_model_snapshot.js similarity index 82% rename from api/api/xpack.ml.delete_model_snapshot.js rename to api/api/ml.delete_model_snapshot.js index 96e6f9246..61c1b8737 100644 --- a/api/api/xpack.ml.delete_model_snapshot.js +++ b/api/api/ml.delete_model_snapshot.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlDeleteModelSnapshot (opts) { +function buildMlDeleteModelSnapshot (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.delete_model_snapshot](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-snapshot.html) request + * Perform a [ml.delete_model_snapshot](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-delete-snapshot.html) request * * @param {string} job_id - The ID of the job to fetch * @param {string} snapshot_id - The ID of the snapshot to delete */ - return function xpackMlDeleteModelSnapshot (params, options, callback) { + return function mlDeleteModelSnapshot (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlDeleteModelSnapshot (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlDeleteModelSnapshot(params, options, (err, body) => { + mlDeleteModelSnapshot(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -98,11 +98,14 @@ function buildXpackMlDeleteModelSnapshot (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'model_snapshots' + '/' + encodeURIComponent(params['snapshot_id'] || params['snapshotId']) + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'model_snapshots', params['snapshot_id'] || params['snapshotId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -119,4 +122,4 @@ function buildXpackMlDeleteModelSnapshot (opts) { } } -module.exports = buildXpackMlDeleteModelSnapshot +module.exports = buildMlDeleteModelSnapshot diff --git a/api/api/xpack.ml.find_file_structure.js b/api/api/ml.find_file_structure.js similarity index 89% rename from api/api/xpack.ml.find_file_structure.js rename to api/api/ml.find_file_structure.js index 17d4f0241..cc22f0c0d 100644 --- a/api/api/xpack.ml.find_file_structure.js +++ b/api/api/ml.find_file_structure.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMlFindFileStructure (opts) { +function buildMlFindFileStructure (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.find_file_structure](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-file-structure.html) request + * Perform a [ml.find_file_structure](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-file-structure.html) request * * @param {int} lines_to_sample - How many lines of the file should be included in the analysis * @param {time} timeout - Timeout after which the analysis will be aborted @@ -21,7 +21,7 @@ function buildXpackMlFindFileStructure (opts) { * @param {boolean} explain - Whether to include a commentary on how the structure was derived * @param {object} body - The contents of the file to be analyzed */ - return function xpackMlFindFileStructure (params, options, callback) { + return function mlFindFileStructure (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -35,7 +35,7 @@ function buildXpackMlFindFileStructure (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlFindFileStructure(params, options, (err, body) => { + mlFindFileStructure(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -114,11 +114,14 @@ function buildXpackMlFindFileStructure (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'find_file_structure' + // build request object - const parts = ['_xpack', 'ml', 'find_file_structure'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -135,4 +138,4 @@ function buildXpackMlFindFileStructure (opts) { } } -module.exports = buildXpackMlFindFileStructure +module.exports = buildMlFindFileStructure diff --git a/api/api/xpack.ml.flush_job.js b/api/api/ml.flush_job.js similarity index 86% rename from api/api/xpack.ml.flush_job.js rename to api/api/ml.flush_job.js index 8adc2b00f..8f47ecdb2 100644 --- a/api/api/xpack.ml.flush_job.js +++ b/api/api/ml.flush_job.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMlFlushJob (opts) { +function buildMlFlushJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.flush_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-flush-job.html) request + * Perform a [ml.flush_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-flush-job.html) request * * @param {string} job_id - The name of the job to flush * @param {boolean} calc_interim - Calculates interim results for the most recent bucket or all buckets within the latency period @@ -14,7 +14,7 @@ function buildXpackMlFlushJob (opts) { * @param {string} skip_time - Skips time to the given value without generating results or updating the model for the skipped interval * @param {object} body - Flush parameters */ - return function xpackMlFlushJob (params, options, callback) { + return function mlFlushJob (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -28,7 +28,7 @@ function buildXpackMlFlushJob (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlFlushJob(params, options, (err, body) => { + mlFlushJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -91,11 +91,14 @@ function buildXpackMlFlushJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_flush' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_flush'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -112,4 +115,4 @@ function buildXpackMlFlushJob (opts) { } } -module.exports = buildXpackMlFlushJob +module.exports = buildMlFlushJob diff --git a/api/api/xpack.ml.forecast.js b/api/api/ml.forecast.js similarity index 86% rename from api/api/xpack.ml.forecast.js rename to api/api/ml.forecast.js index 80d6b9e7d..f6c0119b9 100644 --- a/api/api/xpack.ml.forecast.js +++ b/api/api/ml.forecast.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackMlForecast (opts) { +function buildMlForecast (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.forecast](undefined) request + * Perform a [ml.forecast](undefined) request * * @param {string} job_id - The ID of the job to forecast for * @param {time} duration - The duration of the forecast * @param {time} expires_in - The time interval after which the forecast expires. Expired forecasts will be deleted at the first opportunity. */ - return function xpackMlForecast (params, options, callback) { + return function mlForecast (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackMlForecast (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlForecast(params, options, (err, body) => { + mlForecast(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -87,11 +87,14 @@ function buildXpackMlForecast (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_forecast' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_forecast'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -108,4 +111,4 @@ function buildXpackMlForecast (opts) { } } -module.exports = buildXpackMlForecast +module.exports = buildMlForecast diff --git a/api/api/xpack.ml.get_buckets.js b/api/api/ml.get_buckets.js similarity index 81% rename from api/api/xpack.ml.get_buckets.js rename to api/api/ml.get_buckets.js index d4e6da0e9..bda3bdbaa 100644 --- a/api/api/xpack.ml.get_buckets.js +++ b/api/api/ml.get_buckets.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMlGetBuckets (opts) { +function buildMlGetBuckets (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_buckets](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-bucket.html) request + * Perform a [ml.get_buckets](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-bucket.html) request * * @param {string} job_id - ID of the job to get bucket results from * @param {string} timestamp - The timestamp of the desired single bucket result @@ -19,7 +19,7 @@ function buildXpackMlGetBuckets (opts) { * @param {boolean} desc - Set the sort direction * @param {object} body - Bucket selection details if not provided in URI */ - return function xpackMlGetBuckets (params, options, callback) { + return function mlGetBuckets (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -33,7 +33,7 @@ function buildXpackMlGetBuckets (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetBuckets(params, options, (err, body) => { + mlGetBuckets(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -112,11 +112,18 @@ function buildXpackMlGetBuckets (opts) { ignore = [ignore] } + var path = '' + + if ((params['job_id'] || params['jobId']) != null && (params['timestamp']) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'results' + '/' + 'buckets' + '/' + encodeURIComponent(params['timestamp']) + } else { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'results' + '/' + 'buckets' + } + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'results', 'buckets', params['timestamp']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -133,4 +140,4 @@ function buildXpackMlGetBuckets (opts) { } } -module.exports = buildXpackMlGetBuckets +module.exports = buildMlGetBuckets diff --git a/api/api/xpack.ml.get_calendar_events.js b/api/api/ml.get_calendar_events.js similarity index 86% rename from api/api/xpack.ml.get_calendar_events.js rename to api/api/ml.get_calendar_events.js index b01aa18f3..4a9f9872e 100644 --- a/api/api/xpack.ml.get_calendar_events.js +++ b/api/api/ml.get_calendar_events.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMlGetCalendarEvents (opts) { +function buildMlGetCalendarEvents (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_calendar_events](undefined) request + * Perform a [ml.get_calendar_events](undefined) request * * @param {string} calendar_id - The ID of the calendar containing the events * @param {string} job_id - Get events for the job. When this option is used calendar_id must be '_all' @@ -13,7 +13,7 @@ function buildXpackMlGetCalendarEvents (opts) { * @param {int} from - Skips a number of events * @param {int} size - Specifies a max number of events to get */ - return function xpackMlGetCalendarEvents (params, options, callback) { + return function mlGetCalendarEvents (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -27,7 +27,7 @@ function buildXpackMlGetCalendarEvents (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetCalendarEvents(params, options, (err, body) => { + mlGetCalendarEvents(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -96,11 +96,14 @@ function buildXpackMlGetCalendarEvents (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + '/' + 'events' + // build request object - const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId'], 'events'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -117,4 +120,4 @@ function buildXpackMlGetCalendarEvents (opts) { } } -module.exports = buildXpackMlGetCalendarEvents +module.exports = buildMlGetCalendarEvents diff --git a/api/api/xpack.ml.get_calendars.js b/api/api/ml.get_calendars.js similarity index 82% rename from api/api/xpack.ml.get_calendars.js rename to api/api/ml.get_calendars.js index 04bec5eb2..1ff78b88e 100644 --- a/api/api/xpack.ml.get_calendars.js +++ b/api/api/ml.get_calendars.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackMlGetCalendars (opts) { +function buildMlGetCalendars (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_calendars](undefined) request + * Perform a [ml.get_calendars](undefined) request * * @param {string} calendar_id - The ID of the calendar to fetch * @param {int} from - skips a number of calendars * @param {int} size - specifies a max number of calendars to get */ - return function xpackMlGetCalendars (params, options, callback) { + return function mlGetCalendars (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackMlGetCalendars (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetCalendars(params, options, (err, body) => { + mlGetCalendars(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -81,11 +81,18 @@ function buildXpackMlGetCalendars (opts) { ignore = [ignore] } + var path = '' + + if ((params['calendar_id'] || params['calendarId']) != null) { + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + } else { + path = '/' + '_ml' + '/' + 'calendars' + } + // build request object - const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -102,4 +109,4 @@ function buildXpackMlGetCalendars (opts) { } } -module.exports = buildXpackMlGetCalendars +module.exports = buildMlGetCalendars diff --git a/api/api/xpack.ml.get_categories.js b/api/api/ml.get_categories.js similarity index 75% rename from api/api/xpack.ml.get_categories.js rename to api/api/ml.get_categories.js index 749fbb47c..268a64846 100644 --- a/api/api/xpack.ml.get_categories.js +++ b/api/api/ml.get_categories.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMlGetCategories (opts) { +function buildMlGetCategories (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_categories](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-category.html) request + * Perform a [ml.get_categories](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-category.html) request * * @param {string} job_id - The name of the job * @param {long} category_id - The identifier of the category definition of interest @@ -12,7 +12,7 @@ function buildXpackMlGetCategories (opts) { * @param {int} size - specifies a max number of categories to get * @param {object} body - Category selection details if not provided in URI */ - return function xpackMlGetCategories (params, options, callback) { + return function mlGetCategories (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -26,7 +26,7 @@ function buildXpackMlGetCategories (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetCategories(params, options, (err, body) => { + mlGetCategories(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -83,13 +83,18 @@ function buildXpackMlGetCategories (opts) { ignore = [ignore] } + var path = '' + + if ((params['job_id'] || params['jobId']) != null && (params['category_id'] || params['categoryId']) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'results' + '/' + 'categories' + '/' + encodeURIComponent(params['category_id'] || params['categoryId']) + } else { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'results' + '/' + 'categories' + } + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'results', 'categories'] const request = { method, - path: (params['job_id'] || params['jobId']) != null - ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') - : '/_xpack/ml/anomaly_detectors/{job_id}/results/categories/{category_id}', + path, body: params.body || '', querystring } @@ -106,4 +111,4 @@ function buildXpackMlGetCategories (opts) { } } -module.exports = buildXpackMlGetCategories +module.exports = buildMlGetCategories diff --git a/api/api/xpack.ml.get_datafeed_stats.js b/api/api/ml.get_datafeed_stats.js similarity index 78% rename from api/api/xpack.ml.get_datafeed_stats.js rename to api/api/ml.get_datafeed_stats.js index 496d18b75..6d84d3f61 100644 --- a/api/api/xpack.ml.get_datafeed_stats.js +++ b/api/api/ml.get_datafeed_stats.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlGetDatafeedStats (opts) { +function buildMlGetDatafeedStats (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_datafeed_stats](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed-stats.html) request + * Perform a [ml.get_datafeed_stats](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed-stats.html) request * * @param {string} datafeed_id - The ID of the datafeeds stats to fetch * @param {boolean} allow_no_datafeeds - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) */ - return function xpackMlGetDatafeedStats (params, options, callback) { + return function mlGetDatafeedStats (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlGetDatafeedStats (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetDatafeedStats(params, options, (err, body) => { + mlGetDatafeedStats(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -78,11 +78,18 @@ function buildXpackMlGetDatafeedStats (opts) { ignore = [ignore] } + var path = '' + + if ((params['datafeed_id'] || params['datafeedId']) != null) { + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + '/' + '_stats' + } else { + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + '_stats' + } + // build request object - const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId'], '_stats'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -99,4 +106,4 @@ function buildXpackMlGetDatafeedStats (opts) { } } -module.exports = buildXpackMlGetDatafeedStats +module.exports = buildMlGetDatafeedStats diff --git a/api/api/xpack.ml.get_datafeeds.js b/api/api/ml.get_datafeeds.js similarity index 80% rename from api/api/xpack.ml.get_datafeeds.js rename to api/api/ml.get_datafeeds.js index ede837077..98a90d8db 100644 --- a/api/api/xpack.ml.get_datafeeds.js +++ b/api/api/ml.get_datafeeds.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlGetDatafeeds (opts) { +function buildMlGetDatafeeds (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_datafeeds](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed.html) request + * Perform a [ml.get_datafeeds](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-datafeed.html) request * * @param {string} datafeed_id - The ID of the datafeeds to fetch * @param {boolean} allow_no_datafeeds - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) */ - return function xpackMlGetDatafeeds (params, options, callback) { + return function mlGetDatafeeds (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlGetDatafeeds (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetDatafeeds(params, options, (err, body) => { + mlGetDatafeeds(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -78,11 +78,18 @@ function buildXpackMlGetDatafeeds (opts) { ignore = [ignore] } + var path = '' + + if ((params['datafeed_id'] || params['datafeedId']) != null) { + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + } else { + path = '/' + '_ml' + '/' + 'datafeeds' + } + // build request object - const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -99,4 +106,4 @@ function buildXpackMlGetDatafeeds (opts) { } } -module.exports = buildXpackMlGetDatafeeds +module.exports = buildMlGetDatafeeds diff --git a/api/api/xpack.ml.get_filters.js b/api/api/ml.get_filters.js similarity index 82% rename from api/api/xpack.ml.get_filters.js rename to api/api/ml.get_filters.js index 83b6d2a77..952af25a9 100644 --- a/api/api/xpack.ml.get_filters.js +++ b/api/api/ml.get_filters.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackMlGetFilters (opts) { +function buildMlGetFilters (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_filters](undefined) request + * Perform a [ml.get_filters](undefined) request * * @param {string} filter_id - The ID of the filter to fetch * @param {int} from - skips a number of filters * @param {int} size - specifies a max number of filters to get */ - return function xpackMlGetFilters (params, options, callback) { + return function mlGetFilters (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackMlGetFilters (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetFilters(params, options, (err, body) => { + mlGetFilters(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -81,11 +81,18 @@ function buildXpackMlGetFilters (opts) { ignore = [ignore] } + var path = '' + + if ((params['filter_id'] || params['filterId']) != null) { + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(params['filter_id'] || params['filterId']) + } else { + path = '/' + '_ml' + '/' + 'filters' + } + // build request object - const parts = ['_xpack', 'ml', 'filters', params['filter_id'] || params['filterId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -102,4 +109,4 @@ function buildXpackMlGetFilters (opts) { } } -module.exports = buildXpackMlGetFilters +module.exports = buildMlGetFilters diff --git a/api/api/xpack.ml.get_influencers.js b/api/api/ml.get_influencers.js similarity index 85% rename from api/api/xpack.ml.get_influencers.js rename to api/api/ml.get_influencers.js index 8c8fed39e..d7629cb08 100644 --- a/api/api/xpack.ml.get_influencers.js +++ b/api/api/ml.get_influencers.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMlGetInfluencers (opts) { +function buildMlGetInfluencers (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_influencers](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-influencer.html) request + * Perform a [ml.get_influencers](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-influencer.html) request * * @param {string} job_id - * @param {boolean} exclude_interim - Exclude interim results @@ -17,7 +17,7 @@ function buildXpackMlGetInfluencers (opts) { * @param {boolean} desc - whether the results should be sorted in decending order * @param {object} body - Influencer selection criteria */ - return function xpackMlGetInfluencers (params, options, callback) { + return function mlGetInfluencers (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -31,7 +31,7 @@ function buildXpackMlGetInfluencers (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetInfluencers(params, options, (err, body) => { + mlGetInfluencers(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -100,11 +100,14 @@ function buildXpackMlGetInfluencers (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'results' + '/' + 'influencers' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'results', 'influencers'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -121,4 +124,4 @@ function buildXpackMlGetInfluencers (opts) { } } -module.exports = buildXpackMlGetInfluencers +module.exports = buildMlGetInfluencers diff --git a/api/api/xpack.ml.get_job_stats.js b/api/api/ml.get_job_stats.js similarity index 79% rename from api/api/xpack.ml.get_job_stats.js rename to api/api/ml.get_job_stats.js index 26b9fe6a0..0b96ccb0f 100644 --- a/api/api/xpack.ml.get_job_stats.js +++ b/api/api/ml.get_job_stats.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlGetJobStats (opts) { +function buildMlGetJobStats (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_job_stats](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-stats.html) request + * Perform a [ml.get_job_stats](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-stats.html) request * * @param {string} job_id - The ID of the jobs stats to fetch * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) */ - return function xpackMlGetJobStats (params, options, callback) { + return function mlGetJobStats (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlGetJobStats (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetJobStats(params, options, (err, body) => { + mlGetJobStats(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -78,11 +78,18 @@ function buildXpackMlGetJobStats (opts) { ignore = [ignore] } + var path = '' + + if ((params['job_id'] || params['jobId']) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_stats' + } else { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_stats' + } + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_stats'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -99,4 +106,4 @@ function buildXpackMlGetJobStats (opts) { } } -module.exports = buildXpackMlGetJobStats +module.exports = buildMlGetJobStats diff --git a/api/api/xpack.ml.get_jobs.js b/api/api/ml.get_jobs.js similarity index 81% rename from api/api/xpack.ml.get_jobs.js rename to api/api/ml.get_jobs.js index ca5598ab8..5d471a4af 100644 --- a/api/api/xpack.ml.get_jobs.js +++ b/api/api/ml.get_jobs.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlGetJobs (opts) { +function buildMlGetJobs (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_jobs](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job.html) request + * Perform a [ml.get_jobs](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job.html) request * * @param {string} job_id - The ID of the jobs to fetch * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) */ - return function xpackMlGetJobs (params, options, callback) { + return function mlGetJobs (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlGetJobs (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetJobs(params, options, (err, body) => { + mlGetJobs(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -78,11 +78,18 @@ function buildXpackMlGetJobs (opts) { ignore = [ignore] } + var path = '' + + if ((params['job_id'] || params['jobId']) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + } else { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + } + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -99,4 +106,4 @@ function buildXpackMlGetJobs (opts) { } } -module.exports = buildXpackMlGetJobs +module.exports = buildMlGetJobs diff --git a/api/api/xpack.ml.get_model_snapshots.js b/api/api/ml.get_model_snapshots.js similarity index 79% rename from api/api/xpack.ml.get_model_snapshots.js rename to api/api/ml.get_model_snapshots.js index f3cc57b0b..49511b048 100644 --- a/api/api/xpack.ml.get_model_snapshots.js +++ b/api/api/ml.get_model_snapshots.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMlGetModelSnapshots (opts) { +function buildMlGetModelSnapshots (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_model_snapshots](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-snapshot.html) request + * Perform a [ml.get_model_snapshots](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-snapshot.html) request * * @param {string} job_id - The ID of the job to fetch * @param {string} snapshot_id - The ID of the snapshot to fetch @@ -16,7 +16,7 @@ function buildXpackMlGetModelSnapshots (opts) { * @param {boolean} desc - True if the results should be sorted in descending order * @param {object} body - Model snapshot selection criteria */ - return function xpackMlGetModelSnapshots (params, options, callback) { + return function mlGetModelSnapshots (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -30,7 +30,7 @@ function buildXpackMlGetModelSnapshots (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetModelSnapshots(params, options, (err, body) => { + mlGetModelSnapshots(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -103,11 +103,18 @@ function buildXpackMlGetModelSnapshots (opts) { ignore = [ignore] } + var path = '' + + if ((params['job_id'] || params['jobId']) != null && (params['snapshot_id'] || params['snapshotId']) != null) { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'model_snapshots' + '/' + encodeURIComponent(params['snapshot_id'] || params['snapshotId']) + } else { + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'model_snapshots' + } + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'model_snapshots', params['snapshot_id'] || params['snapshotId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -124,4 +131,4 @@ function buildXpackMlGetModelSnapshots (opts) { } } -module.exports = buildXpackMlGetModelSnapshots +module.exports = buildMlGetModelSnapshots diff --git a/api/api/xpack.ml.get_overall_buckets.js b/api/api/ml.get_overall_buckets.js similarity index 85% rename from api/api/xpack.ml.get_overall_buckets.js rename to api/api/ml.get_overall_buckets.js index 9aa67112f..a9db109a2 100644 --- a/api/api/xpack.ml.get_overall_buckets.js +++ b/api/api/ml.get_overall_buckets.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMlGetOverallBuckets (opts) { +function buildMlGetOverallBuckets (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_overall_buckets](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-overall-buckets.html) request + * Perform a [ml.get_overall_buckets](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-overall-buckets.html) request * * @param {string} job_id - The job IDs for which to calculate overall bucket results * @param {int} top_n - The number of top job bucket scores to be used in the overall_score calculation @@ -16,7 +16,7 @@ function buildXpackMlGetOverallBuckets (opts) { * @param {boolean} allow_no_jobs - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) * @param {object} body - Overall bucket selection details if not provided in URI */ - return function xpackMlGetOverallBuckets (params, options, callback) { + return function mlGetOverallBuckets (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -30,7 +30,7 @@ function buildXpackMlGetOverallBuckets (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetOverallBuckets(params, options, (err, body) => { + mlGetOverallBuckets(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -97,11 +97,14 @@ function buildXpackMlGetOverallBuckets (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'results' + '/' + 'overall_buckets' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'results', 'overall_buckets'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -118,4 +121,4 @@ function buildXpackMlGetOverallBuckets (opts) { } } -module.exports = buildXpackMlGetOverallBuckets +module.exports = buildMlGetOverallBuckets diff --git a/api/api/xpack.ml.get_records.js b/api/api/ml.get_records.js similarity index 85% rename from api/api/xpack.ml.get_records.js rename to api/api/ml.get_records.js index f5e2a2b88..5f8b35aba 100644 --- a/api/api/xpack.ml.get_records.js +++ b/api/api/ml.get_records.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMlGetRecords (opts) { +function buildMlGetRecords (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.get_records](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-record.html) request + * Perform a [ml.get_records](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-record.html) request * * @param {string} job_id - * @param {boolean} exclude_interim - Exclude interim results @@ -17,7 +17,7 @@ function buildXpackMlGetRecords (opts) { * @param {boolean} desc - Set the sort direction * @param {object} body - Record selection criteria */ - return function xpackMlGetRecords (params, options, callback) { + return function mlGetRecords (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -31,7 +31,7 @@ function buildXpackMlGetRecords (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlGetRecords(params, options, (err, body) => { + mlGetRecords(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -100,11 +100,14 @@ function buildXpackMlGetRecords (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'results' + '/' + 'records' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'results', 'records'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -121,4 +124,4 @@ function buildXpackMlGetRecords (opts) { } } -module.exports = buildXpackMlGetRecords +module.exports = buildMlGetRecords diff --git a/api/api/xpack.ml.info.js b/api/api/ml.info.js similarity index 85% rename from api/api/xpack.ml.info.js rename to api/api/ml.info.js index cab59acec..3885261f9 100644 --- a/api/api/xpack.ml.info.js +++ b/api/api/ml.info.js @@ -1,13 +1,13 @@ 'use strict' -function buildXpackMlInfo (opts) { +function buildMlInfo (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.info](undefined) request + * Perform a [ml.info](undefined) request * */ - return function xpackMlInfo (params, options, callback) { + return function mlInfo (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -21,7 +21,7 @@ function buildXpackMlInfo (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlInfo(params, options, (err, body) => { + mlInfo(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -68,11 +68,14 @@ function buildXpackMlInfo (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'info' + // build request object - const parts = ['_xpack', 'ml', 'info'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -89,4 +92,4 @@ function buildXpackMlInfo (opts) { } } -module.exports = buildXpackMlInfo +module.exports = buildMlInfo diff --git a/api/api/xpack.ml.open_job.js b/api/api/ml.open_job.js similarity index 84% rename from api/api/xpack.ml.open_job.js rename to api/api/ml.open_job.js index 2b1bd7d56..47df12f64 100644 --- a/api/api/xpack.ml.open_job.js +++ b/api/api/ml.open_job.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackMlOpenJob (opts) { +function buildMlOpenJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.open_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html) request + * Perform a [ml.open_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html) request * * @param {string} job_id - The ID of the job to open * @param {boolean} ignore_downtime - Controls if gaps in data are treated as anomalous or as a maintenance window after a job re-start * @param {time} timeout - Controls the time to wait until a job has opened. Default to 30 minutes */ - return function xpackMlOpenJob (params, options, callback) { + return function mlOpenJob (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackMlOpenJob (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlOpenJob(params, options, (err, body) => { + mlOpenJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -85,11 +85,14 @@ function buildXpackMlOpenJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_open' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_open'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -106,4 +109,4 @@ function buildXpackMlOpenJob (opts) { } } -module.exports = buildXpackMlOpenJob +module.exports = buildMlOpenJob diff --git a/api/api/xpack.ml.post_calendar_events.js b/api/api/ml.post_calendar_events.js similarity index 83% rename from api/api/xpack.ml.post_calendar_events.js rename to api/api/ml.post_calendar_events.js index 742901991..565807442 100644 --- a/api/api/xpack.ml.post_calendar_events.js +++ b/api/api/ml.post_calendar_events.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlPostCalendarEvents (opts) { +function buildMlPostCalendarEvents (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.post_calendar_events](undefined) request + * Perform a [ml.post_calendar_events](undefined) request * * @param {string} calendar_id - The ID of the calendar to modify * @param {object} body - A list of events */ - return function xpackMlPostCalendarEvents (params, options, callback) { + return function mlPostCalendarEvents (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlPostCalendarEvents (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPostCalendarEvents(params, options, (err, body) => { + mlPostCalendarEvents(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackMlPostCalendarEvents (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + '/' + 'events' + // build request object - const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId'], 'events'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -105,4 +108,4 @@ function buildXpackMlPostCalendarEvents (opts) { } } -module.exports = buildXpackMlPostCalendarEvents +module.exports = buildMlPostCalendarEvents diff --git a/api/api/xpack.ml.post_data.js b/api/api/ml.post_data.js similarity index 84% rename from api/api/xpack.ml.post_data.js rename to api/api/ml.post_data.js index 859c816e7..708b4fdf8 100644 --- a/api/api/xpack.ml.post_data.js +++ b/api/api/ml.post_data.js @@ -1,17 +1,17 @@ 'use strict' -function buildXpackMlPostData (opts) { +function buildMlPostData (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.post_data](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-data.html) request + * Perform a [ml.post_data](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-post-data.html) request * * @param {string} job_id - The name of the job receiving the data * @param {string} reset_start - Optional parameter to specify the start of the bucket resetting range * @param {string} reset_end - Optional parameter to specify the end of the bucket resetting range * @param {object} body - The data to process */ - return function xpackMlPostData (params, options, callback) { + return function mlPostData (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -25,7 +25,7 @@ function buildXpackMlPostData (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPostData(params, options, (err, body) => { + mlPostData(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -88,11 +88,14 @@ function buildXpackMlPostData (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_data' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_data'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -109,4 +112,4 @@ function buildXpackMlPostData (opts) { } } -module.exports = buildXpackMlPostData +module.exports = buildMlPostData diff --git a/api/api/xpack.ml.preview_datafeed.js b/api/api/ml.preview_datafeed.js similarity index 81% rename from api/api/xpack.ml.preview_datafeed.js rename to api/api/ml.preview_datafeed.js index 4b13d142a..6d0c27191 100644 --- a/api/api/xpack.ml.preview_datafeed.js +++ b/api/api/ml.preview_datafeed.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackMlPreviewDatafeed (opts) { +function buildMlPreviewDatafeed (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.preview_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html) request + * Perform a [ml.preview_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-preview-datafeed.html) request * * @param {string} datafeed_id - The ID of the datafeed to preview */ - return function xpackMlPreviewDatafeed (params, options, callback) { + return function mlPreviewDatafeed (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackMlPreviewDatafeed (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPreviewDatafeed(params, options, (err, body) => { + mlPreviewDatafeed(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -83,11 +83,14 @@ function buildXpackMlPreviewDatafeed (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + '/' + '_preview' + // build request object - const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId'], '_preview'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -104,4 +107,4 @@ function buildXpackMlPreviewDatafeed (opts) { } } -module.exports = buildXpackMlPreviewDatafeed +module.exports = buildMlPreviewDatafeed diff --git a/api/api/xpack.ml.put_calendar.js b/api/api/ml.put_calendar.js similarity index 84% rename from api/api/xpack.ml.put_calendar.js rename to api/api/ml.put_calendar.js index eab6cc376..16220fea7 100644 --- a/api/api/xpack.ml.put_calendar.js +++ b/api/api/ml.put_calendar.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlPutCalendar (opts) { +function buildMlPutCalendar (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.put_calendar](undefined) request + * Perform a [ml.put_calendar](undefined) request * * @param {string} calendar_id - The ID of the calendar to create * @param {object} body - The calendar details */ - return function xpackMlPutCalendar (params, options, callback) { + return function mlPutCalendar (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlPutCalendar (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPutCalendar(params, options, (err, body) => { + mlPutCalendar(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -78,11 +78,14 @@ function buildXpackMlPutCalendar (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + // build request object - const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -99,4 +102,4 @@ function buildXpackMlPutCalendar (opts) { } } -module.exports = buildXpackMlPutCalendar +module.exports = buildMlPutCalendar diff --git a/api/api/xpack.ml.put_calendar_job.js b/api/api/ml.put_calendar_job.js similarity index 85% rename from api/api/xpack.ml.put_calendar_job.js rename to api/api/ml.put_calendar_job.js index 0ea1a089e..d61cdce3f 100644 --- a/api/api/xpack.ml.put_calendar_job.js +++ b/api/api/ml.put_calendar_job.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlPutCalendarJob (opts) { +function buildMlPutCalendarJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.put_calendar_job](undefined) request + * Perform a [ml.put_calendar_job](undefined) request * * @param {string} calendar_id - The ID of the calendar to modify * @param {string} job_id - The ID of the job to add to the calendar */ - return function xpackMlPutCalendarJob (params, options, callback) { + return function mlPutCalendarJob (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlPutCalendarJob (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPutCalendarJob(params, options, (err, body) => { + mlPutCalendarJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -98,11 +98,14 @@ function buildXpackMlPutCalendarJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'calendars' + '/' + encodeURIComponent(params['calendar_id'] || params['calendarId']) + '/' + 'jobs' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + // build request object - const parts = ['_xpack', 'ml', 'calendars', params['calendar_id'] || params['calendarId'], 'jobs', params['job_id'] || params['jobId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -119,4 +122,4 @@ function buildXpackMlPutCalendarJob (opts) { } } -module.exports = buildXpackMlPutCalendarJob +module.exports = buildMlPutCalendarJob diff --git a/api/api/xpack.ml.put_datafeed.js b/api/api/ml.put_datafeed.js similarity index 83% rename from api/api/xpack.ml.put_datafeed.js rename to api/api/ml.put_datafeed.js index fa011a506..3cc416c86 100644 --- a/api/api/xpack.ml.put_datafeed.js +++ b/api/api/ml.put_datafeed.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlPutDatafeed (opts) { +function buildMlPutDatafeed (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.put_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-datafeed.html) request + * Perform a [ml.put_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-datafeed.html) request * * @param {string} datafeed_id - The ID of the datafeed to create * @param {object} body - The datafeed config */ - return function xpackMlPutDatafeed (params, options, callback) { + return function mlPutDatafeed (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlPutDatafeed (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPutDatafeed(params, options, (err, body) => { + mlPutDatafeed(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackMlPutDatafeed (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + // build request object - const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -105,4 +108,4 @@ function buildXpackMlPutDatafeed (opts) { } } -module.exports = buildXpackMlPutDatafeed +module.exports = buildMlPutDatafeed diff --git a/api/api/xpack.ml.put_filter.js b/api/api/ml.put_filter.js similarity index 85% rename from api/api/xpack.ml.put_filter.js rename to api/api/ml.put_filter.js index 64baba8d5..2f2645f05 100644 --- a/api/api/xpack.ml.put_filter.js +++ b/api/api/ml.put_filter.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlPutFilter (opts) { +function buildMlPutFilter (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.put_filter](undefined) request + * Perform a [ml.put_filter](undefined) request * * @param {string} filter_id - The ID of the filter to create * @param {object} body - The filter details */ - return function xpackMlPutFilter (params, options, callback) { + return function mlPutFilter (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlPutFilter (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPutFilter(params, options, (err, body) => { + mlPutFilter(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackMlPutFilter (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(params['filter_id'] || params['filterId']) + // build request object - const parts = ['_xpack', 'ml', 'filters', params['filter_id'] || params['filterId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -105,4 +108,4 @@ function buildXpackMlPutFilter (opts) { } } -module.exports = buildXpackMlPutFilter +module.exports = buildMlPutFilter diff --git a/api/api/xpack.ml.put_job.js b/api/api/ml.put_job.js similarity index 83% rename from api/api/xpack.ml.put_job.js rename to api/api/ml.put_job.js index 333249a33..b9abe9a4e 100644 --- a/api/api/xpack.ml.put_job.js +++ b/api/api/ml.put_job.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlPutJob (opts) { +function buildMlPutJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.put_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html) request + * Perform a [ml.put_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-put-job.html) request * * @param {string} job_id - The ID of the job to create * @param {object} body - The job */ - return function xpackMlPutJob (params, options, callback) { + return function mlPutJob (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlPutJob (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlPutJob(params, options, (err, body) => { + mlPutJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackMlPutJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -105,4 +108,4 @@ function buildXpackMlPutJob (opts) { } } -module.exports = buildXpackMlPutJob +module.exports = buildMlPutJob diff --git a/api/api/xpack.ml.revert_model_snapshot.js b/api/api/ml.revert_model_snapshot.js similarity index 83% rename from api/api/xpack.ml.revert_model_snapshot.js rename to api/api/ml.revert_model_snapshot.js index b04c713bf..dd4446ada 100644 --- a/api/api/xpack.ml.revert_model_snapshot.js +++ b/api/api/ml.revert_model_snapshot.js @@ -1,17 +1,17 @@ 'use strict' -function buildXpackMlRevertModelSnapshot (opts) { +function buildMlRevertModelSnapshot (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.revert_model_snapshot](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-revert-snapshot.html) request + * Perform a [ml.revert_model_snapshot](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-revert-snapshot.html) request * * @param {string} job_id - The ID of the job to fetch * @param {string} snapshot_id - The ID of the snapshot to revert to * @param {boolean} delete_intervening_results - Should we reset the results back to the time of the snapshot? * @param {object} body - Reversion options */ - return function xpackMlRevertModelSnapshot (params, options, callback) { + return function mlRevertModelSnapshot (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -25,7 +25,7 @@ function buildXpackMlRevertModelSnapshot (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlRevertModelSnapshot(params, options, (err, body) => { + mlRevertModelSnapshot(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -94,11 +94,14 @@ function buildXpackMlRevertModelSnapshot (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'model_snapshots' + '/' + encodeURIComponent(params['snapshot_id'] || params['snapshotId']) + '/' + '_revert' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'model_snapshots', params['snapshot_id'] || params['snapshotId'], '_revert'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -115,4 +118,4 @@ function buildXpackMlRevertModelSnapshot (opts) { } } -module.exports = buildXpackMlRevertModelSnapshot +module.exports = buildMlRevertModelSnapshot diff --git a/api/api/xpack.ml.start_datafeed.js b/api/api/ml.start_datafeed.js similarity index 83% rename from api/api/xpack.ml.start_datafeed.js rename to api/api/ml.start_datafeed.js index 57fc53830..789b906f8 100644 --- a/api/api/xpack.ml.start_datafeed.js +++ b/api/api/ml.start_datafeed.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMlStartDatafeed (opts) { +function buildMlStartDatafeed (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.start_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-start-datafeed.html) request + * Perform a [ml.start_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-start-datafeed.html) request * * @param {string} datafeed_id - The ID of the datafeed to start * @param {string} start - The start time from where the datafeed should begin @@ -12,7 +12,7 @@ function buildXpackMlStartDatafeed (opts) { * @param {time} timeout - Controls the time to wait until a datafeed has started. Default to 20 seconds * @param {object} body - The start datafeed parameters */ - return function xpackMlStartDatafeed (params, options, callback) { + return function mlStartDatafeed (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -26,7 +26,7 @@ function buildXpackMlStartDatafeed (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlStartDatafeed(params, options, (err, body) => { + mlStartDatafeed(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -85,11 +85,14 @@ function buildXpackMlStartDatafeed (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + '/' + '_start' + // build request object - const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId'], '_start'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -106,4 +109,4 @@ function buildXpackMlStartDatafeed (opts) { } } -module.exports = buildXpackMlStartDatafeed +module.exports = buildMlStartDatafeed diff --git a/api/api/xpack.ml.stop_datafeed.js b/api/api/ml.stop_datafeed.js similarity index 84% rename from api/api/xpack.ml.stop_datafeed.js rename to api/api/ml.stop_datafeed.js index e0a8cd330..59ec92d8e 100644 --- a/api/api/xpack.ml.stop_datafeed.js +++ b/api/api/ml.stop_datafeed.js @@ -1,17 +1,17 @@ 'use strict' -function buildXpackMlStopDatafeed (opts) { +function buildMlStopDatafeed (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.stop_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-stop-datafeed.html) request + * Perform a [ml.stop_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-stop-datafeed.html) request * * @param {string} datafeed_id - The ID of the datafeed to stop * @param {boolean} allow_no_datafeeds - Whether to ignore if a wildcard expression matches no datafeeds. (This includes `_all` string or when no datafeeds have been specified) * @param {boolean} force - True if the datafeed should be forcefully stopped. * @param {time} timeout - Controls the time to wait until a datafeed has stopped. Default to 20 seconds */ - return function xpackMlStopDatafeed (params, options, callback) { + return function mlStopDatafeed (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -25,7 +25,7 @@ function buildXpackMlStopDatafeed (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlStopDatafeed(params, options, (err, body) => { + mlStopDatafeed(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackMlStopDatafeed (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + '/' + '_stop' + // build request object - const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId'], '_stop'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -105,4 +108,4 @@ function buildXpackMlStopDatafeed (opts) { } } -module.exports = buildXpackMlStopDatafeed +module.exports = buildMlStopDatafeed diff --git a/api/api/xpack.ml.update_datafeed.js b/api/api/ml.update_datafeed.js similarity index 82% rename from api/api/xpack.ml.update_datafeed.js rename to api/api/ml.update_datafeed.js index 15d6881df..e2742e273 100644 --- a/api/api/xpack.ml.update_datafeed.js +++ b/api/api/ml.update_datafeed.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlUpdateDatafeed (opts) { +function buildMlUpdateDatafeed (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.update_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-datafeed.html) request + * Perform a [ml.update_datafeed](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-datafeed.html) request * * @param {string} datafeed_id - The ID of the datafeed to update * @param {object} body - The datafeed update settings */ - return function xpackMlUpdateDatafeed (params, options, callback) { + return function mlUpdateDatafeed (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlUpdateDatafeed (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlUpdateDatafeed(params, options, (err, body) => { + mlUpdateDatafeed(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackMlUpdateDatafeed (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'datafeeds' + '/' + encodeURIComponent(params['datafeed_id'] || params['datafeedId']) + '/' + '_update' + // build request object - const parts = ['_xpack', 'ml', 'datafeeds', params['datafeed_id'] || params['datafeedId'], '_update'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -105,4 +108,4 @@ function buildXpackMlUpdateDatafeed (opts) { } } -module.exports = buildXpackMlUpdateDatafeed +module.exports = buildMlUpdateDatafeed diff --git a/api/api/xpack.ml.update_filter.js b/api/api/ml.update_filter.js similarity index 84% rename from api/api/xpack.ml.update_filter.js rename to api/api/ml.update_filter.js index 21543f6c1..1f5e094c7 100644 --- a/api/api/xpack.ml.update_filter.js +++ b/api/api/ml.update_filter.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlUpdateFilter (opts) { +function buildMlUpdateFilter (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.update_filter](undefined) request + * Perform a [ml.update_filter](undefined) request * * @param {string} filter_id - The ID of the filter to update * @param {object} body - The filter update */ - return function xpackMlUpdateFilter (params, options, callback) { + return function mlUpdateFilter (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlUpdateFilter (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlUpdateFilter(params, options, (err, body) => { + mlUpdateFilter(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackMlUpdateFilter (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'filters' + '/' + encodeURIComponent(params['filter_id'] || params['filterId']) + '/' + '_update' + // build request object - const parts = ['_xpack', 'ml', 'filters', params['filter_id'] || params['filterId'], '_update'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -105,4 +108,4 @@ function buildXpackMlUpdateFilter (opts) { } } -module.exports = buildXpackMlUpdateFilter +module.exports = buildMlUpdateFilter diff --git a/api/api/xpack.ml.update_job.js b/api/api/ml.update_job.js similarity index 83% rename from api/api/xpack.ml.update_job.js rename to api/api/ml.update_job.js index d0bd8c310..5d4ee264e 100644 --- a/api/api/xpack.ml.update_job.js +++ b/api/api/ml.update_job.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackMlUpdateJob (opts) { +function buildMlUpdateJob (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.update_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-job.html) request + * Perform a [ml.update_job](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-job.html) request * * @param {string} job_id - The ID of the job to create * @param {object} body - The job update settings */ - return function xpackMlUpdateJob (params, options, callback) { + return function mlUpdateJob (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackMlUpdateJob (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlUpdateJob(params, options, (err, body) => { + mlUpdateJob(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackMlUpdateJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + '_update' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], '_update'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -105,4 +108,4 @@ function buildXpackMlUpdateJob (opts) { } } -module.exports = buildXpackMlUpdateJob +module.exports = buildMlUpdateJob diff --git a/api/api/xpack.ml.update_model_snapshot.js b/api/api/ml.update_model_snapshot.js similarity index 83% rename from api/api/xpack.ml.update_model_snapshot.js rename to api/api/ml.update_model_snapshot.js index a01271522..e2fe7ec1b 100644 --- a/api/api/xpack.ml.update_model_snapshot.js +++ b/api/api/ml.update_model_snapshot.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackMlUpdateModelSnapshot (opts) { +function buildMlUpdateModelSnapshot (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.update_model_snapshot](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-snapshot.html) request + * Perform a [ml.update_model_snapshot](http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-update-snapshot.html) request * * @param {string} job_id - The ID of the job to fetch * @param {string} snapshot_id - The ID of the snapshot to update * @param {object} body - The model snapshot properties to update */ - return function xpackMlUpdateModelSnapshot (params, options, callback) { + return function mlUpdateModelSnapshot (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackMlUpdateModelSnapshot (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlUpdateModelSnapshot(params, options, (err, body) => { + mlUpdateModelSnapshot(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -99,11 +99,14 @@ function buildXpackMlUpdateModelSnapshot (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(params['job_id'] || params['jobId']) + '/' + 'model_snapshots' + '/' + encodeURIComponent(params['snapshot_id'] || params['snapshotId']) + '/' + '_update' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', params['job_id'] || params['jobId'], 'model_snapshots', params['snapshot_id'] || params['snapshotId'], '_update'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -120,4 +123,4 @@ function buildXpackMlUpdateModelSnapshot (opts) { } } -module.exports = buildXpackMlUpdateModelSnapshot +module.exports = buildMlUpdateModelSnapshot diff --git a/api/api/xpack.ml.validate.js b/api/api/ml.validate.js similarity index 85% rename from api/api/xpack.ml.validate.js rename to api/api/ml.validate.js index fe14682e2..2f9dd9e22 100644 --- a/api/api/xpack.ml.validate.js +++ b/api/api/ml.validate.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackMlValidate (opts) { +function buildMlValidate (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.validate](undefined) request + * Perform a [ml.validate](undefined) request * * @param {object} body - The job config */ - return function xpackMlValidate (params, options, callback) { + return function mlValidate (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackMlValidate (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlValidate(params, options, (err, body) => { + mlValidate(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -77,11 +77,14 @@ function buildXpackMlValidate (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_validate' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', '_validate'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -98,4 +101,4 @@ function buildXpackMlValidate (opts) { } } -module.exports = buildXpackMlValidate +module.exports = buildMlValidate diff --git a/api/api/xpack.ml.validate_detector.js b/api/api/ml.validate_detector.js similarity index 83% rename from api/api/xpack.ml.validate_detector.js rename to api/api/ml.validate_detector.js index 9a4215521..93cceaf23 100644 --- a/api/api/xpack.ml.validate_detector.js +++ b/api/api/ml.validate_detector.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackMlValidateDetector (opts) { +function buildMlValidateDetector (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ml.validate_detector](undefined) request + * Perform a [ml.validate_detector](undefined) request * * @param {object} body - The detector */ - return function xpackMlValidateDetector (params, options, callback) { + return function mlValidateDetector (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackMlValidateDetector (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMlValidateDetector(params, options, (err, body) => { + mlValidateDetector(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -77,11 +77,14 @@ function buildXpackMlValidateDetector (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_ml' + '/' + 'anomaly_detectors' + '/' + '_validate' + '/' + 'detector' + // build request object - const parts = ['_xpack', 'ml', 'anomaly_detectors', '_validate', 'detector'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -98,4 +101,4 @@ function buildXpackMlValidateDetector (opts) { } } -module.exports = buildXpackMlValidateDetector +module.exports = buildMlValidateDetector diff --git a/api/api/xpack.monitoring.bulk.js b/api/api/monitoring.bulk.js similarity index 83% rename from api/api/xpack.monitoring.bulk.js rename to api/api/monitoring.bulk.js index 35e9dea06..aa71f8154 100644 --- a/api/api/xpack.monitoring.bulk.js +++ b/api/api/monitoring.bulk.js @@ -1,10 +1,10 @@ 'use strict' -function buildXpackMonitoringBulk (opts) { +function buildMonitoringBulk (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.monitoring.bulk](http://www.elastic.co/guide/en/monitoring/current/appendix-api-bulk.html) request + * Perform a [monitoring.bulk](http://www.elastic.co/guide/en/monitoring/current/appendix-api-bulk.html) request * * @param {string} type - Default document type for items which don't provide one * @param {string} system_id - Identifier of the monitored system @@ -12,7 +12,7 @@ function buildXpackMonitoringBulk (opts) { * @param {string} interval - Collection interval (e.g., '10s' or '10000ms') of the payload * @param {object} body - The operation definition and data (action-data pairs), separated by newlines */ - return function xpackMonitoringBulk (params, options, callback) { + return function monitoringBulk (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -26,7 +26,7 @@ function buildXpackMonitoringBulk (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackMonitoringBulk(params, options, (err, body) => { + monitoringBulk(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -85,11 +85,18 @@ function buildXpackMonitoringBulk (opts) { ignore = [ignore] } + var path = '' + + if ((params['type']) != null) { + path = '/' + '_monitoring' + '/' + encodeURIComponent(params['type']) + '/' + 'bulk' + } else { + path = '/' + '_monitoring' + '/' + 'bulk' + } + // build request object - const parts = ['_xpack', 'monitoring', params['type'], '_bulk'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -106,4 +113,4 @@ function buildXpackMonitoringBulk (opts) { } } -module.exports = buildXpackMonitoringBulk +module.exports = buildMonitoringBulk diff --git a/api/api/msearch.js b/api/api/msearch.js index b4aa9faea..8cc3c750d 100644 --- a/api/api/msearch.js +++ b/api/api/msearch.js @@ -13,6 +13,7 @@ function buildMsearch (opts) { * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response * @param {number} pre_filter_shard_size - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on it's rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. * @param {number} max_concurrent_shard_requests - The number of concurrent shard requests each sub search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response * @param {object} body - The request definitions (metadata-search request definition pairs), separated by newlines */ return function msearch (params, options, callback) { @@ -60,6 +61,7 @@ function buildMsearch (opts) { 'typed_keys', 'pre_filter_shard_size', 'max_concurrent_shard_requests', + 'rest_total_hits_as_int', 'pretty', 'human', 'error_trace', @@ -72,6 +74,7 @@ function buildMsearch (opts) { 'typedKeys', 'preFilterShardSize', 'maxConcurrentShardRequests', + 'restTotalHitsAsInt', 'pretty', 'human', 'errorTrace', @@ -110,11 +113,20 @@ function buildMsearch (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_msearch' + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_msearch' + } else { + path = '/' + '_msearch' + } + // build request object - const parts = [params['index'], params['type'], '_msearch'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, bulkBody: params.body, querystring } diff --git a/api/api/msearch_template.js b/api/api/msearch_template.js index 2d7331260..d0b6ed126 100644 --- a/api/api/msearch_template.js +++ b/api/api/msearch_template.js @@ -11,6 +11,7 @@ function buildMsearchTemplate (opts) { * @param {enum} search_type - Search operation type * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response * @param {number} max_concurrent_searches - Controls the maximum number of concurrent searches the multi search api will execute + * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response * @param {object} body - The request definitions (metadata-search request definition pairs), separated by newlines */ return function msearchTemplate (params, options, callback) { @@ -56,6 +57,7 @@ function buildMsearchTemplate (opts) { 'search_type', 'typed_keys', 'max_concurrent_searches', + 'rest_total_hits_as_int', 'pretty', 'human', 'error_trace', @@ -66,6 +68,7 @@ function buildMsearchTemplate (opts) { 'searchType', 'typedKeys', 'maxConcurrentSearches', + 'restTotalHitsAsInt', 'pretty', 'human', 'errorTrace', @@ -104,11 +107,20 @@ function buildMsearchTemplate (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_msearch' + '/' + 'template' + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_msearch' + '/' + 'template' + } else { + path = '/' + '_msearch' + '/' + 'template' + } + // build request object - const parts = [params['index'], params['type'], '_msearch', 'template'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, bulkBody: params.body, querystring } diff --git a/api/api/mtermvectors.js b/api/api/mtermvectors.js index a2628e6a0..eb743c9fd 100644 --- a/api/api/mtermvectors.js +++ b/api/api/mtermvectors.js @@ -126,11 +126,20 @@ function buildMtermvectors (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_mtermvectors' + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_mtermvectors' + } else { + path = '/' + '_mtermvectors' + } + // build request object - const parts = [params['index'], params['type'], '_mtermvectors'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/nodes.hot_threads.js b/api/api/nodes.hot_threads.js index b19169efe..9eb77104d 100644 --- a/api/api/nodes.hot_threads.js +++ b/api/api/nodes.hot_threads.js @@ -103,13 +103,24 @@ function buildNodesHotThreads (opts) { ignore = [ignore] } + var path = '' + + if ((params['node_id'] || params['nodeId']) != null) { + path = '/' + '_cluster' + '/' + 'nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'hotthreads' + } else if ((params['node_id'] || params['nodeId']) != null) { + path = '/' + '_cluster' + '/' + 'nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'hot_threads' + } else if ((params['node_id'] || params['nodeId']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'hotthreads' + } else if ((params['node_id'] || params['nodeId']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'hot_threads' + } else { + path = '/' + '_cluster' + '/' + 'nodes' + '/' + 'hotthreads' + } + // build request object - const parts = ['_cluster', 'nodes', params['node_id'] || params['nodeId'], 'hot_threads'] const request = { method, - path: (params['node_id'] || params['nodeId']) != null - ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') - : '/_nodes/hot_threads', + path, body: null, querystring } diff --git a/api/api/nodes.info.js b/api/api/nodes.info.js index c2ef92c6d..0fe37efdd 100644 --- a/api/api/nodes.info.js +++ b/api/api/nodes.info.js @@ -92,11 +92,22 @@ function buildNodesInfo (opts) { ignore = [ignore] } + var path = '' + + if ((params['node_id'] || params['nodeId']) != null && (params['metric']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + encodeURIComponent(params['metric']) + } else if ((params['node_id'] || params['nodeId']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + } else if ((params['metric']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['metric']) + } else { + path = '/' + '_nodes' + } + // build request object - const parts = ['_nodes', params['node_id'] || params['nodeId'], params['metric']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/nodes.reload_secure_settings.js b/api/api/nodes.reload_secure_settings.js index 98d3f5c3a..0f04f3c0a 100644 --- a/api/api/nodes.reload_secure_settings.js +++ b/api/api/nodes.reload_secure_settings.js @@ -4,7 +4,7 @@ function buildNodesReloadSecureSettings (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [nodes.reload_secure_settings](https://www.elastic.co/guide/en/elasticsearch/reference/6.5/secure-settings.html#reloadable-secure-settings) request + * Perform a [nodes.reload_secure_settings](https://www.elastic.co/guide/en/elasticsearch/reference/master/secure-settings.html#reloadable-secure-settings) request * * @param {list} node_id - A comma-separated list of node IDs to span the reload/reinit call. Should stay empty because reloading usually involves all cluster nodes. * @param {time} timeout - Explicit operation timeout @@ -88,11 +88,18 @@ function buildNodesReloadSecureSettings (opts) { ignore = [ignore] } + var path = '' + + if ((params['node_id'] || params['nodeId']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'reload_secure_settings' + } else { + path = '/' + '_nodes' + '/' + 'reload_secure_settings' + } + // build request object - const parts = ['_nodes', params['node_id'] || params['nodeId'], 'reload_secure_settings'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/nodes.stats.js b/api/api/nodes.stats.js index b4faa6ba4..dc80a9363 100644 --- a/api/api/nodes.stats.js +++ b/api/api/nodes.stats.js @@ -111,11 +111,26 @@ function buildNodesStats (opts) { ignore = [ignore] } + var path = '' + + if ((params['node_id'] || params['nodeId']) != null && (params['metric']) != null && (params['index_metric'] || params['indexMetric']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'stats' + '/' + encodeURIComponent(params['metric']) + '/' + encodeURIComponent(params['index_metric'] || params['indexMetric']) + } else if ((params['node_id'] || params['nodeId']) != null && (params['metric']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'stats' + '/' + encodeURIComponent(params['metric']) + } else if ((params['metric']) != null && (params['index_metric'] || params['indexMetric']) != null) { + path = '/' + '_nodes' + '/' + 'stats' + '/' + encodeURIComponent(params['metric']) + '/' + encodeURIComponent(params['index_metric'] || params['indexMetric']) + } else if ((params['node_id'] || params['nodeId']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'stats' + } else if ((params['metric']) != null) { + path = '/' + '_nodes' + '/' + 'stats' + '/' + encodeURIComponent(params['metric']) + } else { + path = '/' + '_nodes' + '/' + 'stats' + } + // build request object - const parts = ['_nodes', params['node_id'] || params['nodeId'], 'stats', params['metric'], params['index_metric'] || params['indexMetric']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/nodes.usage.js b/api/api/nodes.usage.js index 37b7244de..13a1010e1 100644 --- a/api/api/nodes.usage.js +++ b/api/api/nodes.usage.js @@ -89,11 +89,22 @@ function buildNodesUsage (opts) { ignore = [ignore] } + var path = '' + + if ((params['node_id'] || params['nodeId']) != null && (params['metric']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'usage' + '/' + encodeURIComponent(params['metric']) + } else if ((params['node_id'] || params['nodeId']) != null) { + path = '/' + '_nodes' + '/' + encodeURIComponent(params['node_id'] || params['nodeId']) + '/' + 'usage' + } else if ((params['metric']) != null) { + path = '/' + '_nodes' + '/' + 'usage' + '/' + encodeURIComponent(params['metric']) + } else { + path = '/' + '_nodes' + '/' + 'usage' + } + // build request object - const parts = ['_nodes', params['node_id'] || params['nodeId'], 'usage', params['metric']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/ping.js b/api/api/ping.js index 98af2d2d4..ea12fc318 100644 --- a/api/api/ping.js +++ b/api/api/ping.js @@ -84,11 +84,14 @@ function buildPing (opts) { ignore = [ignore] } + var path = '' + + path = '/' + // build request object - const parts = [] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/put_script.js b/api/api/put_script.js index be52f8e01..a1597dbc1 100644 --- a/api/api/put_script.js +++ b/api/api/put_script.js @@ -110,11 +110,18 @@ function buildPutScript (opts) { ignore = [ignore] } + var path = '' + + if ((params['id']) != null && (params['context']) != null) { + path = '/' + '_scripts' + '/' + encodeURIComponent(params['id']) + '/' + encodeURIComponent(params['context']) + } else { + path = '/' + '_scripts' + '/' + encodeURIComponent(params['id']) + } + // build request object - const parts = ['_scripts', params['id'], params['context']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/rank_eval.js b/api/api/rank_eval.js index 3b693eaf4..26590c7d2 100644 --- a/api/api/rank_eval.js +++ b/api/api/rank_eval.js @@ -95,11 +95,18 @@ function buildRankEval (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_rank_eval' + } else { + path = '/' + '_rank_eval' + } + // build request object - const parts = [params['index'], '_rank_eval'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/reindex.js b/api/api/reindex.js index c61ca9587..6a5a1f43d 100644 --- a/api/api/reindex.js +++ b/api/api/reindex.js @@ -103,11 +103,14 @@ function buildReindex (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_reindex' + // build request object - const parts = ['_reindex'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/reindex_rethrottle.js b/api/api/reindex_rethrottle.js index 1d80eeddf..35961aa79 100644 --- a/api/api/reindex_rethrottle.js +++ b/api/api/reindex_rethrottle.js @@ -100,11 +100,14 @@ function buildReindexRethrottle (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_reindex' + '/' + encodeURIComponent(params['task_id'] || params['taskId']) + '/' + '_rethrottle' + // build request object - const parts = ['_reindex', params['task_id'] || params['taskId'], '_rethrottle'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/render_search_template.js b/api/api/render_search_template.js index a6c50ec8b..e4a8e742c 100644 --- a/api/api/render_search_template.js +++ b/api/api/render_search_template.js @@ -78,11 +78,18 @@ function buildRenderSearchTemplate (opts) { ignore = [ignore] } + var path = '' + + if ((params['id']) != null) { + path = '/' + '_render' + '/' + 'template' + '/' + encodeURIComponent(params['id']) + } else { + path = '/' + '_render' + '/' + 'template' + } + // build request object - const parts = ['_render', 'template', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/scripts_painless_execute.js b/api/api/scripts_painless_execute.js index 028e3e479..1093a6333 100644 --- a/api/api/scripts_painless_execute.js +++ b/api/api/scripts_painless_execute.js @@ -77,11 +77,14 @@ function buildScriptsPainlessExecute (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_scripts' + '/' + 'painless' + '/' + '_execute' + // build request object - const parts = ['_scripts', 'painless', '_execute'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/scroll.js b/api/api/scroll.js index 0f09babcd..f1b7063b8 100644 --- a/api/api/scroll.js +++ b/api/api/scroll.js @@ -9,6 +9,7 @@ function buildScroll (opts) { * @param {string} scroll_id - The scroll ID * @param {time} scroll - Specify how long a consistent view of the index should be maintained for scrolled search * @param {string} scroll_id - The scroll ID for scrolled search + * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response * @param {object} body - The scroll ID if not passed by URL or query parameter. */ return function scroll (params, options, callback) { @@ -37,6 +38,7 @@ function buildScroll (opts) { const acceptedQuerystring = [ 'scroll', 'scroll_id', + 'rest_total_hits_as_int', 'pretty', 'human', 'error_trace', @@ -46,6 +48,7 @@ function buildScroll (opts) { const acceptedQuerystringCamelCased = [ 'scroll', 'scrollId', + 'restTotalHitsAsInt', 'pretty', 'human', 'errorTrace', @@ -84,11 +87,18 @@ function buildScroll (opts) { ignore = [ignore] } + var path = '' + + if ((params['scroll_id'] || params['scrollId']) != null) { + path = '/' + '_search' + '/' + 'scroll' + '/' + encodeURIComponent(params['scroll_id'] || params['scrollId']) + } else { + path = '/' + '_search' + '/' + 'scroll' + } + // build request object - const parts = ['_search', 'scroll', params['scroll_id'] || params['scrollId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/search.js b/api/api/search.js index 48bc3702a..2b49563a7 100644 --- a/api/api/search.js +++ b/api/api/search.js @@ -17,6 +17,7 @@ function buildSearch (opts) { * @param {list} docvalue_fields - A comma-separated list of fields to return as the docvalue representation of a field for each hit * @param {number} from - Starting offset (default: 0) * @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {boolean} ignore_throttled - Whether specified concrete, expanded or aliased indices should be ignored when throttled * @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {boolean} lenient - Specify whether format-based query failures (such as providing text to a numeric field) should be ignored @@ -28,8 +29,8 @@ function buildSearch (opts) { * @param {number} size - Number of hits to return (default: 10) * @param {list} sort - A comma-separated list of : pairs * @param {list} _source - True or false to return the _source field or not, or a list of fields to return - * @param {list} _source_exclude - A list of fields to exclude from the returned _source field - * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {list} _source_excludes - A list of fields to exclude from the returned _source field + * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {number} terminate_after - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. * @param {list} stats - Specific 'tag' of the request for logging and statistical purposes * @param {string} suggest_field - Specify which field to use for suggestions @@ -44,8 +45,9 @@ function buildSearch (opts) { * @param {boolean} version - Specify whether to return document version as part of a hit * @param {boolean} request_cache - Specify if request cache should be used for this request or not, defaults to index level setting * @param {number} batched_reduce_size - The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large. - * @param {number} max_concurrent_shard_requests - The number of concurrent shard requests this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests + * @param {number} max_concurrent_shard_requests - The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests * @param {number} pre_filter_shard_size - A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on it's rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint. + * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response * @param {object} body - The search definition using the Query DSL */ return function search (params, options, callback) { @@ -89,6 +91,7 @@ function buildSearch (opts) { 'docvalue_fields', 'from', 'ignore_unavailable', + 'ignore_throttled', 'allow_no_indices', 'expand_wildcards', 'lenient', @@ -100,8 +103,8 @@ function buildSearch (opts) { 'size', 'sort', '_source', - '_source_exclude', - '_source_include', + '_source_excludes', + '_source_includes', 'terminate_after', 'stats', 'suggest_field', @@ -118,6 +121,7 @@ function buildSearch (opts) { 'batched_reduce_size', 'max_concurrent_shard_requests', 'pre_filter_shard_size', + 'rest_total_hits_as_int', 'pretty', 'human', 'error_trace', @@ -134,6 +138,7 @@ function buildSearch (opts) { 'docvalueFields', 'from', 'ignoreUnavailable', + 'ignoreThrottled', 'allowNoIndices', 'expandWildcards', 'lenient', @@ -145,8 +150,8 @@ function buildSearch (opts) { 'size', 'sort', '_source', - '_sourceExclude', - '_sourceInclude', + '_sourceExcludes', + '_sourceIncludes', 'terminateAfter', 'stats', 'suggestField', @@ -163,6 +168,7 @@ function buildSearch (opts) { 'batchedReduceSize', 'maxConcurrentShardRequests', 'preFilterShardSize', + 'restTotalHitsAsInt', 'pretty', 'human', 'errorTrace', @@ -201,11 +207,20 @@ function buildSearch (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_search' + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_search' + } else { + path = '/' + '_search' + } + // build request object - const parts = [params['index'], params['type'], '_search'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/search_shards.js b/api/api/search_shards.js index cc1ec72ff..95ade603e 100644 --- a/api/api/search_shards.js +++ b/api/api/search_shards.js @@ -103,11 +103,18 @@ function buildSearchShards (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_search_shards' + } else { + path = '/' + '_search_shards' + } + // build request object - const parts = [params['index'], '_search_shards'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/search_template.js b/api/api/search_template.js index 66af6e928..63cdbb441 100644 --- a/api/api/search_template.js +++ b/api/api/search_template.js @@ -9,6 +9,7 @@ function buildSearchTemplate (opts) { * @param {list} index - A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices * @param {list} type - A comma-separated list of document types to search; leave empty to perform the operation on all types * @param {boolean} ignore_unavailable - Whether specified concrete indices should be ignored when unavailable (missing or closed) + * @param {boolean} ignore_throttled - Whether specified concrete, expanded or aliased indices should be ignored when throttled * @param {boolean} allow_no_indices - Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) * @param {enum} expand_wildcards - Whether to expand wildcard expression to concrete indices that are open, closed or both. * @param {string} preference - Specify the node or shard the operation should be performed on (default: random) @@ -18,6 +19,7 @@ function buildSearchTemplate (opts) { * @param {boolean} explain - Specify whether to return detailed information about score computation as part of a hit * @param {boolean} profile - Specify whether to profile the query execution * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response * @param {object} body - The search definition template and its params */ return function searchTemplate (params, options, callback) { @@ -61,6 +63,7 @@ function buildSearchTemplate (opts) { const keys = Object.keys(params) const acceptedQuerystring = [ 'ignore_unavailable', + 'ignore_throttled', 'allow_no_indices', 'expand_wildcards', 'preference', @@ -70,6 +73,7 @@ function buildSearchTemplate (opts) { 'explain', 'profile', 'typed_keys', + 'rest_total_hits_as_int', 'pretty', 'human', 'error_trace', @@ -78,6 +82,7 @@ function buildSearchTemplate (opts) { ] const acceptedQuerystringCamelCased = [ 'ignoreUnavailable', + 'ignoreThrottled', 'allowNoIndices', 'expandWildcards', 'preference', @@ -87,6 +92,7 @@ function buildSearchTemplate (opts) { 'explain', 'profile', 'typedKeys', + 'restTotalHitsAsInt', 'pretty', 'human', 'errorTrace', @@ -125,11 +131,20 @@ function buildSearchTemplate (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_search' + '/' + 'template' + } else if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_search' + '/' + 'template' + } else { + path = '/' + '_search' + '/' + 'template' + } + // build request object - const parts = [params['index'], params['type'], '_search', 'template'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.ssl.certificates.js b/api/api/security.authenticate.js similarity index 82% rename from api/api/xpack.ssl.certificates.js rename to api/api/security.authenticate.js index 142900399..d1bd8a815 100644 --- a/api/api/xpack.ssl.certificates.js +++ b/api/api/security.authenticate.js @@ -1,13 +1,13 @@ 'use strict' -function buildXpackSslCertificates (opts) { +function buildSecurityAuthenticate (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.ssl.certificates](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-ssl.html) request + * Perform a [security.authenticate](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-authenticate.html) request * */ - return function xpackSslCertificates (params, options, callback) { + return function securityAuthenticate (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -21,7 +21,7 @@ function buildXpackSslCertificates (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSslCertificates(params, options, (err, body) => { + securityAuthenticate(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -76,11 +76,14 @@ function buildXpackSslCertificates (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + '_authenticate' + // build request object - const parts = ['_xpack', 'ssl', 'certificates'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -97,4 +100,4 @@ function buildXpackSslCertificates (opts) { } } -module.exports = buildXpackSslCertificates +module.exports = buildSecurityAuthenticate diff --git a/api/api/xpack.security.change_password.js b/api/api/security.change_password.js similarity index 80% rename from api/api/xpack.security.change_password.js rename to api/api/security.change_password.js index d67131909..fc07667d7 100644 --- a/api/api/xpack.security.change_password.js +++ b/api/api/security.change_password.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackSecurityChangePassword (opts) { +function buildSecurityChangePassword (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.change_password](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-change-password.html) request + * Perform a [security.change_password](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-change-password.html) request * * @param {string} username - The username of the user to change the password for * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. * @param {object} body - the new password for the user */ - return function xpackSecurityChangePassword (params, options, callback) { + return function securityChangePassword (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackSecurityChangePassword (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityChangePassword(params, options, (err, body) => { + securityChangePassword(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -79,11 +79,18 @@ function buildXpackSecurityChangePassword (opts) { ignore = [ignore] } + var path = '' + + if ((params['username']) != null) { + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(params['username']) + '/' + '_password' + } else { + path = '/' + '_security' + '/' + 'user' + '/' + '_password' + } + // build request object - const parts = ['_xpack', 'security', 'user', params['username'], '_password'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -100,4 +107,4 @@ function buildXpackSecurityChangePassword (opts) { } } -module.exports = buildXpackSecurityChangePassword +module.exports = buildSecurityChangePassword diff --git a/api/api/xpack.security.clear_cached_realms.js b/api/api/security.clear_cached_realms.js similarity index 81% rename from api/api/xpack.security.clear_cached_realms.js rename to api/api/security.clear_cached_realms.js index b4f81bcfa..0d89991dd 100644 --- a/api/api/xpack.security.clear_cached_realms.js +++ b/api/api/security.clear_cached_realms.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackSecurityClearCachedRealms (opts) { +function buildSecurityClearCachedRealms (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.clear_cached_realms](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-cache.html) request + * Perform a [security.clear_cached_realms](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-cache.html) request * * @param {list} realms - Comma-separated list of realms to clear * @param {list} usernames - Comma-separated list of usernames to clear from the cache */ - return function xpackSecurityClearCachedRealms (params, options, callback) { + return function securityClearCachedRealms (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackSecurityClearCachedRealms (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityClearCachedRealms(params, options, (err, body) => { + securityClearCachedRealms(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackSecurityClearCachedRealms (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'realm' + '/' + encodeURIComponent(params['realms']) + '/' + '_clear_cache' + // build request object - const parts = ['_xpack', 'security', 'realm', params['realms'], '_clear_cache'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -105,4 +108,4 @@ function buildXpackSecurityClearCachedRealms (opts) { } } -module.exports = buildXpackSecurityClearCachedRealms +module.exports = buildSecurityClearCachedRealms diff --git a/api/api/xpack.security.clear_cached_roles.js b/api/api/security.clear_cached_roles.js similarity index 80% rename from api/api/xpack.security.clear_cached_roles.js rename to api/api/security.clear_cached_roles.js index eaf91a87d..d4f658bcd 100644 --- a/api/api/xpack.security.clear_cached_roles.js +++ b/api/api/security.clear_cached_roles.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackSecurityClearCachedRoles (opts) { +function buildSecurityClearCachedRoles (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.clear_cached_roles](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-role-cache.html) request + * Perform a [security.clear_cached_roles](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-clear-role-cache.html) request * * @param {list} name - Role name */ - return function xpackSecurityClearCachedRoles (params, options, callback) { + return function securityClearCachedRoles (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackSecurityClearCachedRoles (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityClearCachedRoles(params, options, (err, body) => { + securityClearCachedRoles(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -83,11 +83,14 @@ function buildXpackSecurityClearCachedRoles (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(params['name']) + '/' + '_clear_cache' + // build request object - const parts = ['_xpack', 'security', 'role', params['name'], '_clear_cache'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -104,4 +107,4 @@ function buildXpackSecurityClearCachedRoles (opts) { } } -module.exports = buildXpackSecurityClearCachedRoles +module.exports = buildSecurityClearCachedRoles diff --git a/api/api/xpack.security.delete_privileges.js b/api/api/security.delete_privileges.js similarity index 86% rename from api/api/xpack.security.delete_privileges.js rename to api/api/security.delete_privileges.js index db0e8a974..0a0f6492b 100644 --- a/api/api/xpack.security.delete_privileges.js +++ b/api/api/security.delete_privileges.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackSecurityDeletePrivileges (opts) { +function buildSecurityDeletePrivileges (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.delete_privileges](TODO) request + * Perform a [security.delete_privileges](TODO) request * * @param {string} application - Application name * @param {string} name - Privilege name * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ - return function xpackSecurityDeletePrivileges (params, options, callback) { + return function securityDeletePrivileges (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackSecurityDeletePrivileges (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityDeletePrivileges(params, options, (err, body) => { + securityDeletePrivileges(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -99,11 +99,14 @@ function buildXpackSecurityDeletePrivileges (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(params['application']) + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_xpack', 'security', 'privilege', params['application'], params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -120,4 +123,4 @@ function buildXpackSecurityDeletePrivileges (opts) { } } -module.exports = buildXpackSecurityDeletePrivileges +module.exports = buildSecurityDeletePrivileges diff --git a/api/api/xpack.security.delete_role.js b/api/api/security.delete_role.js similarity index 83% rename from api/api/xpack.security.delete_role.js rename to api/api/security.delete_role.js index b03c57aac..c7d2ccb83 100644 --- a/api/api/xpack.security.delete_role.js +++ b/api/api/security.delete_role.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackSecurityDeleteRole (opts) { +function buildSecurityDeleteRole (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.delete_role](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role.html) request + * Perform a [security.delete_role](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role.html) request * * @param {string} name - Role name * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ - return function xpackSecurityDeleteRole (params, options, callback) { + return function securityDeleteRole (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackSecurityDeleteRole (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityDeleteRole(params, options, (err, body) => { + securityDeleteRole(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackSecurityDeleteRole (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_xpack', 'security', 'role', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -105,4 +108,4 @@ function buildXpackSecurityDeleteRole (opts) { } } -module.exports = buildXpackSecurityDeleteRole +module.exports = buildSecurityDeleteRole diff --git a/api/api/xpack.security.delete_role_mapping.js b/api/api/security.delete_role_mapping.js similarity index 82% rename from api/api/xpack.security.delete_role_mapping.js rename to api/api/security.delete_role_mapping.js index 6c012203b..0ddde9ce2 100644 --- a/api/api/xpack.security.delete_role_mapping.js +++ b/api/api/security.delete_role_mapping.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackSecurityDeleteRoleMapping (opts) { +function buildSecurityDeleteRoleMapping (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.delete_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role-mapping.html) request + * Perform a [security.delete_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role-mapping.html) request * * @param {string} name - Role-mapping name * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ - return function xpackSecurityDeleteRoleMapping (params, options, callback) { + return function securityDeleteRoleMapping (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackSecurityDeleteRoleMapping (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityDeleteRoleMapping(params, options, (err, body) => { + securityDeleteRoleMapping(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackSecurityDeleteRoleMapping (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_xpack', 'security', 'role_mapping', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -105,4 +108,4 @@ function buildXpackSecurityDeleteRoleMapping (opts) { } } -module.exports = buildXpackSecurityDeleteRoleMapping +module.exports = buildSecurityDeleteRoleMapping diff --git a/api/api/xpack.security.delete_user.js b/api/api/security.delete_user.js similarity index 83% rename from api/api/xpack.security.delete_user.js rename to api/api/security.delete_user.js index 9368dcfec..b5418ad91 100644 --- a/api/api/xpack.security.delete_user.js +++ b/api/api/security.delete_user.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackSecurityDeleteUser (opts) { +function buildSecurityDeleteUser (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.delete_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-user.html) request + * Perform a [security.delete_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-user.html) request * * @param {string} username - username * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ - return function xpackSecurityDeleteUser (params, options, callback) { + return function securityDeleteUser (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackSecurityDeleteUser (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityDeleteUser(params, options, (err, body) => { + securityDeleteUser(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -84,11 +84,14 @@ function buildXpackSecurityDeleteUser (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(params['username']) + // build request object - const parts = ['_xpack', 'security', 'user', params['username']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -105,4 +108,4 @@ function buildXpackSecurityDeleteUser (opts) { } } -module.exports = buildXpackSecurityDeleteUser +module.exports = buildSecurityDeleteUser diff --git a/api/api/xpack.security.disable_user.js b/api/api/security.disable_user.js similarity index 82% rename from api/api/xpack.security.disable_user.js rename to api/api/security.disable_user.js index 571ec63a8..095724886 100644 --- a/api/api/xpack.security.disable_user.js +++ b/api/api/security.disable_user.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackSecurityDisableUser (opts) { +function buildSecurityDisableUser (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.disable_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-disable-user.html) request + * Perform a [security.disable_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-disable-user.html) request * * @param {string} username - The username of the user to disable * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ - return function xpackSecurityDisableUser (params, options, callback) { + return function securityDisableUser (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackSecurityDisableUser (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityDisableUser(params, options, (err, body) => { + securityDisableUser(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -78,11 +78,14 @@ function buildXpackSecurityDisableUser (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(params['username']) + '/' + '_disable' + // build request object - const parts = ['_xpack', 'security', 'user', params['username'], '_disable'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -99,4 +102,4 @@ function buildXpackSecurityDisableUser (opts) { } } -module.exports = buildXpackSecurityDisableUser +module.exports = buildSecurityDisableUser diff --git a/api/api/xpack.security.enable_user.js b/api/api/security.enable_user.js similarity index 82% rename from api/api/xpack.security.enable_user.js rename to api/api/security.enable_user.js index a6affe02b..24509b689 100644 --- a/api/api/xpack.security.enable_user.js +++ b/api/api/security.enable_user.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackSecurityEnableUser (opts) { +function buildSecurityEnableUser (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.enable_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-enable-user.html) request + * Perform a [security.enable_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-enable-user.html) request * * @param {string} username - The username of the user to enable * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. */ - return function xpackSecurityEnableUser (params, options, callback) { + return function securityEnableUser (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackSecurityEnableUser (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityEnableUser(params, options, (err, body) => { + securityEnableUser(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -78,11 +78,14 @@ function buildXpackSecurityEnableUser (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(params['username']) + '/' + '_enable' + // build request object - const parts = ['_xpack', 'security', 'user', params['username'], '_enable'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } @@ -99,4 +102,4 @@ function buildXpackSecurityEnableUser (opts) { } } -module.exports = buildXpackSecurityEnableUser +module.exports = buildSecurityEnableUser diff --git a/api/api/xpack.security.get_privileges.js b/api/api/security.get_privileges.js similarity index 84% rename from api/api/xpack.security.get_privileges.js rename to api/api/security.get_privileges.js index 683c06458..816d288e6 100644 --- a/api/api/xpack.security.get_privileges.js +++ b/api/api/security.get_privileges.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackSecurityGetPrivileges (opts) { +function buildSecurityGetPrivileges (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.get_privileges](TODO) request + * Perform a [security.get_privileges](TODO) request * * @param {string} application - Application name * @param {string} name - Privilege name */ - return function xpackSecurityGetPrivileges (params, options, callback) { + return function securityGetPrivileges (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackSecurityGetPrivileges (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityGetPrivileges(params, options, (err, body) => { + securityGetPrivileges(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -86,11 +86,14 @@ function buildXpackSecurityGetPrivileges (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'privilege' + '/' + encodeURIComponent(params['application']) + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_xpack', 'security', 'privilege', params['application'], params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -107,4 +110,4 @@ function buildXpackSecurityGetPrivileges (opts) { } } -module.exports = buildXpackSecurityGetPrivileges +module.exports = buildSecurityGetPrivileges diff --git a/api/api/xpack.security.get_role.js b/api/api/security.get_role.js similarity index 80% rename from api/api/xpack.security.get_role.js rename to api/api/security.get_role.js index 9d4ce7d5c..6937deaab 100644 --- a/api/api/xpack.security.get_role.js +++ b/api/api/security.get_role.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackSecurityGetRole (opts) { +function buildSecurityGetRole (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.get_role](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html) request + * Perform a [security.get_role](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html) request * * @param {string} name - Role name */ - return function xpackSecurityGetRole (params, options, callback) { + return function securityGetRole (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackSecurityGetRole (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityGetRole(params, options, (err, body) => { + securityGetRole(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -77,11 +77,18 @@ function buildXpackSecurityGetRole (opts) { ignore = [ignore] } + var path = '' + + if ((params['name']) != null) { + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(params['name']) + } else { + path = '/' + '_security' + '/' + 'role' + } + // build request object - const parts = ['_xpack', 'security', 'role', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -98,4 +105,4 @@ function buildXpackSecurityGetRole (opts) { } } -module.exports = buildXpackSecurityGetRole +module.exports = buildSecurityGetRole diff --git a/api/api/xpack.security.get_role_mapping.js b/api/api/security.get_role_mapping.js similarity index 78% rename from api/api/xpack.security.get_role_mapping.js rename to api/api/security.get_role_mapping.js index 101ec8783..6730f8e25 100644 --- a/api/api/xpack.security.get_role_mapping.js +++ b/api/api/security.get_role_mapping.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackSecurityGetRoleMapping (opts) { +function buildSecurityGetRoleMapping (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.get_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role-mapping.html) request + * Perform a [security.get_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role-mapping.html) request * * @param {string} name - Role-Mapping name */ - return function xpackSecurityGetRoleMapping (params, options, callback) { + return function securityGetRoleMapping (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackSecurityGetRoleMapping (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityGetRoleMapping(params, options, (err, body) => { + securityGetRoleMapping(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -77,11 +77,18 @@ function buildXpackSecurityGetRoleMapping (opts) { ignore = [ignore] } + var path = '' + + if ((params['name']) != null) { + path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(params['name']) + } else { + path = '/' + '_security' + '/' + 'role_mapping' + } + // build request object - const parts = ['_xpack', 'security', 'role_mapping', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -98,4 +105,4 @@ function buildXpackSecurityGetRoleMapping (opts) { } } -module.exports = buildXpackSecurityGetRoleMapping +module.exports = buildSecurityGetRoleMapping diff --git a/api/api/xpack.security.get_token.js b/api/api/security.get_token.js similarity index 81% rename from api/api/xpack.security.get_token.js rename to api/api/security.get_token.js index 0f439b381..7dcfc72cd 100644 --- a/api/api/xpack.security.get_token.js +++ b/api/api/security.get_token.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackSecurityGetToken (opts) { +function buildSecurityGetToken (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.get_token](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html) request + * Perform a [security.get_token](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-token.html) request * * @param {object} body - The token request to get */ - return function xpackSecurityGetToken (params, options, callback) { + return function securityGetToken (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackSecurityGetToken (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityGetToken(params, options, (err, body) => { + securityGetToken(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -77,11 +77,14 @@ function buildXpackSecurityGetToken (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'oauth2' + '/' + 'token' + // build request object - const parts = ['_xpack', 'security', 'oauth2', 'token'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -98,4 +101,4 @@ function buildXpackSecurityGetToken (opts) { } } -module.exports = buildXpackSecurityGetToken +module.exports = buildSecurityGetToken diff --git a/api/api/xpack.security.get_user.js b/api/api/security.get_user.js similarity index 80% rename from api/api/xpack.security.get_user.js rename to api/api/security.get_user.js index 8bc1aa65e..13fb8e9fe 100644 --- a/api/api/xpack.security.get_user.js +++ b/api/api/security.get_user.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackSecurityGetUser (opts) { +function buildSecurityGetUser (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.get_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user.html) request + * Perform a [security.get_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user.html) request * * @param {list} username - A comma-separated list of usernames */ - return function xpackSecurityGetUser (params, options, callback) { + return function securityGetUser (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackSecurityGetUser (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityGetUser(params, options, (err, body) => { + securityGetUser(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -77,11 +77,18 @@ function buildXpackSecurityGetUser (opts) { ignore = [ignore] } + var path = '' + + if ((params['username']) != null) { + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(params['username']) + } else { + path = '/' + '_security' + '/' + 'user' + } + // build request object - const parts = ['_xpack', 'security', 'user', params['username']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -98,4 +105,4 @@ function buildXpackSecurityGetUser (opts) { } } -module.exports = buildXpackSecurityGetUser +module.exports = buildSecurityGetUser diff --git a/api/api/xpack.security.authenticate.js b/api/api/security.get_user_privileges.js similarity index 81% rename from api/api/xpack.security.authenticate.js rename to api/api/security.get_user_privileges.js index 71c4439a7..5403767bd 100644 --- a/api/api/xpack.security.authenticate.js +++ b/api/api/security.get_user_privileges.js @@ -1,13 +1,13 @@ 'use strict' -function buildXpackSecurityAuthenticate (opts) { +function buildSecurityGetUserPrivileges (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.authenticate](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-authenticate.html) request + * Perform a [security.get_user_privileges](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-privileges.html) request * */ - return function xpackSecurityAuthenticate (params, options, callback) { + return function securityGetUserPrivileges (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -21,7 +21,7 @@ function buildXpackSecurityAuthenticate (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityAuthenticate(params, options, (err, body) => { + securityGetUserPrivileges(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -76,11 +76,14 @@ function buildXpackSecurityAuthenticate (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'user' + '/' + '_privileges' + // build request object - const parts = ['_xpack', 'security', '_authenticate'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } @@ -97,4 +100,4 @@ function buildXpackSecurityAuthenticate (opts) { } } -module.exports = buildXpackSecurityAuthenticate +module.exports = buildSecurityGetUserPrivileges diff --git a/api/api/xpack.security.has_privileges.js b/api/api/security.has_privileges.js similarity index 78% rename from api/api/xpack.security.has_privileges.js rename to api/api/security.has_privileges.js index 2524dd9fe..7fa1f3e5c 100644 --- a/api/api/xpack.security.has_privileges.js +++ b/api/api/security.has_privileges.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackSecurityHasPrivileges (opts) { +function buildSecurityHasPrivileges (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.has_privileges](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html) request + * Perform a [security.has_privileges](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html) request * * @param {string} user - Username * @param {object} body - The privileges to test */ - return function xpackSecurityHasPrivileges (params, options, callback) { + return function securityHasPrivileges (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackSecurityHasPrivileges (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityHasPrivileges(params, options, (err, body) => { + securityHasPrivileges(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -78,11 +78,18 @@ function buildXpackSecurityHasPrivileges (opts) { ignore = [ignore] } + var path = '' + + if ((params['user']) != null) { + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(params['user']) + '/' + '_has_privileges' + } else { + path = '/' + '_security' + '/' + 'user' + '/' + '_has_privileges' + } + // build request object - const parts = ['_xpack', 'security', 'user', params['user'], '_has_privileges'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -99,4 +106,4 @@ function buildXpackSecurityHasPrivileges (opts) { } } -module.exports = buildXpackSecurityHasPrivileges +module.exports = buildSecurityHasPrivileges diff --git a/api/api/xpack.security.invalidate_token.js b/api/api/security.invalidate_token.js similarity index 80% rename from api/api/xpack.security.invalidate_token.js rename to api/api/security.invalidate_token.js index 36155e2b6..45ec5bd9b 100644 --- a/api/api/xpack.security.invalidate_token.js +++ b/api/api/security.invalidate_token.js @@ -1,14 +1,14 @@ 'use strict' -function buildXpackSecurityInvalidateToken (opts) { +function buildSecurityInvalidateToken (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.invalidate_token](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html) request + * Perform a [security.invalidate_token](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html) request * * @param {object} body - The token to invalidate */ - return function xpackSecurityInvalidateToken (params, options, callback) { + return function securityInvalidateToken (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -22,7 +22,7 @@ function buildXpackSecurityInvalidateToken (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityInvalidateToken(params, options, (err, body) => { + securityInvalidateToken(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -77,11 +77,14 @@ function buildXpackSecurityInvalidateToken (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'oauth2' + '/' + 'token' + // build request object - const parts = ['_xpack', 'security', 'oauth2', 'token'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -98,4 +101,4 @@ function buildXpackSecurityInvalidateToken (opts) { } } -module.exports = buildXpackSecurityInvalidateToken +module.exports = buildSecurityInvalidateToken diff --git a/api/api/xpack.security.put_privileges.js b/api/api/security.put_privileges.js similarity index 85% rename from api/api/xpack.security.put_privileges.js rename to api/api/security.put_privileges.js index 94ac619b4..6f18c7f68 100644 --- a/api/api/xpack.security.put_privileges.js +++ b/api/api/security.put_privileges.js @@ -1,15 +1,15 @@ 'use strict' -function buildXpackSecurityPutPrivileges (opts) { +function buildSecurityPutPrivileges (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.put_privileges](TODO) request + * Perform a [security.put_privileges](TODO) request * * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. * @param {object} body - The privilege(s) to add */ - return function xpackSecurityPutPrivileges (params, options, callback) { + return function securityPutPrivileges (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -23,7 +23,7 @@ function buildXpackSecurityPutPrivileges (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityPutPrivileges(params, options, (err, body) => { + securityPutPrivileges(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -78,11 +78,14 @@ function buildXpackSecurityPutPrivileges (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'privilege' + // build request object - const parts = ['_xpack', 'security', 'privilege'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -99,4 +102,4 @@ function buildXpackSecurityPutPrivileges (opts) { } } -module.exports = buildXpackSecurityPutPrivileges +module.exports = buildSecurityPutPrivileges diff --git a/api/api/xpack.security.put_role.js b/api/api/security.put_role.js similarity index 84% rename from api/api/xpack.security.put_role.js rename to api/api/security.put_role.js index 3b78e8370..259ad1b0e 100644 --- a/api/api/xpack.security.put_role.js +++ b/api/api/security.put_role.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackSecurityPutRole (opts) { +function buildSecurityPutRole (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.put_role](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html) request + * Perform a [security.put_role](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html) request * * @param {string} name - Role name * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. * @param {object} body - The role to add */ - return function xpackSecurityPutRole (params, options, callback) { + return function securityPutRole (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackSecurityPutRole (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityPutRole(params, options, (err, body) => { + securityPutRole(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -85,11 +85,14 @@ function buildXpackSecurityPutRole (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'role' + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_xpack', 'security', 'role', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -106,4 +109,4 @@ function buildXpackSecurityPutRole (opts) { } } -module.exports = buildXpackSecurityPutRole +module.exports = buildSecurityPutRole diff --git a/api/api/xpack.security.put_role_mapping.js b/api/api/security.put_role_mapping.js similarity index 83% rename from api/api/xpack.security.put_role_mapping.js rename to api/api/security.put_role_mapping.js index d340aaaeb..03b74a65f 100644 --- a/api/api/xpack.security.put_role_mapping.js +++ b/api/api/security.put_role_mapping.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackSecurityPutRoleMapping (opts) { +function buildSecurityPutRoleMapping (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.put_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role-mapping.html) request + * Perform a [security.put_role_mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role-mapping.html) request * * @param {string} name - Role-mapping name * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. * @param {object} body - The role to add */ - return function xpackSecurityPutRoleMapping (params, options, callback) { + return function securityPutRoleMapping (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackSecurityPutRoleMapping (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityPutRoleMapping(params, options, (err, body) => { + securityPutRoleMapping(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -85,11 +85,14 @@ function buildXpackSecurityPutRoleMapping (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'role_mapping' + '/' + encodeURIComponent(params['name']) + // build request object - const parts = ['_xpack', 'security', 'role_mapping', params['name']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -106,4 +109,4 @@ function buildXpackSecurityPutRoleMapping (opts) { } } -module.exports = buildXpackSecurityPutRoleMapping +module.exports = buildSecurityPutRoleMapping diff --git a/api/api/xpack.security.put_user.js b/api/api/security.put_user.js similarity index 84% rename from api/api/xpack.security.put_user.js rename to api/api/security.put_user.js index 7b45b427e..ddc512d15 100644 --- a/api/api/xpack.security.put_user.js +++ b/api/api/security.put_user.js @@ -1,16 +1,16 @@ 'use strict' -function buildXpackSecurityPutUser (opts) { +function buildSecurityPutUser (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, result } = opts /** - * Perform a [xpack.security.put_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html) request + * Perform a [security.put_user](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html) request * * @param {string} username - The username of the User * @param {enum} refresh - If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. * @param {object} body - The user to add */ - return function xpackSecurityPutUser (params, options, callback) { + return function securityPutUser (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -24,7 +24,7 @@ function buildXpackSecurityPutUser (opts) { // promises support if (callback == null) { return new Promise((resolve, reject) => { - xpackSecurityPutUser(params, options, (err, body) => { + securityPutUser(params, options, (err, body) => { err ? reject(err) : resolve(body) }) }) @@ -85,11 +85,14 @@ function buildXpackSecurityPutUser (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_security' + '/' + 'user' + '/' + encodeURIComponent(params['username']) + // build request object - const parts = ['_xpack', 'security', 'user', params['username']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } @@ -106,4 +109,4 @@ function buildXpackSecurityPutUser (opts) { } } -module.exports = buildXpackSecurityPutUser +module.exports = buildSecurityPutUser diff --git a/api/api/snapshot.create.js b/api/api/snapshot.create.js index 873982d68..3b4f9a239 100644 --- a/api/api/snapshot.create.js +++ b/api/api/snapshot.create.js @@ -107,11 +107,14 @@ function buildSnapshotCreate (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + '/' + encodeURIComponent(params['snapshot']) + // build request object - const parts = ['_snapshot', params['repository'], params['snapshot']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/snapshot.create_repository.js b/api/api/snapshot.create_repository.js index 9a6aefde6..a8845077f 100644 --- a/api/api/snapshot.create_repository.js +++ b/api/api/snapshot.create_repository.js @@ -101,11 +101,14 @@ function buildSnapshotCreateRepository (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + // build request object - const parts = ['_snapshot', params['repository']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/snapshot.delete.js b/api/api/snapshot.delete.js index 22a5c691d..1e3753ae0 100644 --- a/api/api/snapshot.delete.js +++ b/api/api/snapshot.delete.js @@ -109,11 +109,14 @@ function buildSnapshotDelete (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + '/' + encodeURIComponent(params['snapshot']) + // build request object - const parts = ['_snapshot', params['repository'], params['snapshot']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/snapshot.delete_repository.js b/api/api/snapshot.delete_repository.js index fa26f7174..01b30678d 100644 --- a/api/api/snapshot.delete_repository.js +++ b/api/api/snapshot.delete_repository.js @@ -97,11 +97,14 @@ function buildSnapshotDeleteRepository (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + // build request object - const parts = ['_snapshot', params['repository']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/snapshot.get.js b/api/api/snapshot.get.js index 5fbded88b..e3e74caf1 100644 --- a/api/api/snapshot.get.js +++ b/api/api/snapshot.get.js @@ -115,11 +115,14 @@ function buildSnapshotGet (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + '/' + encodeURIComponent(params['snapshot']) + // build request object - const parts = ['_snapshot', params['repository'], params['snapshot']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/snapshot.get_repository.js b/api/api/snapshot.get_repository.js index 4eb197991..02dc64e37 100644 --- a/api/api/snapshot.get_repository.js +++ b/api/api/snapshot.get_repository.js @@ -91,11 +91,18 @@ function buildSnapshotGetRepository (opts) { ignore = [ignore] } + var path = '' + + if ((params['repository']) != null) { + path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + } else { + path = '/' + '_snapshot' + } + // build request object - const parts = ['_snapshot', params['repository']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/snapshot.restore.js b/api/api/snapshot.restore.js index d0577e954..da587e286 100644 --- a/api/api/snapshot.restore.js +++ b/api/api/snapshot.restore.js @@ -107,11 +107,14 @@ function buildSnapshotRestore (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + '/' + encodeURIComponent(params['snapshot']) + '/' + '_restore' + // build request object - const parts = ['_snapshot', params['repository'], params['snapshot'], '_restore'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/snapshot.status.js b/api/api/snapshot.status.js index 8c618f622..a80f9aed2 100644 --- a/api/api/snapshot.status.js +++ b/api/api/snapshot.status.js @@ -100,11 +100,20 @@ function buildSnapshotStatus (opts) { ignore = [ignore] } + var path = '' + + if ((params['repository']) != null && (params['snapshot']) != null) { + path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + '/' + encodeURIComponent(params['snapshot']) + '/' + '_status' + } else if ((params['repository']) != null) { + path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + '/' + '_status' + } else { + path = '/' + '_snapshot' + '/' + '_status' + } + // build request object - const parts = ['_snapshot', params['repository'], params['snapshot'], '_status'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/snapshot.verify_repository.js b/api/api/snapshot.verify_repository.js index b93250b38..ab26069cc 100644 --- a/api/api/snapshot.verify_repository.js +++ b/api/api/snapshot.verify_repository.js @@ -97,11 +97,14 @@ function buildSnapshotVerifyRepository (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_snapshot' + '/' + encodeURIComponent(params['repository']) + '/' + '_verify' + // build request object - const parts = ['_snapshot', params['repository'], '_verify'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/ssl.certificates.js b/api/api/ssl.certificates.js new file mode 100644 index 000000000..7e6adc9a1 --- /dev/null +++ b/api/api/ssl.certificates.js @@ -0,0 +1,103 @@ +'use strict' + +function buildSslCertificates (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, result } = opts + /** + * Perform a [ssl.certificates](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-ssl.html) request + * + */ + return function sslCertificates (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + // promises support + if (callback == null) { + return new Promise((resolve, reject) => { + sslCertificates(params, options, (err, body) => { + err ? reject(err) : resolve(body) + }) + }) + } + + // check required parameters + if (params.body != null) { + return callback( + new ConfigurationError('This API does not require a body'), + result + ) + } + + // build querystring object + const querystring = {} + const keys = Object.keys(params) + const acceptedQuerystring = [ + + ] + const acceptedQuerystringCamelCased = [ + + ] + + for (var i = 0, len = keys.length; i < len; i++) { + var key = keys[i] + if (acceptedQuerystring.indexOf(key) !== -1) { + querystring[key] = params[key] + } else { + var camelIndex = acceptedQuerystringCamelCased.indexOf(key) + if (camelIndex !== -1) { + querystring[acceptedQuerystring[camelIndex]] = params[key] + } + } + } + + // configure http method + var method = params.method + if (method == null) { + method = 'GET' + } + + // validate headers object + if (params.headers != null && typeof params.headers !== 'object') { + return callback( + new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), + result + ) + } + + var ignore = options.ignore || null + if (typeof ignore === 'number') { + ignore = [ignore] + } + + var path = '' + + path = '/' + '_ssl' + '/' + 'certificates' + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + const requestOptions = { + ignore, + requestTimeout: options.requestTimeout || null, + maxRetries: options.maxRetries || null, + asStream: options.asStream || false, + headers: options.headers || null + } + + return makeRequest(request, requestOptions, callback) + } +} + +module.exports = buildSslCertificates diff --git a/api/api/tasks.cancel.js b/api/api/tasks.cancel.js index d2ed6a011..14eb29793 100644 --- a/api/api/tasks.cancel.js +++ b/api/api/tasks.cancel.js @@ -94,11 +94,18 @@ function buildTasksCancel (opts) { ignore = [ignore] } + var path = '' + + if ((params['task_id'] || params['taskId']) != null) { + path = '/' + '_tasks' + '/' + encodeURIComponent(params['task_id'] || params['taskId']) + '/' + '_cancel' + } else { + path = '/' + '_tasks' + '/' + '_cancel' + } + // build request object - const parts = ['_tasks', params['task_id'] || params['taskId'], '_cancel'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/tasks.get.js b/api/api/tasks.get.js index 0fab38d31..998a14f64 100644 --- a/api/api/tasks.get.js +++ b/api/api/tasks.get.js @@ -97,11 +97,14 @@ function buildTasksGet (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_tasks' + '/' + encodeURIComponent(params['task_id'] || params['taskId']) + // build request object - const parts = ['_tasks', params['task_id'] || params['taskId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/tasks.list.js b/api/api/tasks.list.js index 90cabbcc4..8696defb6 100644 --- a/api/api/tasks.list.js +++ b/api/api/tasks.list.js @@ -105,11 +105,14 @@ function buildTasksList (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_tasks' + // build request object - const parts = ['_tasks'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/termvectors.js b/api/api/termvectors.js index ec2354fc4..3888a41aa 100644 --- a/api/api/termvectors.js +++ b/api/api/termvectors.js @@ -50,25 +50,6 @@ function buildTermvectors (opts) { result ) } - if (params['type'] == null) { - return callback( - new ConfigurationError('Missing required parameter: type'), - result - ) - } - - // check required url components - if (params['id'] != null && (params['type'] == null || params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: type, index'), - result - ) - } else if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) - } // build querystring object const querystring = {} @@ -143,11 +124,22 @@ function buildTermvectors (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null && (params['id']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_termvectors' + } else if ((params['index']) != null && (params['id']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_termvectors' + '/' + encodeURIComponent(params['id']) + } else if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_termvectors' + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_termvectors' + } + // build request object - const parts = [params['index'], params['type'], params['id'], '_termvectors'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/update.js b/api/api/update.js index 13e8539ee..73bcfecf0 100644 --- a/api/api/update.js +++ b/api/api/update.js @@ -10,10 +10,9 @@ function buildUpdate (opts) { * @param {string} index - The name of the index * @param {string} type - The type of the document * @param {string} wait_for_active_shards - Sets the number of shard copies that must be active before proceeding with the update operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) - * @param {list} fields - A comma-separated list of fields to return in the response * @param {list} _source - True or false to return the _source field or not, or a list of fields to return - * @param {list} _source_exclude - A list of fields to exclude from the returned _source field - * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {list} _source_excludes - A list of fields to exclude from the returned _source field + * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {string} lang - The script language (default: painless) * @param {string} parent - ID of the parent document. Is is only used for routing and when for the upsert request * @param {enum} refresh - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. @@ -57,12 +56,6 @@ function buildUpdate (opts) { result ) } - if (params['type'] == null) { - return callback( - new ConfigurationError('Missing required parameter: type'), - result - ) - } if (params['body'] == null) { return callback( new ConfigurationError('Missing required parameter: body'), @@ -70,28 +63,14 @@ function buildUpdate (opts) { ) } - // check required url components - if (params['id'] != null && (params['type'] == null || params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: type, index'), - result - ) - } else if (params['type'] != null && (params['index'] == null)) { - return callback( - new ConfigurationError('Missing required parameter of the url: index'), - result - ) - } - // build querystring object const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ 'wait_for_active_shards', - 'fields', '_source', - '_source_exclude', - '_source_include', + '_source_excludes', + '_source_includes', 'lang', 'parent', 'refresh', @@ -108,10 +87,9 @@ function buildUpdate (opts) { ] const acceptedQuerystringCamelCased = [ 'waitForActiveShards', - 'fields', '_source', - '_sourceExclude', - '_sourceInclude', + '_sourceExcludes', + '_sourceIncludes', 'lang', 'parent', 'refresh', @@ -158,11 +136,18 @@ function buildUpdate (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null && (params['id']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + encodeURIComponent(params['id']) + '/' + '_update' + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_update' + '/' + encodeURIComponent(params['id']) + } + // build request object - const parts = [params['index'], params['type'], params['id'], '_update'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/update_by_query.js b/api/api/update_by_query.js index 1f06382ff..e7b4c31bd 100644 --- a/api/api/update_by_query.js +++ b/api/api/update_by_query.js @@ -28,8 +28,8 @@ function buildUpdateByQuery (opts) { * @param {number} size - Number of hits to return (default: 10) * @param {list} sort - A comma-separated list of : pairs * @param {list} _source - True or false to return the _source field or not, or a list of fields to return - * @param {list} _source_exclude - A list of fields to exclude from the returned _source field - * @param {list} _source_include - A list of fields to extract and return from the _source field + * @param {list} _source_excludes - A list of fields to exclude from the returned _source field + * @param {list} _source_includes - A list of fields to extract and return from the _source field * @param {number} terminate_after - The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. * @param {list} stats - Specific 'tag' of the request for logging and statistical purposes * @param {boolean} version - Specify whether to return document version as part of a hit @@ -104,8 +104,8 @@ function buildUpdateByQuery (opts) { 'size', 'sort', '_source', - '_source_exclude', - '_source_include', + '_source_excludes', + '_source_includes', 'terminate_after', 'stats', 'version', @@ -145,8 +145,8 @@ function buildUpdateByQuery (opts) { 'size', 'sort', '_source', - '_sourceExclude', - '_sourceInclude', + '_sourceExcludes', + '_sourceIncludes', 'terminateAfter', 'stats', 'version', @@ -197,11 +197,18 @@ function buildUpdateByQuery (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_update_by_query' + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_update_by_query' + } + // build request object - const parts = [params['index'], params['type'], '_update_by_query'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/update_by_query_rethrottle.js b/api/api/update_by_query_rethrottle.js index 8fb894f7a..4e55ab341 100644 --- a/api/api/update_by_query_rethrottle.js +++ b/api/api/update_by_query_rethrottle.js @@ -100,11 +100,14 @@ function buildUpdateByQueryRethrottle (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_update_by_query' + '/' + encodeURIComponent(params['task_id'] || params['taskId']) + '/' + '_rethrottle' + // build request object - const parts = ['_update_by_query', params['task_id'] || params['taskId'], '_rethrottle'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/xpack.graph.explore.js b/api/api/xpack.graph.explore.js index 02d33ae1e..0513c7e8b 100644 --- a/api/api/xpack.graph.explore.js +++ b/api/api/xpack.graph.explore.js @@ -83,11 +83,18 @@ function buildXpackGraphExplore (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_graph' + '/' + 'explore' + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_graph' + '/' + 'explore' + } + // build request object - const parts = [params['index'], params['type'], '_xpack', 'graph', '_explore'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.info.js b/api/api/xpack.info.js index eb2fe9c60..92bd594d8 100644 --- a/api/api/xpack.info.js +++ b/api/api/xpack.info.js @@ -77,11 +77,14 @@ function buildXpackInfo (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_xpack' + // build request object - const parts = ['_xpack'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.license.delete.js b/api/api/xpack.license.delete.js index 281519cf5..f021661f1 100644 --- a/api/api/xpack.license.delete.js +++ b/api/api/xpack.license.delete.js @@ -76,11 +76,14 @@ function buildXpackLicenseDelete (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_license' + // build request object - const parts = ['_xpack', 'license'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/xpack.license.get.js b/api/api/xpack.license.get.js index e3910bcf0..6d2a404a2 100644 --- a/api/api/xpack.license.get.js +++ b/api/api/xpack.license.get.js @@ -77,11 +77,14 @@ function buildXpackLicenseGet (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_license' + // build request object - const parts = ['_xpack', 'license'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.license.get_basic_status.js b/api/api/xpack.license.get_basic_status.js index a7e368eb2..80b700fae 100644 --- a/api/api/xpack.license.get_basic_status.js +++ b/api/api/xpack.license.get_basic_status.js @@ -76,11 +76,14 @@ function buildXpackLicenseGetBasicStatus (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_license' + '/' + 'basic_status' + // build request object - const parts = ['_xpack', 'license', 'basic_status'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.license.get_trial_status.js b/api/api/xpack.license.get_trial_status.js index d773b29bd..b1875fcc3 100644 --- a/api/api/xpack.license.get_trial_status.js +++ b/api/api/xpack.license.get_trial_status.js @@ -76,11 +76,14 @@ function buildXpackLicenseGetTrialStatus (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_license' + '/' + 'trial_status' + // build request object - const parts = ['_xpack', 'license', 'trial_status'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.license.post.js b/api/api/xpack.license.post.js index 964586b89..38cae7f83 100644 --- a/api/api/xpack.license.post.js +++ b/api/api/xpack.license.post.js @@ -70,11 +70,14 @@ function buildXpackLicensePost (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_license' + // build request object - const parts = ['_xpack', 'license'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.license.post_start_basic.js b/api/api/xpack.license.post_start_basic.js index ddee829a9..39e16ebc1 100644 --- a/api/api/xpack.license.post_start_basic.js +++ b/api/api/xpack.license.post_start_basic.js @@ -77,11 +77,14 @@ function buildXpackLicensePostStartBasic (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_license' + '/' + 'start_basic' + // build request object - const parts = ['_xpack', 'license', 'start_basic'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/xpack.license.post_start_trial.js b/api/api/xpack.license.post_start_trial.js index f3a4a85a0..b9c934e9d 100644 --- a/api/api/xpack.license.post_start_trial.js +++ b/api/api/xpack.license.post_start_trial.js @@ -80,11 +80,14 @@ function buildXpackLicensePostStartTrial (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_license' + '/' + 'start_trial' + // build request object - const parts = ['_xpack', 'license', 'start_trial'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/xpack.migration.deprecations.js b/api/api/xpack.migration.deprecations.js index 31b984b58..53cd0f260 100644 --- a/api/api/xpack.migration.deprecations.js +++ b/api/api/xpack.migration.deprecations.js @@ -77,11 +77,18 @@ function buildXpackMigrationDeprecations (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + '_migration' + '/' + 'deprecations' + } else { + path = '/' + '_migration' + '/' + 'deprecations' + } + // build request object - const parts = [params['index'], '_xpack', 'migration', 'deprecations'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.migration.get_assistance.js b/api/api/xpack.migration.get_assistance.js index aed1707bd..62b98ca71 100644 --- a/api/api/xpack.migration.get_assistance.js +++ b/api/api/xpack.migration.get_assistance.js @@ -76,11 +76,18 @@ function buildXpackMigrationGetAssistance (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null) { + path = '/' + '_migration' + '/' + 'assistance' + '/' + encodeURIComponent(params['index']) + } else { + path = '/' + '_migration' + '/' + 'assistance' + } + // build request object - const parts = ['_xpack', 'migration', 'assistance', params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.migration.upgrade.js b/api/api/xpack.migration.upgrade.js index 48a151080..1c3cb5aa3 100644 --- a/api/api/xpack.migration.upgrade.js +++ b/api/api/xpack.migration.upgrade.js @@ -78,11 +78,14 @@ function buildXpackMigrationUpgrade (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_migration' + '/' + 'upgrade' + '/' + encodeURIComponent(params['index']) + // build request object - const parts = ['_xpack', 'migration', 'upgrade', params['index']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.rollup.delete_job.js b/api/api/xpack.rollup.delete_job.js index 42c6f36e1..d9df1880f 100644 --- a/api/api/xpack.rollup.delete_job.js +++ b/api/api/xpack.rollup.delete_job.js @@ -77,11 +77,14 @@ function buildXpackRollupDeleteJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(params['id']) + // build request object - const parts = ['_xpack', 'rollup', 'job', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.rollup.get_jobs.js b/api/api/xpack.rollup.get_jobs.js index 980d5a898..f9bf7992f 100644 --- a/api/api/xpack.rollup.get_jobs.js +++ b/api/api/xpack.rollup.get_jobs.js @@ -69,11 +69,18 @@ function buildXpackRollupGetJobs (opts) { ignore = [ignore] } + var path = '' + + if ((params['id']) != null) { + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(params['id']) + } else { + path = '/' + '_rollup' + '/' + 'job' + } + // build request object - const parts = ['_xpack', 'rollup', 'job'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.rollup.get_rollup_caps.js b/api/api/xpack.rollup.get_rollup_caps.js index fde5b147c..083e6a905 100644 --- a/api/api/xpack.rollup.get_rollup_caps.js +++ b/api/api/xpack.rollup.get_rollup_caps.js @@ -69,11 +69,18 @@ function buildXpackRollupGetRollupCaps (opts) { ignore = [ignore] } + var path = '' + + if ((params['id']) != null) { + path = '/' + '_rollup' + '/' + 'data' + '/' + encodeURIComponent(params['id']) + } else { + path = '/' + '_rollup' + '/' + 'data' + } + // build request object - const parts = ['_xpack', 'rollup', 'data'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.rollup.get_rollup_index_caps.js b/api/api/xpack.rollup.get_rollup_index_caps.js index b7a0b5c7f..5a62668d6 100644 --- a/api/api/xpack.rollup.get_rollup_index_caps.js +++ b/api/api/xpack.rollup.get_rollup_index_caps.js @@ -77,11 +77,14 @@ function buildXpackRollupGetRollupIndexCaps (opts) { ignore = [ignore] } + var path = '' + + path = '/' + encodeURIComponent(params['index']) + '/' + '_rollup' + '/' + 'data' + // build request object - const parts = [params['index'], '_xpack', 'rollup', 'data'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.rollup.put_job.js b/api/api/xpack.rollup.put_job.js index dc72b711e..df8f39fbf 100644 --- a/api/api/xpack.rollup.put_job.js +++ b/api/api/xpack.rollup.put_job.js @@ -84,11 +84,14 @@ function buildXpackRollupPutJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(params['id']) + // build request object - const parts = ['_xpack', 'rollup', 'job', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.rollup.rollup_search.js b/api/api/xpack.rollup.rollup_search.js index b8667f92b..68a8d1610 100644 --- a/api/api/xpack.rollup.rollup_search.js +++ b/api/api/xpack.rollup.rollup_search.js @@ -8,6 +8,8 @@ function buildXpackRollupRollupSearch (opts) { * * @param {string} index - The index or index-pattern (containing rollup or regular data) that should be searched * @param {string} type - The doc type inside the index + * @param {boolean} typed_keys - Specify whether aggregation and suggester names should be prefixed by their respective types in the response + * @param {boolean} rest_total_hits_as_int - Indicates whether hits.total should be rendered as an integer or an object in the rest search response * @param {object} body - The search request body */ return function xpackRollupRollupSearch (params, options, callback) { @@ -56,10 +58,12 @@ function buildXpackRollupRollupSearch (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ - + 'typed_keys', + 'rest_total_hits_as_int' ] const acceptedQuerystringCamelCased = [ - + 'typedKeys', + 'restTotalHitsAsInt' ] for (var i = 0, len = keys.length; i < len; i++) { @@ -93,13 +97,18 @@ function buildXpackRollupRollupSearch (opts) { ignore = [ignore] } + var path = '' + + if ((params['index']) != null && (params['type']) != null) { + path = '/' + encodeURIComponent(params['index']) + '/' + encodeURIComponent(params['type']) + '/' + '_rollup_search' + } else { + path = '/' + encodeURIComponent(params['index']) + '/' + '_rollup_search' + } + // build request object - const parts = [params['index'], params['type'], '_rollup_search'] const request = { method, - path: params['index'] != null && params['type'] != null - ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') - : '/{index}/_rollup_search', + path, body: params.body || '', querystring } diff --git a/api/api/xpack.rollup.start_job.js b/api/api/xpack.rollup.start_job.js index a0b168f98..7b2314546 100644 --- a/api/api/xpack.rollup.start_job.js +++ b/api/api/xpack.rollup.start_job.js @@ -77,11 +77,14 @@ function buildXpackRollupStartJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(params['id']) + '/' + '_start' + // build request object - const parts = ['_xpack', 'rollup', 'job', params['id'], '_start'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.rollup.stop_job.js b/api/api/xpack.rollup.stop_job.js index cfad8708a..c3215a3a0 100644 --- a/api/api/xpack.rollup.stop_job.js +++ b/api/api/xpack.rollup.stop_job.js @@ -7,6 +7,8 @@ function buildXpackRollupStopJob (opts) { * Perform a [xpack.rollup.stop_job]() request * * @param {string} id - The ID of the job to stop + * @param {boolean} wait_for_completion - True if the API should block until the job has fully stopped, false if should be executed async. Defaults to false. + * @param {time} timeout - Block for (at maximum) the specified duration while waiting for the job to stop. Defaults to 30s. */ return function xpackRollupStopJob (params, options, callback) { options = options || {} @@ -40,10 +42,12 @@ function buildXpackRollupStopJob (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ - + 'wait_for_completion', + 'timeout' ] const acceptedQuerystringCamelCased = [ - + 'waitForCompletion', + 'timeout' ] for (var i = 0, len = keys.length; i < len; i++) { @@ -77,11 +81,14 @@ function buildXpackRollupStopJob (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_rollup' + '/' + 'job' + '/' + encodeURIComponent(params['id']) + '/' + '_stop' + // build request object - const parts = ['_xpack', 'rollup', 'job', params['id'], '_stop'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.security.get_user_privileges.js b/api/api/xpack.security.get_user_privileges.js deleted file mode 100644 index 5be01585c..000000000 --- a/api/api/xpack.security.get_user_privileges.js +++ /dev/null @@ -1,100 +0,0 @@ -'use strict' - -function buildXpackSecurityGetUserPrivileges (opts) { - // eslint-disable-next-line no-unused-vars - const { makeRequest, ConfigurationError, result } = opts - /** - * Perform a [xpack.security.get_user_privileges](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-privileges.html) request - * - */ - return function xpackSecurityGetUserPrivileges (params, options, callback) { - options = options || {} - if (typeof options === 'function') { - callback = options - options = {} - } - if (typeof params === 'function' || params == null) { - callback = params - params = {} - options = {} - } - // promises support - if (callback == null) { - return new Promise((resolve, reject) => { - xpackSecurityGetUserPrivileges(params, options, (err, body) => { - err ? reject(err) : resolve(body) - }) - }) - } - - // check required parameters - if (params.body != null) { - return callback( - new ConfigurationError('This API does not require a body'), - result - ) - } - - // build querystring object - const querystring = {} - const keys = Object.keys(params) - const acceptedQuerystring = [ - - ] - const acceptedQuerystringCamelCased = [ - - ] - - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i] - if (acceptedQuerystring.indexOf(key) !== -1) { - querystring[key] = params[key] - } else { - var camelIndex = acceptedQuerystringCamelCased.indexOf(key) - if (camelIndex !== -1) { - querystring[acceptedQuerystring[camelIndex]] = params[key] - } - } - } - - // configure http method - var method = params.method - if (method == null) { - method = 'GET' - } - - // validate headers object - if (params.headers != null && typeof params.headers !== 'object') { - return callback( - new ConfigurationError(`Headers should be an object, instead got: ${typeof params.headers}`), - result - ) - } - - var ignore = options.ignore || null - if (typeof ignore === 'number') { - ignore = [ignore] - } - - // build request object - const parts = ['_xpack', 'security', 'user', '_privileges'] - const request = { - method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), - body: null, - querystring - } - - const requestOptions = { - ignore, - requestTimeout: options.requestTimeout || null, - maxRetries: options.maxRetries || null, - asStream: options.asStream || false, - headers: options.headers || null - } - - return makeRequest(request, requestOptions, callback) - } -} - -module.exports = buildXpackSecurityGetUserPrivileges diff --git a/api/api/xpack.sql.clear_cursor.js b/api/api/xpack.sql.clear_cursor.js index 9b299bc19..0d69796bc 100644 --- a/api/api/xpack.sql.clear_cursor.js +++ b/api/api/xpack.sql.clear_cursor.js @@ -77,11 +77,14 @@ function buildXpackSqlClearCursor (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_sql' + '/' + 'close' + // build request object - const parts = ['_xpack', 'sql', 'close'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.sql.query.js b/api/api/xpack.sql.query.js index 1e1cb28b3..6030181da 100644 --- a/api/api/xpack.sql.query.js +++ b/api/api/xpack.sql.query.js @@ -78,11 +78,14 @@ function buildXpackSqlQuery (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_sql' + // build request object - const parts = ['_xpack', 'sql'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.sql.translate.js b/api/api/xpack.sql.translate.js index 680f037c8..2a3450652 100644 --- a/api/api/xpack.sql.translate.js +++ b/api/api/xpack.sql.translate.js @@ -77,11 +77,14 @@ function buildXpackSqlTranslate (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_sql' + '/' + 'translate' + // build request object - const parts = ['_xpack', 'sql', 'translate'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.usage.js b/api/api/xpack.usage.js index 2e810ef06..09df41f17 100644 --- a/api/api/xpack.usage.js +++ b/api/api/xpack.usage.js @@ -77,11 +77,14 @@ function buildXpackUsage (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_xpack' + '/' + 'usage' + // build request object - const parts = ['_xpack', 'usage'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.watcher.ack_watch.js b/api/api/xpack.watcher.ack_watch.js index 99b781b83..bca2cc0df 100644 --- a/api/api/xpack.watcher.ack_watch.js +++ b/api/api/xpack.watcher.ack_watch.js @@ -8,7 +8,6 @@ function buildXpackWatcherAckWatch (opts) { * * @param {string} watch_id - Watch ID * @param {list} action_id - A comma-separated list of the action ids to be acked - * @param {time} master_timeout - Explicit operation timeout for connection to master node */ return function xpackWatcherAckWatch (params, options, callback) { options = options || {} @@ -56,10 +55,10 @@ function buildXpackWatcherAckWatch (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ - 'master_timeout' + ] const acceptedQuerystringCamelCased = [ - 'masterTimeout' + ] for (var i = 0, len = keys.length; i < len; i++) { @@ -93,11 +92,18 @@ function buildXpackWatcherAckWatch (opts) { ignore = [ignore] } + var path = '' + + if ((params['watch_id'] || params['watchId']) != null && (params['action_id'] || params['actionId']) != null) { + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['watch_id'] || params['watchId']) + '/' + '_ack' + '/' + encodeURIComponent(params['action_id'] || params['actionId']) + } else { + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['watch_id'] || params['watchId']) + '/' + '_ack' + } + // build request object - const parts = ['_xpack', 'watcher', 'watch', params['watch_id'] || params['watchId'], '_ack', params['action_id'] || params['actionId']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/xpack.watcher.activate_watch.js b/api/api/xpack.watcher.activate_watch.js index 96333bdb0..cc2e7674b 100644 --- a/api/api/xpack.watcher.activate_watch.js +++ b/api/api/xpack.watcher.activate_watch.js @@ -7,7 +7,6 @@ function buildXpackWatcherActivateWatch (opts) { * Perform a [xpack.watcher.activate_watch](https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-activate-watch.html) request * * @param {string} watch_id - Watch ID - * @param {time} master_timeout - Explicit operation timeout for connection to master node */ return function xpackWatcherActivateWatch (params, options, callback) { options = options || {} @@ -47,10 +46,10 @@ function buildXpackWatcherActivateWatch (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ - 'master_timeout' + ] const acceptedQuerystringCamelCased = [ - 'masterTimeout' + ] for (var i = 0, len = keys.length; i < len; i++) { @@ -84,11 +83,14 @@ function buildXpackWatcherActivateWatch (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['watch_id'] || params['watchId']) + '/' + '_activate' + // build request object - const parts = ['_xpack', 'watcher', 'watch', params['watch_id'] || params['watchId'], '_activate'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/xpack.watcher.deactivate_watch.js b/api/api/xpack.watcher.deactivate_watch.js index b9d3cbaf2..5392ed21d 100644 --- a/api/api/xpack.watcher.deactivate_watch.js +++ b/api/api/xpack.watcher.deactivate_watch.js @@ -7,7 +7,6 @@ function buildXpackWatcherDeactivateWatch (opts) { * Perform a [xpack.watcher.deactivate_watch](https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-deactivate-watch.html) request * * @param {string} watch_id - Watch ID - * @param {time} master_timeout - Explicit operation timeout for connection to master node */ return function xpackWatcherDeactivateWatch (params, options, callback) { options = options || {} @@ -47,10 +46,10 @@ function buildXpackWatcherDeactivateWatch (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ - 'master_timeout' + ] const acceptedQuerystringCamelCased = [ - 'masterTimeout' + ] for (var i = 0, len = keys.length; i < len; i++) { @@ -84,11 +83,14 @@ function buildXpackWatcherDeactivateWatch (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['watch_id'] || params['watchId']) + '/' + '_deactivate' + // build request object - const parts = ['_xpack', 'watcher', 'watch', params['watch_id'] || params['watchId'], '_deactivate'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/xpack.watcher.delete_watch.js b/api/api/xpack.watcher.delete_watch.js index 92a900d88..a0e590960 100644 --- a/api/api/xpack.watcher.delete_watch.js +++ b/api/api/xpack.watcher.delete_watch.js @@ -7,7 +7,6 @@ function buildXpackWatcherDeleteWatch (opts) { * Perform a [xpack.watcher.delete_watch](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-delete-watch.html) request * * @param {string} id - Watch ID - * @param {time} master_timeout - Explicit operation timeout for connection to master node */ return function xpackWatcherDeleteWatch (params, options, callback) { options = options || {} @@ -47,10 +46,10 @@ function buildXpackWatcherDeleteWatch (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ - 'master_timeout' + ] const acceptedQuerystringCamelCased = [ - 'masterTimeout' + ] for (var i = 0, len = keys.length; i < len; i++) { @@ -84,11 +83,14 @@ function buildXpackWatcherDeleteWatch (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['id']) + // build request object - const parts = ['_xpack', 'watcher', 'watch', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/xpack.watcher.execute_watch.js b/api/api/xpack.watcher.execute_watch.js index 10b81222e..45c897650 100644 --- a/api/api/xpack.watcher.execute_watch.js +++ b/api/api/xpack.watcher.execute_watch.js @@ -71,11 +71,18 @@ function buildXpackWatcherExecuteWatch (opts) { ignore = [ignore] } + var path = '' + + if ((params['id']) != null) { + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['id']) + '/' + '_execute' + } else { + path = '/' + '_watcher' + '/' + 'watch' + '/' + '_execute' + } + // build request object - const parts = ['_xpack', 'watcher', 'watch', params['id'], '_execute'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.watcher.get_watch.js b/api/api/xpack.watcher.get_watch.js index dadb61d0c..223cddf13 100644 --- a/api/api/xpack.watcher.get_watch.js +++ b/api/api/xpack.watcher.get_watch.js @@ -83,11 +83,14 @@ function buildXpackWatcherGetWatch (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['id']) + // build request object - const parts = ['_xpack', 'watcher', 'watch', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.watcher.put_watch.js b/api/api/xpack.watcher.put_watch.js index f1bf4956f..59317d9c3 100644 --- a/api/api/xpack.watcher.put_watch.js +++ b/api/api/xpack.watcher.put_watch.js @@ -7,7 +7,6 @@ function buildXpackWatcherPutWatch (opts) { * Perform a [xpack.watcher.put_watch](http://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api-put-watch.html) request * * @param {string} id - Watch ID - * @param {time} master_timeout - Explicit operation timeout for connection to master node * @param {boolean} active - Specify whether the watch is in/active by default * @param {number} version - Explicit version number for concurrency control * @param {object} body - The watch @@ -44,12 +43,10 @@ function buildXpackWatcherPutWatch (opts) { const querystring = {} const keys = Object.keys(params) const acceptedQuerystring = [ - 'master_timeout', 'active', 'version' ] const acceptedQuerystringCamelCased = [ - 'masterTimeout', 'active', 'version' ] @@ -85,11 +82,14 @@ function buildXpackWatcherPutWatch (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_watcher' + '/' + 'watch' + '/' + encodeURIComponent(params['id']) + // build request object - const parts = ['_xpack', 'watcher', 'watch', params['id']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: params.body || '', querystring } diff --git a/api/api/xpack.watcher.start.js b/api/api/xpack.watcher.start.js index 0232e3b46..0d2eae0e0 100644 --- a/api/api/xpack.watcher.start.js +++ b/api/api/xpack.watcher.start.js @@ -76,11 +76,14 @@ function buildXpackWatcherStart (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_watcher' + '/' + '_start' + // build request object - const parts = ['_xpack', 'watcher', '_start'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/api/xpack.watcher.stats.js b/api/api/xpack.watcher.stats.js index 0b6124eb7..64417cf55 100644 --- a/api/api/xpack.watcher.stats.js +++ b/api/api/xpack.watcher.stats.js @@ -81,11 +81,18 @@ function buildXpackWatcherStats (opts) { ignore = [ignore] } + var path = '' + + if ((params['metric']) != null) { + path = '/' + '_watcher' + '/' + 'stats' + '/' + encodeURIComponent(params['metric']) + } else { + path = '/' + '_watcher' + '/' + 'stats' + } + // build request object - const parts = ['_xpack', 'watcher', 'stats', params['metric']] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: null, querystring } diff --git a/api/api/xpack.watcher.stop.js b/api/api/xpack.watcher.stop.js index 18550bc80..a414bbb68 100644 --- a/api/api/xpack.watcher.stop.js +++ b/api/api/xpack.watcher.stop.js @@ -76,11 +76,14 @@ function buildXpackWatcherStop (opts) { ignore = [ignore] } + var path = '' + + path = '/' + '_watcher' + '/' + '_stop' + // build request object - const parts = ['_xpack', 'watcher', '_stop'] const request = { method, - path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'), + path, body: '', querystring } diff --git a/api/index.js b/api/index.js index 0f4bb3df9..2993857b2 100644 --- a/api/index.js +++ b/api/index.js @@ -88,6 +88,25 @@ function ESAPI (opts) { getScript: lazyLoad('./api/get_script.js', opts), get_source: lazyLoad('./api/get_source.js', opts), getSource: lazyLoad('./api/get_source.js', opts), + ilm: { + delete_lifecycle: lazyLoad('./api/ilm.delete_lifecycle.js', opts), + deleteLifecycle: lazyLoad('./api/ilm.delete_lifecycle.js', opts), + explain_lifecycle: lazyLoad('./api/ilm.explain_lifecycle.js', opts), + explainLifecycle: lazyLoad('./api/ilm.explain_lifecycle.js', opts), + get_lifecycle: lazyLoad('./api/ilm.get_lifecycle.js', opts), + getLifecycle: lazyLoad('./api/ilm.get_lifecycle.js', opts), + get_status: lazyLoad('./api/ilm.get_status.js', opts), + getStatus: lazyLoad('./api/ilm.get_status.js', opts), + move_to_step: lazyLoad('./api/ilm.move_to_step.js', opts), + moveToStep: lazyLoad('./api/ilm.move_to_step.js', opts), + put_lifecycle: lazyLoad('./api/ilm.put_lifecycle.js', opts), + putLifecycle: lazyLoad('./api/ilm.put_lifecycle.js', opts), + remove_policy: lazyLoad('./api/ilm.remove_policy.js', opts), + removePolicy: lazyLoad('./api/ilm.remove_policy.js', opts), + retry: lazyLoad('./api/ilm.retry.js', opts), + start: lazyLoad('./api/ilm.start.js', opts), + stop: lazyLoad('./api/ilm.stop.js', opts) + }, index: lazyLoad('./api/index.js', opts), indices: { analyze: lazyLoad('./api/indices.analyze.js', opts), @@ -111,6 +130,7 @@ function ESAPI (opts) { flush_synced: lazyLoad('./api/indices.flush_synced.js', opts), flushSynced: lazyLoad('./api/indices.flush_synced.js', opts), forcemerge: lazyLoad('./api/indices.forcemerge.js', opts), + freeze: lazyLoad('./api/indices.freeze.js', opts), get: lazyLoad('./api/indices.get.js', opts), get_alias: lazyLoad('./api/indices.get_alias.js', opts), getAlias: lazyLoad('./api/indices.get_alias.js', opts), @@ -142,6 +162,7 @@ function ESAPI (opts) { shrink: lazyLoad('./api/indices.shrink.js', opts), split: lazyLoad('./api/indices.split.js', opts), stats: lazyLoad('./api/indices.stats.js', opts), + unfreeze: lazyLoad('./api/indices.unfreeze.js', opts), update_aliases: lazyLoad('./api/indices.update_aliases.js', opts), updateAliases: lazyLoad('./api/indices.update_aliases.js', opts), upgrade: lazyLoad('./api/indices.upgrade.js', opts), @@ -161,6 +182,98 @@ function ESAPI (opts) { simulate: lazyLoad('./api/ingest.simulate.js', opts) }, mget: lazyLoad('./api/mget.js', opts), + ml: { + close_job: lazyLoad('./api/ml.close_job.js', opts), + closeJob: lazyLoad('./api/ml.close_job.js', opts), + delete_calendar: lazyLoad('./api/ml.delete_calendar.js', opts), + deleteCalendar: lazyLoad('./api/ml.delete_calendar.js', opts), + delete_calendar_event: lazyLoad('./api/ml.delete_calendar_event.js', opts), + deleteCalendarEvent: lazyLoad('./api/ml.delete_calendar_event.js', opts), + delete_calendar_job: lazyLoad('./api/ml.delete_calendar_job.js', opts), + deleteCalendarJob: lazyLoad('./api/ml.delete_calendar_job.js', opts), + delete_datafeed: lazyLoad('./api/ml.delete_datafeed.js', opts), + deleteDatafeed: lazyLoad('./api/ml.delete_datafeed.js', opts), + delete_expired_data: lazyLoad('./api/ml.delete_expired_data.js', opts), + deleteExpiredData: lazyLoad('./api/ml.delete_expired_data.js', opts), + delete_filter: lazyLoad('./api/ml.delete_filter.js', opts), + deleteFilter: lazyLoad('./api/ml.delete_filter.js', opts), + delete_forecast: lazyLoad('./api/ml.delete_forecast.js', opts), + deleteForecast: lazyLoad('./api/ml.delete_forecast.js', opts), + delete_job: lazyLoad('./api/ml.delete_job.js', opts), + deleteJob: lazyLoad('./api/ml.delete_job.js', opts), + delete_model_snapshot: lazyLoad('./api/ml.delete_model_snapshot.js', opts), + deleteModelSnapshot: lazyLoad('./api/ml.delete_model_snapshot.js', opts), + find_file_structure: lazyLoad('./api/ml.find_file_structure.js', opts), + findFileStructure: lazyLoad('./api/ml.find_file_structure.js', opts), + flush_job: lazyLoad('./api/ml.flush_job.js', opts), + flushJob: lazyLoad('./api/ml.flush_job.js', opts), + forecast: lazyLoad('./api/ml.forecast.js', opts), + get_buckets: lazyLoad('./api/ml.get_buckets.js', opts), + getBuckets: lazyLoad('./api/ml.get_buckets.js', opts), + get_calendar_events: lazyLoad('./api/ml.get_calendar_events.js', opts), + getCalendarEvents: lazyLoad('./api/ml.get_calendar_events.js', opts), + get_calendars: lazyLoad('./api/ml.get_calendars.js', opts), + getCalendars: lazyLoad('./api/ml.get_calendars.js', opts), + get_categories: lazyLoad('./api/ml.get_categories.js', opts), + getCategories: lazyLoad('./api/ml.get_categories.js', opts), + get_datafeed_stats: lazyLoad('./api/ml.get_datafeed_stats.js', opts), + getDatafeedStats: lazyLoad('./api/ml.get_datafeed_stats.js', opts), + get_datafeeds: lazyLoad('./api/ml.get_datafeeds.js', opts), + getDatafeeds: lazyLoad('./api/ml.get_datafeeds.js', opts), + get_filters: lazyLoad('./api/ml.get_filters.js', opts), + getFilters: lazyLoad('./api/ml.get_filters.js', opts), + get_influencers: lazyLoad('./api/ml.get_influencers.js', opts), + getInfluencers: lazyLoad('./api/ml.get_influencers.js', opts), + get_job_stats: lazyLoad('./api/ml.get_job_stats.js', opts), + getJobStats: lazyLoad('./api/ml.get_job_stats.js', opts), + get_jobs: lazyLoad('./api/ml.get_jobs.js', opts), + getJobs: lazyLoad('./api/ml.get_jobs.js', opts), + get_model_snapshots: lazyLoad('./api/ml.get_model_snapshots.js', opts), + getModelSnapshots: lazyLoad('./api/ml.get_model_snapshots.js', opts), + get_overall_buckets: lazyLoad('./api/ml.get_overall_buckets.js', opts), + getOverallBuckets: lazyLoad('./api/ml.get_overall_buckets.js', opts), + get_records: lazyLoad('./api/ml.get_records.js', opts), + getRecords: lazyLoad('./api/ml.get_records.js', opts), + info: lazyLoad('./api/ml.info.js', opts), + open_job: lazyLoad('./api/ml.open_job.js', opts), + openJob: lazyLoad('./api/ml.open_job.js', opts), + post_calendar_events: lazyLoad('./api/ml.post_calendar_events.js', opts), + postCalendarEvents: lazyLoad('./api/ml.post_calendar_events.js', opts), + post_data: lazyLoad('./api/ml.post_data.js', opts), + postData: lazyLoad('./api/ml.post_data.js', opts), + preview_datafeed: lazyLoad('./api/ml.preview_datafeed.js', opts), + previewDatafeed: lazyLoad('./api/ml.preview_datafeed.js', opts), + put_calendar: lazyLoad('./api/ml.put_calendar.js', opts), + putCalendar: lazyLoad('./api/ml.put_calendar.js', opts), + put_calendar_job: lazyLoad('./api/ml.put_calendar_job.js', opts), + putCalendarJob: lazyLoad('./api/ml.put_calendar_job.js', opts), + put_datafeed: lazyLoad('./api/ml.put_datafeed.js', opts), + putDatafeed: lazyLoad('./api/ml.put_datafeed.js', opts), + put_filter: lazyLoad('./api/ml.put_filter.js', opts), + putFilter: lazyLoad('./api/ml.put_filter.js', opts), + put_job: lazyLoad('./api/ml.put_job.js', opts), + putJob: lazyLoad('./api/ml.put_job.js', opts), + revert_model_snapshot: lazyLoad('./api/ml.revert_model_snapshot.js', opts), + revertModelSnapshot: lazyLoad('./api/ml.revert_model_snapshot.js', opts), + start_datafeed: lazyLoad('./api/ml.start_datafeed.js', opts), + startDatafeed: lazyLoad('./api/ml.start_datafeed.js', opts), + stop_datafeed: lazyLoad('./api/ml.stop_datafeed.js', opts), + stopDatafeed: lazyLoad('./api/ml.stop_datafeed.js', opts), + update_datafeed: lazyLoad('./api/ml.update_datafeed.js', opts), + updateDatafeed: lazyLoad('./api/ml.update_datafeed.js', opts), + update_filter: lazyLoad('./api/ml.update_filter.js', opts), + updateFilter: lazyLoad('./api/ml.update_filter.js', opts), + update_job: lazyLoad('./api/ml.update_job.js', opts), + updateJob: lazyLoad('./api/ml.update_job.js', opts), + update_model_snapshot: lazyLoad('./api/ml.update_model_snapshot.js', opts), + updateModelSnapshot: lazyLoad('./api/ml.update_model_snapshot.js', opts), + validate: lazyLoad('./api/ml.validate.js', opts), + validate_detector: lazyLoad('./api/ml.validate_detector.js', opts), + validateDetector: lazyLoad('./api/ml.validate_detector.js', opts) + }, + monitoring: { + bulk: lazyLoad('./api/monitoring.bulk.js', opts) + }, msearch: lazyLoad('./api/msearch.js', opts), msearch_template: lazyLoad('./api/msearch_template.js', opts), msearchTemplate: lazyLoad('./api/msearch_template.js', opts), @@ -192,6 +305,51 @@ function ESAPI (opts) { searchShards: lazyLoad('./api/search_shards.js', opts), search_template: lazyLoad('./api/search_template.js', opts), searchTemplate: lazyLoad('./api/search_template.js', opts), + security: { + authenticate: lazyLoad('./api/security.authenticate.js', opts), + change_password: lazyLoad('./api/security.change_password.js', opts), + changePassword: lazyLoad('./api/security.change_password.js', opts), + clear_cached_realms: lazyLoad('./api/security.clear_cached_realms.js', opts), + clearCachedRealms: lazyLoad('./api/security.clear_cached_realms.js', opts), + clear_cached_roles: lazyLoad('./api/security.clear_cached_roles.js', opts), + clearCachedRoles: lazyLoad('./api/security.clear_cached_roles.js', opts), + delete_privileges: lazyLoad('./api/security.delete_privileges.js', opts), + deletePrivileges: lazyLoad('./api/security.delete_privileges.js', opts), + delete_role: lazyLoad('./api/security.delete_role.js', opts), + deleteRole: lazyLoad('./api/security.delete_role.js', opts), + delete_role_mapping: lazyLoad('./api/security.delete_role_mapping.js', opts), + deleteRoleMapping: lazyLoad('./api/security.delete_role_mapping.js', opts), + delete_user: lazyLoad('./api/security.delete_user.js', opts), + deleteUser: lazyLoad('./api/security.delete_user.js', opts), + disable_user: lazyLoad('./api/security.disable_user.js', opts), + disableUser: lazyLoad('./api/security.disable_user.js', opts), + enable_user: lazyLoad('./api/security.enable_user.js', opts), + enableUser: lazyLoad('./api/security.enable_user.js', opts), + get_privileges: lazyLoad('./api/security.get_privileges.js', opts), + getPrivileges: lazyLoad('./api/security.get_privileges.js', opts), + get_role: lazyLoad('./api/security.get_role.js', opts), + getRole: lazyLoad('./api/security.get_role.js', opts), + get_role_mapping: lazyLoad('./api/security.get_role_mapping.js', opts), + getRoleMapping: lazyLoad('./api/security.get_role_mapping.js', opts), + get_token: lazyLoad('./api/security.get_token.js', opts), + getToken: lazyLoad('./api/security.get_token.js', opts), + get_user: lazyLoad('./api/security.get_user.js', opts), + getUser: lazyLoad('./api/security.get_user.js', opts), + get_user_privileges: lazyLoad('./api/security.get_user_privileges.js', opts), + getUserPrivileges: lazyLoad('./api/security.get_user_privileges.js', opts), + has_privileges: lazyLoad('./api/security.has_privileges.js', opts), + hasPrivileges: lazyLoad('./api/security.has_privileges.js', opts), + invalidate_token: lazyLoad('./api/security.invalidate_token.js', opts), + invalidateToken: lazyLoad('./api/security.invalidate_token.js', opts), + put_privileges: lazyLoad('./api/security.put_privileges.js', opts), + putPrivileges: lazyLoad('./api/security.put_privileges.js', opts), + put_role: lazyLoad('./api/security.put_role.js', opts), + putRole: lazyLoad('./api/security.put_role.js', opts), + put_role_mapping: lazyLoad('./api/security.put_role_mapping.js', opts), + putRoleMapping: lazyLoad('./api/security.put_role_mapping.js', opts), + put_user: lazyLoad('./api/security.put_user.js', opts), + putUser: lazyLoad('./api/security.put_user.js', opts) + }, snapshot: { create: lazyLoad('./api/snapshot.create.js', opts), create_repository: lazyLoad('./api/snapshot.create_repository.js', opts), @@ -207,6 +365,9 @@ function ESAPI (opts) { verify_repository: lazyLoad('./api/snapshot.verify_repository.js', opts), verifyRepository: lazyLoad('./api/snapshot.verify_repository.js', opts) }, + ssl: { + certificates: lazyLoad('./api/ssl.certificates.js', opts) + }, tasks: { cancel: lazyLoad('./api/tasks.cancel.js', opts), get: lazyLoad('./api/tasks.get.js', opts), @@ -242,98 +403,6 @@ function ESAPI (opts) { getAssistance: lazyLoad('./api/xpack.migration.get_assistance.js', opts), upgrade: lazyLoad('./api/xpack.migration.upgrade.js', opts) }, - ml: { - close_job: lazyLoad('./api/xpack.ml.close_job.js', opts), - closeJob: lazyLoad('./api/xpack.ml.close_job.js', opts), - delete_calendar: lazyLoad('./api/xpack.ml.delete_calendar.js', opts), - deleteCalendar: lazyLoad('./api/xpack.ml.delete_calendar.js', opts), - delete_calendar_event: lazyLoad('./api/xpack.ml.delete_calendar_event.js', opts), - deleteCalendarEvent: lazyLoad('./api/xpack.ml.delete_calendar_event.js', opts), - delete_calendar_job: lazyLoad('./api/xpack.ml.delete_calendar_job.js', opts), - deleteCalendarJob: lazyLoad('./api/xpack.ml.delete_calendar_job.js', opts), - delete_datafeed: lazyLoad('./api/xpack.ml.delete_datafeed.js', opts), - deleteDatafeed: lazyLoad('./api/xpack.ml.delete_datafeed.js', opts), - delete_expired_data: lazyLoad('./api/xpack.ml.delete_expired_data.js', opts), - deleteExpiredData: lazyLoad('./api/xpack.ml.delete_expired_data.js', opts), - delete_filter: lazyLoad('./api/xpack.ml.delete_filter.js', opts), - deleteFilter: lazyLoad('./api/xpack.ml.delete_filter.js', opts), - delete_forecast: lazyLoad('./api/xpack.ml.delete_forecast.js', opts), - deleteForecast: lazyLoad('./api/xpack.ml.delete_forecast.js', opts), - delete_job: lazyLoad('./api/xpack.ml.delete_job.js', opts), - deleteJob: lazyLoad('./api/xpack.ml.delete_job.js', opts), - delete_model_snapshot: lazyLoad('./api/xpack.ml.delete_model_snapshot.js', opts), - deleteModelSnapshot: lazyLoad('./api/xpack.ml.delete_model_snapshot.js', opts), - find_file_structure: lazyLoad('./api/xpack.ml.find_file_structure.js', opts), - findFileStructure: lazyLoad('./api/xpack.ml.find_file_structure.js', opts), - flush_job: lazyLoad('./api/xpack.ml.flush_job.js', opts), - flushJob: lazyLoad('./api/xpack.ml.flush_job.js', opts), - forecast: lazyLoad('./api/xpack.ml.forecast.js', opts), - get_buckets: lazyLoad('./api/xpack.ml.get_buckets.js', opts), - getBuckets: lazyLoad('./api/xpack.ml.get_buckets.js', opts), - get_calendar_events: lazyLoad('./api/xpack.ml.get_calendar_events.js', opts), - getCalendarEvents: lazyLoad('./api/xpack.ml.get_calendar_events.js', opts), - get_calendars: lazyLoad('./api/xpack.ml.get_calendars.js', opts), - getCalendars: lazyLoad('./api/xpack.ml.get_calendars.js', opts), - get_categories: lazyLoad('./api/xpack.ml.get_categories.js', opts), - getCategories: lazyLoad('./api/xpack.ml.get_categories.js', opts), - get_datafeed_stats: lazyLoad('./api/xpack.ml.get_datafeed_stats.js', opts), - getDatafeedStats: lazyLoad('./api/xpack.ml.get_datafeed_stats.js', opts), - get_datafeeds: lazyLoad('./api/xpack.ml.get_datafeeds.js', opts), - getDatafeeds: lazyLoad('./api/xpack.ml.get_datafeeds.js', opts), - get_filters: lazyLoad('./api/xpack.ml.get_filters.js', opts), - getFilters: lazyLoad('./api/xpack.ml.get_filters.js', opts), - get_influencers: lazyLoad('./api/xpack.ml.get_influencers.js', opts), - getInfluencers: lazyLoad('./api/xpack.ml.get_influencers.js', opts), - get_job_stats: lazyLoad('./api/xpack.ml.get_job_stats.js', opts), - getJobStats: lazyLoad('./api/xpack.ml.get_job_stats.js', opts), - get_jobs: lazyLoad('./api/xpack.ml.get_jobs.js', opts), - getJobs: lazyLoad('./api/xpack.ml.get_jobs.js', opts), - get_model_snapshots: lazyLoad('./api/xpack.ml.get_model_snapshots.js', opts), - getModelSnapshots: lazyLoad('./api/xpack.ml.get_model_snapshots.js', opts), - get_overall_buckets: lazyLoad('./api/xpack.ml.get_overall_buckets.js', opts), - getOverallBuckets: lazyLoad('./api/xpack.ml.get_overall_buckets.js', opts), - get_records: lazyLoad('./api/xpack.ml.get_records.js', opts), - getRecords: lazyLoad('./api/xpack.ml.get_records.js', opts), - info: lazyLoad('./api/xpack.ml.info.js', opts), - open_job: lazyLoad('./api/xpack.ml.open_job.js', opts), - openJob: lazyLoad('./api/xpack.ml.open_job.js', opts), - post_calendar_events: lazyLoad('./api/xpack.ml.post_calendar_events.js', opts), - postCalendarEvents: lazyLoad('./api/xpack.ml.post_calendar_events.js', opts), - post_data: lazyLoad('./api/xpack.ml.post_data.js', opts), - postData: lazyLoad('./api/xpack.ml.post_data.js', opts), - preview_datafeed: lazyLoad('./api/xpack.ml.preview_datafeed.js', opts), - previewDatafeed: lazyLoad('./api/xpack.ml.preview_datafeed.js', opts), - put_calendar: lazyLoad('./api/xpack.ml.put_calendar.js', opts), - putCalendar: lazyLoad('./api/xpack.ml.put_calendar.js', opts), - put_calendar_job: lazyLoad('./api/xpack.ml.put_calendar_job.js', opts), - putCalendarJob: lazyLoad('./api/xpack.ml.put_calendar_job.js', opts), - put_datafeed: lazyLoad('./api/xpack.ml.put_datafeed.js', opts), - putDatafeed: lazyLoad('./api/xpack.ml.put_datafeed.js', opts), - put_filter: lazyLoad('./api/xpack.ml.put_filter.js', opts), - putFilter: lazyLoad('./api/xpack.ml.put_filter.js', opts), - put_job: lazyLoad('./api/xpack.ml.put_job.js', opts), - putJob: lazyLoad('./api/xpack.ml.put_job.js', opts), - revert_model_snapshot: lazyLoad('./api/xpack.ml.revert_model_snapshot.js', opts), - revertModelSnapshot: lazyLoad('./api/xpack.ml.revert_model_snapshot.js', opts), - start_datafeed: lazyLoad('./api/xpack.ml.start_datafeed.js', opts), - startDatafeed: lazyLoad('./api/xpack.ml.start_datafeed.js', opts), - stop_datafeed: lazyLoad('./api/xpack.ml.stop_datafeed.js', opts), - stopDatafeed: lazyLoad('./api/xpack.ml.stop_datafeed.js', opts), - update_datafeed: lazyLoad('./api/xpack.ml.update_datafeed.js', opts), - updateDatafeed: lazyLoad('./api/xpack.ml.update_datafeed.js', opts), - update_filter: lazyLoad('./api/xpack.ml.update_filter.js', opts), - updateFilter: lazyLoad('./api/xpack.ml.update_filter.js', opts), - update_job: lazyLoad('./api/xpack.ml.update_job.js', opts), - updateJob: lazyLoad('./api/xpack.ml.update_job.js', opts), - update_model_snapshot: lazyLoad('./api/xpack.ml.update_model_snapshot.js', opts), - updateModelSnapshot: lazyLoad('./api/xpack.ml.update_model_snapshot.js', opts), - validate: lazyLoad('./api/xpack.ml.validate.js', opts), - validate_detector: lazyLoad('./api/xpack.ml.validate_detector.js', opts), - validateDetector: lazyLoad('./api/xpack.ml.validate_detector.js', opts) - }, - monitoring: { - bulk: lazyLoad('./api/xpack.monitoring.bulk.js', opts) - }, rollup: { delete_job: lazyLoad('./api/xpack.rollup.delete_job.js', opts), deleteJob: lazyLoad('./api/xpack.rollup.delete_job.js', opts), @@ -352,60 +421,12 @@ function ESAPI (opts) { stop_job: lazyLoad('./api/xpack.rollup.stop_job.js', opts), stopJob: lazyLoad('./api/xpack.rollup.stop_job.js', opts) }, - security: { - authenticate: lazyLoad('./api/xpack.security.authenticate.js', opts), - change_password: lazyLoad('./api/xpack.security.change_password.js', opts), - changePassword: lazyLoad('./api/xpack.security.change_password.js', opts), - clear_cached_realms: lazyLoad('./api/xpack.security.clear_cached_realms.js', opts), - clearCachedRealms: lazyLoad('./api/xpack.security.clear_cached_realms.js', opts), - clear_cached_roles: lazyLoad('./api/xpack.security.clear_cached_roles.js', opts), - clearCachedRoles: lazyLoad('./api/xpack.security.clear_cached_roles.js', opts), - delete_privileges: lazyLoad('./api/xpack.security.delete_privileges.js', opts), - deletePrivileges: lazyLoad('./api/xpack.security.delete_privileges.js', opts), - delete_role: lazyLoad('./api/xpack.security.delete_role.js', opts), - deleteRole: lazyLoad('./api/xpack.security.delete_role.js', opts), - delete_role_mapping: lazyLoad('./api/xpack.security.delete_role_mapping.js', opts), - deleteRoleMapping: lazyLoad('./api/xpack.security.delete_role_mapping.js', opts), - delete_user: lazyLoad('./api/xpack.security.delete_user.js', opts), - deleteUser: lazyLoad('./api/xpack.security.delete_user.js', opts), - disable_user: lazyLoad('./api/xpack.security.disable_user.js', opts), - disableUser: lazyLoad('./api/xpack.security.disable_user.js', opts), - enable_user: lazyLoad('./api/xpack.security.enable_user.js', opts), - enableUser: lazyLoad('./api/xpack.security.enable_user.js', opts), - get_privileges: lazyLoad('./api/xpack.security.get_privileges.js', opts), - getPrivileges: lazyLoad('./api/xpack.security.get_privileges.js', opts), - get_role: lazyLoad('./api/xpack.security.get_role.js', opts), - getRole: lazyLoad('./api/xpack.security.get_role.js', opts), - get_role_mapping: lazyLoad('./api/xpack.security.get_role_mapping.js', opts), - getRoleMapping: lazyLoad('./api/xpack.security.get_role_mapping.js', opts), - get_token: lazyLoad('./api/xpack.security.get_token.js', opts), - getToken: lazyLoad('./api/xpack.security.get_token.js', opts), - get_user: lazyLoad('./api/xpack.security.get_user.js', opts), - getUser: lazyLoad('./api/xpack.security.get_user.js', opts), - get_user_privileges: lazyLoad('./api/xpack.security.get_user_privileges.js', opts), - getUserPrivileges: lazyLoad('./api/xpack.security.get_user_privileges.js', opts), - has_privileges: lazyLoad('./api/xpack.security.has_privileges.js', opts), - hasPrivileges: lazyLoad('./api/xpack.security.has_privileges.js', opts), - invalidate_token: lazyLoad('./api/xpack.security.invalidate_token.js', opts), - invalidateToken: lazyLoad('./api/xpack.security.invalidate_token.js', opts), - put_privileges: lazyLoad('./api/xpack.security.put_privileges.js', opts), - putPrivileges: lazyLoad('./api/xpack.security.put_privileges.js', opts), - put_role: lazyLoad('./api/xpack.security.put_role.js', opts), - putRole: lazyLoad('./api/xpack.security.put_role.js', opts), - put_role_mapping: lazyLoad('./api/xpack.security.put_role_mapping.js', opts), - putRoleMapping: lazyLoad('./api/xpack.security.put_role_mapping.js', opts), - put_user: lazyLoad('./api/xpack.security.put_user.js', opts), - putUser: lazyLoad('./api/xpack.security.put_user.js', opts) - }, sql: { clear_cursor: lazyLoad('./api/xpack.sql.clear_cursor.js', opts), clearCursor: lazyLoad('./api/xpack.sql.clear_cursor.js', opts), query: lazyLoad('./api/xpack.sql.query.js', opts), translate: lazyLoad('./api/xpack.sql.translate.js', opts) }, - ssl: { - certificates: lazyLoad('./api/xpack.ssl.certificates.js', opts) - }, usage: lazyLoad('./api/xpack.usage.js', opts), watcher: { ack_watch: lazyLoad('./api/xpack.watcher.ack_watch.js', opts), @@ -422,7 +443,6 @@ function ESAPI (opts) { getWatch: lazyLoad('./api/xpack.watcher.get_watch.js', opts), put_watch: lazyLoad('./api/xpack.watcher.put_watch.js', opts), putWatch: lazyLoad('./api/xpack.watcher.put_watch.js', opts), - restart: lazyLoad('./api/xpack.watcher.restart.js', opts), start: lazyLoad('./api/xpack.watcher.start.js', opts), stats: lazyLoad('./api/xpack.watcher.stats.js', opts), stop: lazyLoad('./api/xpack.watcher.stop.js', opts) diff --git a/api/requestParams.d.ts b/api/requestParams.d.ts index 8277562fe..637bc48b1 100644 --- a/api/requestParams.d.ts +++ b/api/requestParams.d.ts @@ -15,10 +15,9 @@ export interface Bulk extends Generic { refresh?: 'true' | 'false' | 'wait_for'; routing?: string; timeout?: string; - fields?: string | string[]; _source?: string | string[]; - _source_exclude?: string | string[]; - _source_include?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; pipeline?: string; body: any; } @@ -302,6 +301,8 @@ export interface ClusterState extends Generic { local?: boolean; master_timeout?: string; flat_settings?: boolean; + wait_for_metadata_version?: number; + wait_for_timeout?: string; ignore_unavailable?: boolean; allow_no_indices?: boolean; expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; @@ -317,6 +318,7 @@ export interface Count extends Generic { index?: string | string[]; type?: string | string[]; ignore_unavailable?: boolean; + ignore_throttled?: boolean; allow_no_indices?: boolean; expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; min_score?: number; @@ -350,7 +352,7 @@ export interface Create extends Generic { export interface Delete extends Generic { id: string; index: string; - type: string; + type?: string; wait_for_active_shards?: string; parent?: string; refresh?: 'true' | 'false' | 'wait_for'; @@ -382,8 +384,8 @@ export interface DeleteByQuery extends Generic { size?: number; sort?: string | string[]; _source?: string | string[]; - _source_exclude?: string | string[]; - _source_include?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; terminate_after?: number; stats?: string | string[]; version?: boolean; @@ -412,7 +414,7 @@ export interface DeleteScript extends Generic { export interface Exists extends Generic { id: string; index: string; - type: string; + type?: string; stored_fields?: string | string[]; parent?: string; preference?: string; @@ -420,8 +422,8 @@ export interface Exists extends Generic { refresh?: boolean; routing?: string; _source?: string | string[]; - _source_exclude?: string | string[]; - _source_include?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; version?: number; version_type?: 'internal' | 'external' | 'external_gte' | 'force'; } @@ -436,8 +438,8 @@ export interface ExistsSource extends Generic { refresh?: boolean; routing?: string; _source?: string | string[]; - _source_exclude?: string | string[]; - _source_include?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; version?: number; version_type?: 'internal' | 'external' | 'external_gte' | 'force'; } @@ -445,7 +447,7 @@ export interface ExistsSource extends Generic { export interface Explain extends Generic { id: string; index: string; - type: string; + type?: string; analyze_wildcard?: boolean; analyzer?: string; default_operator?: 'AND' | 'OR'; @@ -457,8 +459,8 @@ export interface Explain extends Generic { q?: string; routing?: string; _source?: string | string[]; - _source_exclude?: string | string[]; - _source_include?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; body?: any; } @@ -468,13 +470,12 @@ export interface FieldCaps extends Generic { ignore_unavailable?: boolean; allow_no_indices?: boolean; expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; - body?: any; } export interface Get extends Generic { id: string; index: string; - type: string; + type?: string; stored_fields?: string | string[]; parent?: string; preference?: string; @@ -482,6 +483,8 @@ export interface Get extends Generic { refresh?: boolean; routing?: string; _source?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; _source_exclude?: string | string[]; _source_include?: string | string[]; version?: number; @@ -503,8 +506,8 @@ export interface GetSource extends Generic { refresh?: boolean; routing?: string; _source?: string | string[]; - _source_exclude?: string | string[]; - _source_include?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; version?: number; version_type?: 'internal' | 'external' | 'external_gte' | 'force'; } @@ -512,7 +515,7 @@ export interface GetSource extends Generic { export interface Index extends Generic { id?: string; index: string; - type: string; + type?: string; wait_for_active_shards?: string; op_type?: 'index' | 'create'; parent?: string; @@ -532,14 +535,12 @@ export interface IndicesAnalyze extends Generic { export interface IndicesClearCache extends Generic { index?: string | string[]; - field_data?: boolean; fielddata?: boolean; fields?: string | string[]; query?: boolean; ignore_unavailable?: boolean; allow_no_indices?: boolean; expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; - request_cache?: boolean; request?: boolean; } @@ -554,10 +555,10 @@ export interface IndicesClose extends Generic { export interface IndicesCreate extends Generic { index: string; + include_type_name?: string; wait_for_active_shards?: string; timeout?: string; master_timeout?: string; - update_all_types?: boolean; body?: any; } @@ -678,6 +679,7 @@ export interface IndicesGetFieldMapping extends Generic { export interface IndicesGetMapping extends Generic { index?: string | string[]; type?: string | string[]; + include_type_name?: string; ignore_unavailable?: boolean; allow_no_indices?: boolean; expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; @@ -731,13 +733,13 @@ export interface IndicesPutAlias extends Generic { export interface IndicesPutMapping extends Generic { index?: string | string[]; - type: string; + type?: string; + include_type_name?: string; timeout?: string; master_timeout?: string; ignore_unavailable?: boolean; allow_no_indices?: boolean; expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; - update_all_types?: boolean; body: any; } @@ -906,8 +908,8 @@ export interface Mget extends Generic { refresh?: boolean; routing?: string; _source?: string | string[]; - _source_exclude?: string | string[]; - _source_include?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; body: any; } @@ -919,6 +921,7 @@ export interface Msearch extends Generic { typed_keys?: boolean; pre_filter_shard_size?: number; max_concurrent_shard_requests?: number; + rest_total_hits_as_int?: boolean; body: any; } @@ -928,6 +931,7 @@ export interface MsearchTemplate extends Generic { search_type?: 'query_then_fetch' | 'query_and_fetch' | 'dfs_query_then_fetch' | 'dfs_query_and_fetch'; typed_keys?: boolean; max_concurrent_searches?: number; + rest_total_hits_as_int?: boolean; body: any; } @@ -1038,6 +1042,7 @@ export interface ScriptsPainlessExecute extends Generic { export interface Scroll extends Generic { scroll_id?: string; scroll?: string; + rest_total_hits_as_int?: boolean; body?: any; } @@ -1053,6 +1058,7 @@ export interface Search extends Generic { docvalue_fields?: string | string[]; from?: number; ignore_unavailable?: boolean; + ignore_throttled?: boolean; allow_no_indices?: boolean; expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; lenient?: boolean; @@ -1064,8 +1070,8 @@ export interface Search extends Generic { size?: number; sort?: string | string[]; _source?: string | string[]; - _source_exclude?: string | string[]; - _source_include?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; terminate_after?: number; stats?: string | string[]; suggest_field?: string; @@ -1082,6 +1088,7 @@ export interface Search extends Generic { batched_reduce_size?: number; max_concurrent_shard_requests?: number; pre_filter_shard_size?: number; + rest_total_hits_as_int?: boolean; body?: any; } @@ -1099,6 +1106,7 @@ export interface SearchTemplate extends Generic { index?: string | string[]; type?: string | string[]; ignore_unavailable?: boolean; + ignore_throttled?: boolean; allow_no_indices?: boolean; expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; preference?: string; @@ -1108,6 +1116,7 @@ export interface SearchTemplate extends Generic { explain?: boolean; profile?: boolean; typed_keys?: boolean; + rest_total_hits_as_int?: boolean; body: any; } @@ -1199,7 +1208,7 @@ export interface TasksList extends Generic { export interface Termvectors extends Generic { index: string; - type: string; + type?: string; id?: string; term_statistics?: boolean; field_statistics?: boolean; @@ -1219,12 +1228,11 @@ export interface Termvectors extends Generic { export interface Update extends Generic { id: string; index: string; - type: string; + type?: string; wait_for_active_shards?: string; - fields?: string | string[]; _source?: string | string[]; - _source_exclude?: string | string[]; - _source_include?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; lang?: string; parent?: string; refresh?: 'true' | 'false' | 'wait_for'; @@ -1259,8 +1267,8 @@ export interface UpdateByQuery extends Generic { size?: number; sort?: string | string[]; _source?: string | string[]; - _source_exclude?: string | string[]; - _source_include?: string | string[]; + _source_excludes?: string | string[]; + _source_includes?: string | string[]; terminate_after?: number; stats?: string | string[]; version?: boolean; @@ -1319,6 +1327,481 @@ export interface CcrUnfollow extends Generic { index: string; } +export interface IlmDeleteLifecycle extends Generic { + policy?: string; +} + +export interface IlmExplainLifecycle extends Generic { + index?: string; + human?: boolean; +} + +export interface IlmGetLifecycle extends Generic { + policy?: string; +} + +export interface IlmGetStatus extends Generic { +} + +export interface IlmMoveToStep extends Generic { + index?: string; + body?: any; +} + +export interface IlmPutLifecycle extends Generic { + policy?: string; + body?: any; +} + +export interface IlmRemovePolicy extends Generic { + index?: string; +} + +export interface IlmRetry extends Generic { + index?: string; +} + +export interface IlmStart extends Generic { +} + +export interface IlmStop extends Generic { +} + +export interface IndicesFreeze extends Generic { + index: string; + timeout?: string; + master_timeout?: string; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + wait_for_active_shards?: string; +} + +export interface IndicesUnfreeze extends Generic { + index: string; + timeout?: string; + master_timeout?: string; + ignore_unavailable?: boolean; + allow_no_indices?: boolean; + expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; + wait_for_active_shards?: string; +} + +export interface MlCloseJob extends Generic { + job_id: string; + allow_no_jobs?: boolean; + force?: boolean; + timeout?: string; +} + +export interface MlDeleteCalendar extends Generic { + calendar_id: string; +} + +export interface MlDeleteCalendarEvent extends Generic { + calendar_id: string; + event_id: string; +} + +export interface MlDeleteCalendarJob extends Generic { + calendar_id: string; + job_id: string; +} + +export interface MlDeleteDatafeed extends Generic { + datafeed_id: string; + force?: boolean; +} + +export interface MlDeleteExpiredData extends Generic { +} + +export interface MlDeleteFilter extends Generic { + filter_id: string; +} + +export interface MlDeleteForecast extends Generic { + job_id: string; + forecast_id?: string; + allow_no_forecasts?: boolean; + timeout?: string; +} + +export interface MlDeleteJob extends Generic { + job_id: string; + force?: boolean; + wait_for_completion?: boolean; +} + +export interface MlDeleteModelSnapshot extends Generic { + job_id: string; + snapshot_id: string; +} + +export interface MlFindFileStructure extends Generic { + lines_to_sample?: number; + timeout?: string; + charset?: string; + format?: 'ndjson' | 'xml' | 'delimited' | 'semi_structured_text'; + has_header_row?: boolean; + column_names?: string | string[]; + delimiter?: string; + quote?: string; + should_trim_fields?: boolean; + grok_pattern?: string; + timestamp_field?: string; + timestamp_format?: string; + explain?: boolean; + body: any; +} + +export interface MlFlushJob extends Generic { + job_id: string; + calc_interim?: boolean; + start?: string; + end?: string; + advance_time?: string; + skip_time?: string; + body?: any; +} + +export interface MlForecast extends Generic { + job_id: string; + duration?: string; + expires_in?: string; +} + +export interface MlGetBuckets extends Generic { + job_id: string; + timestamp?: string; + expand?: boolean; + exclude_interim?: boolean; + from?: number; + size?: number; + start?: string; + end?: string; + anomaly_score?: number; + sort?: string; + desc?: boolean; + body?: any; +} + +export interface MlGetCalendarEvents extends Generic { + calendar_id: string; + job_id?: string; + start?: string; + end?: string; + from?: number; + size?: number; +} + +export interface MlGetCalendars extends Generic { + calendar_id?: string; + from?: number; + size?: number; +} + +export interface MlGetCategories extends Generic { + job_id: string; + category_id?: number; + from?: number; + size?: number; + body?: any; +} + +export interface MlGetDatafeedStats extends Generic { + datafeed_id?: string; + allow_no_datafeeds?: boolean; +} + +export interface MlGetDatafeeds extends Generic { + datafeed_id?: string; + allow_no_datafeeds?: boolean; +} + +export interface MlGetFilters extends Generic { + filter_id?: string; + from?: number; + size?: number; +} + +export interface MlGetInfluencers extends Generic { + job_id: string; + exclude_interim?: boolean; + from?: number; + size?: number; + start?: string; + end?: string; + influencer_score?: number; + sort?: string; + desc?: boolean; + body?: any; +} + +export interface MlGetJobStats extends Generic { + job_id?: string; + allow_no_jobs?: boolean; +} + +export interface MlGetJobs extends Generic { + job_id?: string; + allow_no_jobs?: boolean; +} + +export interface MlGetModelSnapshots extends Generic { + job_id: string; + snapshot_id?: string; + from?: number; + size?: number; + start?: string; + end?: string; + sort?: string; + desc?: boolean; + body?: any; +} + +export interface MlGetOverallBuckets extends Generic { + job_id: string; + top_n?: number; + bucket_span?: string; + overall_score?: number; + exclude_interim?: boolean; + start?: string; + end?: string; + allow_no_jobs?: boolean; + body?: any; +} + +export interface MlGetRecords extends Generic { + job_id: string; + exclude_interim?: boolean; + from?: number; + size?: number; + start?: string; + end?: string; + record_score?: number; + sort?: string; + desc?: boolean; + body?: any; +} + +export interface MlInfo extends Generic { +} + +export interface MlOpenJob extends Generic { + job_id: string; + ignore_downtime?: boolean; + timeout?: string; +} + +export interface MlPostCalendarEvents extends Generic { + calendar_id: string; + body: any; +} + +export interface MlPostData extends Generic { + job_id: string; + reset_start?: string; + reset_end?: string; + body: any; +} + +export interface MlPreviewDatafeed extends Generic { + datafeed_id: string; +} + +export interface MlPutCalendar extends Generic { + calendar_id: string; + body?: any; +} + +export interface MlPutCalendarJob extends Generic { + calendar_id: string; + job_id: string; +} + +export interface MlPutDatafeed extends Generic { + datafeed_id: string; + body: any; +} + +export interface MlPutFilter extends Generic { + filter_id: string; + body: any; +} + +export interface MlPutJob extends Generic { + job_id: string; + body: any; +} + +export interface MlRevertModelSnapshot extends Generic { + job_id: string; + snapshot_id: string; + delete_intervening_results?: boolean; + body?: any; +} + +export interface MlStartDatafeed extends Generic { + datafeed_id: string; + start?: string; + end?: string; + timeout?: string; + body?: any; +} + +export interface MlStopDatafeed extends Generic { + datafeed_id: string; + allow_no_datafeeds?: boolean; + force?: boolean; + timeout?: string; +} + +export interface MlUpdateDatafeed extends Generic { + datafeed_id: string; + body: any; +} + +export interface MlUpdateFilter extends Generic { + filter_id: string; + body: any; +} + +export interface MlUpdateJob extends Generic { + job_id: string; + body: any; +} + +export interface MlUpdateModelSnapshot extends Generic { + job_id: string; + snapshot_id: string; + body: any; +} + +export interface MlValidate extends Generic { + body: any; +} + +export interface MlValidateDetector extends Generic { + body: any; +} + +export interface MonitoringBulk extends Generic { + type?: string; + system_id?: string; + system_api_version?: string; + interval?: string; + body: any; +} + +export interface SecurityAuthenticate extends Generic { +} + +export interface SecurityChangePassword extends Generic { + username?: string; + refresh?: 'true' | 'false' | 'wait_for'; + body: any; +} + +export interface SecurityClearCachedRealms extends Generic { + realms: string | string[]; + usernames?: string | string[]; +} + +export interface SecurityClearCachedRoles extends Generic { + name: string | string[]; +} + +export interface SecurityDeletePrivileges extends Generic { + application: string; + name: string; + refresh?: 'true' | 'false' | 'wait_for'; +} + +export interface SecurityDeleteRole extends Generic { + name: string; + refresh?: 'true' | 'false' | 'wait_for'; +} + +export interface SecurityDeleteRoleMapping extends Generic { + name: string; + refresh?: 'true' | 'false' | 'wait_for'; +} + +export interface SecurityDeleteUser extends Generic { + username: string; + refresh?: 'true' | 'false' | 'wait_for'; +} + +export interface SecurityDisableUser extends Generic { + username?: string; + refresh?: 'true' | 'false' | 'wait_for'; +} + +export interface SecurityEnableUser extends Generic { + username?: string; + refresh?: 'true' | 'false' | 'wait_for'; +} + +export interface SecurityGetPrivileges extends Generic { + application?: string; + name?: string; +} + +export interface SecurityGetRole extends Generic { + name?: string; +} + +export interface SecurityGetRoleMapping extends Generic { + name?: string; +} + +export interface SecurityGetToken extends Generic { + body: any; +} + +export interface SecurityGetUser extends Generic { + username?: string | string[]; +} + +export interface SecurityGetUserPrivileges extends Generic { +} + +export interface SecurityHasPrivileges extends Generic { + user?: string; + body: any; +} + +export interface SecurityInvalidateToken extends Generic { + body: any; +} + +export interface SecurityPutPrivileges extends Generic { + refresh?: 'true' | 'false' | 'wait_for'; + body: any; +} + +export interface SecurityPutRole extends Generic { + name: string; + refresh?: 'true' | 'false' | 'wait_for'; + body: any; +} + +export interface SecurityPutRoleMapping extends Generic { + name: string; + refresh?: 'true' | 'false' | 'wait_for'; + body: any; +} + +export interface SecurityPutUser extends Generic { + username: string; + refresh?: 'true' | 'false' | 'wait_for'; + body: any; +} + +export interface SslCertificates extends Generic { +} + export interface XpackGraphExplore extends Generic { index?: string | string[]; type?: string | string[]; @@ -1374,313 +1857,6 @@ export interface XpackMigrationUpgrade extends Generic { wait_for_completion?: boolean; } -export interface XpackMlCloseJob extends Generic { - job_id: string; - allow_no_jobs?: boolean; - force?: boolean; - timeout?: string; -} - -export interface XpackMlDeleteCalendar extends Generic { - calendar_id: string; -} - -export interface XpackMlDeleteCalendarEvent extends Generic { - calendar_id: string; - event_id: string; -} - -export interface XpackMlDeleteCalendarJob extends Generic { - calendar_id: string; - job_id: string; -} - -export interface XpackMlDeleteDatafeed extends Generic { - datafeed_id: string; - force?: boolean; -} - -export interface XpackMlDeleteExpiredData extends Generic { -} - -export interface XpackMlDeleteFilter extends Generic { - filter_id: string; -} - -export interface XpackMlDeleteForecast extends Generic { - job_id: string; - forecast_id?: string; - allow_no_forecasts?: boolean; - timeout?: string; -} - -export interface XpackMlDeleteJob extends Generic { - job_id: string; - force?: boolean; - wait_for_completion?: boolean; -} - -export interface XpackMlDeleteModelSnapshot extends Generic { - job_id: string; - snapshot_id: string; -} - -export interface XpackMlFindFileStructure extends Generic { - lines_to_sample?: number; - timeout?: string; - charset?: string; - format?: 'ndjson' | 'xml' | 'delimited' | 'semi_structured_text'; - has_header_row?: boolean; - column_names?: string | string[]; - delimiter?: string; - quote?: string; - should_trim_fields?: boolean; - grok_pattern?: string; - timestamp_field?: string; - timestamp_format?: string; - explain?: boolean; - body: any; -} - -export interface XpackMlFlushJob extends Generic { - job_id: string; - calc_interim?: boolean; - start?: string; - end?: string; - advance_time?: string; - skip_time?: string; - body?: any; -} - -export interface XpackMlForecast extends Generic { - job_id: string; - duration?: string; - expires_in?: string; -} - -export interface XpackMlGetBuckets extends Generic { - job_id: string; - timestamp?: string; - expand?: boolean; - exclude_interim?: boolean; - from?: number; - size?: number; - start?: string; - end?: string; - anomaly_score?: number; - sort?: string; - desc?: boolean; - body?: any; -} - -export interface XpackMlGetCalendarEvents extends Generic { - calendar_id: string; - job_id?: string; - start?: string; - end?: string; - from?: number; - size?: number; -} - -export interface XpackMlGetCalendars extends Generic { - calendar_id?: string; - from?: number; - size?: number; -} - -export interface XpackMlGetCategories extends Generic { - job_id: string; - category_id?: number; - from?: number; - size?: number; - body?: any; -} - -export interface XpackMlGetDatafeedStats extends Generic { - datafeed_id?: string; - allow_no_datafeeds?: boolean; -} - -export interface XpackMlGetDatafeeds extends Generic { - datafeed_id?: string; - allow_no_datafeeds?: boolean; -} - -export interface XpackMlGetFilters extends Generic { - filter_id?: string; - from?: number; - size?: number; -} - -export interface XpackMlGetInfluencers extends Generic { - job_id: string; - exclude_interim?: boolean; - from?: number; - size?: number; - start?: string; - end?: string; - influencer_score?: number; - sort?: string; - desc?: boolean; - body?: any; -} - -export interface XpackMlGetJobStats extends Generic { - job_id?: string; - allow_no_jobs?: boolean; -} - -export interface XpackMlGetJobs extends Generic { - job_id?: string; - allow_no_jobs?: boolean; -} - -export interface XpackMlGetModelSnapshots extends Generic { - job_id: string; - snapshot_id?: string; - from?: number; - size?: number; - start?: string; - end?: string; - sort?: string; - desc?: boolean; - body?: any; -} - -export interface XpackMlGetOverallBuckets extends Generic { - job_id: string; - top_n?: number; - bucket_span?: string; - overall_score?: number; - exclude_interim?: boolean; - start?: string; - end?: string; - allow_no_jobs?: boolean; - body?: any; -} - -export interface XpackMlGetRecords extends Generic { - job_id: string; - exclude_interim?: boolean; - from?: number; - size?: number; - start?: string; - end?: string; - record_score?: number; - sort?: string; - desc?: boolean; - body?: any; -} - -export interface XpackMlInfo extends Generic { -} - -export interface XpackMlOpenJob extends Generic { - job_id: string; - ignore_downtime?: boolean; - timeout?: string; -} - -export interface XpackMlPostCalendarEvents extends Generic { - calendar_id: string; - body: any; -} - -export interface XpackMlPostData extends Generic { - job_id: string; - reset_start?: string; - reset_end?: string; - body: any; -} - -export interface XpackMlPreviewDatafeed extends Generic { - datafeed_id: string; -} - -export interface XpackMlPutCalendar extends Generic { - calendar_id: string; - body?: any; -} - -export interface XpackMlPutCalendarJob extends Generic { - calendar_id: string; - job_id: string; -} - -export interface XpackMlPutDatafeed extends Generic { - datafeed_id: string; - body: any; -} - -export interface XpackMlPutFilter extends Generic { - filter_id: string; - body: any; -} - -export interface XpackMlPutJob extends Generic { - job_id: string; - body: any; -} - -export interface XpackMlRevertModelSnapshot extends Generic { - job_id: string; - snapshot_id: string; - delete_intervening_results?: boolean; - body?: any; -} - -export interface XpackMlStartDatafeed extends Generic { - datafeed_id: string; - start?: string; - end?: string; - timeout?: string; - body?: any; -} - -export interface XpackMlStopDatafeed extends Generic { - datafeed_id: string; - allow_no_datafeeds?: boolean; - force?: boolean; - timeout?: string; -} - -export interface XpackMlUpdateDatafeed extends Generic { - datafeed_id: string; - body: any; -} - -export interface XpackMlUpdateFilter extends Generic { - filter_id: string; - body: any; -} - -export interface XpackMlUpdateJob extends Generic { - job_id: string; - body: any; -} - -export interface XpackMlUpdateModelSnapshot extends Generic { - job_id: string; - snapshot_id: string; - body: any; -} - -export interface XpackMlValidate extends Generic { - body: any; -} - -export interface XpackMlValidateDetector extends Generic { - body: any; -} - -export interface XpackMonitoringBulk extends Generic { - type?: string; - system_id?: string; - system_api_version?: string; - interval?: string; - body: any; -} - export interface XpackRollupDeleteJob extends Generic { id: string; } @@ -1705,6 +1881,8 @@ export interface XpackRollupPutJob extends Generic { export interface XpackRollupRollupSearch extends Generic { index: string; type?: string; + typed_keys?: boolean; + rest_total_hits_as_int?: boolean; body: any; } @@ -1714,111 +1892,8 @@ export interface XpackRollupStartJob extends Generic { export interface XpackRollupStopJob extends Generic { id: string; -} - -export interface XpackSecurityAuthenticate extends Generic { -} - -export interface XpackSecurityChangePassword extends Generic { - username?: string; - refresh?: 'true' | 'false' | 'wait_for'; - body: any; -} - -export interface XpackSecurityClearCachedRealms extends Generic { - realms: string | string[]; - usernames?: string | string[]; -} - -export interface XpackSecurityClearCachedRoles extends Generic { - name: string | string[]; -} - -export interface XpackSecurityDeletePrivileges extends Generic { - application: string; - name: string; - refresh?: 'true' | 'false' | 'wait_for'; -} - -export interface XpackSecurityDeleteRole extends Generic { - name: string; - refresh?: 'true' | 'false' | 'wait_for'; -} - -export interface XpackSecurityDeleteRoleMapping extends Generic { - name: string; - refresh?: 'true' | 'false' | 'wait_for'; -} - -export interface XpackSecurityDeleteUser extends Generic { - username: string; - refresh?: 'true' | 'false' | 'wait_for'; -} - -export interface XpackSecurityDisableUser extends Generic { - username?: string; - refresh?: 'true' | 'false' | 'wait_for'; -} - -export interface XpackSecurityEnableUser extends Generic { - username?: string; - refresh?: 'true' | 'false' | 'wait_for'; -} - -export interface XpackSecurityGetPrivileges extends Generic { - application?: string; - name?: string; -} - -export interface XpackSecurityGetRole extends Generic { - name?: string; -} - -export interface XpackSecurityGetRoleMapping extends Generic { - name?: string; -} - -export interface XpackSecurityGetToken extends Generic { - body: any; -} - -export interface XpackSecurityGetUser extends Generic { - username?: string | string[]; -} - -export interface XpackSecurityGetUserPrivileges extends Generic { -} - -export interface XpackSecurityHasPrivileges extends Generic { - user?: string; - body: any; -} - -export interface XpackSecurityInvalidateToken extends Generic { - body: any; -} - -export interface XpackSecurityPutPrivileges extends Generic { - refresh?: 'true' | 'false' | 'wait_for'; - body: any; -} - -export interface XpackSecurityPutRole extends Generic { - name: string; - refresh?: 'true' | 'false' | 'wait_for'; - body: any; -} - -export interface XpackSecurityPutRoleMapping extends Generic { - name: string; - refresh?: 'true' | 'false' | 'wait_for'; - body: any; -} - -export interface XpackSecurityPutUser extends Generic { - username: string; - refresh?: 'true' | 'false' | 'wait_for'; - body: any; + wait_for_completion?: boolean; + timeout?: string; } export interface XpackSqlClearCursor extends Generic { @@ -1834,9 +1909,6 @@ export interface XpackSqlTranslate extends Generic { body: any; } -export interface XpackSslCertificates extends Generic { -} - export interface XpackUsage extends Generic { master_timeout?: string; } @@ -1844,22 +1916,18 @@ export interface XpackUsage extends Generic { export interface XpackWatcherAckWatch extends Generic { watch_id: string; action_id?: string | string[]; - master_timeout?: string; } export interface XpackWatcherActivateWatch extends Generic { watch_id: string; - master_timeout?: string; } export interface XpackWatcherDeactivateWatch extends Generic { watch_id: string; - master_timeout?: string; } export interface XpackWatcherDeleteWatch extends Generic { id: string; - master_timeout?: string; } export interface XpackWatcherExecuteWatch extends Generic { @@ -1874,20 +1942,16 @@ export interface XpackWatcherGetWatch extends Generic { export interface XpackWatcherPutWatch extends Generic { id: string; - master_timeout?: string; active?: boolean; version?: number; body?: any; } -export interface XpackWatcherRestart extends Generic { -} - export interface XpackWatcherStart extends Generic { } export interface XpackWatcherStats extends Generic { - metric?: '_all' | 'queued_watches' | 'pending_watches'; + metric?: '_all' | 'queued_watches' | 'current_watches' | 'pending_watches'; emit_stacktraces?: boolean; } diff --git a/index.d.ts b/index.d.ts index 76c140c35..55c878df9 100644 --- a/index.d.ts +++ b/index.d.ts @@ -128,6 +128,25 @@ declare class Client extends EventEmitter { getScript: ApiMethod get_source: ApiMethod getSource: ApiMethod + ilm: { + delete_lifecycle: ApiMethod + deleteLifecycle: ApiMethod + explain_lifecycle: ApiMethod + explainLifecycle: ApiMethod + get_lifecycle: ApiMethod + getLifecycle: ApiMethod + get_status: ApiMethod + getStatus: ApiMethod + move_to_step: ApiMethod + moveToStep: ApiMethod + put_lifecycle: ApiMethod + putLifecycle: ApiMethod + remove_policy: ApiMethod + removePolicy: ApiMethod + retry: ApiMethod + start: ApiMethod + stop: ApiMethod + } index: ApiMethod indices: { analyze: ApiMethod @@ -151,6 +170,7 @@ declare class Client extends EventEmitter { flush_synced: ApiMethod flushSynced: ApiMethod forcemerge: ApiMethod + freeze: ApiMethod get: ApiMethod get_alias: ApiMethod getAlias: ApiMethod @@ -182,6 +202,7 @@ declare class Client extends EventEmitter { shrink: ApiMethod split: ApiMethod stats: ApiMethod + unfreeze: ApiMethod update_aliases: ApiMethod updateAliases: ApiMethod upgrade: ApiMethod @@ -201,6 +222,98 @@ declare class Client extends EventEmitter { simulate: ApiMethod } mget: ApiMethod + ml: { + close_job: ApiMethod + closeJob: ApiMethod + delete_calendar: ApiMethod + deleteCalendar: ApiMethod + delete_calendar_event: ApiMethod + deleteCalendarEvent: ApiMethod + delete_calendar_job: ApiMethod + deleteCalendarJob: ApiMethod + delete_datafeed: ApiMethod + deleteDatafeed: ApiMethod + delete_expired_data: ApiMethod + deleteExpiredData: ApiMethod + delete_filter: ApiMethod + deleteFilter: ApiMethod + delete_forecast: ApiMethod + deleteForecast: ApiMethod + delete_job: ApiMethod + deleteJob: ApiMethod + delete_model_snapshot: ApiMethod + deleteModelSnapshot: ApiMethod + find_file_structure: ApiMethod + findFileStructure: ApiMethod + flush_job: ApiMethod + flushJob: ApiMethod + forecast: ApiMethod + get_buckets: ApiMethod + getBuckets: ApiMethod + get_calendar_events: ApiMethod + getCalendarEvents: ApiMethod + get_calendars: ApiMethod + getCalendars: ApiMethod + get_categories: ApiMethod + getCategories: ApiMethod + get_datafeed_stats: ApiMethod + getDatafeedStats: ApiMethod + get_datafeeds: ApiMethod + getDatafeeds: ApiMethod + get_filters: ApiMethod + getFilters: ApiMethod + get_influencers: ApiMethod + getInfluencers: ApiMethod + get_job_stats: ApiMethod + getJobStats: ApiMethod + get_jobs: ApiMethod + getJobs: ApiMethod + get_model_snapshots: ApiMethod + getModelSnapshots: ApiMethod + get_overall_buckets: ApiMethod + getOverallBuckets: ApiMethod + get_records: ApiMethod + getRecords: ApiMethod + info: ApiMethod + open_job: ApiMethod + openJob: ApiMethod + post_calendar_events: ApiMethod + postCalendarEvents: ApiMethod + post_data: ApiMethod + postData: ApiMethod + preview_datafeed: ApiMethod + previewDatafeed: ApiMethod + put_calendar: ApiMethod + putCalendar: ApiMethod + put_calendar_job: ApiMethod + putCalendarJob: ApiMethod + put_datafeed: ApiMethod + putDatafeed: ApiMethod + put_filter: ApiMethod + putFilter: ApiMethod + put_job: ApiMethod + putJob: ApiMethod + revert_model_snapshot: ApiMethod + revertModelSnapshot: ApiMethod + start_datafeed: ApiMethod + startDatafeed: ApiMethod + stop_datafeed: ApiMethod + stopDatafeed: ApiMethod + update_datafeed: ApiMethod + updateDatafeed: ApiMethod + update_filter: ApiMethod + updateFilter: ApiMethod + update_job: ApiMethod + updateJob: ApiMethod + update_model_snapshot: ApiMethod + updateModelSnapshot: ApiMethod + validate: ApiMethod + validate_detector: ApiMethod + validateDetector: ApiMethod + } + monitoring: { + bulk: ApiMethod + } msearch: ApiMethod msearch_template: ApiMethod msearchTemplate: ApiMethod @@ -232,6 +345,51 @@ declare class Client extends EventEmitter { searchShards: ApiMethod search_template: ApiMethod searchTemplate: ApiMethod + security: { + authenticate: ApiMethod + change_password: ApiMethod + changePassword: ApiMethod + clear_cached_realms: ApiMethod + clearCachedRealms: ApiMethod + clear_cached_roles: ApiMethod + clearCachedRoles: ApiMethod + delete_privileges: ApiMethod + deletePrivileges: ApiMethod + delete_role: ApiMethod + deleteRole: ApiMethod + delete_role_mapping: ApiMethod + deleteRoleMapping: ApiMethod + delete_user: ApiMethod + deleteUser: ApiMethod + disable_user: ApiMethod + disableUser: ApiMethod + enable_user: ApiMethod + enableUser: ApiMethod + get_privileges: ApiMethod + getPrivileges: ApiMethod + get_role: ApiMethod + getRole: ApiMethod + get_role_mapping: ApiMethod + getRoleMapping: ApiMethod + get_token: ApiMethod + getToken: ApiMethod + get_user: ApiMethod + getUser: ApiMethod + get_user_privileges: ApiMethod + getUserPrivileges: ApiMethod + has_privileges: ApiMethod + hasPrivileges: ApiMethod + invalidate_token: ApiMethod + invalidateToken: ApiMethod + put_privileges: ApiMethod + putPrivileges: ApiMethod + put_role: ApiMethod + putRole: ApiMethod + put_role_mapping: ApiMethod + putRoleMapping: ApiMethod + put_user: ApiMethod + putUser: ApiMethod + } snapshot: { create: ApiMethod create_repository: ApiMethod @@ -247,6 +405,9 @@ declare class Client extends EventEmitter { verify_repository: ApiMethod verifyRepository: ApiMethod } + ssl: { + certificates: ApiMethod + } tasks: { cancel: ApiMethod get: ApiMethod @@ -282,98 +443,6 @@ declare class Client extends EventEmitter { getAssistance: ApiMethod upgrade: ApiMethod } - ml: { - close_job: ApiMethod - closeJob: ApiMethod - delete_calendar: ApiMethod - deleteCalendar: ApiMethod - delete_calendar_event: ApiMethod - deleteCalendarEvent: ApiMethod - delete_calendar_job: ApiMethod - deleteCalendarJob: ApiMethod - delete_datafeed: ApiMethod - deleteDatafeed: ApiMethod - delete_expired_data: ApiMethod - deleteExpiredData: ApiMethod - delete_filter: ApiMethod - deleteFilter: ApiMethod - delete_forecast: ApiMethod - deleteForecast: ApiMethod - delete_job: ApiMethod - deleteJob: ApiMethod - delete_model_snapshot: ApiMethod - deleteModelSnapshot: ApiMethod - find_file_structure: ApiMethod - findFileStructure: ApiMethod - flush_job: ApiMethod - flushJob: ApiMethod - forecast: ApiMethod - get_buckets: ApiMethod - getBuckets: ApiMethod - get_calendar_events: ApiMethod - getCalendarEvents: ApiMethod - get_calendars: ApiMethod - getCalendars: ApiMethod - get_categories: ApiMethod - getCategories: ApiMethod - get_datafeed_stats: ApiMethod - getDatafeedStats: ApiMethod - get_datafeeds: ApiMethod - getDatafeeds: ApiMethod - get_filters: ApiMethod - getFilters: ApiMethod - get_influencers: ApiMethod - getInfluencers: ApiMethod - get_job_stats: ApiMethod - getJobStats: ApiMethod - get_jobs: ApiMethod - getJobs: ApiMethod - get_model_snapshots: ApiMethod - getModelSnapshots: ApiMethod - get_overall_buckets: ApiMethod - getOverallBuckets: ApiMethod - get_records: ApiMethod - getRecords: ApiMethod - info: ApiMethod - open_job: ApiMethod - openJob: ApiMethod - post_calendar_events: ApiMethod - postCalendarEvents: ApiMethod - post_data: ApiMethod - postData: ApiMethod - preview_datafeed: ApiMethod - previewDatafeed: ApiMethod - put_calendar: ApiMethod - putCalendar: ApiMethod - put_calendar_job: ApiMethod - putCalendarJob: ApiMethod - put_datafeed: ApiMethod - putDatafeed: ApiMethod - put_filter: ApiMethod - putFilter: ApiMethod - put_job: ApiMethod - putJob: ApiMethod - revert_model_snapshot: ApiMethod - revertModelSnapshot: ApiMethod - start_datafeed: ApiMethod - startDatafeed: ApiMethod - stop_datafeed: ApiMethod - stopDatafeed: ApiMethod - update_datafeed: ApiMethod - updateDatafeed: ApiMethod - update_filter: ApiMethod - updateFilter: ApiMethod - update_job: ApiMethod - updateJob: ApiMethod - update_model_snapshot: ApiMethod - updateModelSnapshot: ApiMethod - validate: ApiMethod - validate_detector: ApiMethod - validateDetector: ApiMethod - } - monitoring: { - bulk: ApiMethod - } rollup: { delete_job: ApiMethod deleteJob: ApiMethod @@ -392,60 +461,12 @@ declare class Client extends EventEmitter { stop_job: ApiMethod stopJob: ApiMethod } - security: { - authenticate: ApiMethod - change_password: ApiMethod - changePassword: ApiMethod - clear_cached_realms: ApiMethod - clearCachedRealms: ApiMethod - clear_cached_roles: ApiMethod - clearCachedRoles: ApiMethod - delete_privileges: ApiMethod - deletePrivileges: ApiMethod - delete_role: ApiMethod - deleteRole: ApiMethod - delete_role_mapping: ApiMethod - deleteRoleMapping: ApiMethod - delete_user: ApiMethod - deleteUser: ApiMethod - disable_user: ApiMethod - disableUser: ApiMethod - enable_user: ApiMethod - enableUser: ApiMethod - get_privileges: ApiMethod - getPrivileges: ApiMethod - get_role: ApiMethod - getRole: ApiMethod - get_role_mapping: ApiMethod - getRoleMapping: ApiMethod - get_token: ApiMethod - getToken: ApiMethod - get_user: ApiMethod - getUser: ApiMethod - get_user_privileges: ApiMethod - getUserPrivileges: ApiMethod - has_privileges: ApiMethod - hasPrivileges: ApiMethod - invalidate_token: ApiMethod - invalidateToken: ApiMethod - put_privileges: ApiMethod - putPrivileges: ApiMethod - put_role: ApiMethod - putRole: ApiMethod - put_role_mapping: ApiMethod - putRoleMapping: ApiMethod - put_user: ApiMethod - putUser: ApiMethod - } sql: { clear_cursor: ApiMethod clearCursor: ApiMethod query: ApiMethod translate: ApiMethod } - ssl: { - certificates: ApiMethod - } usage: ApiMethod watcher: { ack_watch: ApiMethod @@ -462,7 +483,6 @@ declare class Client extends EventEmitter { getWatch: ApiMethod put_watch: ApiMethod putWatch: ApiMethod - restart: ApiMethod start: ApiMethod stats: ApiMethod stop: ApiMethod diff --git a/scripts/es-docker.sh b/scripts/es-docker.sh index 74082aa06..c77bd3c54 100755 --- a/scripts/es-docker.sh +++ b/scripts/es-docker.sh @@ -5,8 +5,10 @@ exec docker run \ -e "node.attr.testattr=test" \ -e "path.repo=/tmp" \ -e "repositories.url.allowed_urls=http://snapshot.*" \ + -e "discovery.type=single-node" \ -p 9200:9200 \ - docker.elastic.co/elasticsearch/elasticsearch:6.5.0 + docker.elastic.co/elasticsearch/elasticsearch:7.0.0-alpha2 + # docker.elastic.co/elasticsearch/elasticsearch:6.5.4 # -e "xpack.security.enabled=true" \ # -e "ELASTIC_PASSWORD=passw0rd" \ diff --git a/scripts/utils/generate.js b/scripts/utils/generate.js index c9be7dce2..fade273a4 100644 --- a/scripts/utils/generate.js +++ b/scripts/utils/generate.js @@ -7,8 +7,11 @@ const allowedMethods = { } // list of apis that does not need any kind of validation -// because of how the url is built +// because of how the url is built or the `type` handling in ES7 const noPathValidation = [ + 'exists', + 'explain', + 'get', 'indices.get_alias', 'indices.exists_alias', 'indices.get_field_mapping', @@ -19,7 +22,9 @@ const noPathValidation = [ 'nodes.info', 'nodes.stats', 'nodes.usage', - 'tasks.cancel' + 'tasks.cancel', + 'termvectors', + 'update' ] // apis that uses bulkBody property @@ -36,7 +41,7 @@ function generate (spec, common) { .replace(/_([a-z])/g, k => k[1].toUpperCase()) const methods = spec[api].methods - const { path, paths, parts, params } = spec[api].url + const { paths, parts, params } = spec[api].url const acceptedQuerystring = [] const required = [] @@ -131,11 +136,14 @@ function generate (spec, common) { ignore = [ignore] } + + var path = '' + ${buildPath(api)} + // build request object - const parts = ${getUrlParts()} const request = { method, - ${buildPath(api)} + path, ${genBody(api, methods, spec[api].body)} querystring } @@ -241,91 +249,76 @@ function generate (spec, common) { } function buildPath () { - // if the default path is static, we should add a dynamic check - // to figure out which path to use, see cluster.stats - // otherwise we can skip that check - const p1 = paths - .reduce((a, b) => a.split('/').length > b.split('/').length ? a : b) - .split('/') - .filter(chunk => !chunk.startsWith('{')) - .join('/') - - const p2 = path - .split('/') - .filter(chunk => !chunk.startsWith('{')) - .join('/') - - if (p1 === p2 || !needsPathValidation(api)) { - return `path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),`.trim() + const toCamelCase = str => { + return str[0] === '_' + ? '_' + str.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase()) + : str.replace(/_([a-z])/g, k => k[1].toUpperCase()) } - const dynamicParts = checkDynamicParts() - if (dynamicParts.length) { - return ` - path: ${dynamicParts} - ? '/' + parts.filter(Boolean).map(encodeURIComponent).join('/') - : '${path}', - `.trim() - } else { - return `path: '/' + parts.filter(Boolean).map(encodeURIComponent).join('/'),`.trim() + const genAccessKey = str => { + const camelStr = toCamelCase(str) + return camelStr === str + ? `params['${str}']` + : `params['${str}'] || params['${camelStr}']` } - } - function checkDynamicParts () { - const chunks = paths - .reduce((a, b) => a.split('/').length > b.split('/').length ? a : b) - .split('/') - .filter(Boolean) + const genCheck = path => { + return path + .split('/') + .filter(Boolean) + .map(p => p.startsWith('{') ? `(${genAccessKey(p.slice(1, -1))}) != null` : false) + .filter(Boolean) + .join(' && ') + } - var str = '' - chunks.forEach((chunk, index) => { - if (chunk.startsWith('{') && chunk.endsWith('}')) { - chunk = chunk.slice(1, -1) - // url parts can be declared in camelCase fashion - var camelCased = chunk[0] === '_' - ? '_' + chunk.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase()) - : chunk.replace(/_([a-z])/g, k => k[1].toUpperCase()) + const genPath = path => { + path = path + .split('/') + .filter(Boolean) + .map(p => p.startsWith('{') ? `encodeURIComponent(${genAccessKey(p.slice(1, -1))})` : `'${p}'`) + .join(' + \'/\' + ') + return path.length > 0 ? ('\'/\' + ' + path) : '\'/\'' + } - if (chunk === camelCased) { - str += `params['${chunk}'] != null && ` - } else { - str += `(params['${chunk}'] || params['${camelCased}']) != null && ` + var code = '' + var hasStaticPath = false + var singlePathComponent = false + paths + .filter(path => { + if (path.indexOf('{') > -1) return true + if (hasStaticPath === false) { + hasStaticPath = true + return true } - } - }) - - // removes last ' && ' - return str.slice(0, -4) - } - - function getUrlParts () { - const chunks = paths - .reduce((a, b) => a.split('/').length > b.split('/').length ? a : b) - .split('/') - .filter(Boolean) - var str = '[' - chunks.forEach((chunk, index) => { - if (chunk.startsWith('{') && chunk.endsWith('}')) { - chunk = chunk.slice(1, -1) - // url parts can be declared in camelCase fashion - var camelCased = chunk[0] === '_' - ? '_' + chunk.slice(1).replace(/_([a-z])/g, k => k[1].toUpperCase()) - : chunk.replace(/_([a-z])/g, k => k[1].toUpperCase()) - - if (chunk === camelCased) { - str += `params['${chunk}']` + return false + }) + .sort((a, b) => (b.split('{').length + b.split('/').length) - (a.split('{').length + a.split('/').length)) + .forEach((path, index, arr) => { + if (arr.length === 1) { + singlePathComponent = true + code += ` + path = ${genPath(path)} + ` + } else if (index === 0) { + code += ` + if (${genCheck(path)}) { + path = ${genPath(path)} + ` + } else if (index === arr.length - 1) { + code += ` + } else { + path = ${genPath(path)} + ` } else { - str += `params['${chunk}'] || params['${camelCased}']` + code += ` + } else if (${genCheck(path)}) { + path = ${genPath(path)} + ` } - } else { - str += `'${chunk}'` - } - if (index !== chunks.length - 1) { - str += ', ' - } - }) - str += ']' - return str + }) + + code += singlePathComponent ? '' : '}' + return code } } diff --git a/test/integration/index.js b/test/integration/index.js index 67f5a1473..e3625a8f6 100644 --- a/test/integration/index.js +++ b/test/integration/index.js @@ -15,6 +15,14 @@ const esRepo = 'https://github.com/elastic/elasticsearch.git' const esFolder = join(__dirname, '..', '..', 'elasticsearch') const yamlFolder = join(esFolder, 'rest-api-spec', 'src', 'main', 'resources', 'rest-api-spec', 'test') // const xPackYamlFolder = join(esFolder, 'x-pack', 'plugin', 'src', 'test', 'resources', 'rest-api-spec', 'test') +const customSkips = [ + // skipping because we are booting ES with `discovery.type=single-node` + // and this test will fail because of this configuration + 'nodes.stats/30_discovery.yml', + // the expected error is returning a 503, + // which triggers a retry and the node to be marked as dead + 'search.aggregation/240_max_buckets.yml' +] function Runner (opts) { if (!(this instanceof Runner)) { @@ -35,11 +43,14 @@ Runner.prototype.start = function () { const parse = this.parse.bind(this) const client = this.client - // client.on('response', (request, response) => { - // console.log('\n\n') - // console.log('REQUEST', request) - // console.log('\n') - // console.log('RESPONSE', response) + // client.on('response', (err, meta) => { + // console.log('Request', meta.request) + // if (err) { + // console.log('Error', err) + // } else { + // console.log('Response', JSON.stringify(meta.response, null, 2)) + // } + // console.log() // }) // Get the build hash of Elasticsearch @@ -72,6 +83,9 @@ Runner.prototype.start = function () { files.forEach(runTestFile.bind(this)) function runTestFile (file) { + for (var i = 0; i < customSkips.length; i++) { + if (file.endsWith(customSkips[i])) return + } // create a subtest for the specific folder tap.test(file.slice(file.indexOf(`${sep}elasticsearch${sep}`)), { jobs: 1 }, tap1 => { // read the yaml file @@ -237,7 +251,7 @@ if (require.main === module) { default: { // node: 'http://elastic:passw0rd@localhost:9200', node: process.env.TEST_ES_SERVER || 'http://localhost:9200', - version: '6.5', + version: '7.0', bailout: false } }) diff --git a/test/unit/connection.test.js b/test/unit/connection.test.js index b2e8d92d6..8eb248c9b 100644 --- a/test/unit/connection.test.js +++ b/test/unit/connection.test.js @@ -582,7 +582,7 @@ test('Should disallow two-byte characters in URL path', t => { url: new URL('http://localhost:9200') }) connection.request({ - path: '/thisisinvalid' + encodeURIComponent('\uffe2'), + path: '/thisisinvalid\uffe2', method: 'GET' }, (err, res) => { t.strictEqual(