From 383c77add34a19b7aa910771690e40ada266dcef Mon Sep 17 00:00:00 2001 From: Theo Truong Date: Wed, 13 Sep 2023 11:22:55 -0600 Subject: [PATCH] Added Security namespace to Client Signed-off-by: Theo Truong --- api/index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/api/index.js b/api/index.js index 71dc3e4d3..d98e3a280 100644 --- a/api/index.js +++ b/api/index.js @@ -71,7 +71,7 @@ const reindexRethrottleApi = require('./api/reindex_rethrottle'); const renderSearchTemplateApi = require('./api/render_search_template'); const scriptsPainlessExecuteApi = require('./api/scripts_painless_execute'); const scrollApi = require('./api/scroll'); -const securityApi = require('./api/security'); +const SecurityApi = require('./api/security'); const searchApi = require('./api/search'); const searchShardsApi = require('./api/search_shards'); const searchTemplateApi = require('./api/search_template'); @@ -92,6 +92,7 @@ const kFeatures = Symbol('Features'); const kIndices = Symbol('Indices'); const kIngest = Symbol('Ingest'); const kNodes = Symbol('Nodes'); +const kSecurity = Symbol('Security'); const kShutdown = Symbol('Shutdown'); const kSnapshot = Symbol('Snapshot'); const kTasks = Symbol('Tasks'); @@ -105,6 +106,7 @@ function OpenSearchAPI(opts) { this[kIndices] = null; this[kIngest] = null; this[kNodes] = null; + this[kSecurity] = null; this[kShutdown] = null; this[kSnapshot] = null; this[kTasks] = null; @@ -145,7 +147,6 @@ OpenSearchAPI.prototype.reindexRethrottle = reindexRethrottleApi; OpenSearchAPI.prototype.renderSearchTemplate = renderSearchTemplateApi; OpenSearchAPI.prototype.scriptsPainlessExecute = scriptsPainlessExecuteApi; OpenSearchAPI.prototype.scroll = scrollApi; -OpenSearchAPI.prototype.security = securityApi; OpenSearchAPI.prototype.search = searchApi; OpenSearchAPI.prototype.searchShards = searchShardsApi; OpenSearchAPI.prototype.searchTemplate = searchTemplateApi; @@ -327,6 +328,14 @@ Object.defineProperties(OpenSearchAPI.prototype, { return this.searchTemplate; }, }, + security: { + get() { + if (this[kSecurity] === null) { + this[kSecurity] = new SecurityApi(this.transport, this[kConfigurationError]); + } + return this[kSecurity]; + }, + }, shutdown: { get() { if (this[kShutdown] === null) {