'use strict' const assert = require('assert') function ESAPI (opts) { assert(opts.makeRequest, 'Missing makeRequest function') assert(opts.ConfigurationError, 'Missing ConfigurationError class') assert(opts.result, 'Missing default result object') const apis = { bulk: lazyLoad('./api/bulk.js', opts), cat: { aliases: lazyLoad('./api/cat.aliases.js', opts), allocation: lazyLoad('./api/cat.allocation.js', opts), count: lazyLoad('./api/cat.count.js', opts), fielddata: lazyLoad('./api/cat.fielddata.js', opts), health: lazyLoad('./api/cat.health.js', opts), help: lazyLoad('./api/cat.help.js', opts), indices: lazyLoad('./api/cat.indices.js', opts), master: lazyLoad('./api/cat.master.js', opts), nodeattrs: lazyLoad('./api/cat.nodeattrs.js', opts), nodes: lazyLoad('./api/cat.nodes.js', opts), pending_tasks: lazyLoad('./api/cat.pending_tasks.js', opts), pendingTasks: lazyLoad('./api/cat.pending_tasks.js', opts), plugins: lazyLoad('./api/cat.plugins.js', opts), recovery: lazyLoad('./api/cat.recovery.js', opts), repositories: lazyLoad('./api/cat.repositories.js', opts), segments: lazyLoad('./api/cat.segments.js', opts), shards: lazyLoad('./api/cat.shards.js', opts), snapshots: lazyLoad('./api/cat.snapshots.js', opts), tasks: lazyLoad('./api/cat.tasks.js', opts), templates: lazyLoad('./api/cat.templates.js', opts), thread_pool: lazyLoad('./api/cat.thread_pool.js', opts), threadPool: lazyLoad('./api/cat.thread_pool.js', opts) }, ccr: { delete_auto_follow_pattern: lazyLoad('./api/ccr.delete_auto_follow_pattern.js', opts), deleteAutoFollowPattern: lazyLoad('./api/ccr.delete_auto_follow_pattern.js', opts), follow: lazyLoad('./api/ccr.follow.js', opts), follow_stats: lazyLoad('./api/ccr.follow_stats.js', opts), followStats: lazyLoad('./api/ccr.follow_stats.js', opts), get_auto_follow_pattern: lazyLoad('./api/ccr.get_auto_follow_pattern.js', opts), getAutoFollowPattern: lazyLoad('./api/ccr.get_auto_follow_pattern.js', opts), pause_follow: lazyLoad('./api/ccr.pause_follow.js', opts), pauseFollow: lazyLoad('./api/ccr.pause_follow.js', opts), put_auto_follow_pattern: lazyLoad('./api/ccr.put_auto_follow_pattern.js', opts), putAutoFollowPattern: lazyLoad('./api/ccr.put_auto_follow_pattern.js', opts), resume_follow: lazyLoad('./api/ccr.resume_follow.js', opts), resumeFollow: lazyLoad('./api/ccr.resume_follow.js', opts), stats: lazyLoad('./api/ccr.stats.js', opts), unfollow: lazyLoad('./api/ccr.unfollow.js', opts) }, clear_scroll: lazyLoad('./api/clear_scroll.js', opts), clearScroll: lazyLoad('./api/clear_scroll.js', opts), cluster: { allocation_explain: lazyLoad('./api/cluster.allocation_explain.js', opts), allocationExplain: lazyLoad('./api/cluster.allocation_explain.js', opts), get_settings: lazyLoad('./api/cluster.get_settings.js', opts), getSettings: lazyLoad('./api/cluster.get_settings.js', opts), health: lazyLoad('./api/cluster.health.js', opts), pending_tasks: lazyLoad('./api/cluster.pending_tasks.js', opts), pendingTasks: lazyLoad('./api/cluster.pending_tasks.js', opts), put_settings: lazyLoad('./api/cluster.put_settings.js', opts), putSettings: lazyLoad('./api/cluster.put_settings.js', opts), remote_info: lazyLoad('./api/cluster.remote_info.js', opts), remoteInfo: lazyLoad('./api/cluster.remote_info.js', opts), reroute: lazyLoad('./api/cluster.reroute.js', opts), state: lazyLoad('./api/cluster.state.js', opts), stats: lazyLoad('./api/cluster.stats.js', opts) }, count: lazyLoad('./api/count.js', opts), create: lazyLoad('./api/create.js', opts), delete: lazyLoad('./api/delete.js', opts), delete_by_query: lazyLoad('./api/delete_by_query.js', opts), deleteByQuery: lazyLoad('./api/delete_by_query.js', opts), delete_by_query_rethrottle: lazyLoad('./api/delete_by_query_rethrottle.js', opts), deleteByQueryRethrottle: lazyLoad('./api/delete_by_query_rethrottle.js', opts), delete_script: lazyLoad('./api/delete_script.js', opts), deleteScript: lazyLoad('./api/delete_script.js', opts), exists: lazyLoad('./api/exists.js', opts), exists_source: lazyLoad('./api/exists_source.js', opts), existsSource: lazyLoad('./api/exists_source.js', opts), explain: lazyLoad('./api/explain.js', opts), field_caps: lazyLoad('./api/field_caps.js', opts), fieldCaps: lazyLoad('./api/field_caps.js', opts), get: lazyLoad('./api/get.js', opts), get_script: lazyLoad('./api/get_script.js', opts), getScript: lazyLoad('./api/get_script.js', opts), get_source: lazyLoad('./api/get_source.js', opts), getSource: lazyLoad('./api/get_source.js', opts), 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), clear_cache: lazyLoad('./api/indices.clear_cache.js', opts), clearCache: lazyLoad('./api/indices.clear_cache.js', opts), close: lazyLoad('./api/indices.close.js', opts), create: lazyLoad('./api/indices.create.js', opts), delete: lazyLoad('./api/indices.delete.js', opts), delete_alias: lazyLoad('./api/indices.delete_alias.js', opts), deleteAlias: lazyLoad('./api/indices.delete_alias.js', opts), delete_template: lazyLoad('./api/indices.delete_template.js', opts), deleteTemplate: lazyLoad('./api/indices.delete_template.js', opts), exists: lazyLoad('./api/indices.exists.js', opts), exists_alias: lazyLoad('./api/indices.exists_alias.js', opts), existsAlias: lazyLoad('./api/indices.exists_alias.js', opts), exists_template: lazyLoad('./api/indices.exists_template.js', opts), existsTemplate: lazyLoad('./api/indices.exists_template.js', opts), exists_type: lazyLoad('./api/indices.exists_type.js', opts), existsType: lazyLoad('./api/indices.exists_type.js', opts), flush: lazyLoad('./api/indices.flush.js', opts), flush_synced: lazyLoad('./api/indices.flush_synced.js', opts), flushSynced: lazyLoad('./api/indices.flush_synced.js', opts), forcemerge: lazyLoad('./api/indices.forcemerge.js', opts), freeze: lazyLoad('./api/indices.freeze.js', opts), get: lazyLoad('./api/indices.get.js', opts), get_alias: lazyLoad('./api/indices.get_alias.js', opts), getAlias: lazyLoad('./api/indices.get_alias.js', opts), get_field_mapping: lazyLoad('./api/indices.get_field_mapping.js', opts), getFieldMapping: lazyLoad('./api/indices.get_field_mapping.js', opts), get_mapping: lazyLoad('./api/indices.get_mapping.js', opts), getMapping: lazyLoad('./api/indices.get_mapping.js', opts), get_settings: lazyLoad('./api/indices.get_settings.js', opts), getSettings: lazyLoad('./api/indices.get_settings.js', opts), get_template: lazyLoad('./api/indices.get_template.js', opts), getTemplate: lazyLoad('./api/indices.get_template.js', opts), get_upgrade: lazyLoad('./api/indices.get_upgrade.js', opts), getUpgrade: lazyLoad('./api/indices.get_upgrade.js', opts), open: lazyLoad('./api/indices.open.js', opts), put_alias: lazyLoad('./api/indices.put_alias.js', opts), putAlias: lazyLoad('./api/indices.put_alias.js', opts), put_mapping: lazyLoad('./api/indices.put_mapping.js', opts), putMapping: lazyLoad('./api/indices.put_mapping.js', opts), put_settings: lazyLoad('./api/indices.put_settings.js', opts), putSettings: lazyLoad('./api/indices.put_settings.js', opts), put_template: lazyLoad('./api/indices.put_template.js', opts), putTemplate: lazyLoad('./api/indices.put_template.js', opts), recovery: lazyLoad('./api/indices.recovery.js', opts), refresh: lazyLoad('./api/indices.refresh.js', opts), rollover: lazyLoad('./api/indices.rollover.js', opts), segments: lazyLoad('./api/indices.segments.js', opts), shard_stores: lazyLoad('./api/indices.shard_stores.js', opts), shardStores: lazyLoad('./api/indices.shard_stores.js', opts), shrink: lazyLoad('./api/indices.shrink.js', opts), split: lazyLoad('./api/indices.split.js', opts), stats: lazyLoad('./api/indices.stats.js', opts), unfreeze: lazyLoad('./api/indices.unfreeze.js', opts), update_aliases: lazyLoad('./api/indices.update_aliases.js', opts), updateAliases: lazyLoad('./api/indices.update_aliases.js', opts), upgrade: lazyLoad('./api/indices.upgrade.js', opts), validate_query: lazyLoad('./api/indices.validate_query.js', opts), validateQuery: lazyLoad('./api/indices.validate_query.js', opts) }, info: lazyLoad('./api/info.js', opts), ingest: { delete_pipeline: lazyLoad('./api/ingest.delete_pipeline.js', opts), deletePipeline: lazyLoad('./api/ingest.delete_pipeline.js', opts), get_pipeline: lazyLoad('./api/ingest.get_pipeline.js', opts), getPipeline: lazyLoad('./api/ingest.get_pipeline.js', opts), processor_grok: lazyLoad('./api/ingest.processor_grok.js', opts), processorGrok: lazyLoad('./api/ingest.processor_grok.js', opts), put_pipeline: lazyLoad('./api/ingest.put_pipeline.js', opts), putPipeline: lazyLoad('./api/ingest.put_pipeline.js', opts), simulate: lazyLoad('./api/ingest.simulate.js', opts) }, 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), mtermvectors: lazyLoad('./api/mtermvectors.js', opts), nodes: { hot_threads: lazyLoad('./api/nodes.hot_threads.js', opts), hotThreads: lazyLoad('./api/nodes.hot_threads.js', opts), info: lazyLoad('./api/nodes.info.js', opts), reload_secure_settings: lazyLoad('./api/nodes.reload_secure_settings.js', opts), reloadSecureSettings: lazyLoad('./api/nodes.reload_secure_settings.js', opts), stats: lazyLoad('./api/nodes.stats.js', opts), usage: lazyLoad('./api/nodes.usage.js', opts) }, ping: lazyLoad('./api/ping.js', opts), put_script: lazyLoad('./api/put_script.js', opts), putScript: lazyLoad('./api/put_script.js', opts), rank_eval: lazyLoad('./api/rank_eval.js', opts), rankEval: lazyLoad('./api/rank_eval.js', opts), reindex: lazyLoad('./api/reindex.js', opts), reindex_rethrottle: lazyLoad('./api/reindex_rethrottle.js', opts), reindexRethrottle: lazyLoad('./api/reindex_rethrottle.js', opts), render_search_template: lazyLoad('./api/render_search_template.js', opts), renderSearchTemplate: lazyLoad('./api/render_search_template.js', opts), scripts_painless_execute: lazyLoad('./api/scripts_painless_execute.js', opts), scriptsPainlessExecute: lazyLoad('./api/scripts_painless_execute.js', opts), scroll: lazyLoad('./api/scroll.js', opts), search: lazyLoad('./api/search.js', opts), search_shards: lazyLoad('./api/search_shards.js', opts), searchShards: lazyLoad('./api/search_shards.js', opts), search_template: lazyLoad('./api/search_template.js', opts), searchTemplate: lazyLoad('./api/search_template.js', opts), 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), createRepository: lazyLoad('./api/snapshot.create_repository.js', opts), delete: lazyLoad('./api/snapshot.delete.js', opts), delete_repository: lazyLoad('./api/snapshot.delete_repository.js', opts), deleteRepository: lazyLoad('./api/snapshot.delete_repository.js', opts), get: lazyLoad('./api/snapshot.get.js', opts), get_repository: lazyLoad('./api/snapshot.get_repository.js', opts), getRepository: lazyLoad('./api/snapshot.get_repository.js', opts), restore: lazyLoad('./api/snapshot.restore.js', opts), status: lazyLoad('./api/snapshot.status.js', opts), verify_repository: lazyLoad('./api/snapshot.verify_repository.js', opts), verifyRepository: lazyLoad('./api/snapshot.verify_repository.js', opts) }, ssl: { certificates: lazyLoad('./api/ssl.certificates.js', opts) }, tasks: { cancel: lazyLoad('./api/tasks.cancel.js', opts), get: lazyLoad('./api/tasks.get.js', opts), list: lazyLoad('./api/tasks.list.js', opts) }, termvectors: lazyLoad('./api/termvectors.js', opts), update: lazyLoad('./api/update.js', opts), update_by_query: lazyLoad('./api/update_by_query.js', opts), updateByQuery: lazyLoad('./api/update_by_query.js', opts), update_by_query_rethrottle: lazyLoad('./api/update_by_query_rethrottle.js', opts), updateByQueryRethrottle: lazyLoad('./api/update_by_query_rethrottle.js', opts), xpack: { graph: { explore: lazyLoad('./api/xpack.graph.explore.js', opts) }, info: lazyLoad('./api/xpack.info.js', opts), license: { delete: lazyLoad('./api/xpack.license.delete.js', opts), get: lazyLoad('./api/xpack.license.get.js', opts), get_basic_status: lazyLoad('./api/xpack.license.get_basic_status.js', opts), getBasicStatus: lazyLoad('./api/xpack.license.get_basic_status.js', opts), get_trial_status: lazyLoad('./api/xpack.license.get_trial_status.js', opts), getTrialStatus: lazyLoad('./api/xpack.license.get_trial_status.js', opts), post: lazyLoad('./api/xpack.license.post.js', opts), post_start_basic: lazyLoad('./api/xpack.license.post_start_basic.js', opts), postStartBasic: lazyLoad('./api/xpack.license.post_start_basic.js', opts), post_start_trial: lazyLoad('./api/xpack.license.post_start_trial.js', opts), postStartTrial: lazyLoad('./api/xpack.license.post_start_trial.js', opts) }, migration: { deprecations: lazyLoad('./api/xpack.migration.deprecations.js', opts), get_assistance: lazyLoad('./api/xpack.migration.get_assistance.js', opts), getAssistance: lazyLoad('./api/xpack.migration.get_assistance.js', opts), upgrade: lazyLoad('./api/xpack.migration.upgrade.js', opts) }, rollup: { delete_job: lazyLoad('./api/xpack.rollup.delete_job.js', opts), deleteJob: lazyLoad('./api/xpack.rollup.delete_job.js', opts), get_jobs: lazyLoad('./api/xpack.rollup.get_jobs.js', opts), getJobs: lazyLoad('./api/xpack.rollup.get_jobs.js', opts), get_rollup_caps: lazyLoad('./api/xpack.rollup.get_rollup_caps.js', opts), getRollupCaps: lazyLoad('./api/xpack.rollup.get_rollup_caps.js', opts), get_rollup_index_caps: lazyLoad('./api/xpack.rollup.get_rollup_index_caps.js', opts), getRollupIndexCaps: lazyLoad('./api/xpack.rollup.get_rollup_index_caps.js', opts), put_job: lazyLoad('./api/xpack.rollup.put_job.js', opts), putJob: lazyLoad('./api/xpack.rollup.put_job.js', opts), rollup_search: lazyLoad('./api/xpack.rollup.rollup_search.js', opts), rollupSearch: lazyLoad('./api/xpack.rollup.rollup_search.js', opts), start_job: lazyLoad('./api/xpack.rollup.start_job.js', opts), startJob: lazyLoad('./api/xpack.rollup.start_job.js', opts), stop_job: lazyLoad('./api/xpack.rollup.stop_job.js', opts), stopJob: lazyLoad('./api/xpack.rollup.stop_job.js', opts) }, 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) }, usage: lazyLoad('./api/xpack.usage.js', opts), watcher: { ack_watch: lazyLoad('./api/xpack.watcher.ack_watch.js', opts), ackWatch: lazyLoad('./api/xpack.watcher.ack_watch.js', opts), activate_watch: lazyLoad('./api/xpack.watcher.activate_watch.js', opts), activateWatch: lazyLoad('./api/xpack.watcher.activate_watch.js', opts), deactivate_watch: lazyLoad('./api/xpack.watcher.deactivate_watch.js', opts), deactivateWatch: lazyLoad('./api/xpack.watcher.deactivate_watch.js', opts), delete_watch: lazyLoad('./api/xpack.watcher.delete_watch.js', opts), deleteWatch: lazyLoad('./api/xpack.watcher.delete_watch.js', opts), execute_watch: lazyLoad('./api/xpack.watcher.execute_watch.js', opts), executeWatch: lazyLoad('./api/xpack.watcher.execute_watch.js', opts), get_watch: lazyLoad('./api/xpack.watcher.get_watch.js', opts), getWatch: lazyLoad('./api/xpack.watcher.get_watch.js', opts), put_watch: lazyLoad('./api/xpack.watcher.put_watch.js', opts), putWatch: lazyLoad('./api/xpack.watcher.put_watch.js', opts), start: lazyLoad('./api/xpack.watcher.start.js', opts), stats: lazyLoad('./api/xpack.watcher.stats.js', opts), stop: lazyLoad('./api/xpack.watcher.stop.js', opts) } } } return apis } // It's unlikely that a user needs all of our APIs, // and since require is a sync operation that takes time // (given the amount of APIs we have), let's lazy load them, // so a given API file will be required only // if the user actually needs that API. // The following implementation takes advantage // of js closures to have a simple cache with the least overhead. function lazyLoad (file, opts) { var fn = null return function _lazyLoad (params, options, callback) { if (fn === null) { fn = require(file)(opts) } return fn(params, options, callback) } } module.exports = ESAPI